Manual:DIL Manual/speed

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

speed

Field (integer, read-only; units: characters; also on a cmdptr).

ch.speed : integer
c.speed : integer

On a character: the combat speed. Lower is faster: 12 (SPEED_DEFAULT) is one attack per combat round, 4 (SPEED_MIN) is three, and 200 (SPEED_MAX) is the slowest; the constants are in vme.h. A zone file sets it with speed, and affects with APF_SPEED (haste, slow) change it.

On a cmdptr: the command's combat speed, from turns in vme/etc/commands.def; 0 for a command without one.

Notes

  • It can't be assigned (vmc: "Illegal lvalue").
  • On an object, a room or null it fails.
  • change_speed() is something else: it delays a fighting character's next attack and leaves .speed alone.

Example

dilbegin integer speed_percent(u : unitptr);
var
   i : integer;
   n : integer;
code
{
   i := u.speed;
   if (i == SPEED_DEFAULT)
      return (100);
   if (i < SPEED_MIN)
      i := SPEED_MIN;
   if (i > SPEED_MAX)
      i := SPEED_MAX;

   n := (100 * SPEED_DEFAULT) / i;
   if (n > 200)
      n := 200;
   if (n < 25)
      n := 25;
   return (n);
}
dilend

Turns a character's speed into a percentage of normal speed, as status does in commands.zon.

See also