Klausbrain
Based on game build 714014 | Last updated: 2026-03-03
Overview
Klausbrain is the AI behavior tree component for the boss entity Klaus. It orchestrates Klaus's core behavioral patterns—namely rage triggering when soldier count is low, chomp attacks when unchained and targeting an enemy, combat engagement via ChaseAndAttack, periodic reset of combat state, and wandering near his spawn point. It relies heavily on external components for target detection (combat), soldier count monitoring (commander), location tracking (knownlocations), and timing (timer).
Usage example
-- The component is automatically added and used by the Klaus prefab (prefabs/klaus.lua).
-- It is not intended for direct manual instantiation in mod code.
-- Standard usage is via the prefab definition, e.g.:
-- inst:AddComponent("brain")
-- inst.components.brain:SetBrainClass("klausbrain")
Dependencies & tags
Components used: combat, commander, knownlocations, timer
Tags: None identified.
Properties
No public properties.
Main functions
OnStart()
- Description: Initializes Klaus's behavior tree. Sets up priority-based behavior nodes for enraging (when soldier count < 2), chomping (when unchained and has a target), chasing/attacking, resetting combat engagement after 10 seconds, and wandering within 5 units of the home position.
- Parameters: None.
- Returns: Nothing.
OnInitializationComplete()
- Description: Records Klaus's current ground-level position (with
yclamped to0) as"spawnpoint"inknownlocations. Thedont_overwriteflag prevents overwriting if already set. - Parameters: None.
- Returns: Nothing.
Events & listeners
- Listens to: None identified.
- Pushes:
enrage— fired whenShouldEnragecondition is met.chomp— fired whenShouldChompcondition is met.- (Internally,
ChaseAndAttackandWandermay push further events, but these are defined externally.)