Difference between revisions of "Manual:DIL Manual/SFB DEAD"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="sfbdead"></span>
+
= SFB_DEAD =
−
SFB_DEAD          Death message
+
'''Constant''' (integer, vme.h: 0x0010).
  
−
  When this flag is set, the routine gets activated when a PC or NPC dies:
+
wait(SFB_DEAD, condition)
  
−
      'activator'... will point to the PC/NPC that is about to die.
+
The death event. It is sent when a player or a monster dies, at the start of its death: it still carries and wears all its things, and no corpse has been made yet.
−
      'argument'.... is empty.
 
  
−
      command(CMD_AUTO_DEATH) will evaluate to TRUE
+
== What the event holds ==
 +
{| class="wikitable"
 +
! Variable !! Value
 +
|-
 +
| activator || the character who is dying
 +
|-
 +
| argument || empty
 +
|-
 +
| command(CMD_AUTO_DEATH) || TRUE
 +
|-
 +
| medium, target || null
 +
|}
  
−
  The SFB_DEAD message is sent, just as the character dies, while his items are
+
== Notes ==
−
  still equipped, just before the corpse is created. The character's '.fighting'
+
* Unlike the other events, the dying character's own programs get it too, without <code>aware</code>: <code>wait(SFB_DEAD, activator == self)</code> on a monster catches its own death.
−
  field points to his primary opponent, although this person does not necessarily
+
* It also reaches the room, what the dying character carries and wears, and the others in the room, as a command does (see [[Manual:DIL Manual/SFB CMD|SFB_CMD]]). A cursed item can catch its owner's death with <code>activator == self.outside</code>.
−
  have to be the one that killed him.
+
* It is sent by every real death: killed in combat, and killed by a god's <code>slay</code>. The killer isn't in the event. The dying character's <code>fighting</code> field usually points to an opponent, but not necessarily the one who struck last; the example looks for everyone who fought it.
 +
* The death itself goes on after the program has run; it can't be blocked.
  
−
  This can be exploited by making items wiz invisible (the .minv field) just as
+
== Example ==
−
   the message is received, causing them to stay inside the player rather than
+
<pre>
−
  being transferred to the corpse. This does both give the ultimate crash
+
dilbegin fnpri(FN_PRI_BLOCK-2) avenge();
−
   protection, as well as a means of letting items, such as bribe items, forever
+
var
−
   be a part of the player (remember to make it un-wizinvis when the player
+
   u : unitptr;
−
  returns from heaven - players should not have access to items while in heaven).
+
code
 +
{
 +
   :loop:
 +
   wait(SFB_DEAD, activator == self);
  
−
---~---~---~---~---~---~---~---~---
+
  foreach (UNIT_ST_PC, u)
−
<span id="sfbdead"></span>
+
  {
−
SFB_DEAD          Death message
+
      if ((u.fighting == self) and (u.outside == self.outside))
 +
        log(u.name + " killed " + self.name + ".");
 +
  }
  
−
   When this flag is set, the routine gets activated when a PC or NPC dies:
+
   goto loop;
 +
}
 +
dilend
 +
</pre>
 +
A monster that, as it dies, logs every player in the room who was fighting it, after MurderBanish in guilds.zon.
  
−
      'activator'... will point to the PC/NPC that is about to die.
+
== See also ==
−
      'argument'.... is empty.
+
* [[Manual:DIL Manual/wait()|wait()]]
−
 
+
* [[Manual:DIL Manual/interrupt()|interrupt()]]
−
      command(CMD_AUTO_DEATH) will evaluate to TRUE
+
* [[Manual:DIL Manual/fighting|fighting]]
−
 
+
* [[Manual:DIL Manual/SFB COM|SFB_COM]]
−
  The SFB_DEAD message is sent, just as the character dies, while his items are
 
−
  still equipped, just before the corpse is created.  The character's '.fighting'
 
−
  field points to his primary opponent, although this person does not necessarily
 
−
  have to be the one that killed him.
 
−
 
 
−
  This can be exploited by making items wiz invisible (the .minv field) just as
 
−
  the message is received, causing them to stay inside the player rather than
 
−
  being transferred to the corpse. This does both give the ultimate crash
 
−
  protection, as well as a means of letting items, such as bribe items, forever
 
−
  be a part of the player (remember to make it un-wizinvis when the player
 
−
  returns from heaven - players should not have access to items while in heaven).
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 

Latest revision as of 23:24, 14 November 2026

SFB_DEAD

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

wait(SFB_DEAD, condition)

The death event. It is sent when a player or a monster dies, at the start of its death: it still carries and wears all its things, and no corpse has been made yet.

What the event holds

Variable Value
activator the character who is dying
argument empty
command(CMD_AUTO_DEATH) TRUE
medium, target null

Notes

  • Unlike the other events, the dying character's own programs get it too, without aware: wait(SFB_DEAD, activator == self) on a monster catches its own death.
  • It also reaches the room, what the dying character carries and wears, and the others in the room, as a command does (see SFB_CMD). A cursed item can catch its owner's death with activator == self.outside.
  • It is sent by every real death: killed in combat, and killed by a god's slay. The killer isn't in the event. The dying character's fighting field usually points to an opponent, but not necessarily the one who struck last; the example looks for everyone who fought it.
  • The death itself goes on after the program has run; it can't be blocked.

Example

dilbegin fnpri(FN_PRI_BLOCK-2) avenge();
var
   u : unitptr;
code
{
   :loop:
   wait(SFB_DEAD, activator == self);

   foreach (UNIT_ST_PC, u)
   {
      if ((u.fighting == self) and (u.outside == self.outside))
         log(u.name + " killed " + self.name + ".");
   }

   goto loop;
}
dilend

A monster that, as it dies, logs every player in the room who was fighting it, after MurderBanish in guilds.zon.

See also