Manual:DIL Manual/SFB DONE

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_DONE

Constant (integer, vme.h: 0x0800).

wait(SFB_DONE, condition)

The "it has happened" event. It is sent after a command has succeeded: an item was given, taken or dropped, a character moved, a spell was cast. A program waiting with SFB_DONE learns about it after the fact, so block can't undo anything; use SFB_CMD or SFB_PRE to stop a command.

What the event holds

activator, medium, target, power and argument are set by the command that sends it; command("name") tells which command it was. Some of them:

Command activator medium target power
command("give") the giver the item, or the money the one who got it the amount, for money
command("get") the taker where it was taken from (null from the floor) the item 0
command("drop") the one dropping null the item 0
command("north") etc. the one moving the room being left the room being entered the direction
command(CMD_AUTO_ENTER) the one moving the unit that moved (the character, or what carried it) the room that was left the direction
command("cast") the caster the caster, or the scroll, wand or staff the target the spell number

Notes

  • give, get and drop are commands written in DIL (baseget.zon) that send the event with send_done(); any DIL command can do the same. Check the send_done() call in the command's source when you need to know what a command puts in each value.
  • The event reaches the activator's surroundings, as a command does (see SFB_CMD), and also target or the unit named in send_done() when it is somewhere else.
  • The direction event is sent while the mover is still in the old room; CMD_AUTO_ENTER comes after it has arrived, and is heard in the new room.
  • When a player enters the game (CMD_AUTO_PLAY) or leaves it (CMD_AUTO_LEAVE), an SFB_DONE goes to the room void@basis.
  • A program doesn't get the events of its own unit unless it is declared aware.
  • Given money is merged with the coins the receiver already has, so medium may be the whole pile; power is the amount given.

Example

dilbegin thanks();
var
   pc : unitptr;
code
{
   :start:
   wait(SFB_DONE, command("give") and (target == self));

   pc := activator;
   if (medium.type != UNIT_ST_OBJ)
      goto start;

   exec("say Thank you for " + medium.name + ", " + pc.name + ".", self);
   goto start;
}
dilend

A monster that thanks whoever gives it something.

See also