Manual:DIL Manual/SFB PRE
Jump to navigation
Jump to search
Contents
SFB_PRE
Constant (integer, vme.h: 0x0400).
wait(SFB_PRE, condition)
The "about to happen" event. It is sent just before a spell takes effect and just before damage is dealt, and the programs that get it can change it: set power to change how strong it is, or block to stop it.
Before a spell: command("cast")
| Variable | Value |
|---|---|
| activator | the caster |
| medium | the caster, or the scroll, wand or staff the spell comes from |
| target | the target of the spell |
| argument | the spell number (SPL_* in values.h), followed by the spell's own argument, which is usually empty
|
| power | how well the spell succeeds (its "hm"); read and write |
block stops the spell: nothing happens, and the caster's cast_spell() gets the value of power back, so set it to -1 as well.
Before damage: command(CMD_AUTO_DAMAGE)
| Variable | Value |
|---|---|
| activator | the one who deals the damage |
| medium | the weapon, or what the damage comes from |
| target | the one who takes it |
| argument | three numbers: the attack group (MSG_TYPE_WEAPON, MSG_TYPE_SPELL, MSG_TYPE_SKILL or MSG_TYPE_OTHER, vme.h), the attack within the group (for weapons a WPN_*), and the body part hit (in melee one of WEAR_HEAD, WEAR_HANDS, WEAR_ARMS, WEAR_BODY, WEAR_LEGS or WEAR_FEET)
|
| power | the damage; read and write. Don't set it below 0. |
block cancels the damage completely.
Notes
- The event reaches the activator's surroundings, as a command does (see SFB_CMD), and the target too when it is somewhere else.
- A program doesn't get the events of its own unit unless it is declared
aware: a monster that changes the damage of its own blows needsaware, as comb_poison in function.zon does. send_pre()sends this event from DIL.- Take the numbers out of
argumentwithgetword()andatoi().
Example
dilbegin fireward();
var
s : string;
spl : integer;
code
{
heartbeat := PULSE_SEC;
:start:
wait(SFB_PRE, command("cast") and (target == self));
s := getword(argument);
spl := atoi(s);
if (spl == SPL_FIREBALL_3)
{
act("The flames die around $1n.", A_SOMEONE, self, null, null, TO_ROOM);
power := -1;
block;
}
goto start;
}
dilend
dilbegin dmghalf();
code
{
heartbeat := PULSE_SEC;
:start:
wait(SFB_PRE, command(CMD_AUTO_DAMAGE) and (target == self.outside));
if (power > 1)
power := power / 2;
goto start;
}
dilend
fireward makes a monster immune to the strongest fireball; dmghalf on an item halves the damage its carrier takes.