-
Notifications
You must be signed in to change notification settings - Fork 5
attackEvents
- AttackEvents
- modApi.events
A module adding attack related events to the mod loader's modApi.events.
A global variable of the same name (AttackEvents) will also be created, keeping track of versioning of this module.
Requires modApiExt and EventifyModApiExtHooks being initialized first.
Returns a table of information about the current attack in progress, if one exists, or nil if not.
Return table:
| Table Field | Type | Description |
|---|---|---|
mission |
table | A table holding information about the current mission |
pawn |
userdata | The pawn using the skill |
skillId |
string | Id of the skill being used |
p1 |
Point |
p1 argument to GetSkillEffect; position of the pawn using the skill |
p2 |
Point |
p2 argument to GetSkillEffect; the targeted point on which to use the skill |
See onAttackResolved. This event is used in the same way, with the exception that it will only be dispatched when the unit executing the attack is an ally.
See onAttackStart. This event is used in the same way, with the exception that it will only be dispatched when the unit executing the attack is an ally.
| Argument name | Type | Description |
|---|---|---|
mission |
table | A table holding information about the current mission |
pawn |
userdata | The pawn using the skill |
skillId |
string | Id of the skill being used |
p1 |
Point |
p1 argument to GetSkillEffect; position of the pawn using the skill |
p2 |
Point |
p2 argument to GetSkillEffect; the targeted point on which to use the skill |
Dispatched when a unit's attack (including Move) has completely resolved, and the board is no longer busy. The full outcome of the weapon shall now have been resolved.
Example:
local function handler(mission, pawn, weaponId, p1, p2)
LOGF("%s used by %s at %s has been completely resolved", weaponId, pawn:GetMechName(), p2:GetString())
end
modApi.events.onAttackResolved:subscribe(handler)
| Argument name | Type | Description |
|---|---|---|
mission |
table | A table holding information about the current mission |
pawn |
userdata | The pawn using the skill |
skillId |
string | Id of the skill being used |
p1 |
Point |
p1 argument to GetSkillEffect; position of the pawn using the skill |
p2 |
Point |
p2 argument to GetSkillEffect; the targeted point on which to use the skill |
Dispatched when a unit begins executing an attack (including Move). It will not be dispatched from attacks carried out in a tip image.
Example:
local function handler(mission, pawn, weaponId, p1, p2)
LOGF("%s used by %s at %s has started", weaponId, pawn:GetMechName(), p2:GetString())
end
modApi.events.onAttackStart:subscribe(handler)
See onAttackResolved. This event is used in the same way, with the exception that it will only be dispatched when the unit executing the attack is an enemy.
See onAttackStart. This event is used in the same way, with the exception that it will only be dispatched when the unit executing the attack is an enemy.
| Argument name | Type | Description |
|---|---|---|
pawn |
userdata | The pawn using the skill |
piOrigin |
Point | The origin of the queued attack |
piTarget |
Point | Unknown. More testing needed |
piQueuedShot |
Point | The target of the queued attack |
iQueuedSkill |
string | The id of the skill being queued |
Dispatched when a unit has its attack canceled. This event will not be dispatched from an attack being canceled due to the unit being killed, or from the unit carrying out its attack normally. It will also not be dispatched from attacks carried out in a tip image.
Example:
local function handler(pawn, piOrigin, piTarget, piQueuedShot, iQueuedSkill)
LOGF("%s's attack with %s from %s to %s was canceled",
pawn:GetMechName(),
iQueuedSkill,
piOrigin:GetString(),
piQueuedShot:GetString()
)
end
modApi.events.onQueuedAttackCanceled:subscribe(handler)
| Argument name | Type | Description |
|---|---|---|
pawn |
userdata | The pawn using the skill |
piOrigin |
Point | The origin of the queued attack |
piTarget |
Point | Unknown. More testing needed |
piQueuedShot |
Point | The target of the queued attack |
iQueuedSkill |
string | The id of the skill being queued |
Dispatched when a unit queues up an attack. This event will not be dispatched from attacks carried out in a tip image.
Example:
local function handler(pawn, piOrigin, piTarget, piQueuedShot, iQueuedSkill)
LOGF("%s queued up an attack with %s from %s to %s",
pawn:GetMechName(),
iQueuedSkill,
piOrigin:GetString(),
piQueuedShot:GetString()
)
end
modApi.events.onQueuedAttackInitiated:subscribe(handler)