Manual:DIL Manual/position update()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:22, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

position_update()

Procedure. Sets a character's position from its hit points, and kills it at -11 or below.

position_update(u : unitptr)

Call it after changing a character's hp, so that its position fits:

Hit points Position
1 or more unchanged; a stunned or worse character stands up (POSITION_STANDING)
0 to -2 POSITION_STUNNED
-3 to -5 POSITION_INCAP
-6 to -10 POSITION_MORTALLYW
-11 or less POSITION_DEAD, and the character dies at once

The constants are in vme.h.

Parameters

Name Type Meaning
u unitptr The player or NPC.

Notes

  • On an object, a room or a null unit nothing happens.
  • At -11 or below the character dies as from any other death: programs nearby get SFB_DEAD, and the death program in death.zon makes the corpse and, for a player, starts the death sequence. Nobody gets experience for it. The unit can be gone afterwards, so don't use it again; a secure on it fires.
  • The change of position itself gives no message; write your own with act().
  • With 1 or more hit points a sleeping, resting or sitting character stays as it is.

Example

dilbegin falling_log(pc : unitptr);
code
{
   if ((pc.type != UNIT_ST_PC) and (pc.type != UNIT_ST_NPC))
      return;
   act("A heavy log swings down and knocks you senseless!",
       A_ALWAYS, pc, null, null, TO_CHAR);
   act("A heavy log swings down and knocks $1n senseless!",
       A_SOMEONE, pc, null, null, TO_REST);
   pc.hp := 0;               // 0 hit points: stunned, not dead
   position_update(pc);
   return;
}
dilend

A trap that knocks a character out without killing it, as the guild guards do in barbarian.zon.

See also