Difference between revisions of "Manual:DIL Manual/change speed()"

From DikuMUD Wiki
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:
 +
= change_speed() =
 +
'''Procedure.''' Delays a fighting character's next attacks.
  
 +
change_speed(u : unitptr, delay : integer)
  
−
<span id="bpchngs"></span>
+
Holds back a character in combat: its next attacks come later. Every combat round
−
change_speed( u : unitptr, i : integer )
+
(<code>PULSE_VIOLENCE</code>, 3 seconds) gives a fighter 12 points of time, so
−
  u : the unit on which you wish to alter the current combat speed.
+
<code>change_speed(u, PULSE_VIOLENCE)</code>, which is 12, costs it one round. Spells and skills
−
  i : the amount to add to the speed.
+
use it for stuns and for the time a quaffed potion or a spell takes in a fight.
  
−
  Beware, this is not the 'speed' as in the speed field, rather this is
+
This is not the [[Manual:DIL Manual/speed|speed]] field.
−
  the speed which is calculated during combat. It is used for spells like
 
−
  'stun' which effectively puts the character out of combat for one
 
−
  round. Such a spell would be implemented like:
 
  
−
    change_speed(u, 12)
+
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| u || unitptr || The character.
 +
|-
 +
| delay || integer || The delay, in quarter seconds (<code>PULSE_SEC</code> is 4).
 +
|}
  
−
  and would only cause any effect if 'u' was fighting already (if not,
+
== Notes ==
−
  use setfighting).
+
* It only works on a character that is in a fight. On anyone else, or null, nothing happens.
 +
* The delay is at least 4 (at normal speed), so a small, zero or negative <code>delay</code> still costs 4: it can't speed anyone up.
 +
* The delay is scaled by the character's [[Manual:DIL Manual/speed|speed]]: a character with speed 6, twice as fast as the usual 12, loses half as much.
  
−
---~---~---~---~---~---~---~---~---
+
== Example ==
 +
<pre>
 +
dilbegin stun_blow(tgt : unitptr);
 +
code
 +
{
 +
  if (tgt.position != POSITION_FIGHTING)
 +
      return;
 +
  act("You reel from the blow!", A_ALWAYS, tgt, null, null, TO_CHAR);
 +
  act("$1n reels from the blow!", A_SOMEONE, tgt, null, null, TO_REST);
 +
  change_speed(tgt, PULSE_VIOLENCE);  // loses one combat round
 +
  return;
 +
}
 +
dilend
 +
</pre>
 +
Stuns a fighting character for one round, as in spells.zon.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/speed|speed]]
 +
* [[Manual:DIL Manual/set fighting()|set_fighting()]]
 +
* [[Manual:DIL Manual/fighting|fighting]]

Latest revision as of 23:21, 14 November 2026

change_speed()

Procedure. Delays a fighting character's next attacks.

change_speed(u : unitptr, delay : integer)

Holds back a character in combat: its next attacks come later. Every combat round (PULSE_VIOLENCE, 3 seconds) gives a fighter 12 points of time, so change_speed(u, PULSE_VIOLENCE), which is 12, costs it one round. Spells and skills use it for stuns and for the time a quaffed potion or a spell takes in a fight.

This is not the speed field.

Parameters

Name Type Meaning
u unitptr The character.
delay integer The delay, in quarter seconds (PULSE_SEC is 4).

Notes

  • It only works on a character that is in a fight. On anyone else, or null, nothing happens.
  • The delay is at least 4 (at normal speed), so a small, zero or negative delay still costs 4: it can't speed anyone up.
  • The delay is scaled by the character's speed: a character with speed 6, twice as fast as the usual 12, loses half as much.

Example

dilbegin stun_blow(tgt : unitptr);
code
{
   if (tgt.position != POSITION_FIGHTING)
      return;
   act("You reel from the blow!", A_ALWAYS, tgt, null, null, TO_CHAR);
   act("$1n reels from the blow!", A_SOMEONE, tgt, null, null, TO_REST);
   change_speed(tgt, PULSE_VIOLENCE);   // loses one combat round
   return;
}
dilend

Stuns a fighting character for one round, as in spells.zon.

See also