Class RangedAttack
Methods
rangedattack:init (data) | Initiate a ranged attack from its definition. |
rangedattack:get_name () | Get the name of the ranged attack. |
rangedattack:get_description () | Get the description of the ranged attack. |
rangedattack:use (target, attacker, item) | Use the ranged attack |
rangedattack:does_hit (target, attacker, item) | Calculate whether the ranged attack hits. |
rangedattack:calc_hit_chance (target, attacker, item) | Calculate the chance the ranged attack will hit. |
rangedattack:recharge (possessor, item) | Recharge the charges of the ranged attack. |
rangedattack:get_potential_targets (attacker) | Gets potential targets of a ranged attack. |
Methods
- rangedattack:init (data)
-
Initiate a ranged attack from its definition. You shouldn't use this function, the game uses it at loadtime to instantiate the ranged attacks.
Parameters:
- data Table. The table of attack information.
Returns:
-
ranged_attack. The attack itself.
- rangedattack:get_name ()
-
Get the name of the ranged attack.
Returns:
-
String. The name of the attack.
- rangedattack:get_description ()
-
Get the description of the ranged attack.
Returns:
-
String. The description of the attack.
- rangedattack:use (target, attacker, item)
-
Use the ranged attack
Parameters:
- target Creature. The creature being targeted.
- attacker Creature. The creature doing the attack.
- item Item. The item being used to do the ranged attack (optional).
Returns:
-
Boolean. Whether the attack was successful.
- rangedattack:does_hit (target, attacker, item)
-
Calculate whether the ranged attack hits.
Parameters:
- target Creature. The creature being targeted.
- attacker Creature. The creature doing the attack.
- item Item. The item being used to do the attack. (optional)
Returns:
-
Boolean. Whether the attack hits or not.
- rangedattack:calc_hit_chance (target, attacker, item)
-
Calculate the chance the ranged attack will hit. *MAY WANT TO CHANGE FOR YOUR OWN GAME*
Parameters:
- target Creature. The creature being targeted.
- attacker Creature. The creature doing the attack.
- item Item. The item being used to do the attack. (optional)
Returns:
-
Number. The % hit chance.
- rangedattack:recharge (possessor, item)
-
Recharge the charges of the ranged attack.
Parameters:
- possessor Creature. The creature who has the attack.
- item Item. The item that has the attack.
Returns:
-
Boolean. Whether the recharging was successful.
- rangedattack:get_potential_targets (attacker)
-
Gets potential targets of a ranged attack. Defaults to seen creatures
Parameters:
- attacker Creature. The user of the ranged attack
Returns:
-
Table. A list of potential targets