Table of Contents

Interface INPCBrain

Namespace
FishMMO.Shared.Core
Assembly
FishMMO.Shared.dll

The server-side brain of an NPC, as seen from shared code.

public interface INPCBrain : ICharacterBehaviour
Inherited Members

Remarks

The brain itself lives in the server assembly and is attached to an NPC only when the server spawns it, so a client never has one and shared code cannot name its type. This is the whole surface shared code needs: the aim the brain solved, whether it is evading, the corpse hand-off, facing an interactor, and the two threat mechanics ECA actions apply. Everything else about AI is the server's business.

Resolved through ICharacter's behaviour registry like any other controller, so character.TryGet(out INPCBrain brain) answers false on every client and on every player.

Properties

AimRotation

The rotation whose forward vector is the direction this NPC aims, refreshed every network tick.

Quaternion AimRotation { get; }

Property Value

Quaternion

IsEvading

True while the NPC is walking home after a leash pulled it out of a fight. An evading NPC takes no damage, no threat, no taunt, no debuff from another character and no knockback, and a hit on it is reported to the attacker as Evade. Shared code asks through CharacterEvade.RefusesHostileEffects, not here directly.

bool IsEvading { get; }

Property Value

bool

Remarks

The evade is what stops a leash being farmed: without it a player could drag a mob to the edge of its leash and hit it all the way home, or hit it once on the way to reset the fight on their own terms. Server-side only — a client has no brain, so this is never true there.

Separate from Immortal on purpose. Immortal is authored on the prefab (a training dummy, a quest giver), set on corpses and toggled by administrators; the brain borrowing it for an evade would have to save and restore it around every way out of the return, and one missed path would leave a mob unkillable for the rest of its life. The evade is derived from the brain's current state instead, so it ends whenever the return does, however it ends.

Methods

ApplyAreaThreat(ICharacter, float, int)

Records a nearby cast against an NPC that is already in combat.

void ApplyAreaThreat(ICharacter caster, float threatPoints, int resourceSpent)

Parameters

caster ICharacter

The casting character.

threatPoints float

Flat threat added, only while the NPC already has a threat table.

resourceSpent int

Resource the cast spent, weighted by the NPC's own resource weight.

ApplyKnockback(Vector3)

Shoves this NPC across the ground: velocity (metres per second, horizontal) is added to its body and bled off over a fraction of a second, during which it does not walk under its own power.

void ApplyKnockback(Vector3 velocity)

Parameters

velocity Vector3

The push, metres per second. Only the horizontal part is used.

Remarks

Moves the NavMesh agent, so the push follows the walkable ground and stops at walls and edges like a walk would. The caller (KnockbackHitAction) has already asked the harm rule, the evade and the incapacitation gates.

ApplyTaunt(ICharacter, float, bool, float, bool)

Taunts this NPC: threat for taunter, optionally enough to put it on top of the table, and optionally an immediate target switch.

void ApplyTaunt(ICharacter taunter, float threatPoints, bool guaranteeTopThreat, float leadOverHighest, bool forceImmediateTargetSwitch)

Parameters

taunter ICharacter

The taunting character.

threatPoints float

Flat threat added.

guaranteeTopThreat bool

When true, adds at least enough to outscore every other entry.

leadOverHighest float

Margin above the previous highest score when guaranteeing top threat.

forceImmediateTargetSwitch bool

When true, the NPC switches to the taunter now.

BlinkTo(Vector3, Quaternion)

Moves this NPC to position at once (a blink), onto the nearest point of the NavMesh, facing facing. Any knockback in progress ends.

bool BlinkTo(Vector3 position, Quaternion facing)

Parameters

position Vector3

Where to land.

facing Quaternion

The rotation to land with; only its heading is used.

Returns

bool

True when the NPC was placed on the NavMesh.

FaceInteractor(Transform)

Turns to face a character that is interacting with this NPC and stops wandering.

void FaceInteractor(Transform interactor)

Parameters

interactor Transform

The interacting character's transform.

ResumeAfterCorpse()

Starts a brain that SuspendForCorpse() stopped.

void ResumeAfterCorpse()

SuspendForCorpse()

Stops the brain for a corpse: no thinking, no movement, no target, no threat.

bool SuspendForCorpse()

Returns

bool

True when the brain was running and has been stopped by this call.