Manual:DIL Manual/power
Jump to navigation
Jump to search
Contents
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).activatoris the attacker,mediumthe weapon,targetthe victim, andargumentthree numbers: attack group, attack number, hit location. - SFB_PRE for a spell: the spell's power (spell_parser.cpp);
argumentstarts with the spell number. To stop the spell,block; death.zon also setspower := -1first. - SFB_DONE after
giveof 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.
- SFB_PRE with
- 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_powein 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.