Kitcoonbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The KitcoonBrain component implements the behavior tree logic for Kitcoon entities in Don't Starve Together. It orchestrates high-level decision making, prioritizing behaviors such as staying near and following the owner, avoiding active combat, playing with toys or other Kitcoons, and watching minigames when the owner participates. The brain integrates several behaviors (Follow, Wander, FaceEntity, Panic, RunAway, StandStill, Leash) and dynamically selects the most appropriate action based on context provided by multiple components.
Dependencies & Tags
- Components used:
burnable(viaIsBurning)combat(to check combat participation)entitytracker(to locate owner, home den, and nearby entities)follower(to retrieve owner/leader)grouptargeter(to check if entity is targeting the owner)locomotor(to check if owner is moving)minigame(to access minigame watch distances)minigame_participator(to detect if owner is in a minigame)sleeper(to avoid playing with sleeping entities)timer(to check for panic state)
- Tags: The brain references tags such as
"busy","playerghost","kitcoon","cattoy","cattoyairborne","catfood","scarytoprey","_combat","_health","wall","INLIMBO","FX","NOCLICK","DECOR","stump","burnt","notarget","flight","fire","irreplaceable"for filtering and conditionals. It does not directly manipulate tags but reads them viaFindEntityandHasTagcalls.
Properties
The KitcoonBrain class has no public properties beyond inherited Behavior Tree (BT) state. All internal logic is driven by local functions and node data captured in the behavior tree.
Main Functions
KitcoonBrain:OnStart()
- Description: Initializes the behavior tree by constructing a priority-based hierarchy of behavior nodes. This method defines the full behavioral sequence, including combat avoidance, minigame watching, toy play, affection, and wandering.
- Parameters: None.
- Returns: None.
GetOwner(inst)
- Description: Helper that retrieves the Kitcoon’s owner/leader from the
followercomponent. - Parameters:
inst— the Kitcoon entity instance. - Returns: The leader instance, or
nilif not present.
OwnerIsClose(inst)
- Description: Determines if the owner is within a maximum follow distance.
- Parameters:
inst— the Kitcoon entity instance. - Returns:
trueif owner exists and is withinMAX_FOLLOW_DISTunits; otherwisefalse.
GetDenPos(inst)
- Description: Retrieves the position of the Kitcoon’s den (home entity) tracked via
entitytracker. - Parameters:
inst— the Kitcoon entity instance. - Returns: Position vector of the den, or
nilif den is not found.
LoveOwner(inst)
- Description: Attempts to initiate a nuzzle action toward the owner, respecting timing and luck constraints.
- Parameters:
inst— the Kitcoon entity instance. - Returns: Action result (via
BufferedAction), ornilif conditions are not met.
_avoidtargetfn(self, target)
- Description: Core combat-avoidance predicate. Determines if a given entity represents a dangerous combat situation the Kitcoon should avoid.
- Parameters:
self— the behavior context.target— the entity to evaluate for combat threat.
- Returns:
trueif the target poses a combat risk to the owner (per proximity, active targeting, or recent combat); otherwisefalse.
CombatAvoidanceFindEntityCheck(self)
- Description: Factory function returning a filter predicate for
FindEntity, used to locate combat threats for avoidance. - Parameters:
self— the behavior context. - Returns: A function
(ent) -> booleanthat evaluates ifentshould trigger combat avoidance.
ValidateCombatAvoidance(self)
- Description: Re-validates an active combat avoidance state to ensure the threat persists and remains in range before terminating it.
- Parameters:
self— the behavior context. - Returns:
trueif the combat threat remains valid and within range; otherwisefalse.
ShouldPanic(inst)
- Description: Checks if the Kitcoon should enter a panic state (due to explicit panic timer or a burning den).
- Parameters:
inst— the Kitcoon entity instance. - Returns:
trueif panic timer exists or den is burning; otherwisefalse.
FindPlaymate(self)
- Description: Attempts to locate or retain a nearby Kitcoon playmate, respecting play cooldowns, proximity to owner, and sleep state.
- Parameters:
self— the behavior context. - Returns:
trueif a valid playmate is found or retained; otherwisefalse.
TargetCanPlay(self, target, owner)
- Description: Verifies if a given entity is eligible to play (e.g., not busy, not sleeping, on passable terrain).
- Parameters:
self— the behavior context.target— the candidate playmate.owner— the Kitcoon’s owner.
- Returns:
trueif the target can play; otherwisefalse.
PlayAction(inst)
- Description: Attempts to play with a nearby toy or food item, reserving it briefly to prevent concurrent access.
- Parameters:
inst— the Kitcoon entity instance. - Returns: A
BufferedActionornilif no valid target or cooldown active.
GetFollowToy(inst)
- Description: Retrieves the current toy object being followed, if valid and not in limbo.
- Parameters:
inst— the Kitcoon entity instance. - Returns: The toy entity, or
nil.
WatchingMinigame(inst)
- Description: Returns the minigame the Kitcoon’s owner is participating in, if any.
- Parameters:
inst— the Kitcoon entity instance. - Returns: The
minigamecomponent instance, ornil.
WatchingMinigame_MinDist(inst), WatchingMinigame_TargetDist(inst), WatchingMinigame_MaxDist(inst)
- Description: Convenience helpers returning minigame watch distance thresholds (
watchdist_min,watchdist_target,watchdist_max) from the owner’s minigame component. - Parameters:
inst— the Kitcoon entity instance. - Returns: Float value of the respective distance threshold, or
0if no minigame.
Events & Listeners
-
Pushes:
"critter_avoidcombat"with{avoid=true}or{avoid=false}— to notify system of combat avoidance entry/exit."start_playwithplaymate"with{target=playfultarget}— to signal intent to interact with playmate."on_played_with"withtarget— fired after successfully playing with a toy.
-
Listens to:
- None defined in this brain (all event usage is via pushing; listening is handled by external systems like state graphs or other components).