Manual:DIL Manual/hp
Jump to navigation
Jump to search
Contents
hp
Field (integer, read/write; units: all).
u.hp : integer
The unit's current hit points. For a character it is its health. Objects and rooms have hit points too (the hit line in the zone file); scripts may use them as an item's condition, as basis.zon does, where an object below -1 is broken.
The maximum is the max_hp field.
Notes
- An NPC is loaded with full hit points, mana and endurance: the regeneration program every NPC gets (
regenerate@update) sets them to their maximum, so the values in the zone file aren't what a program reads. - Assigning sets the number and nothing else: it isn't capped at max_hp, and the character's position doesn't change. Call position_update() afterwards: at 0 or below the character is stunned, at -3 incapacitated, at -6 mortally wounded, and at -11 or below it dies there and then.
- Any zone may assign it, for players too.
- Stored as a signed 32-bit number.
- On null it fails.
Example
dilbegin smite(vict : unitptr, dam : integer);
code
{
if ((vict.type != UNIT_ST_PC) and (vict.type != UNIT_ST_NPC))
return;
vict.hp := vict.hp - dam;
position_update(vict);
return;
}
dilend
Hurts a character outside combat and lets the server work out whether it is stunned or dead, as knight.zon and arena.zon do.