Manual:DIL Manual/SFB COM
Jump to navigation
Jump to search
SFB_COM
Constant (integer, vme.h: 0x0020).
wait(SFB_COM, condition)
The combat event. It is sent every time a character makes a melee attack, after the attack is rolled and before its damage is worked out (a fumble sends none). A program waiting with SFB_COM wakes for every attack made near it; its unit doesn't have to be in the fight.
What the event holds
| Variable | Value |
|---|---|
| activator | the character making the attack |
| argument | empty |
| command(CMD_AUTO_COMBAT) | TRUE |
| medium, target | null: the one attacked is activator.fighting
|
Notes
- The event reaches the same units as a command (see SFB_CMD): the attacker's room, what the attacker carries and wears, and the others in the room.
- A program doesn't get the attacks of its own unit unless it is declared
aware. A monster that wants to act on its own attacks needsaware; to act when it is attacked, checkself.fightingorself.position == POSITION_FIGHTING. - In a fight of several rounds the event comes often: keep the condition of the
wait()narrow. - To change the damage of a hit, use
SFB_PREwithcommand(CMD_AUTO_DAMAGE)instead.
Example
dilbegin nokill();
var
pc : unitptr;
room : unitptr;
code
{
heartbeat := PULSE_SEC * 3;
:start:
wait(SFB_COM, self.position == POSITION_FIGHTING);
pc := self.fighting;
room := self.outside.exit_to[SOUTH];
if ((pc == null) or (room == null))
goto start;
if (pc.level >= IMMORTAL_LEVEL)
goto start;
act("Black-covered shapes drag $1n out of the guild.",
A_SOMEONE, pc, null, null, TO_ROOM);
act("Black-covered shapes drag you out of the guild!",
A_SOMEONE, pc, null, null, TO_CHAR);
stop_fighting(pc, null);
link(pc, room);
goto start;
}
dilend
A guild master whose guards throw out anyone who fights him, after nokill in assassin.zon.