Difference between revisions of "Manual:DIL Manual/meleedamage()"
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = 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 [[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. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! 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 <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. | ||
| + | |} | ||
| − | + | == Returns == | |
| − | + | 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. | |
| − | |||
| − | + | == Notes == | |
| − | + | * 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. | |
| − | + | * 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. | ||
| − | + | == 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()]] | |
| − | + | * [[Manual:DIL Manual/equipment()|equipment()]] | |
| − | + | * [[Manual:DIL Manual/addequip()|addequip()]] | |
| − | + | * [[Manual:DIL Manual/unequip()|unequip()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
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 makesattfight 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.