Skip to content
Gabriel Guariglia Perez edited this page May 31, 2022 · 4 revisions

Table of Contents

 

AttackEvents

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.

 

getCurrentAttackInfo

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

 

onAllyAttackResolved

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.

 

onAllyAttackStart

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.

 

onAttackResolved

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)

 

onAttackStart

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)

 

onEnemyAttackResolved

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.

 

onEnemyAttackStart

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.

 

onQueuedAttackCanceled

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)

 

onQueuedAttackInitiated

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)

 

Clone this wiki locally