Shadowthrall Horns Brain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The ShadowThrallHornsBrain component implements the behavior tree for the Shadowthrall Horns entity, which functions as a coordinated sub-division of the larger Shadowthrall boss. It manages combat prioritization, sequential attack coordination (especially with "hands" and "wings" teammates), and positional behavior (wandering, targeting, formation positioning). This brain integrates with several components: Combat for attack state and target tracking, EntityTracker for referencing teammates, and KnownLocations for spawn-based homing.
Usage example
This brain is typically attached to an entity instance during prefab initialization and does not require manual method calls. The behavior tree is constructed automatically when the entity enters its StateGraph.
inst:AddComponent("shadowthrallhornsbrain")
-- The component is added implicitly via prefabs that use this brain class
-- and the behavior tree starts running when the entity's stategraph begins.
Dependencies & tags
Components used:
combat: accessed viainst.components.combat.target,inst.components.combat:InCooldown(),inst.components.combat:TargetIs(target).entitytracker: accessed viainst.components.entitytracker:GetEntity(name).knownlocations: accessed viainst.components.knownlocations:GetLocation(name).stategraph: referenced viainst.sg:HasStateTag("jumping"),inst.sg.mem.lastattack.
Tags: None identified (no tags added/removed by this component directly).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst.formation | number or nil | nil | Angle offset (in degrees) used to compute formation position relative to the target; only used if non-nil. |
bt | BT | nil (assigned in OnStart) | The BehaviorTree root instance constructed during OnStart() initialization. |
Main functions
OnStart()
- Description: Initializes the behavior tree root node for the Shadowthrall Horns entity. Constructs a hierarchical priority tree that handles turn-based attack sequencing, movement toward targets, formation positioning, wandering, and attack triggering.
- Parameters: None.
- Returns: None.
- Error states: This function must be called exactly once during entity initialization (typically via the StateGraph). If
inst.formationis set but target position is unavailable, formation calculation silently returnsnil.
GetHome(inst)
- Description: Helper function that retrieves the spawn point location for use in wandering or leashing logic.
- Parameters:
inst: Entity instance.
- Returns:
vector3ornil— position of the location named"spawnpoint"fromKnownLocations, ornilif not found. - Error states: Returns
nilif"spawnpoint"has not been registered inKnownLocations.
GetTarget(inst)
- Description: Retrieves the current combat target of the entity.
- Parameters:
inst: Entity instance.
- Returns: Entity instance or
nil— the value ofinst.components.combat.target. - Error states: May return
nilif no target is set.
GetTargetPos(inst)
- Description: Returns the current world position of the combat target.
- Parameters:
inst: Entity instance.
- Returns:
vector3ornil— position of the target, ornilif no target exists. - Error states: Returns
nilif target isnilor target lacksGetPosition().
GetFormationPos(inst)
- Description: Calculates a position offset from the target based on the entity's configured
inst.formationangle and a fixed distance (FORMATION_DIST = 6). - Parameters:
inst: Entity instance.
- Returns:
vector3ornil— offset position ifinst.formationis set and target position is available; otherwisenil. - Error states: May return
nilifinst.formationisnil, or ifGetTargetPos(inst)returnsnil.
IsTheirTurnToAttack(inst, teammate)
- Description: Determines whether a specified teammate (
teammatename such as"hands"or"wings") should attack before this entity based on attack timestamp comparison and shared target. - Parameters:
inst: Entity instance.teammate:string— name key for the teammate entity as registered inEntityTracker.
- Returns:
boolean—trueif the teammate is present, has a valid StateGraph memory with a recordedlastattack, and attacked earlier than this entity while sharing the same target. - Error states: Returns
falseif teammate isnil, missing StateGraph, missinglastattack, missing Combat component, or has a different target.
IsMyTurnToAttack(inst)
- Description: Checks whether this entity is allowed to initiate an attack, considering both its own combat cooldown and precedence over teammates.
- Parameters:
inst: Entity instance.
- Returns:
boolean—trueif attack is not on cooldown and no teammate with precedence has attacked more recently. - Error states: Returns
falseif currently in attack cooldown or if a teammate's turn is active perIsTheirTurnToAttack.
IsTarget(inst, target)
- Description: Convenience wrapper around
Combat:TargetIs. - Parameters:
inst: Entity instance.target: Entity instance — the entity to compare against the current combat target.
- Returns:
boolean—trueiftargetmatchesinst.components.combat.target. - Error states: Returns
falseiftargetisnilor mismatched.
Events & listeners
- Listens to: None (this brain does not register its own event listeners; it uses StateGraph memory and component callbacks).
- Pushes:
"doattack"— pushed viainst:PushEvent("doattack", { target = ... })when the entity’s turn arrives and attack conditions are met (insideForceAttacknode). This event triggers the actual combat action sequence.
The "doattack" event is expected to be handled elsewhere, typically by combat-related StateGraph states or prefabs referencing the entity's attack logic.