Manual:DIL Manual/stop fighting()

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

stop_fighting()

Procedure. Ends a character's fight with one opponent, or with all.

stop_fighting(u : unitptr, t : unitptr)

With t null, u stops fighting everyone, and everyone stops fighting u. With a character as t, only the fight between u and t ends; u goes on with its other opponents.

When u has no opponents left, it stands up: its position becomes standing (or lower, as its hit points allow), and its CHAR_SELF_DEFENCE flag is cleared.

Parameters

Name Type Meaning
u unitptr The character whose fight ends.
t unitptr The opponent to stop fighting, or null for all of them.

Notes

  • u must be a character; on anything else, or null, nothing happens. A t that isn't a character counts as null.
  • The first argument can't be the word null (vmc refuses it); the second can.
  • Call it with a t only when u is fighting (u.fighting != null): on a character not in a fight, stop_fighting(u, t) crashes the server.
  • stop_fighting(u, null) on a character not in a fight makes it stand up: a sleeping or resting character is standing afterwards.
  • It gives no message, and doesn't stop anyone from attacking again.

Example

dilbegin peace_bell();
var
   u : unitptr;
code
{
   :start:
   wait(SFB_CMD, command("ring") and ("bell" in argument));
   block;
   act("$1n rings the bell, and a deep calm fills the room.",
       A_ALWAYS, activator, null, null, TO_ALL);
   foreach (UNIT_ST_PC | UNIT_ST_NPC, u)
   {
      if (u.fighting != null)
         stop_fighting(u, null);
   }
   goto start;
}
dilend

A bell that stops every fight in the room when rung.

See also