Difference between revisions of "Manual:DIL Manual/power"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = 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 <code>command(CMD_AUTO_DAMAGE)</code>: the damage about to be dealt (fight.cpp). <code>activator</code> is the attacker, <code>medium</code> the weapon, <code>target</code> the victim, and <code>argument</code> three numbers: attack group, attack number, hit location. | ||
| + | ** SFB_PRE for a spell: the spell's power (spell_parser.cpp); <code>argument</code> starts with the spell number. To stop the spell, <code>block</code>; death.zon also sets <code>power := -1</code> first. | ||
| + | ** SFB_DONE after <code>give</code> 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 (<code>dilfe_powe</code> 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 == | ||
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | A weapon (<code>dilcopy sharp_edge@zone(20);</code>) whose wielder's hits do 20 percent more damage, as comb_poison in function.zon adds to <code>power</code>. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/send pre()|send pre()]] | ||
| + | * [[Manual:DIL Manual/send done()|send done()]] | ||
| + | * [[Manual:DIL Manual/medium|medium]] | ||
| + | * [[Manual:DIL Manual/SFB PRE|SFB PRE]] | ||
| + | * [[Manual:DIL Manual/SFB DONE|SFB DONE]] | ||
Latest revision as of 23:19, 14 November 2026
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.