Alterguardian Phase3Brain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The Alterguardian_Phase3Brain component implements the decision-making logic for the Alter Guardian in its third combat phase. It uses a behavior tree (BT) to orchestrate high-priority actions such as attacking, returning to the spawn point when far away, dodging player proximity, and maintaining orientation toward the current target. The brain depends on Combat, KnownLocations, and Timer components to make decisions and execute actions, and leverages existing behavior modules like StandAndAttack, RunAway, FaceEntity, StandStill, and custom actions.
Dependencies & Tags
- Components used:
combat,knownlocations,timer - Tags: None added, removed, or explicitly checked at the brain level. The behavior tree references the tag constraints
PHASE3_HUNTERPARAMS(_combat,not INLIMBO or playerghost,character or monster or shadowminion) for target selection during dodging, but these are not applied as tags to the brain entity itself. - Behaviours used (via
require):doaction,standandattack,standstill
Properties
No public properties are initialized or stored in the constructor (Class(function(self, inst) ... end)). All logic is implemented inline within function closures or defined as local functions outside the constructor.
Main Functions
AlterGuardian_Phase3Brain:OnStart()
- Description: Initializes and assigns the behavior tree (
self.bt) for the Alter Guardian in phase 3. The behavior tree prioritizes actions: (1) attacking when possible, (2) returning to the spawn point if too far, (3) dodging players if the "runaway_blocker" timer does not exist, (4) rotating to face the target, and (5) standing still as fallback. - Parameters: None (method of
AlterGuardian_Phase3Brainclass) - Returns:
nil
AlterGuardian_Phase3Brain:OnInitializationComplete()
- Description: Records the entity's current position as the
"spawnpoint"location using theknownlocationscomponent. This position is later used by theGoHomeActionto guide movement when the entity drifts too far away. - Parameters: None (method of
AlterGuardian_Phase3Brainclass) - Returns:
nil
GoHomeAction(inst)
- Description: Returns a
BufferedActionto walk toward the recorded spawn point if the entity is too far (distance squared >TUNING.ALTERGUARDIAN_PHASE3_GOHOMEDSQ). Otherwise, returnsniland clearsisdodgingstate. Setsinst.sg.mem.isdodging = trueduring homing. - Parameters:
inst: The entity instance (Alter Guardian)
- Returns:
BufferedActionornil
GetFaceTargetFn(inst)
- Description: Determines the optimal target for the entity to face. Prioritizes the current
combat.target; falls back to the closest valid player or NPC withinTUNING.ALTERGUARDIAN_PHASE3_ATTACK_RANGE(unlessnotarget). Clearsisdodgingstate. - Parameters:
inst: The entity instance (Alter Guardian)
- Returns:
entornil
KeepFaceTargetFn(inst, target)
- Description: Returns
trueif the entity should continue facing the given target (i.e., the target is valid, notnotarget, and withinTUNING.ALTERGUARDIAN_PHASE3_ATTACK_RANGE + 3units). - Parameters:
inst: The entity instance (Alter Guardian)target: The target entity to check distance against
- Returns:
boolean
ShouldAttack(inst)
- Description: Returns
trueif the entity is ready to attack—i.e., a combat target exists,Combat:CanAttack()passes (range, cooldown, state), and not currently in attack cooldown. - Parameters:
inst: The entity instance (Alter Guardian)
- Returns:
boolean
ShouldDodge(inst)
- Description: Returns
trueif the "runaway_blocker" timer does not exist on thetimercomponent, indicating the entity should initiate dodge/avoid behavior. Setsinst.sg.mem.isdodging = trueon dodge, otherwise clears it. - Parameters:
inst: The entity instance (Alter Guardian)
- Returns:
boolean
Events & Listeners
This brain component does not register any event listeners or push events. It relies entirely on synchronous behavior tree evaluation and component method calls.