Difference between revisions of "Manual:DIL Manual/power"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="power"></span>
+
= power =
−
'power'
+
'''Variable''' (integer, read/write).
−
    This variable is an integer which can be reassigned. It is used in
 
−
    permission messages and in a few done messages. For example a permission
 
−
    request to damage a person with 100 damage would have power equal 100.
 
−
    This could then be reduced to 50 by assigning a new number.
 
−
    See description of messages for more information.
 
  
−
  ---~---~---~---~---~---~---~---~---
+
  power : integer
−
<span id="power"></span>
 
−
'power'
 
−
    This variable is an integer which can be reassigned. It is used in
 
−
    permission messages and in a few done messages. For example a permission
 
−
    request to damage a person with 100 damage would have power equal 100.
 
−
    This could then be reduced to 50 by assigning a new number.
 
−
    See description of messages for more information.
 
  
−
---~---~---~---~---~---~---~---~---
+
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

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