Skip to content

SetAnimalHostile

Sets an animal on a player - it runs after them and bites.

The animal runs after the player at its kind’s pace (a wolf ~6.5 m/s, a boar 5) and, at their feet, bites standing every second and a half or so: on every screen a wolf or a dog plays its attack, a boar gores. It stays close between bites, within reach of a sword, and after every third backs off a little - a dog hops back, a boar runs out and charges in again. The bite lands on a player still within reach when it arrives - its kind’s damage (a wolf 12, a boar 18, a dog 7 …; SetAnimalAttack changes it) through their armour, and half that from their stamina; OnActorAttack may change or cancel it. A wolf’s or a boar’s bite bleeds. The hunt ends when the player dies, leaves, goes to another world or gets far away (2.5 times the animal’s behaviour radius, 30 m at least), when the animal dies, with a MoveActor or StopActor of yours, or with SetAnimalHostile(id, nil).

SetAnimalHostile(id, pid)
Parameter Type
id number the animal
pid number | nil the player to hunt; nil calls a hunt off

boolean - false for anything but a live animal, or a player who is dead, not in the world or in another one

-- a wolf pack falls on whoever steps into the clearing
function OnPlayerEnterZone(pid, zone)
if zone == clearing then
for _, wolf in ipairs(pack) do SetAnimalHostile(wolf, pid) end
end
end

SetAnimalBehavior · SetAnimalFlee · SetAnimalAttack · GetAnimalState · OnActorAttack · the NPC actors group of the index