Houndbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The houndbrain component implements the behavior tree for hounds, governing their movement, combat, and social interactions. It dynamically selects behaviors based on hound type (pet_hound, clay, or lunar_aligned), presence of a leader, home location, and current game state (day/night, statue status). It relies heavily on external behavior nodes (e.g., Wander, ChaseAndAttack, Leash) and integrates with combat, follower, homeseeker, eater, and burnable components to make context-aware decisions.
Dependencies & Tags
- Components used:
burnable(IsBurning)combat(GetHitRange,GetLastAttackedTime,HasTarget,InCooldown,target)eater(CanEat,GetEdibleTags)follower(GetLeader)homeseeker(home)
- Tags:
pet_hound– identifies tamed hounds; affects aggression, home seeking, and waiting behavior.clay– clay hounds (e.g., from the Ruins); triggers special statue-related behavior.lunar_aligned– mutated hounds; disables carcass-eating behavior.INLIMBO,outofreach– excluded tags when searching for food.creaturecorpse,NOCLICK,fire– used when selecting carcasses.statue– checked to detect if a leader is petrified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
reanimatetime | number? / boolean? | nil | Timestamp or flag indicating when to reanimate a leader or the hound itself after being a statue. Used in both clay and pet hound logic. |
carcass | Entity? | nil | Stores the current valid carcass target selected by SelectCarcass(). Cleared or updated on subsequent ticks. |
Main Functions
HoundBrain:OnStart()
- Description: Initializes the brain’s behavior tree (BT) at startup. Constructs a priority-based behavior tree whose top-level structure differs significantly for
clayhounds versus other hounds. Selects behavior nodes based on dynamic conditions (e.g.,GetLeader(),GetHome(),IsPet,ismutated). The BT root is assigned toself.bt. - Parameters: None.
- Returns:
nil
HoundBrain:SelectCarcass()
- Description: Searches within
SEE_DIST(30) units for a valid creature corpse (ignoringNOCLICKandfiretags), and stores the result inself.carcass. Does not check if the carcass is burning or mutating. - Parameters: None.
- Returns:
boolean—trueif a carcass is found,falseotherwise.
HoundBrain:CheckCarcass()
- Description: Validates the currently selected
carcass: ensures it is not burning (viaburnable:IsBurning()), is valid, still acreaturecorpse, and not mutating. - Parameters: None.
- Returns:
boolean—trueifself.carcassmeets all validity criteria.
HoundBrain:GetCarcassPos()
- Description: Returns the world position of the valid
carcass, ornilif invalid. - Parameters: None.
- Returns:
Vector3?— Position of the carcass, ornil.
Helper Functions (Internal Use)
IsFoodValid(item, inst)
- Description: Predicate used when searching for food. Returns
trueif the item is edible and located on a passable point. - Parameters:
item(Entity) — Candidate food item.inst(Entity) — The hound entity.
- Returns:
boolean
EatFoodAction(inst)
- Description: Called by
DoActionto propose an EAT action toward nearby edible food. Aborts if the hound is alreadybusywithout awantstoeatstate tag. - Parameters:
inst(Entity) - Returns:
BufferedAction?— Action object if food is found,nilotherwise.
GetLeader(inst), GetHome(inst), GetHomePos(inst)
- Description: Convenience wrappers to access the leader (via
follower) and home position (viahomeseeker). Returnsnilif the component or respective value is missing. - Parameters:
inst(Entity) - Returns:
Entity?(leader) orVector3?(home position)
GetNoLeaderLeashPos(inst)
- Description: Returns the home position only if the hound currently has no leader (i.e., leash logic should use home as the anchor).
- Parameters:
inst(Entity) - Returns:
Vector3?— Home position if leader isnil; otherwisenil.
GetWanderPoint(inst)
- Description: Returns the position of the leader or nearest player (if no leader) as the point to wander around.
- Parameters:
inst(Entity) - Returns:
Vector3?— Position to use as wander target.
ShouldStandStill(inst)
- Description: Determines if a pet hound should stand still: only if it is nighttime, has no leader, no combat target, and is within
SIT_BOY_DIST(10) of home. - Parameters:
inst(Entity) - Returns:
boolean
TryReanimate(self)
- Description: Orchestrates reanimation logic for hounds waiting for a leader or while unclaimed. Uses
reanimatetimeas a timer/flag: sets initial delay (random() * .5or3), then switches totrue, finally triggering"reanimate"event with the target. - Parameters:
self(HoundBrain) — The brain instance (for state persistence). - Returns:
nil
ShouldBecomeStatue(inst)
- Description: Returns
trueif the hound should initiate statue state: leader must be within10units and in a"statue"state. - Parameters:
inst(Entity) - Returns:
boolean
GetClayLeaderLeashPos(inst)
- Description: Computes a relative position around the leader using
inst.leader_offset(forclayhounds). Returnsnilif leader or offset is missing. - Parameters:
inst(Entity) - Returns:
Vector3?
FaceFormation(inst)
- Description: Aligns the hound’s rotation with its leader’s if the current state allows rotation (
canrotatestate tag). - Parameters:
inst(Entity) - Returns:
nil
Events & Listeners
-
Listens to:
- (Internal — behavior nodes handle most state transitions; no explicit
inst:ListenForEventcalls exist in this file.)
- (Internal — behavior nodes handle most state transitions; no explicit
-
Pushes:
"becomestatue"— Triggered repeatedly in a loop (every3seconds) whenShouldBecomeStatueorGetLeader == nilin clay/abandoned behavior paths."reanimate"— Fired once thereanimatetimetimer completes (set totrue). Payload:{ target = Entity }— the leader or nearest player to face upon reanimation."chomp"— Fired immediately when hound is ready to eat a valid, non-burning, non-mutating carcass and is not in combat cooldown. Payload:{ target = Entity }.
Note: Event pushes are performed via
inst:PushEventandinst:PushEventImmediate— no event registration is defined in this component.