Manual:DIL Manual/defaultpos
Jump to navigation
Jump to search
Contents
defaultpos
Field (integer, read/write; units: NPC).
npc.defaultpos : integer
An NPC's default position, a POSITION_* constant from vme.h (POSITION_SLEEPING, POSITION_RESTING, POSITION_SITTING, POSITION_STANDING, ...). A zone file sets it with default in the mobile, e.g. default POSITION_SITTING.
The server itself does nothing with it besides showing it in wstat and saving it. A program that wants an NPC to go back to its usual position reads it and acts on it.
Notes
- NPCs only. On a player, an object, a room or null the field fails.
- It is not the NPC's present position: that is position.
- Stored as an 8-bit unsigned number.
Example
dilbegin back_to_rest();
code
{
heartbeat := PULSE_SEC * 30;
:start:
wait(SFB_TICK, self.position == POSITION_STANDING);
if (self.fighting != null)
goto start;
if (self.defaultpos == POSITION_SITTING)
exec("sit", self);
else if (self.defaultpos == POSITION_RESTING)
exec("rest", self);
else if (self.defaultpos == POSITION_SLEEPING)
exec("sleep", self);
goto start;
}
dilend
Puts an NPC back in its default position after something got it on its feet.