Manual:DIL Manual/attack type

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

attack_type

Field (integer, read/write; units: characters).

ch.attack_type : integer

The weapon type a character fights with when not wielding a weapon: a WPN_ constant from values.h, such as WPN_FIST, WPN_KICK, WPN_KNEE, WPN_ELBOW, or for animals WPN_BITE, WPN_CLAW, WPN_STING, WPN_CRUSH (with _TINY to _HUGE sizes). It decides the damage table, the speed of the attacks and which weapon skill counts. A zone file sets it with attack in an NPC (NATURAL_DEF(weapon_category, armour_category) in wmacros.h); players change theirs with the attackswitch command (commands.zon).

Notes

  • On an object, a room or null it fails.
  • No access level is needed to assign it.
  • Stored as an unsigned 8-bit number, and not checked: assign only WPN_ weapon types (vmc accepts 7 to 199 in a zone file). The combat code uses it as an index into the weapon tables, so a value of 200 or more reads past their end.
  • weapon_name() gives the name of the type.

Example

dilbegin set_attack(arg : string);
var
   lst : stringlist;
   wpn : intlist;
   i : integer;
code
{
   lst := {"fist", "kick", "knee", "elbow"};
   wpn := {WPN_FIST, WPN_KICK, WPN_KNEE, WPN_ELBOW};
   i := 0;
   while (i < length(lst))
   {
      if (lst.[i] == arg)
      {
         self.attack_type := wpn.[i];
         sendtext("Attack type set to " + weapon_name(self.attack_type) + ".<br/>", self);
         return;
      }
      i := i + 1;
   }
   sendtext("Choose fist, kick, knee or elbow.<br/>", self);
   return;
}
dilend

Lets a player choose how to fight unarmed, as attackswitch does in commands.zon.

See also