Tutorial / Tools > AI
Patrol & Guard
Make patrol routes and guard posts and give NPCs to them.
What it does
Patrol & Guard makes two things NPCs can be given to. A patrol route is a list of points NPCs walk in order. A guard post is a spot with a facing and a radius that NPCs stay within.
Patrolling NPCs walk point to point, wait at each one, fight what they meet and carry on. Guards stay within the radius and face the post's direction. While fighting they chase up to three times the radius, then come back.
Routes and posts are saved for the map. NPCs can be given to them by right click, automatically when they spawn close by, or by NPC tag.
Where to find it
Q menu > KGX's Admin Toolbox > AI > Patrol & Guard.
Admins can use it. Other players can use it only if they are given the tool in Settings > Player Access.
Admins only (v3.6.11.3): this tool sets up the server, so it cannot be given to players; it is greyed out in Settings > Player Access.
Controls
| Key | What it does |
|---|---|
| Left click | Route mode: add a point to the selected route (makes a new route if none is selected). Post mode: place a guard post facing you. |
| Right click | Give the aimed NPC to the selected route or post. In post mode with no post selected: the nearest post. |
| Reload | Route mode: remove the selected route's last point. Post mode: remove the aimed post (reload twice within 3 seconds). |
Options
| Option | What it does | Default |
|---|---|---|
| Left click places | Route points or Guard posts | Route points |
| New posts: radius | Radius of the next guard post you place (32-4000) | 250 |
Routes
The list shows Route, Points and NPCs. A route's tag shows in brackets after its name. Select a route to edit it.
| Option | What it does | Range |
|---|---|---|
| Loop (last point back to the first; off = back and forth) | Loop or back and forth | On for new routes |
| Run | NPCs run between points | Off for new routes |
| Wait at each point (s) | Wait at each point | 0-60, 2 for new routes |
| Auto: NPCs spawning this close to point 1 walk it (0 = off) | Auto radius around the first point | 0-4000 |
| Most NPCs given automatically (0 = no limit) | Cap for auto and tag assignment | 0-32 |
| Tag: every NPC with this tag walks it | Binds the route to an NPC tag | |
| Save route settings | Saves the fields above for the selected route | |
| New route | Asks for a name and makes an empty route |
Right-click a route for Rename..., Go to point 1, Release its NPCs, Remove every point and Delete route.
Guard posts
The list shows Post, Radius and NPCs.
| Option | What it does | Range |
|---|---|---|
| Radius (they stay within) | How far guards may go from the post | 32-4000 |
| Auto: NPCs spawning this close guard it (0 = off) | Auto radius around the post | 0-4000 |
| Most NPCs given automatically (0 = no limit) | Cap for auto and tag assignment | 0-32 |
| Tag: every NPC with this tag guards it | Binds the post to an NPC tag | |
| Save post settings | Saves the fields above for the selected post |
Right-click a post for Rename..., Go to, Release its NPCs and Delete post.
Below the lists are Refresh and Reset to defaults.
How to use it
Make a patrol route
- Set Left click places to Route points.
- Left click the ground at each point in order. The first click makes "Route 1" if no route is selected.
- Right click an NPC. It starts at its nearest point and walks the route.
- Select the route in the list, change Loop, Run or Wait, and click Save route settings.
Post a guard
- Set Left click places to Guard posts and set New posts: radius.
- Stand where the guard should look from, aim at the spot and left click. The post faces toward you.
- Right click NPCs to make them guard it.
Fill a post from an NPC spawner
- Select the post in the list.
- Set Auto: NPCs spawning this close guard it to, for example, 300 and Most NPCs given automatically to 4.
- Click Save post settings. NPCs that spawn within 300 units guard it, up to 4.
Bind a route to a tag
- Select the route, type a tag in Tag: every NPC with this tag walks it, and click Save route settings.
- Give NPCs that tag with the NPC Editor, an NPC Spawner or a Talking NPC.
- Every NPC with the tag walks the route, up to Most NPCs, also after it respawns.
Settings and commands
| Setting | What it does | Default |
|---|---|---|
kgxat_ai_orders |
1 = NPCs carry out orders from the AI tools. Switch it in AI > NPC AI. | 1 |
Tips and limits
- Saved per map in
data/kgx_admin_toolbox/ai_patrols_<map>.json. At most 32 routes of 64 points, and 64 guard posts. - Routes (green points, lines and numbers) and posts (yellow circle, facing line and NPC count) are drawn only while you hold this tool.
- Which NPC walks or guards what is not saved. After a map restart, NPCs are given to routes and posts again by auto radius, by tag, or by hand.
- A tag checks guard posts first, then routes. Orders given by hand are kept until the tag is set again.
- Deleting a route or post releases its NPCs.
- Auto radius only gives an order to an NPC that has none. When a post and a route are both in range, the post wins.
- Guards more than 300 units from their post run back.
- Deleting a route or post is written to the Action Log.