Class: AttackHelper

AttackHelper()

Provides attack and damage-related helpers.

Constructor

new AttackHelper()

Source:

Methods

BuildAttackEffectsSchema() → {string}

Builds a RelaxRNG schema of possible attack effects. See globalscripts/AttackEffects.js for possible elements. Attacks may also have a "Bonuses" element.
Source:
Returns:
- RelaxNG schema string.
Type
string

CauseDamageOverArea(data)

Damages units around a given origin.
Parameters:
Name Type Description
data Object The data sent by the caller.
Properties
Name Type Attributes Description
type string The type of damage.
attackData Object The attack data.
attacker number The entity id of the attacker.
attackerOwner number The player id of the attacker.
origin Vector2D The origin of the projectile hit.
radius number The radius of the splash damage.
shape string The shape of the radius.
direction Vector3D <optional>
The unit vector defining the direction. Needed for linear splash damage.
friendlyFire boolean A flag indicating if allied entities also ought to be damaged.
Source:

GetAttackBonus(source, target, type, template) → {number}

Calculates the attack damage multiplier against a target.
Parameters:
Name Type Description
source number The source entity's id.
target number The target entity's id.
type string The type of attack.
template Object The bonus' template.
Source:
Returns:
- The source entity's attack bonus against the specified target.
Type
number

GetAttackEffectsData()

Returns a template-like object of attack effects.
Source:

GetPlayersToDamage(attackerOwner, friendlyFire) → {Array.<number>}

Get the list of players affected by the damage.
Parameters:
Name Type Description
attackerOwner number The player id of the attacker.
friendlyFire boolean A flag indicating if allied entities are also damaged.
Source:
Returns:
The ids of players need to be damaged.
Type
Array.<number>

GetTotalAttackEffects(target, effectData, effectType, bonusMultiplier, cmpResistance) → {number}

Calculate the total effect taking bonus and resistance into account.
Parameters:
Name Type Description
target number The target of the attack.
effectData Object The effects calculate the effect for.
effectType string The type of effect to apply (e.g. Damage, Capture or ApplyStatus).
bonusMultiplier number The factor to multiply the total effect with.
cmpResistance Object Optionally the resistance component of the target.
Source:
Returns:
- The total value of the effect.
Type
number

HandleAttackEffects(target, data, bonusMultiplier) → {boolean}

Handle an attack peformed on an entity.
Parameters:
Name Type Description
target number The targetted entityID.
data Object The data of the attack.
Properties
Name Type Description
type string The type of attack that was performed (e.g. "Melee" or "Capture").
effectData Object The effects use.
attacker number The entityID that attacked us.
attackerOwner number The playerID that owned the attacker when the attack was performed.
bonusMultiplier number The factor to multiply the total effect with, defaults to 1.
Source:
Returns:
- Whether we handled the attack.
Type
boolean