Difference between revisions of "Manual:DIL Manual/meleedamage()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bfmeleedamage"></span>
+
= meleedamage() =
 +
'''Function''' (integer). Makes a character strike another once, without first putting it into combat.
  
−
  '''Function:  '''
+
  meleedamage(att : unitptr, def : unitptr, bonus : integer, wtype : integer) : integer
−
<i><!--CODE-->meleedamage ( c : unitptr, v : unitptr, b : integer, wt : integer );</i><!--ENDCODE-->
 
  
−
<!--TERM--> '''c'''
+
Works like [[Manual:DIL Manual/meleeattack()|meleeattack()]] with the main hand: one blow from <code>att</code> on <code>def</code> with the hit roll, armour, shield, damage and combat messages. The difference: the call itself doesn't make <code>att</code> fight <code>def</code> or change its position, and <code>att</code> 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.
−
<!--DEFINITION-->         the character that should make an additional attack
 
−
<!--TERM--> '''v'''
 
−
<!--DEFINITION-->         the character being attacked
 
−
<!--TERM--> '''b'''
 
−
<!--DEFINITION-->         any penalty or bonus added to the attack.
 
−
<!--TERM--> '''wt'''
 
−
<!--DEFINITION-->         the weapon type of the attack, if a valid type then that is used for the attack purpose, otherwise the default weapon/hand attack is used.
 
−
<!--TERM-->  '''returns'''
 
−
<!--DEFINITION-->        The amount of damage done or -1 for failed
 
  
−
ch' performs an attack (using whatever weapon is wielded or his bare hands) against 'vict'.
+
== Parameters ==
−
If wtype is within a valid weapon range (WPN_XXX) any weapon will be bypassed,
+
{| class="wikitable"
−
and the value will be used as the attacktype.  Good for things like "meleeattack
+
! Name !! Type !! Meaning
−
(ch, vict, bonus, WPN_CIRCLE_KICK)"  If you want person to be able to perform an
+
|-
−
extra attack even though wielding a weapon or something.  Note that this will
+
| att || unitptr || The attacking character.
−
require BOTH a weapon type WPN_CIRCLE_KICK and a skill "kick" in order for it to
+
|-
−
work.
+
| def || unitptr || The character hit.
−
'''Example:'''
+
|-
−
<i><!--CODE-->
+
| bonus || integer || Added to the hit roll (negative for a penalty).
−
---~---~---~---~---~---~---~---~---
+
|-
 +
| wtype || integer || A weapon type <code>WPN_*</code> from <code>vme/include/values.h</code> (7 to 199) to strike with that type, ignoring any weapon; any other value, such as 0, uses the weapon in <code>WEAR_WIELD</code>, or the natural attack when there is none.
 +
|}
  
−
dilbegin kick(arg : string);
+
== Returns ==
−
external
+
The damage done; 0 for a miss, a fumble or a blow the shield took. -1 when no blow happened: <code>att</code> is incapacitated (below sleeping), <code>def</code> 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.
−
    provoked_attack (victim : unitptr, ch : unitptr);
 
  
−
var
+
== Notes ==
−
    bonus : integer;
+
* Every blow, a miss too, has the usual effects of an attack: a victim that isn't fighting starts fighting <code>att</code>, a victim that is makes <code>att</code> 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.
−
    targ  : unitptr;
+
* The blow costs combat time like an ordinary one (the weapon's speed).
 +
* The blow can kill <code>def</code>. Afterwards the program's secures are checked at once, so a secure on the victim can jump to its label.
  
−
code
+
== Example ==
 +
<pre>
 +
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
 
dilend
 +
</pre>
 +
Throws an item from the inventory at someone, as the throw skill in skills.zon does.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
−
 
+
* [[Manual:DIL Manual/meleeattack()|meleeattack()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/equipment()|equipment()]]
−
<span id="bfmeleedamage"></span>
+
* [[Manual:DIL Manual/addequip()|addequip()]]
−
 
+
* [[Manual:DIL Manual/unequip()|unequip()]]
−
'''Function: '''
 
−
<i><!--CODE-->meleedamage ( c : unitptr, v : unitptr, b : integer, wt : integer );</i><!--ENDCODE-->
 
−
 
 
−
<!--TERM-->  '''c'''
 
−
<!--DEFINITION-->        the character that should make an additional attack
 
−
<!--TERM-->  '''v'''
 
−
<!--DEFINITION-->        the character being attacked
 
−
<!--TERM-->  '''b'''
 
−
<!--DEFINITION-->        any penalty or bonus added to the attack.
 
−
<!--TERM-->  '''wt'''
 
−
<!--DEFINITION-->        the weapon type of the attack, if a valid type then that is used for the attack purpose, otherwise the default weapon/hand attack is used.
 
−
<!--TERM-->  '''returns'''
 
−
<!--DEFINITION-->        The amount of damage done or -1 for failed
 
−
 
 
−
ch' performs an attack (using whatever weapon is wielded or his bare hands) against 'vict'.
 
−
If wtype is within a valid weapon range (WPN_XXX) any weapon will be bypassed,
 
−
and the value will be used as the attacktype.  Good for things like "meleeattack
 
−
(ch, vict, bonus, WPN_CIRCLE_KICK)"  If you want person to be able to perform an
 
−
extra attack even though wielding a weapon or something.  Note that this will
 
−
require BOTH a weapon type WPN_CIRCLE_KICK and a skill "kick" in order for it to
 
−
work.
 
−
'''Example:'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
dilbegin kick(arg : string);
 
−
external
 
−
    provoked_attack (victim : unitptr, ch : unitptr);
 
−
 
 
−
var
 
−
    bonus : integer;
 
−
    targ  : unitptr;
 
−
 
 
−
code
 
−
dilend
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
</i><!--ENDCODE-->
 

Latest revision as of 23:17, 14 November 2026

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