Manual:DIL Manual/meleedamage()

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

meleedamage()

Function (integer). Makes a character strike another once, without first putting it into combat.

meleedamage(att : unitptr, def : unitptr, bonus : integer, wtype : integer) : integer

Works like meleeattack() with the main hand: one blow from att on def with the hit roll, armour, shield, damage and combat messages. The difference: the call itself doesn't make att fight def or change its position, and att doesn't need to be fighting anyone. skills.zon uses it for throwing: the thrown item is put in the wield position for the blow and taken out again.

Parameters

Name Type Meaning
att unitptr The attacking character.
def unitptr The character hit.
bonus integer Added to the hit roll (negative for a penalty).
wtype integer A weapon type WPN_* from vme/include/values.h (7 to 199) to strike with that type, ignoring any weapon; any other value, such as 0, uses the weapon in WEAR_WIELD, or the natural attack when there is none.

Returns

The damage done; 0 for a miss, a fumble or a blow the shield took. -1 when no blow happened: att is incapacitated (below sleeping), def is dead, they are the same unit, or they aren't in the same place. When either unit is null or not a character, the call fails and the variable assigned keeps its old value.

Notes

  • Every blow, a miss too, has the usual effects of an attack: a victim that isn't fighting starts fighting att, a victim that is makes att fight it, it counts as an attack for the law (crimes), and when neither may attack the other under the player-killing rules the damage is 0.
  • The blow costs combat time like an ordinary one (the weapon's speed).
  • The blow can kill def. Afterwards the program's secures are checked at once, so a secure on the victim can jump to its label.

Example

dilbegin throw_at(targ : unitptr, thing : unitptr);
var
   wielded : unitptr;
   dam : integer;
code
{
   wielded := equipment(self, WEAR_WIELD);
   if (wielded != null)
      unequip(wielded);
   addequip(thing, WEAR_WIELD);
   act("You throw $2n at $3n!", A_ALWAYS, self, thing, targ, TO_CHAR);
   act("$1n throws $2n at you!", A_SOMEONE, self, thing, targ, TO_VICT);
   dam := meleedamage(self, targ, 0, 0);
   unequip(thing);
   if (wielded != null)
      addequip(wielded, WEAR_WIELD);
   quit;
}
dilend

Throws an item from the inventory at someone, as the throw skill in skills.zon does.

See also