Wargbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
Wargbrain is the decision-making component for warg and warglet entities. It implements a behavior tree that orchestrates responses to game conditions such as being in an intro state, transforming into a statue (clay wargs), responding to electric fences, spawning hounds (summoning), consuming carcasses, and engaging in combat.
This brain is shared by both warg and warglet, with behavioral adjustments based on entity tags (clay, lunar_aligned). It depends on the Combat and Burnable components for state evaluation, and integrates with custom behaviors (StandStill, ChaseAndAttack, Leash, Wander) to construct its decision logic.
Usage example
This component is not added directly by modders. It is assigned internally to warg/warglet prefabs as their brain component, e.g.:
inst:AddBrain("wargbrain")
For modders: if extending or replicating behavior, initialize the brain like any other component and override OnStart() to modify the behavior tree root.
Dependencies & tags
Components used:
combat: accessesHasTarget(),GetLastAttackedTime(),GetHitRange(),InCooldown()burnable: accessesIsBurning()
Tags checked:
clay: triggers statue loop logic (periodically pushesbecomestatueevent)lunar_aligned: disables panic triggers and carcass-eating behaviorcreaturecorpse: filter for valid carcass targets
Tags added/removed:
- None
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
carcass | Entity? | nil | Stores the nearest valid carcass entity found via SelectCarcass(); valid only while CheckCarcass() returns true |
reanimatetime | number? | nil | Timer/flag used for clay wargs to transition from statue state to active state. nil = wait for proximity, true = pending reanimation event |
Main functions
SelectCarcass()
- Description: Finds the nearest valid corpse within
SEE_DIST(30 units) that matches the criteria: hascreaturecorpsetag, lacksNOCLICKandfiretags, and is not burning. - Parameters: None.
- Returns:
trueif a valid carcass is found and stored inself.carcass;falseotherwise. - Error states: Does not fail; returns
falseif no candidate is found.
CheckCarcass()
- Description: Verifies that the currently stored
carcassis still valid: exists, not burning, and tagged ascreaturecorpse. - Parameters: None.
- Returns:
trueif the carcass is valid;falseotherwise. - Error states: If
self.carcassisnilor invalid, returnsfalse.
GetCarcassPos()
- Description: Returns the 3D position of the valid carcass if
CheckCarcass()passes; otherwise returnsnil. - Parameters: None.
- Returns:
Vector3?— position of the carcass ornil. - Error states: Returns
nilif carcass is invalid or not yet selected.
OnStart()
- Description: Constructs and assigns the behavior tree root for the entity. This method must be called during brain initialization to set up AI logic.
- Parameters: None.
- Returns: None.
- Error states: None. Behavior tree construction is idempotent per call, but only needs to be done once per entity instantiation.
Events & listeners
- Listens to: None explicitly; behavior tree nodes trigger reactions based on runtime state, but no event listeners are registered in this component itself.
- Pushes:
reanimate: triggered viainst:PushEvent("reanimate", { target = player })inTryReanimatewhen a clay warg's reanimation timer elapses and a nearby player exists.chomp: pushed immediately viainst:PushEventImmediate("chomp", { target = self.carcass })when a valid carcass is available and cooldown allows.dohowl: triggered viasg:HandleEvent("dohowl")(via state graph) before attempting to summon a follower.becomestatue: pushed periodically (every 3 seconds) while the entity is clay and not in intro state, via the statue loop in the behavior tree.
Note: Events like
reanimate,chomp, andbecomestatueare pushed on the instance (self.inst), which is the warg/warglet entity. The state graph (self.inst.sg) processesdohowlas a state transition request, not a raw event.