Pawn - itb-community/ITB-ModLoader GitHub Wiki

Pawn

This page describes functions of Pawn that have been added or changed as part of modding API.

  • For a page about the Pawn class as defined in vanilla version of the game, see [Vanilla] Pawn
  • For a page about the Pawn class functions added by the memedit, see Pawn.

 

 

Board Pawn

These functions are relevant to a pawn instance within the game, such as the one returned by Board:GetPawn.

 

ApplyDamage

Signature: void ApplyDamage(SpaceDamage)

Applies a SpaceDamage event directly to the pawn, without affecting the Board. This function uses SkillEffect:AddSafeDamage under the hood.

 

ClearUndoMove

Signature: void ClearUndoMove()

Clears the pawn's undoable flag, so that its most recent move cannot be undone by the player. Useful to prevent undo abuse with some modded weapons / move skills.

Example:

local pawn = Game:GetPawn(1) -- grab some pawn userdata reference
pawn:ClearUndoMove()

 

GetAbility

Signature: string GetAbility()

Returns the pilot skill of the pawn's pilot, or an empty string if the pawn has no pilot or the pilot has no pilot skill.

 

GetMutation

Signature: int GetMutation()

Returns the current mutation (Psion buff) of the pawn, or nil if it has none. See: SetMutation for more info about mutations. Returns nil if called while not in a mission.

 

GetPilotSkill

Signature: string GetPilotSkill()

This function is the same as Pawn.GetAbility.

 

GetEquippedWeapons

Signature: table Pawn:GetEquippedWeapons()

Returns a 2-size list containing the base ids of the pawn's primary and secondary weapons.

Example:

local pawn = Board:GetPawn(0) 
local weapons = pawn:GetEquippedWeapons() 
local primary = weapons[1] 
local secondary = weapons[2] 

LOGF("Pawn %s's equipped base weapons are %s and %s",
	pawn:GetMechName(),
	tostring(primary),
	tostring(secondary)
)

 

GetPoweredWeapons

Signature: table Pawn:GetPoweredWeapons()

Returns a list containing the upgraded ids of the pawn's powered primary and secondary weapons.

Example:

local pawn = Board:GetPawn(0) 
local weapons = pawn:GetPoweredWeapons() 
local weapon1 = weapons[1] 
local weapon2 = weapons[2] 

LOGF("Pawn %s's powered weapons are %s and %s",
	pawn:GetMechName(),
	tostring(weapon1),
	tostring(weapon2)
)

 

GetArmedWeapon

Signature: string Pawn:GetArmedWeapon()

Returns the base skill id of the pawn's armed weapon, or nil if no weapon is armed.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is currently arming %s",
	pawn:GetMechName(),
	tostring(pawn:GetArmedWeapon())
)

 

GetQueued

Signature: table GetQueued()

Returns a table of data containing information about the pawn's current queued attack. Returns nil if the pawn has not queued an attack. Returns nil if called while not in a mission.

Returned table:

Table field Type Description
piOrigin Point Origin of pawn
piTarget Point Unknown. More testing needed
piQueuedShot Point Target tile of attack
iQueuedSkill int index of Skill being queued

 

GetQueuedWeapon

Signature: string Pawn:GetQueuedWeapon()

Returns the internal name of the pawn's queued weapon, or nil if it has no weapon queued.

Example:

local pawn = Board:GetPawn(0) 
local weapon = pawn:GetQueuedWeapon() 

LOGF("Pawn %s has weapon %s queued",
	pawn:GetMechName(),
	tostring(weapon)
)

 

GetQueuedWeaponId

Signature: string Pawn:GetQueuedWeaponId()

Returns the weapon index (generally 1 or 2) of a pawn's queued weapon, or -1 if it has no weapon queued.

index skill
-1 None
0 Move
1 Primary Weapon
2 Secondary Weapon
50 Repair Skill

Example:

local pawn = Board:GetPawn(0) 
local weaponIndex = pawn:GetQueuedWeaponId() 

LOGF("Pawn %s has weapon index %s queued",
	pawn:GetMechName(),
	tostring(weaponIndex)
)

 

