Ticoonbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The ticoonbrain component implements the behavior tree (BT) for a quest-driven entity—commonly known as a "Ticoon"—that tracks a specific target entity named "tracking" via the entitytracker component. It manages three primary modes:
- Quest tracking phase: When
questingistrue, the Ticoon searches for and approaches a tracked entity, emits a "Get Attention" event, and completes the quest upon arrival. - Normal follow mode: Outside of quests, the entity follows its leader within configurable distances and maintains orientation toward the leader.
- Emergency panic responses: Includes standard panic triggers (e.g., fire, electricity) and escape/avoid behavior.
This brain tightly integrates with the follower, entitytracker, and questowner components to synchronize movement and quest progress with the game’s questing system.
Usage example
local inst = Entity()
inst:AddComponent("follower")
inst:AddComponent("entitytracker")
inst:AddComponent("questowner")
inst:AddBrain("ticoonbrain")
-- Set up tracking target
local target = GetWorld():FindEntityByPrefab("kitcoon")
inst.components.entitytracker:AddEntity("tracking", target)
inst.components.questowner.questing = true
-- Trigger quest completion when Ticoon arrives
inst.components.questowner.on_complete_quest = function(qinst)
print("Quest completed: Ticoon has arrived.")
end
Dependencies & tags
Components used:
follower: accessed viainst.components.follower:GetLeader()entitytracker: accessed viainst.components.entitytracker:GetEntity("tracking")questowner: accessed viainst.components.questowner.questingandinst.components.questowner:CompleteQuest()
Tags: None explicitly added, removed, or checked by this brain.
Properties
No public instance properties are defined or initialized in the constructor. All configuration is inlined as local constants and function closures.
Main functions
TicoonBrain:OnStart()
- Description: Initializes the behavior tree root node. Sets up priority-based state handling for panic, tracking, following, and idle behaviors. The tree prioritizes urgent actions (panic, chase) first and defaults to following and facing the leader.
- Parameters: None (method of
TicoonBrainclass). - Returns: None. Assigns
self.bt = BT(self.inst, root)whererootis the constructedPriorityNode. - Error states: None known; assumes
inst.componentsforfollower,entitytracker, andquestownerexist.
Helper Functions (Internal)
The following local functions are used internally by the behavior tree:
GetLeader(inst)
- Description: Returns the leader entity via
follower:GetLeader()if the component exists; otherwisenil. - Parameters:
inst— The entity instance (usuallyself.inst). - Returns: Entity or
nil.
GetTrackingTarget(inst)
- Description: Returns the tracked entity registered under
"tracking"viaentitytracker:GetEntity("tracking"). - Parameters:
inst— The entity instance. - Returns: Entity or
nil.
GoToTrackingTarget(inst)
- Description: Returns a buffered
WALKTOaction toward the tracked entity’s position if the tracking entity exists. - Parameters:
inst— The entity instance. - Returns: An action object or
nil.
WaitForLeader(inst)
- Description: Returns
trueif no leader is present, or if the leader is farther thanTRACKING_LEADER_START_WAITING_DIST(6 units). Used to determine when the Ticoon should wait instead of wandering. - Parameters:
inst— The entity instance. - Returns:
boolean.
GetLeaderPos(inst)
- Description: Returns the leader’s position if a leader exists; otherwise
nil. - Parameters:
inst— The entity instance. - Returns: Vector position (
x,y,z) ornil.
GetTrackingPos(inst)
- Description: Returns the position of the
"tracking"entity if available; otherwisenil. - Parameters:
inst— The entity instance. - Returns: Vector position (
x,y,z) ornil.
KeepFaceTargetFn(inst, target)
- Description: Used by
FaceEntitybehavior. Returnstrueonly if the giventargetmatches the current leader, ensuring the Ticoon only faces its leader (not random entities). - Parameters:
inst: The entity instance.target: Candidate target entity.
- Returns:
boolean.
Events & listeners
-
Listens to:
This component does not register any event listeners directly (noinst:ListenForEventcalls appear in the file). -
Pushes:
"ticoon_getattention"— Pushed when the Ticoon completes its search subsequence and seeks attention before proceeding to the tracking target.
-
Notes:
The brain triggers quest completion logic viaquestowner:CompleteQuest(), which itself fires any registeredon_complete_questhandler. This event is not pushed by the brain itself but by thequestownercomponent.