Manual:DIL Manual/SFB COM

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:24, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 needs aware; to act when it is attacked, check self.fighting or self.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_PRE with command(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.

See also