Difference between revisions of "Manual:DIL Manual/mana"
Jump to navigation
Jump to search
(checked against the compiler and the interpreter; example compiles) |
(corrected from the DIL keyword tests (T029-T043)) |
||
| Line 7: | Line 7: | ||
== Notes == | == Notes == | ||
| + | * An NPC is loaded with full hit points, mana and endurance: the regeneration program every NPC gets (<code>regenerate@update</code>) sets them to their maximum, so the values in the zone file aren't what a program reads. | ||
* Players and NPCs. On an object, a room or null the field fails. | * Players and NPCs. On an object, a room or null the field fails. | ||
* Assignment is not checked against <code>max_mana</code>: a program can set more than the maximum, and less than 0. Clamp it yourself, as update.zon does. | * Assignment is not checked against <code>max_mana</code>: a program can set more than the maximum, and less than 0. Clamp it yourself, as update.zon does. | ||
Latest revision as of 07:20, 15 November 2026
Contents
mana
Field (integer, read/write; units: characters).
ch.mana : integer
A character's current mana: the points that spells cost. The most it regains to is max_mana. Players regain mana in regen_pc@update, a DIL program, which stops at max_mana and never goes below 0.
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. - Players and NPCs. On an object, a room or null the field fails.
- Assignment is not checked against
max_mana: a program can set more than the maximum, and less than 0. Clamp it yourself, as update.zon does. - Stored as a 16-bit signed number: values outside -32768 to 32767 wrap around.
Example
dilbegin give_mana(u : unitptr, amount : integer);
code
{
if ((u.mana + amount) > u.max_mana)
u.mana := u.max_mana;
else
u.mana := u.mana + amount;
return;
}
dilend
Gives a character mana up to the maximum, as the regeneration in update.zon does.