Members
Schema
callerIID
checkTimer
force
lastAttacked
preferredClassesSchema
restrictedClassesSchema
resyncAnimation
target
timer
Methods
Attack(data, lateness)
Attack our target entity.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
string | The attack type to use. |
lateness |
number | The offset of the actual call and when it was expected. |
CanAttack()
Checks whether this entity could ever attack the target, e.g. to decide whether
to bother moving towards it. Covers visibility (mirages included), but its range
check only requires the target to be reachable in principle: it's ORed with
CanEverReachTarget, which ignores terrain. Callers that need to know if the
target is precisely in range right now must check that themselves.
CanEverReachTarget(targetId, type) → {boolean}
Check if the target could potentially ever be reached with the given attack type,
as an optimistic estimate. This assumes the attacker can move to the closest
possible position to the target — ignoring obstructions and terrain features
(e.g., hills) that might help or hinder.
This is a best-effort guess:
- It may return true even when the target is actually unreachable (e.g., turreted
units on walls with a height offset too large for the projectile to overcome).
- It may return false even when the target is reachable (e.g., a nearby hill could
provide enough elevation to hit a "too high" target, but we don't check for that).
Currently these checks are mostly useful to determine if we can reach turreted units
(e.g. on a wall, outpost...).
Parameters:
| Name | Type | Description |
|---|---|---|
targetId |
number | The target entity ID. |
type |
string | The attack type. |
Returns:
- Whether the target is estimated to be reachable (see caveats above).
- Type
- boolean
CompareEntitiesByPreference()
GetAttackEffectsData()
GetAttackName()
GetAttackTypes()
GetAttackYOrigin()
GetBestAttackAgainst(target, allowCapture) → {string}
Find the best attack against a target.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
number | The entity-ID of the target. |
allowCapture |
boolean | Whether capturing is allowed. |
Returns:
- The preferred attack type.
- Type
- string
GetEffectiveAttackRange(target, type) → {Object}
Get the effective range for attacking a specific target, accounting
for elevation and projectile physics where applicable.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
number | The target entity ID. |
type |
string | The attack type. |
Returns:
- The min and max effective range,
or { Infinity, 0 } if the target cannot be reached on a parabolic
trajectory given the current terrain height difference.
- Type
- Object
GetFullAttackRange()
Get the full range of attack using all available attack types.
GetPreference()
Returns undefined if we have no preference or the lowest index of a preferred class.
GetPreferredClasses()
GetProjectileCount()
GetRange()
GetRangeOverlays()
GetRepeatTime()
GetRestrictedClasses()
GetSplashData()
GetTimers()
Init()
IsTargetInRange(target) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
target |
number | The entity ID of the target to check. |
Returns:
- Whether this entity is in range of its target.
- Type
- boolean
OnValueModification()
PerformAttack()
Attack the target entity. This should only be called after a successful range check,
and should only be called after GetTimers().repeat msec has passed since the last
call to PerformAttack.
RepeatRangeCheck()
StartAttacking(target, type, callerIID) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
target |
number | The target to attack. |
type |
string | The type of attack to use. |
callerIID |
number | The IID to notify on specific events. |
Returns:
- Whether we started attacking.
- Type
- boolean
StopAttacking(reason)
Parameters:
| Name | Type | Description |
|---|---|---|
reason |
string | The reason why we stopped attacking. |