Garry's Mod

Garry's Mod

3,047 ratings
Patrol Routes STool
2
2
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Realism
File Size
Posted
Updated
12.064 KB
Feb 14, 2016 @ 7:17pm
Mar 9, 2018 @ 4:37pm
15 Change Notes ( view )

Subscribe to download
Patrol Routes STool

Description
This tool allows you to create complex patrol routes for your NPCs. I made it mainly as a complement to my Stealth Mod. You can find it here: https://steamcommunity.com/sharedfiles/filedetails/?id=608796788 . This is my second project in LUA, I still have much to learn, so there may be bugs. Feel free to post them here and I'll try to fix them as soon as possible.

IT WON'T WORK IF THE MAP DOESN'T HAVE AI NODES
You can still use this tool in those maps, but you'll have to place patrol points really close to each other (less than 150 points of distance to be exact).

You can save and load your current patrol route to a file. Every map has its own list of saved patrol routes. These files are stored inside Garrysmod/data/patrolroutes.

This tool is compatible with the GMod Save system. However, as everyone knows, that system sucks and its bugged as hell. Always rememer to disable AI and move up your NPCs a bit, so they don't get stuck underground when you load.

Tool Settings:
Show Points: To show or hide the patrol points and links.
Show Chances: To show or hide the chances of links.
Autolink: If enabled, any patrol point you place will be automatically linked to the last.
Walk: If enabled, the NPC will walk through the patrol route.
Strict: If enabled, the NPC won't stop following a route to attack an enemy.
Back and Forth: If enabld, the NPC will start moving in the opposite direction if he finds a dead end.
Undirected Links: If enabld, the NPC will take any route, regardless of it's direction.
Wait Time: The time in seconds an NPC will wait at a specific patrol point.
Chance: The relative chance that an NPC will use a specific link.
Starting Node: The node where the NPC will start the patrol route.
Autoassigner Range: Maximum range for the Autoassigner.
Autoassigner Filter: Class filter for the Autoassigner.


Controls:
Mouse1: Add/Remove node.

(E+Mouse1): Select node.
--> Mouse1 on node: Add/Remove link.
--> Mouse1 on selected: Remove all links.
--> Release E: Deselect node.

Mouse2 on NPC: Assign route to NPC / Create assigner / Update assigner route and settings

(E + Mouse2): Recover route from NPC or assigner.

Reload: Clear nodes.


How to make different patrol routes:
- Create one route and assign it to an NPC with Right Click.

- Press RELOAD to clear your current nodes.

- Make another route, and assign it to another NPC.

NPCs will keep their last assigned patrol route even if you make a new one. Clearing or modifying your current route won't affect already assigned ones. You don't need to have all your routes active at the same time!!!


Single NPC mode:
This is the default mode. Make a route and press Mouse2 on an NPC to assign your current route to him. Press E+Mouse2 to recover the route assigned to that NPC.


Autoassigner mode:
In this mode, Right Click on the world to create an autoassigner. This entity will assign any NPC spawned inside a configurable radius to your current patrol route. You can use this to automatically assign NPCs spawned by other tools, like "NPC Spawn Platforms". Press Mouse2 on an existing autoassigner to update its stored route and settings, or E+Mouse2 to recover the route.

You can also filter which NPCs are assigned. Just write their class names separated by commas without spaces in the tool textbox.


Wire Assigner mode:
In this mode, Right Click on the world to create a Wire Assigner. This entity can be controlled with Wiremod tools. You can use this to assign its stored route to specific NPC's, or all NPCs in a certain radius. The radius and filter settings in the toolmenu are ignored, you need to specify them using Wiremod inputs. Press Mouse2 on an existing Wire Assigner to update its stored route and settings, or E+Mouse2 to recover the route.

Wire Inputs:
AssignNPC: When this is not "0", it will assign its stored route to a single NPC.
AssignInRange: When this is not "0", it will assign its stored route to any NPC inside its configured range.
NPC: The NPC you want to assign the route to with "AssignNPC".
Range: The maximum range for "AssignInRange".
Filter: The NPC filter for "AssignInRange". It has to be a list of class names separated by commas, without spaces.


Known Issues:
- I tried to optimize it as much as I could. Still, there can be FPS drops if you have too many patroling NPCs.


Credits:
Big thanks to Silverlan and his NPC Tools. I used part of his NPC Spawner code as a base to make this tool.

Also thanks to thelastpenguin for his pON (Penguin's Object Notation).
Popular Discussions View All (17)
6
Nov 20, 2020 @ 10:57am
NPCs won't return
Imagine sisyphus.
4
Oct 13, 2020 @ 9:37am
flying npc's/striders/rollermines/Combine APC.
Snuffleupagu5
1
Sep 24, 2021 @ 6:51pm
error ?
SHREDDER(V)o¥o(V)
940 Comments
Max Shadow  [author] Apr 11 @ 9:13am 
Make sure the radius is big enough, and also clear the NPC filter field, otherwise it only affects NPCs with those classnames
Soup Can Apr 11 @ 4:15am 
The Autoassigner wont work for some reason and the npcs just stay in place
Max Shadow  [author] Apr 6 @ 11:59am 
Nope. One way to implement that would be to have a toggleable option that automatically connects newly placed nodes with any other node in a certain radius and in line of sight. That would be useful for a waypoint system. Sadly, I haven't played GMod in a while, so it's very unlikely I'll ever update this mod.
Hoovy Apr 6 @ 11:39am 
I have a question, is there some sort of easy way to connect alot of Patrol-Nodes with eachother? Something like, you can set that all Patrol-Nodes in a specific Radius connect to eachother or that 1 Patrol-Node connects with all others
MattsterHamster Jan 7 @ 5:35am 
@AmisAuto, Pretty easy to set that up by disabling "back and forth". This will make an NPC complete its patrol (works best with a one-direction line) and stop at the end.
AmisAuto Jan 1 @ 1:51pm 
Can I make NPC to abandon their route after he reached his last point? I'd like them to go somewhere, and then act on their own.
Detiplays Dec 29, 2023 @ 6:25am 
Combine Faction NPC's don't work. They just stand in place when assigned to a route.
Nietabs Nov 24, 2023 @ 8:11pm 
@Wesker1991 just watched your npc battles, very epic. thank you for showing me this :steamhappy:
Wesker1991 Oct 29, 2023 @ 2:06pm 
SNPCs do work well with this. I have made many YouTube battles with this mod, wouldn't play Garry's Mod without it.
Max Shadow  [author] Oct 21, 2023 @ 8:58am 
Your current map probably doesn't have a nodegraph. Either search for the nodegraph on the workshop, or try a different map. You can also build it with one of Silverlan's tools, but it takes time.