Manual:DIL Manual/SFB DONE
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 thesend_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
targetor the unit named insend_done()when it is somewhere else. - The direction event is sent while the mover is still in the old room;
CMD_AUTO_ENTERcomes 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), anSFB_DONEgoes to the roomvoid@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
mediummay be the whole pile;poweris 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.