IsArmor

Signature: boolean IsArmor()

Returns true if a pawn has armor. false otherwise.

 

IsHighlighted

Signature: boolean IsHighlighted()

Returns true if the pawn is highlighted, otherwise false. Returns nil if called while not in a mission.

 

IsIgnoreFire

Signature: boolean IsIgnoreFire()

Returns true if the pawn is immune to fire, otherwise false.

 

IsIgnoreSmoke

Signature: boolean IsIgnoreSmoke()

Returns true if the pawn ignores smoke, otherwise false.

 

IsIgnoreWeb

Signature: boolean IsIgnoreWeb()

Returns true if the pawn is immune to being webbed, otherwise false.

 

IsMutation

Signature: boolean IsMutation(int)

Returns true if a pawn has the specific mutation (Psion buff). false otherwise. See: SetMutation for more info about mutations. Returns nil if called while not in a mission.

 

IsNeutral

Signature: boolean IsNeutral()

Returns true if the pawn is neutral. false otherwise. Returns nil if called while not in a mission.

 

IsPilotSkill

Signature: boolean IsPilotSkill(string)

Returns true if the pawn has a pilot with the specified pilot skill. false otherwise.

This function is the same as Pawn.IsAbility.

 

IsPowered

Signature: boolean IsPowered()

Returns true if the pawn is powered and able to act. false otherwise. Returns nil if called while not in a mission.

 

IsQueued

Signature: boolean IsQueued()

Returns true if a pawn has queued up an attack. false otherwise.

 

IsWeaponEquipped

Signature: boolean Pawn:IsWeaponEquipped(baseWeapon)

Argument name Type Description
baseWeapon string The base skill to check

Returns true if the pawn is equipped with a weapon with base type baseWeapon. false otherwise.

Example:

local pawn = Board:GetPawn(0) 
local skill = "Prime_Punchmech" 

LOGF("Pawn %s is equipped with %s is %s",
	pawn:GetMechName(),
	skill,
	tostring(pawn:IsWeaponEquipped(skill)),
)

 

IsWeaponPowered

Signature: boolean Pawn:IsWeaponPowered(weapon)

Argument name Type Description
weapon string The skill to check

Returns true if the pawn has powered a weapon of type weapon or a less powered variant of it. false otherwise.

Example: If a pawn has powered Prime_Punchmech_A, the following table shows the results of this method based on the input weapon:

weapon result
Prime_Punchmech true
Prime_Punchmech_A true
Prime_Punchmech_B false
Prime_Punchmech_AB false

 

MoveToBottom

Signature: void Pawn:MoveToBottom()

Tiles can contain multiple units (if you spawn a pawn on an occupied tile or use SetSpace to move a pawn to an occupied space). This moves a unit to the "bottom" of a tile, which makes it the unit that ets affected by anything that only affects a single unit on a tile.

 

SetFire

Signature: void SetFire(boolean)

Setting this to true applies fire to the pawn. Setting to false removes it.

 

SetNeutral

Signature: void SetNeutral(boolean)

Behaves the same way as vanilla SetNeutral, except saves the game immediately if the operation succeeds.

 

SetPowered

Signature: void SetPowered(boolean)

Behaves the same way as vanilla SetPowered, except saves the game immediately if the operation succeeds.

Pawn Type

These functions and fields are relevant to a pawn type class created on initialization, such as the mech pawn classes.

 

MoveSkill

Field containing a move Skill object to use for this pawn. Whenever the pawn moves, this skill will be called instead of the default logic.

The skill can contain a GetTargetArea and a GetSkillEffect function, which will be called at the relevant times. Note that due to a modding limitation, GetTargetArea is not called on hovering over the pawn, but will be properly called once the pawn is selected.

Also note that this does not work for enemy pawns; the MoveSkill field is completely ignored. One possible workaround, depending on your intent, is to use GetWeapon; it returns the index of the weapon the pawn will use (always 1, except for the Bot Leader, who can heal itself). GetWeapon is ran before movement exactly once, so you can use it to trigger effects as long as you make it return 1.