Tutorial / Admin panels > AI
AI Brain
Server-wide settings for smarter NPCs: nav mesh walking, fleeing, calling for help, hearing gunfire, doors, pickups, surrender, jobs and the look-at card.
What it does
AI Brain makes NPCs on the whole server behave smarter. Badly hurt NPCs run away or give up. NPCs of the same kind help a friend under attack, and NPCs come to look when they hear gunfire from someone they hate. They open unlocked doors, pick up weapons and use health kits.
It also runs NPC jobs (police, lockpicker, bomber, hacker, collector, prop resetter, pest, idle). You give jobs per NPC with the NPC Editor, or per tag in AI > NPC AI > NPC tags.
Everyone sees a card above an NPC they look at, with its name, health, job and what it is doing. Admins can also draw NPC paths and targets for debugging.
Where to find it
Q menu > KGX's Admin Toolbox > AI > AI Brain.
Only superadmins can change the settings; for everyone else they are greyed out. The debug drawing works for admins and for players given AI Brain (NPC behaviour settings) in Settings > Player Access.
The panel
| Option | What it does | Default |
|---|---|---|
| AI Brain on (the behaviours below and NPC jobs) | Master switch for the behaviours and jobs | On |
Walking
| Option | What it does | Default |
|---|---|---|
| Walk along the nav mesh when the map has one (AI Paths panel: generate it) | NPC orders are walked along the nav mesh in short legs | On |
| Stuck NPCs try another way | A stuck NPC skips to the next point, then goes straight to the goal | On |
| Open unlocked doors in their way | Walking NPCs open unlocked doors in front of them | On |
Fighting
| Option | What it does | Default | Range |
|---|---|---|---|
| Run away when badly hurt | Fighting NPCs run from their enemy | On | |
| Run away below this health (%) | Health threshold for running away | 25 | 1-90 |
| NPCs of the same kind help a friend that is attacked | Nearby NPCs of the same type join the fight | On | |
| How far they hear a call for help | Radius in units | 800 | 100-4000 |
| Come to look when they hear gunfire from someone they hate | NPCs investigate a player's gunfire | On | |
| How far they hear gunfire | Radius in units | 1200 | 100-5000 |
| Give up to players when badly hurt (drop the weapon, stop fighting) | Surrender to players | Off | |
| Give up below this health (%) | Health threshold for giving up | 15 | 1-90 |
Things
| Option | What it does | Default |
|---|---|---|
| Unarmed NPCs pick up weapons; hurt NPCs use health kits close by | Weapon and health kit pickups | On |
Jobs
| Option | What it does | Default | Range |
|---|---|---|---|
| Seconds between two tasks | Pause between tasks for NPCs with a job | 20 | 3-600 |
| How far NPCs look for work | Search radius in units | 2000 | 200-10000 |
Look-at card
| Option | What it does | Default | Range |
|---|---|---|---|
| Everyone sees a card (name, health, what it does) above an NPC they look at | The card above NPCs | On | |
| How far away the card shows | Distance in units | 500 | 100-3000 |
Apply the numbers above saves the slider values. Checkboxes apply at once.
Debug (you)
| Option | What it does | Default |
|---|---|---|
| Draw NPC paths, nav mesh legs, job targets and enemies (admins) | Draws lines for NPCs within 2500 units of you | Off |
Blue lines: where an NPC walks along the nav mesh. Yellow: its own path (AI Paths). Green: its job's target. Red: its enemy. The number under an NPC is its current schedule.
How to use it
Let NPCs surrender
- As a superadmin, tick Give up to players when badly hurt (drop the weapon, stop fighting).
- Set Give up below this health (%) and click Apply the numbers above.
- An NPC fighting a player below that health drops its weapon, stops fighting and says "Don't shoot! I give up!".
Make NPCs walk on maps without AI nodes
- Generate a nav mesh in AI > AI Paths (superadmins).
- Keep Walk along the nav mesh when the map has one ticked.
- NPC orders from Commander, Patrol & Guard, AI Paths and jobs now follow the nav mesh.
See why an NPC goes the wrong way
- Tick Draw NPC paths, nav mesh legs, job targets and enemies (admins).
- Look at the NPC and follow its blue, yellow, green and red lines.
Settings and commands
| Setting | Default | Range |
|---|---|---|
kgxat_ai_brain |
1 | 0-1 |
kgxat_ai_navmesh |
1 | 0-1 |
kgxat_ai_unstuck |
1 | 0-1 |
kgxat_ai_doors |
1 | 0-1 |
kgxat_ai_flee |
1 | 0-1 |
kgxat_ai_flee_health |
25 | 1-90 |
kgxat_ai_help |
1 | 0-1 |
kgxat_ai_help_radius |
800 | 100-4000 |
kgxat_ai_hear |
1 | 0-1 |
kgxat_ai_hear_radius |
1200 | 100-5000 |
kgxat_ai_surrender |
0 | 0-1 |
kgxat_ai_surrender_health |
15 | 1-90 |
kgxat_ai_pickup |
1 | 0-1 |
kgxat_ai_job_interval |
20 | 3-600 |
kgxat_ai_job_radius |
2000 | 200-10000 |
kgxat_ai_lookui |
1 | 0-1 |
kgxat_ai_lookui_range |
500 | 100-3000 |
kgxat_ai_debug (client) |
0 | 0-1 |
Tips and limits
- Per NPC, the NPC Editor or a tag profile can turn running away and giving up on or off regardless of the server setting. The health thresholds stay server-wide.
- Jobs and pickups only run while the NPC has no order and is not fighting. A police NPC chasing a robber is the exception.
- Only NPCs that use weapons (people, not zombies or antlions) pick things up. They look within 500 units; hurt means below 60% health.
- Surrender happens only when the NPC is fighting a player. A surrendered NPC becomes neutral to every player and holds its spot.
- Nav mesh walking and unstuck work even with AI Brain on unticked. The other behaviours, jobs and the card's health bar need it.
- With
ai_disabledon (AI > NPC AI), the brain does nothing. - Frozen NPCs (NPC Editor) are skipped.