Manual:DIL Manual/destroy()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:23, 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

destroy()

Procedure. Removes a unit from the game.

destroy(u : unitptr)

An NPC or an object is removed together with everything in it: inventory, equipment, contents. A player is saved, taken out of the game and disconnected. Rooms can't be destroyed: on a room nothing happens.

Parameters

Name Type Meaning
u unitptr The unit to remove.

Notes

  • On null nothing happens.
  • destroy(self) ends the program at once: the statements after it don't run.
  • Destroying a unit this program has secured jumps to the secure's label at once, skipping the rest. Call unsecure(u) before destroy(u).
  • To keep what is inside, move it out first: while (u.inside) link(u.inside, u.outside); (as in the example).
  • A player is saved first, unless they are a guest who was never saved.

Example

dilbegin fido();
var
   i : unitptr;
code
{
   on_activation(self.position <= POSITION_SLEEPING, skip);
   heartbeat := PULSE_SEC * 15;

   :loop:
   pause;
   foreach (UNIT_ST_OBJ, i)
   {
      if ((i.objecttype == ITEM_CONTAINER) and isaff(i, ID_CORPSE))
      {
         act("$1n savagely devours $2n.", A_SOMEONE, self, i, null, TO_ROOM);
         while (i.inside)
            link(i.inside, i.outside);
         destroy(i);
         goto loop;
      }
   }
   goto loop;
}
dilend

A dog that eats corpses and leaves what was in them on the floor. Adapted from midgaard.zon.

See also