Skip to main content

add_attack

Discworld living help

add_attack

Name

add_attack - Add a specific attack to an object.

Syntax

add_attack( string name, int chance, int *damage, string type, string skill, mixed func );

Description

add_attack can be used to add a specific attack to a weapon, monster or any other object that ever gets into a fight.

Each argument used in add_attack() is detailed below.

1.This argument must be a string and defines the name of the attack, as it will be called in write_message. i.e. "slash", or "cripple".
2.The percentage chance of happening. This does NOT mean that if you have three add_attacks they need be set at say 20,40,40 as they could all be at 100,100,100 and still work, it is their own percentage chance.
3.This is the damage of the attack in hit points. It consists of three numbers (to form the X+YdZ damage roll).
4.This is the type of damage done. I.e. "sharp", "blunt", "fire", etc..
5.This is the skill that will be used by the attack, read 'help fighting' to see what they are. It will be the word after the last dot in fighting.melee.x
6.Func is an optional variable which can be a string, being the name of a function called with a bunch of data on the weapon when this attack is used, or an array of an object and a string, being the object on which the same sort of function is called and the name of the function.
Example

add_attack( "slice", 88, ({ 32, 5, 15 }), "sharp", "mace", 0 );

This will add an attack "slice" with an 88 percent chance of happening, a 32+5D15 damage roll, of type "slash", using the fighting.combat.melee.sharp skill, and no func argument.

See also

remove_attack, write_message, attack_types