Difference between revisions of "Manual:DIL Manual/stop fighting()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = stop_fighting() = | ||
| + | '''Procedure.''' Ends a character's fight with one opponent, or with all. | ||
| + | stop_fighting(u : unitptr, t : unitptr) | ||
| − | < | + | With <code>t</code> null, <code>u</code> stops fighting everyone, and everyone stops fighting |
| + | <code>u</code>. With a character as <code>t</code>, only the fight between <code>u</code> and | ||
| + | <code>t</code> ends; <code>u</code> goes on with its other opponents. | ||
| − | + | When <code>u</code> has no opponents left, it stands up: its position becomes standing (or | |
| + | lower, as its hit points allow), and its <code>CHAR_SELF_DEFENCE</code> flag is cleared. | ||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| + | | u || unitptr || The character whose fight ends. | ||
| + | |- | ||
| + | | t || unitptr || The opponent to stop fighting, or null for all of them. | ||
| + | |} | ||
| − | + | == Notes == | |
| − | + | * <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. | |
| − | + | * The first argument can't be the word <code>null</code> (vmc refuses it); the second can. | |
| − | + | * '''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. | ||
| − | + | == Example == | |
| − | + | <pre> | |
| − | + | 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 | ||
| + | </pre> | ||
| + | A bell that stops every fight in the room when rung. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/set fighting()|set_fighting()]] | |
| − | + | * [[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
umust be a character; on anything else, or null, nothing happens. Atthat 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
tonly whenuis 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.