Deerclopsbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
deerclopsbrain defines the behavior tree (BT) controller for the Deerclops entity. It coordinates high-level decision-making across combat, movement, and environmental interaction by combining several behavior nodes such as ChaseAndAttack, Wander, DoAction, Leash, and FaceEntity. The brain integrates with the entity's combat, burnable, and knownlocations components to make context-aware choices—including when to grow ice, destroy player structures, or return to a home location. It also supports the Deerclops' unique mechanics such as frenzy states, ice regeneration, and catapault-aware pathing over water.
Dependencies & Tags
- Components used:
combat— readstarget,InCooldown,HasTarget,TargetIs,battlecryenabledburnable— checksIsBurningknownlocations— stores/retrieves"spawnpoint","home","targetbase"positions; callsRememberLocationandForgetLocationworkable— accessed viaaction == ACTIONS.HAMMERto identify destroyable structuresburnableandcombat— used in conjunction to determine ice-regrowth conditions
- Tags:
BASEDESTROY_CANT_TAGS = {"wall"}— used byFindEntityto exclude walls from base destruction targets
- Behaviors imported:
chaseandattack,wander,doaction,attackwall,leash,faceentitygiantutils— provides utility functions:GetWanderAwayPoint,CanProbablyReachTargetFromShore,BufferedAction,FindEntity
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
SEE_DIST | number | 40 | Maximum search radius for base-destroy targets (in game units) |
CHASE_DIST | number | 32 | Deerclops stops chasing beyond this distance |
CHASE_TIME | number | 20 | Maximum chase duration before behavior node re-evaluation |
OUTSIDE_CATAPULT_RANGE | number | Computed value | Minimum safe distance from shore when targeting entities on water, to avoid ranged attacks |
BASEDESTROY_CANT_TAGS | table | {"wall"} | Tags that exclude entities from being targeted for base destruction |
inst.forgethometask | Task | nil | Delayed task to forget "home" location after 30 seconds of inactivity |
Main Functions
BaseDestroy(inst)
- Description: Attempts to find and initiate an action to destroy a nearby hammerable structure (e.g., walls, floors). If a
"targetbase"location has been remembered and a valid target is found, it returns aBufferedActiontargeting that structure. Used by theDoActionbehavior node. - Parameters:
inst— The Deerclops entity instance.
- Returns:
BufferedActiontargeting a structure, ornilif no target found or"targetbase"not known.
GetWanderPos(inst)
- Description: Determines a fallback wandering target position by prioritizing known locations:
"targetbase","home", then"spawnpoint". - Parameters:
inst— The Deerclops entity instance.
- Returns:
Vector3position if a known location exists;nilotherwise.
GetNewHome(inst)
- Description: Assigns a new
"home"position usingGetWanderAwayPoint, and schedules a task to forget this location after 30 seconds. Cancels any existing home-forget task. - Parameters:
inst— The Deerclops entity instance.
- Returns:
nil
GetHomePos(inst)
- Description: Returns the
"home"position, or generates a new one if none exists. - Parameters:
inst— The Deerclops entity instance.
- Returns:
Vector3— The current"home"position.
GetTarget(inst)
- Description: Returns the current combat target.
- Parameters:
inst— The Deerclops entity instance.
- Returns:
Entityornil— The target entity stored ininst.components.combat.target.
IsTarget(inst, target)
- Description: Checks whether the given entity is the current combat target.
- Parameters:
inst— The Deerclops entity instance.target—Entity— Entity to compare against the current target.
- Returns:
boolean—trueiftargetmatches the current target.
GetTargetPos(inst)
- Description: Returns the world position of the current combat target, or
nilif no target exists. - Parameters:
inst— The Deerclops entity instance.
- Returns:
Vector3ornil
ShouldGrowIce(inst)
- Description: Evaluates whether Deerclops should regrow ice (e.g., ice ring, eye ice, body ice). Considers burning state, combat status, frenzy, and memory of missing ice (
sg.mem). Logic covers both out-of-combat regeneration and combat phase-specific summoning/regrowth. - Parameters:
inst— The Deerclops entity instance.
- Returns:
boolean—trueif ice regrowth should be started.
DeerclopsBrain:OnStart()
- Description: Constructs and assigns the root behavior tree node. The behavior tree prioritizes:
- Ice regeneration (if
ShouldGrowIcereturns true) - Battlecry activation (via
AttackWall+DoAction) - Cooldown phase — leash behavior, facing target
- Combat chase and attack
- Target base destruction (via
BaseDestroy) - Attempt to leave via wander-to-home
- General wandering via
GetWanderPos
- Ice regeneration (if
- Parameters: None
- Returns:
nil
DeerclopsBrain:OnInitializationComplete()
- Description: Records the Deerclops' spawn position under the
"spawnpoint"key inknownlocations. Thedont_overwriteflag is set totrue, so it will only be stored once. - Parameters: None
- Returns:
nil
Events & Listeners
- Listens to: None (no
inst:ListenForEventcalls in this file) - Pushes:
"doicegrow"— Pushed by theIceGrowaction node when ice regeneration is triggered
Note: Event pushing is limited to one internal event (
"doicegrow"), and no external event subscriptions are defined in this file.