Manual:DIL Manual/power

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:19, 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

power

Variable (integer, read/write).

power : integer

A number that comes with SFB_PRE and SFB_DONE events. In a pre event a program can change it, and the server goes on with the new value: the damage of a hit, the power of a spell. In a done event it says what was done (the coins given, the direction moved), and changing it changes nothing that has happened.

Notes

  • What it holds:
    • SFB_PRE with command(CMD_AUTO_DAMAGE): the damage about to be dealt (fight.cpp). activator is the attacker, medium the weapon, target the victim, and argument three numbers: attack group, attack number, hit location.
    • SFB_PRE for a spell: the spell's power (spell_parser.cpp); argument starts with the spell number. To stop the spell, block; death.zon also sets power := -1 first.
    • SFB_DONE after give of coins: the amount (baseget.zon). After a move: the direction. After a spell: the spell number. After backstab and similar skills: the damage.
    • send_pre() and send_done() from DIL pass their own power.
  • In other events (commands, messages, ticks) power is normally 0, but it isn't tied to the event: an assignment there writes one spare value that every program then reads until it is changed again (dilfe_powe in dilexp.cpp). Assign it only in a pre event.
  • The programs that get a pre event run one after another; each sees the power the ones before it left.

Example

dilbegin sharp_edge(pct : integer);
code
{
   :start:
   wait(SFB_PRE, command(CMD_AUTO_DAMAGE) and (medium == self));
   if (activator != self.outside)
      goto start;
   if (power <= 0)
      goto start;
   power := power + (power * pct) / 100;
   goto start;
}
dilend

A weapon (dilcopy sharp_edge@zone(20);) whose wielder's hits do 20 percent more damage, as comb_poison in function.zon adds to power.

See also