Difference between revisions of "Manual:DIL Manual/position update()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = position_update() = | |
| − | + | '''Procedure.''' Sets a character's position from its hit points, and kills it at -11 or below. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | position_update(u : unitptr) | |
| − | |||
| − | |||
| − | position_update ( u : unitptr ) | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Call it after changing a character's [[Manual:DIL Manual/hp|hp]], so that its | |
| − | + | [[Manual:DIL Manual/position|position]] fits: | |
| + | |||
| + | {| class="wikitable" | ||
| + | ! Hit points !! Position | ||
| + | |- | ||
| + | | 1 or more || unchanged; a stunned or worse character stands up (<code>POSITION_STANDING</code>) | ||
| + | |- | ||
| + | | 0 to -2 || <code>POSITION_STUNNED</code> | ||
| + | |- | ||
| + | | -3 to -5 || <code>POSITION_INCAP</code> | ||
| + | |- | ||
| + | | -6 to -10 || <code>POSITION_MORTALLYW</code> | ||
| + | |- | ||
| + | | -11 or less || <code>POSITION_DEAD</code>, and the character dies at once | ||
| + | |} | ||
| + | |||
| + | The constants are in vme.h. | ||
| + | |||
| + | == Parameters == | ||
| + | {| class="wikitable" | ||
| + | ! 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 <code>SFB_DEAD</code>, 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 <code>secure</code> on it fires. | ||
| + | * The change of position itself gives no message; write your own with [[Manual:DIL Manual/act()|act()]]. | ||
| + | * With 1 or more hit points a sleeping, resting or sitting character stays as it is. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | A trap that knocks a character out without killing it, as the guild guards do in barbarian.zon. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/hp|hp]] | ||
| + | * [[Manual:DIL Manual/position|position]] | ||
| + | * [[Manual:DIL Manual/max hp|max hp]] | ||
| + | * [[Manual:DIL Manual/stop fighting()|stop_fighting()]] | ||
Latest revision as of 23:22, 14 November 2026
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; asecureon 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.