Stalker Minionbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The stalker_minionbrain component implements a finite state machine using a Behavior Tree (BT) to govern stalker minions (small entities summoned by the Stalker boss). Its primary responsibilities include maintaining leash distance relative to the Stalker, idling while near the Stalker, and initiating self-destruction after a randomized delay following the Stalker's death. It depends on the EntityTracker component to locate the associated Stalker and the Health component to terminate the minion.
Usage example
This component is typically added to minion entities during their initialization, usually via a prefab definition or spawner logic. Example (conceptual; actual instantiation occurs in prefabs like stalker_minion):
local function fn()
local inst = CreateEntity()
inst:AddComponent("stalker_minionbrain")
-- The brain automatically initializes on `OnStart`, no manual call needed.
return inst
end
Dependencies & tags
Components used:
entitytracker— accessed viainst.components.entitytracker:GetEntity("stalker")to retrieve the Stalker target.health— accessed viainst.components.health:IsDead()andinst.components.health:Kill()for lifecycle management.
Tags: None identified.
Properties
No public properties are explicitly initialized in the constructor.
Main functions
StalkerMinionBrain:OnStart()
- Description: Initializes the Behavior Tree (
BT) root node. Defines the logic flow: (1) panic if triggered, (2) enforce leash to Stalker, (3) stand still while Stalker is present, (4) wander during a post-Stalker-death grace period, and (5) kill the minion once the grace period ends. This function is automatically invoked when the entity enters the world. - Parameters: None.
- Returns:
nil. - Error states: None. Assumes
EntityTrackerandHealthcomponents are present.
GetTarget(inst)
- Description: Helper function that retrieves the Stalker entity via the
EntityTrackerusing the"stalker"key. - Parameters:
inst: The entity instance whoseEntityTrackercomponent is queried.
- Returns:
entity instornil— the Stalker entity, ornilif not tracked. - Error states: Returns
nilif the Stalker is not registered inEntityTracker.
GetTargetPos(inst)
- Description: Helper function that returns the current world position of the Stalker target, if available.
- Parameters:
inst: The entity instance whoseEntityTrackercomponent is queried.
- Returns:
Vectorornil— the Stalker's position, ornilif the target is absent. - Error states: Returns
nilifGetTarget(inst)returnsnil.
ShouldDie(self)
- Description: Determines whether the minion should proceed to die. If no delay has been set (i.e.,
self.delay == nil), it calculates a random delay based on whether the Stalker is already dead (stalkerdeadflag), adding randomness for unpredictability. Returnstrueonly when the current game time exceeds the computed delay. - Parameters:
self: The brain component instance.
- Returns:
boolean—trueif the delay has elapsed and the minion should die; otherwisefalse. - Error states:
- Sets
self.delaylazily on first invocation if not present. - Delay =
stalkerdead ? [1, 3]or[3, 5](i.e.,dt + math.random() * dtwheredtis1or3).
- Sets
Events & listeners
None. The component uses behavior tree nodes and direct state queries instead of event-driven logic.