Skip to content

SetAnimalFlee

Runs an animal from a player.

The animal runs straight away from the player at its kind’s flight pace (deer and hares ~9 m/s, a boar 5.5, sheep and cattle 4.5-5) until it is distance metres from them, then stands. A MoveActor or StopActor of yours ends it, and so does SetAnimalFlee(id, nil).

SetAnimalFlee(id, pid [, distance])
Parameter Type
id number the animal
pid number | nil the player to run from; nil stops the flight
distance number metres from the player where it stops (30; 3 to 200) (optional)

boolean - false for anything but a live animal, or a player not in its world

-- the deer bolts when a shot misses it
function OnProjectileHitZone(pid, zone, x, y, z)
if zone == deer_zone then SetAnimalFlee(deer, pid, 60) end
end

SetAnimalHostile · SetAnimalBehavior · GetAnimalState · the NPC actors group of the index