This behavior causes a prefab to panic.
Panic is perhaps the simplest behavior among the 19 behaviours currently implemented in Don’t Starve. The prefabs (as used by the game) will go into the Panic behavior when they take fire damages. The Panic behavior is characterized by its intermittently random running. That is when prefab enters in a panic state, it will run towards a random direction for at least 4s. It will then stop for 1s or 2 before resuming running towards another random direction.
Panic is created as a behaviour tree node and belongs to the general BehaviorNode class. It is found in most base game prefabs’ brain as top priority node. The condition for panic is usually the evaluation of
component.health.takefiredamage, and in Don’t Starve Together,
component.hauntable and component.hauntable.panic. It means that when prefabs take fire damage (or are haunted), they will ignore all other behaviours and start panic.
The Panic node has three status: READY, RUNNING and STANDING. It can be described by the following state diagram.
The Panic decision tree is illustrated below:
Here is an example showing the rabbit brain:
local root = PriorityNode(
-- A While node checks for fire, and then triggers the Panic node.
[...] -- All other nodes are lower, which means the creature will always panic when on fire.