Difference between revisions of "Manual:DIL Manual/stop fighting()"

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="bpstopfighting"></span>
+
= stop_fighting() =
 +
'''Procedure.''' Ends a character's fight with one opponent, or with all.
  
−
  '''Function:'''  <i><!--CODE-->stop_fighting( ch: unitptr, vict : unitptr ) ;</i><!--ENDCODE-->
+
  stop_fighting(u : unitptr, t : unitptr)
  
−
<!--TERM--> '''ch'''
+
With <code>t</code> null, <code>u</code> stops fighting everyone, and everyone stops fighting
−
<!--DEFINITION-->         unitptr - person you are stoping the fighting for
+
<code>u</code>. With a character as <code>t</code>, only the fight between <code>u</code> and
−
<!--TERM--> '''vict'''
+
<code>t</code> ends; <code>u</code> goes on with its other opponents.
−
<!--DEFINITION-->         unitptr - person you are removing from the fighting or null for everyone
 
  
−
This function can be used to cancel combat in a room or with two people.
+
When <code>u</code> has no opponents left, it stands up: its position becomes standing (or
−
The following example copied to a player will stop any fight the player is in.
+
lower, as its hit points allow), and its <code>CHAR_SELF_DEFENCE</code> flag is cleared.
−
'''Example:'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
  
−
dilbegin stop_combat();
+
== Parameters ==
−
code
+
{| class="wikitable"
−
dilend
+
! Name !! Type !! Meaning
−
 
+
|-
−
---~---~---~---~---~---~---~---~---
+
| u || unitptr || The character whose fight ends.
−
 
+
|-
−
</i><!--ENDCODE-->
+
| t || unitptr || The opponent to stop fighting, or null for all of them.
−
 
+
|}
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
<span id="bpstopfighting"></span>
 
−
 
 
−
'''Function:'''  <i><!--CODE-->stop_fighting( ch: unitptr, vict : unitptr ) ;</i><!--ENDCODE-->
 
  
−
<!--TERM--> '''ch'''
+
== Notes ==
−
<!--DEFINITION-->         unitptr - person you are stoping the fighting for
+
* <code>u</code> must be a character; on anything else, or null, nothing happens. A <code>t</code> that isn't a character counts as null.
−
<!--TERM--> '''vict'''
+
* The first argument can't be the word <code>null</code> (vmc refuses it); the second can.
−
<!--DEFINITION-->         unitptr - person you are removing from the fighting or null for everyone
+
* '''Call it with a <code>t</code> only when <code>u</code> is fighting''' (<code>u.fighting != null</code>): on a character not in a fight, <code>stop_fighting(u, t)</code> crashes the server.
 +
* <code>stop_fighting(u, null)</code> 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.
  
−
This function can be used to cancel combat in a room or with two people.
+
== Example ==
−
The following example copied to a player will stop any fight the player is in.
+
<pre>
−
'''Example:'''
+
dilbegin peace_bell();
−
<i><!--CODE-->
+
var
−
---~---~---~---~---~---~---~---~---
+
  u : unitptr;
−
 
+
code
−
dilbegin stop_combat();
+
{
−
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
 
dilend
 +
</pre>
 +
A bell that stops every fight in the room when rung.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
−
 
+
* [[Manual:DIL Manual/set fighting()|set_fighting()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/fighting|fighting]]
−
 
+
* [[Manual:DIL Manual/foreach()|foreach()]]
−
 
 
−
---~---~---~---~---~---~---~---~---
 

Latest revision as of 23:21, 14 November 2026

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