Table of Contents

Class AIRetreatDecision

Namespace
FishMMO.Server.Implementation.World.SceneServer.AI
Assembly
FishMMO.Server.dll

Decides whether a fleeing NPC keeps running, turns around, or disengages.

public static class AIRetreatDecision
Inheritance
AIRetreatDecision
Inherited Members

Remarks

Why this exists as a solver and not as distance tests inside the state. The reported behaviour — an NPC that runs away forever the moment a player chases it — is not a bug in any one comparison. It is the absence of any state that survives a tick: the old state compared the target's distance against SafeDistance and nothing else, so the same inputs always produced the same answer, and a pursuer faster than the NPC meant the inputs never changed. A decision that can see how long this has been going on, and how many times it has already happened, is what makes a chase end.

Pure and Unity-free, matching AICombatDecision: every input arrives in the context and the roll is supplied by the caller, so the whole ladder is assertable.

Fields

PURSUIT_CLOSING_SPEED

Closing speed above which a target counts as pursuing.

public const float PURSUIT_CLOSING_SPEED = 0.5

Field Value

float

Remarks

Not zero: two bodies shuffling around each other inside a NavMesh agent's avoidance radius produce a small positive closing speed in any direction, and treating that as a pursuit would stop every retreat from ever disengaging. Ground speed is several units a second, so half a unit cleanly separates "walking me down" from "standing nearby".

Methods

Decide(in AIRetreatContext)

Reaches the outcome for this tick.

public static AIRetreatOutcome Decide(in AIRetreatContext context)

Parameters

context AIRetreatContext

The inputs for this tick.

Returns

AIRetreatOutcome

The outcome for this tick.

Remarks

The order of these tests is the design. The two hard stops come first, because a chase that cannot end is worse than a chase that ends too early: an NPC that keeps fleeing is unkillable by a melee player, while one that turns too soon merely loses a fight it was going to lose anyway.

A pursuer turns Disengage into KeepRetreating. That single rule is the reported issue. Reaching SafeDistance used to be sufficient on its own, so an NPC that outran nothing in particular stopped and went idle while the player was still running at it — and then the out-of-combat sweep re-acquired the player and the NPC fled again, forever. Being far away only means the NPC is done running if nobody is following.