Skip to content

SetAnimalBehavior

What an animal does by itself - calm, aggressive, defensive or skittish.

  • "calm" (every animal’s to start with): nothing by itself - it walks where you send it, even when hurt.
  • "aggressive": hunts the nearest player who comes within radius metres (SetAnimalHostile), and whoever hurts it.
  • "defensive": turns on whoever hurts it.
  • "skittish": runs from the nearest player who comes within radius metres (SetAnimalFlee, to twice the radius and 30 m at least), and from whoever hurts it.

The behaviour stays through hunts and flights: an aggressive wolf that lost its prey goes for the next player who comes near.

SetAnimalBehavior(id, behavior [, radius])
Parameter Type
id number the animal
behavior string "calm", "aggressive", "defensive" or "skittish"
radius number metres the aggressive and the skittish keep watch over (15; 1 to 100) (optional)

boolean - false for anything but an animal, or an unknown word

-- the forest's wolves attack on sight, its deer bolt, its boars charge whoever wounds them
for _, w in ipairs(wolves) do SetAnimalBehavior(w, "aggressive", 25) end
for _, d in ipairs(deer) do SetAnimalBehavior(d, "skittish", 30) end
for _, b in ipairs(boars) do SetAnimalBehavior(b, "defensive") end

GetAnimalBehavior · SetAnimalHostile · SetAnimalFlee · SetAnimalAttack · the NPC actors group of the index