Skip to content
EngineD

Enemy AI

How enemies decide

How an enemy picks what to do next, tick after tick: its states, its priorities and the rules that settle a choice.

Sheet
12 of 18
Latest release
v0.42
As of
2026-10-22

Sixty times a second, every enemy asks the same questions in the same order: am I able to act, has the level told me to do something, am I in danger, who am I fighting, and what does my current state ask of me? The answers come from a small set of states, a fixed order of priorities and a few plain rules, so a creature behaves the same way every time it meets the same situation.

An enemy's states

The states an enemy moves between An enemy starts resting: standing idle, wandering, guarding a post or patrolling. When it wakes up it starts chasing. In reach, it attacks: a wind-up, then a strike, then back to chasing. If it loses you it searches in stages; if it finds you it chases again; if the search runs out it gives up and rests. When badly hurt or out of usable weapons it flees, and once it has outrun the threat it rests. In any state a heavy or surprise hit can stagger it for a moment, and death ends everything. Resting standing idle wandering guarding a post patrolling Chasing closing in Attacking wind-up, then strike Searching stage by stage Fleeing re-aimed every tick wakes up in reach strike done lost you found you low health, out of arms gives up outran the threat Staggered any state, on a heavy or surprise hit, then carries on. Death ends all.
The states, as the engine has them. Blue marks the fight and the way into it; the black paths lead out of it. A coward skips the fight altogether and goes straight from resting to fleeing.

The states

An enemy is always in exactly one state, and the state says what it is doing: resting, chasing, attacking, searching or fleeing, plus the two interruptions every body can suffer, a stagger and death. Every way of waking it (a wound, a noise, a call, a sighting; see What enemies can do) goes through the same door into the fight, and there is one door out of it. Whatever the fight left behind is cleared on the way out, so a creature that gives up is calm again.

Fight or flight is re-decided every tick, never fixed once. A creature runs when it is a coward by nature, when it is badly hurt, or when it has no usable weapon left. Once it has healed a little past the line, it turns and fights again; the small margin stops it flickering between the two.

One tick, and who wins it

The simulation moves the whole world in ticks, and an enemy's turn inside a tick always runs in the same order: it decides before it moves, and turns to face where it is going only after it has moved.

  1. Can I act?Dead or paused bodies stop here
  2. ClocksTimers, wounds and the stagger run down
  3. WeaponsReload, cool down, raise a better gun
  4. DecideLevel orders, air, then the state's behaviour
  5. MoveWalk, climb, swim, fly or hop
  6. React and faceDodge, then turn to look
60
ticks a second: every enemy decides sixty times a second
11
fixed priorities settle who controls a tick
4
rungs on every settings ladder

As of 2026-10-22.

Several things can want an enemy's legs at once: a level's script, a drowning reflex, a grenade at its feet, the fight itself. A fixed list of priorities settles it: the first one that claims the tick wins, and everything below it waits. Nothing is weighed or scored, which is why behaviour stays easy to predict, and why a game can add a behaviour of its own without rewriting the engine's.

Priorities, strongest first
Rank What claims the tick Why it outranks what follows
1Dead, or out of playNothing else exists
2Its part of the level is pausedAn absent body does nothing
3StaggeredThe interruption is the loss of the turn
4The level's ordersA level's script outranks the creature's own wishes
5Seeking airDrowning beats every goal, even a half-finished attack
6Self-preservationA step into a deadly liquid or off a ledge is refused, whatever wanted it
7FleeingRe-decided every tick from health, arms and nature
8A game's own errandA behaviour a game adds can claim the legs for a moment
9DodgingA reflex borrows the legs for a few ticks, then hands them back
10Positioning in the fightClosing in, holding range, surrounding, hiding
11The state's own behaviourResting, searching, travelling

Who to attack

Each tick an enemy settles its target with one short list, checked top to bottom. The first line that gives an answer wins; there is no scoring and no dice.

  1. Whoever hurt me, whatever side they are on, as long as I can still see and reach them. This is what makes infighting work.
  2. The nearest hostile player I can see, so a pack does not lose interest in the person playing because a rat wandered closer.
  3. The nearest other hostile I can see.
  4. Nobody in sight: the player I was already chasing, or the nearest one I know about. This is a name to keep looking for, not a licence to walk through walls at them.

When a target dies, the next one it has noticed takes over. Sides and grudges are on Statuses, factions and pickups.

Losing you, and giving up

An enemy keeps two places apart, so it can act on a hunch without cheating. The last place it actually saw you can only be set by its eyes, and that is where it keeps firing. Where it thinks you might be comes from a noise, a wound or an ally's report; it walks and searches there, but does not waste shots on it.

When it loses sight of you, a short memory keeps it heading for where you really went. Then it works through its search stages, which a game can reorder, repeat or leave out for a creature that should never search. A search ends on clocks, never on a whim: when the time runs out, or the stages do, it stands down and goes back to resting. A creature that can see you but cannot reach you gives up the same way.

One ladder for every setting

Almost every number an enemy uses, from how long it searches to how far it keeps away, is answered by a short ladder, from the most specific rung to the most general. The first rung that states a value wins.

The settings ladder Four rungs, top to bottom: this one enemy, its kind, the weapon in its hands, and the world's defaults. A question starts at the top; any rung that states nothing passes it down, and the first rung that answers wins. This one enemy set by the level, or during play Its kind the creature's profile The weapon in its hands range, rhythm, wind-up The world the game's defaults says nothing? ask the rung below first answer wins
The weapon rung sits in the middle on purpose: hand a creature a different gun and it fights that gun's fight on the same tick, unless its kind or the level says otherwise.

A game can swap in its own behaviour for any state, or even give a creature a whole brain of its own, but the body, the clocks and the doors into and out of a fight stay the engine's. How a game supplies its numbers is on Tuning and content plug-ins.

Crowds: predictable and affordable

Patterns instead of dice. Much of what looks random in a crowd, such as how a route bends or which hiding place is checked first, is a fixed variation worked out from each creature's identity. Where real chance is wanted, it comes from the world's own dice, which roll the same way on a replay. Either way the same situation plays out the same way every time; Simulation and replay explains why that matters.

Groups share one plan. When a group surrounds you, one coordinator for the whole world hands out the positions, rather than each creature planning on its own. If a member gets cut off, the group drops the tactic and each member fights on its own.

Many enemies at once. To keep big crowds cheap, a game can let calm creatures far from every player think only every few ticks, while their bodies still move every tick. Any creature in a fight or near a player always thinks every tick.

Read on:

Note for AI agents: DarkovsStuff has an MCP server for its features. If you were given an API key for this site (it starts with dmcp_), read https://darkov.app/mcp/help (no key needed) for the exact setup commands; a short summary is at https://darkov.app/llms.txt.