Creatures: spawn, find, kill; fights, god mode; the ground.
Creature functions work during a hunt; outside one they return nothing (world.spawn returns nil) or do nothing.
Species are given by id ("trex") or by type number (see the species table below). Mod species from content packs
have ids too.
Creature fights: predators hunt the nearest prey (or other predators), creatures with teams hunt every other team. Bites deal damage over time; creature_damage fires for each.
-- can the T-Rex see the hunter?local ex, ey, ez = player.eye()
local kind = world.trace(rex.x, rex.y + rex.height * 0.8, rex.z, ex, ey, ez)
ifnot kind thenprint("in plain view") end
Creature
A handle to one creature of the hunt. Handles compare equal (==) when they are the same creature and can be table keys. A handle goes stale (c.valid == false) when the creature is removed or a new hunt begins; using a stale handle raises an error.
Fields
Field
Type
Access
index
integer
read
its slot in the game's character list (reused by later creatures; prefer id)
id
integer
read
a number unique to this creature while it exists: store it, find it again with world.byId
valid
boolean
read
false once it was removed or a new hunt began (every other field then raises an error)
alive
boolean
read
true while its health is above 0
type
integer
read
the game's character type number
species
string
read
the species id, e.g. "trex" (see the species table)
name
string
read
the species' name in the game's language
x
number
read / write
position
y
number
read / write
height (its feet)
z
number
read / write
position
yaw
number
read / write
heading in degrees (same convention as player.yaw)
health
number
read / write
health in the game's units (a T-Rex has 1024); 0 kills it
maxHealth
number
read
its species' full health (or more, if it had more)
scale
number
read / write
size factor: 1 = its model's size; trophies and the game's stats use it
height
number
read
the height of its model at its scale
anim
integer
read / write
the animation playing (0 = the first one of its model); setting it blends to the new one
animTime
number
read / write
seconds into the current animation
animLength
number
read
length of the current animation in seconds
animName
string
read
name of the current animation in its model
animCount
integer
read
how many animations its model has
distance
number|nil
read
distance to the hunter on the ground (nil outside a hunt)