Skip to content
Lemonymous edited this page Jul 6, 2023 · 4 revisions

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

  • 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 mod loader, see Pawn.

 

Table of Contents

 

Pawn

 

AddWeapon

  • void   Pawn:AddWeapon(weaponId, forceEnable)
  • Original function moved to AddWeaponVanilla

  When using the original function, the added weapon will be hidden unless it costs 0 cores, and is of the same class as the unit. If the additional optional parameter forceEnable is true the weapon will be enabled by setting its core cost to zero and matching the class of the unit.

Example:

local pawn = Board:GetPawn(0) 

pawn:AddWeapon("Brute_Tankmech", true) 

 

GetArmedWeaponType

  • string   Pawn:GetArmedWeaponType()
  • Alias GetArmedWeapon
  • Original function moved to GetArmedWeaponVanilla

  Looks up the armed weapon using memedit to get current values, instead of relying on save data which can be out of date.

Example:

local pawn = Board:GetPawn(0) 

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

 

GetBaseWeaponTypes

  • table   Pawn:GetBaseWeaponTypes()
  • Original function moved to GetEquippedWeaponsVanilla
  • Alias GetEquippedWeapons

  Looks up the unit's weapons using memedit to get current values, instead of relying on save data which can be out of date.

Example:

local pawn = Board:GetPawn(0) 
local weapons = pawn:GetBaseWeaponTypes() 
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)
)

 

GetClass

  • string   Pawn:GetClass()

  Returns the unit's current class. This could be different from the class of the unit's type, if it has been changed with SetClass.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's class is %s",
	pawn:GetMechName(),
	tostring(pawn:GetClass())
)

 

GetCustomAnim

  • string   Pawn:GetCustomAnim()

  Returns the unit's current custom animation. By default this should be "", if it has not been changed with SetCustomAnim

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's custom animation is %s",
	pawn:GetMechName(),
	tostring(pawn:GetCustomAnim())
)

 

GetDefaultFaction

  • number   Pawn:GetDefaultFaction()

  Returns the unit's default faction.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's default faction is %s",
	pawn:GetMechName(),
	tostring(pawn:GetDefaultFaction())
)

 

GetImageOffset

  • number   Pawn:GetImageOffset()

  Returns the pawn's image offset, defining which row of the unit's sprite-sheet it should use.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has image offset %s",
	pawn:GetMechName(),
	pawn:GetImageOffset()
)

 

GetImpactMaterial

  • number   Pawn:GetImpactMaterial()

  Returns the pawn's impact material.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has impact material %s",
	pawn:GetMechName(),
	pawn:GetImpactMaterial()
)

 

GetLeader

  • number   Pawn:GetLeader()

  Returns the pawn's psion ability integer. By default all units have the constant LEADER_NONE.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has psion ability integer %s",
	pawn:GetMechName(),
	pawn:GetLeader()
)

 

GetMaxBaseHealth

  • number   Pawn:GetMaxBaseHealth()

  Returns the unit's maximum base health.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has %s max base health",
	pawn:GetMechName(),
	pawn:GetMaxBaseHealth()
)

 

GetMaxHealth

  • number   Pawn:GetMaxHealth()

  Returns the pawn's maximum health.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has %s max health",
	pawn:GetMechName(),
	pawn:GetMaxHealth()
)

 

GetMutation

Overrides the modloader's Pawn:GetMutation function (see wiki) using memedit to check the mutation value, rather than checking the board for present psions.

 

GetOwner

  • number   Pawn:GetOwner()

  Returns the id of the pawn's owner.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has owner with id %s",
	pawn:GetMechName(),
	tostring(pawn:GetOwner())
)

 

GetPoweredWeaponTypes

  • table   Pawn:GetPoweredWeaponTypes()
  • Original function moved to GetPoweredWeapons
  • Alias GetPoweredWeapons

  Looks up the unit's weapons using memedit to get current values, instead of relying on save data which can be out of date.

Example:

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

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

 

GetQueuedTarget

  • Point   Pawn:GetQueuedTarget()

  Missing description - please fill this in if you know the answer.

Example:

-- Missing example

 

GetUndoLoc

  • Point   Pawn:GetUndoLoc()

  Returns the location the unit will end up in if the pawn's Undo Move is used.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's undo location is %s",
	pawn:GetMechName(),
	pawn:GetUndoLoc():GetString(),
)

 

GetWeaponBaseType

  • string   Pawn:GetWeaponBaseType(weaponIndex)

  Returns the base type of the weapon at the specified index.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's weapon at index %s has base type %s",
	pawn:GetMechName(),
	weaponIndex,
	pawn:GetWeaponBaseType(weaponIndex),
)

 

GetWeaponClass

  • string   Pawn:GetWeaponClass(weaponIndex)

  Returns the class of the weapon at the specified index.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's weapon at index %s has class %s",
	pawn:GetMechName(),
	weaponIndex,
	pawn:GetWeaponClass(weaponIndex),
)

 

GetWeaponCount

  • number   Pawn:GetWeaponCount()

  Returns the pawn's number of weapons.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has %s weapons",
	pawn:GetMechName(),
	pawn:GetWeaponCount(),
)

 

GetWeaponLimitedRemaining

  • number   Pawn:GetWeaponLimitedRemaining(weapon_index)
Argument name Type Description
weapon_index number The index of the weapon we want to check. Usually 1 or 2

  Returns the remaining limited uses of the pawn's wepaon in the specified index. Only applicable for limited use weapons.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn's weapon index 1 has %s uses remaining", pawn:GetWeaponLimitedRemaining(1))

 

GetWeaponLimitedUses

  • number   Pawn:GetWeaponLimitedUses(weapon_index)
Argument name Type Description
weapon_index number The index of the weapon we want to check. Usually 1 or 2

  Returns the max limited uses of the pawn's wepaon in the specified index. Only applicable for limited use weapons.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn's weapon index 1 has %s uses in total", pawn:GetWeaponLimitedUses(1))

 

GetWeaponType

  • string   Pawn:GetWeaponType(weaponIndex)

  Returns the current type of the weapon at the specified index. (includes upgrades)

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s's weapon at index %s has type %s",
	pawn:GetMechName(),
	weaponIndex,
	pawn:GetWeaponType(weaponIndex),
)

 

IsBaseWeaponTypeEquipped

  • boolean   Pawn:IsBaseWeaponTypeEquipped()
  • Original function moved to IsWeaponEquippedVanilla
  • Alias IsWeaponEquipped

  Looks up the unit's weapons using memedit to get current values, instead of relying on save data which can be out of date.

Example:

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

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

 

IsInvisible

  • boolean   Pawn:IsInvisible()

  Returns true if the pawn is invisible. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is invisible is %s",
	pawn:GetMechName(),
	tostring(pawn:IsInvisible()),
)

 

IsJumper

  Returns true if the pawn is a Jumper. false otherwise.

Note: Uses memdit to check the unit object instance instead of the unit type.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is a Jumper is %s",
	pawn:GetMechName(),
	tostring(pawn:IsJumper()),
)

 

IsMassive

  • boolean   Pawn:IsMassive()

  Returns true if the pawn is Massive. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is Massive is %s",
	pawn:GetMechName(),
	tostring(pawn:IsMassive()),
)

 

IsMinor

  • boolean   Pawn:IsMinor()

  Returns true if the pawn is Minor. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is Minor is %s",
	pawn:GetMechName(),
	tostring(pawn:IsMinor()),
)

 

IsMissionCritical

  • boolean   Pawn:IsMissionCritical()

  Returns true if the pawn has MissionCritical toggled on. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is MissionCritical is %s",
	pawn:GetMechName(),
	tostring(pawn:IsMissionCritical()),
)

 

IsMovementSpent

  • boolean   Pawn:IsMovementSpent()

  Returns true if the pawn has spent its movement. false otherwise.

Note: a pawn must have both not spent its movement as well as be active to be able to move.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s has spent its movement is %s",
	pawn:GetMechName(),
	tostring(pawn:IsMovementSpent()),
)

 

IsMutation

Overrides the modloader's Pawn:IsMutation function (see wiki) using memedit to check the mutation value being compared, rather than checking the board for present psions.

 

IsNeutral

  • boolean   Pawn:IsNeutral()

  Returns true if the pawn is neutral. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is neutral is %s",
	pawn:GetMechName(),
	tostring(pawn:IsNeutral()),
)

 

IsPushable

  • boolean   Pawn:IsPushable()

  Returns true if the pawn is pushable. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is pushable is %s",
	pawn:GetMechName(),
	tostring(pawn:IsPushable()),
)

 

IsSpaceColor

  • boolean   Pawn:IsSpaceColor()

  Returns true if the pawn colors its occupying tile. false otherwise.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s colors its occupying tile is %s",
	pawn:GetMechName(),
	tostring(pawn:IsSpaceColor()),
)

 

IsTeleporter

  Returns true if the pawn is a Teleporter. false otherwise.

Note: Uses memdit to check the unit object instance instead of the unit type.

Example:

local pawn = Board:GetPawn(0) 

LOGF("Pawn %s is a Teleporter is %s",
	pawn:GetMechName(),
	tostring(pawn:IsTeleporter()),
)

 

IsWeaponTypePowered

  • boolean   Pawn:IsWeaponTypePowered()
  • Original function moved to IsWeaponPoweredVanilla
  • Alias IsWeaponPowered

  Looks up the unit's weapons using memedit to get current values, instead of relying on save data which can be out of date.

Example:

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

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

 

RemoveWeapon

  • void   Pawn:RemoveWeapon(weaponIndex)

  Removes the unit's weapon at the specified weaponIndex, and moves all weapons at indexes above this one index up to fill in the gap.

Example:

local pawn = Board:GetPawn(0) 
pawn:RemoveWeapon(1)

 

SetAcid

  • void   Pawn:SetAcid(acid, no_animation)
  • void   Pawn:SetAcid(acid)
  • Original function moved to SetAcidVanilla
Argument name Type Description
acid boolean Whether to apply or remove acid
no_animation boolean Whether to skip animation and sound

  Same as the original function, but with an additional option argument no_animation; which if set to true skips all sound and animation and applies the effect immediately.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetAcid(true, true)

 

SetBoosted

  • void   Pawn:SetBoosted(boosted)
Argument name Type Description
boosted boolean Whether to apply or remove boosted

  Sets/unsets whether the unit is boosted; making its weapon deal more damage.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetBoosted(true)

 

SetClass

  • void   Pawn:SetClass(class)
Argument name Type Description
class string The class to set

  Sets the unit's class.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetClass("Brute")

 

SetCorpse

  • void   Pawn:SetCorpse(corpse)
Argument name Type Description
corpse boolean Whether to apply or remove corpse

  Sets/unsets whether a unit will leave a corpse when killed.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetCorpse(false)

 

SetDefaultFaction

  • void   Pawn:SetDefaultFaction(faction)
Argument name Type Description
faction number Which faction to set

  Sets the unit's default faction.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetFaction(FACTION_BOTS)

 

SetFlying

  • void   Pawn:SetFlying()
Argument name Type Description
flying boolean Whether to add or remove flying

  Sets or removes the pawn's flying state, as by the specified value.

Example:

local pawn = Game:GetPawn(0) 
pawn:SetFlying(true)

 

SetFrozen

  • void   Pawn:SetFrozen(frozen, no_animation)
  • void   Pawn:SetFrozen(frozen)
  • Original function moved to SetFrozenVanilla
Argument name Type Description
frozen boolean Whether to apply or remove frozen
no_animation boolean Whether to skip animation and sound

  Same as the original function, but with an additional option argument no_animation; which if set to true skips all sound and animation and applies the effect immediately.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetFrozen(true, true)

 

SetImageOffset

  • void   Pawn:SetImageOffset(imageOffset)
Argument name Type Description
imageOffset number Which image offset to set

  Sets the unit's image offset, defining which row of the unit's sprite-sheet it should use.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetImageOffset(1)

 

SetImpactMaterial

  • void   Pawn:SetImpactMaterial(impactMaterial)
Argument name Type Description
impactMaterial number Which impactmaterial to set

  Sets the unit's impact material, defining which impact sounds will play when the unit is hit.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetImpactMaterial(IMPACT_INSECT)

 

SetJumper

  • void   Pawn:SetJumper(jumper)
Argument name Type Description
jumper boolean Whether to make the pawn a Jumper, or to remove that ability

  Changes the unit's movement type to that of a Jumper if jumper is true, or removes that ability if false.

Example:

local pawn = Game:GetPawn(0) 
pawn:SetJumper(true)

 

SetMassive

  • void   Pawn:SetMassive(massive)
Argument name Type Description
massive boolean Whether to make the pawn Massive, or to remove that status

  Changes the unit to Massive if massive is true, or removes Massive from the unit if false.

Massive units can stand in water without getting killed

Example:

local pawn = Game:GetPawn(0) 
pawn:SetMassive(false)

 

SetMaxBaseHealth

  • void   Pawn:SetMaxBaseHealth(maxBaseHealth)
Argument name Type Description
maxBaseHealth number The maximum base health to set

  Sets the pawn's base maximum health to the specified amount.

When in a mission, the base max health does not affect the mech on the board.

When out of mission, the base max health will modify the pawn's maximum health, so the pawn will spawn with increased health when starting a new mission.

Example:

local pawn = Game:GetPawn(0) 
pawn:SetMaxBaseHealth(2)

 

SetMaxHealth

  • void   Pawn:SetMaxHealth(maxHealth)
Argument name Type Description
maxHealth number The maximum health to set

  Sets the pawn's maximum health to the specified amount.

When out of mission, the maximum health does not affect the mech.

When in a mission, the max health will modify the pawn's maximum health.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetMaxHealth(2)

 

SetMech

  • void   Pawn:SetMech(mech)
  • void   Pawn:SetMech()
  • Original function moved to SetMechVanilla
Argument name Type Description
mech boolean Whether to change the pawn to a mech, or remove that status

  Changes the pawn to be considered a mech if mech is true, or removes that classification if false, or calls the original function if the argument is left blank.

Due to how the game will very quickly crash with more or less mechs than exactly 3, this function will not allow setting more than 3 pawns to mechs.

There may be times when forcing a unit to be either a mech or a non-mech can be helpful, which is why this functionality is exposed.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetMech(true)

 

SetMinor

  • void   Pawn:SetMinor(minor)
Argument name Type Description
minor boolean Whether to make the pawn Minor, or to remove that status

  Sets or removes the unit's Minor state, as by the specified value.

Minor units don't give experience when killed; don't burrow underground when escaping; and don't count as a unit for spawning purposes.

Example:

local pawn = Game:GetPawn(0) 
pawn:SetMinor(false)

 

SetMovementSpent

  • void   Pawn:SetMovementSpent(movementSpent)
Argument name Type Description
movementSpent boolean Whether to disable or enable movement

  Spends the unit's movement if true, or unspends it if false.

Note: a pawn must have both not spent its movement as well as be active to be able to move.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetMovementSpent(true)

 

SetOwner

  • void   Pawn:SetOwner(pawnId)
Argument name Type Description
pawnId number The id of the unit to set as owner

  Sets the owner of the unit to the unit with the specified id.

A unit owned by a mech will be displayed next on the left hand side of the screen.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetOwner(1)

 

SetPushable

  • void   Pawn:SetPushable(pawnId)
Argument name Type Description
pushable boolean Whether to make the unit pushable or unpushable

  Makes the unit pushable if pushable is true, or unpushable if false. In-game, a unit that is unpushable is refered to as being Stable.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetPushable(false)

 

SetQueuedTarget

  • void   Pawn:SetQueuedTarget(loc)
Argument name Type Description
loc Point The point to queue the attack

  Changes the queued target of a unit to the specified location.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetQueuedTarget(Point(0,0))

 

SetShield

  • void   Pawn:SetShield(shield, no_animation)
  • void   Pawn:SetShield(shield)
  • Original function moved to SetShieldVanilla
Argument name Type Description
shield boolean Whether to apply or remove shield
no_animation boolean Whether to skip animation and sound

  Same as the original function, but with an additional option argument no_animation; which if set to true skips all sound and animation and applies the effect immediately.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetShield(true, true)

 

SetSpaceColor

  • void   Pawn:SetSpaceColor(spaceColor)
Argument name Type Description
spaceColor boolean Whether the unit's occupying tile is colored or not

  Sets/unsets whether the unit's occupying tile will be colored or not.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetSpaceColor(false)

 

SetTeleporter

  • void   Pawn:SetTeleporter(teleporter)
Argument name Type Description
teleporter boolean Whether to make the pawn a Teleporter, or to remove that ability

  Changes the pawn's movement type to that of a Teleporter if teleporter is true, or removes that ability if false.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetTeleporter(true)

 

SetUndoLoc

  • void   Pawn:SetUndoLoc(loc)
Argument name Type Description
loc Point The location to move the unit when using Undo Move

  Changes the unit's undo location to the specified location.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetUndoLoc(Point(0,0))

 

SetWeaponClass

  • void   Pawn:SetWeaponClass(weaponIndex, class)
Argument name Type Description
weaponIndex number The weapon to change
class string The class to set

  Changes the weapon at the specified index's class.

Note: The class referred to by this function is the class in the weapon object. This is by default set to be the same as the class of the owning unit. This weapon class is then compared to the class of the weapon type table in lua to see if the weapon should have an increased cost for being off-class.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetWeaponClass(1, "Brute")

 

SetWeaponLimitedRemaining

  • void   Pawn:SetWeaponLimitedRemaining(weapon_index, remaining)
Argument name Type Description
weapon_index number The index of the weapon we want to set. Usually 1 or 2
remaining number The number of remaining uses we want to set for the weapon

  Changes the remaining limited uses for a weapon to the specified amount.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetWeaponLimitedRemaining(1, 1) 

 

SetWeaponLimitedUses

  • void   Pawn:SetWeaponLimitedUses(weapon_index, uses)
Argument name Type Description
weapon_index number The index of the weapon we want to set. Usually 1 or 2
uses number The number of total uses we want to set for the weapon

  Changes the total limited uses for a weapon to the specified amount.

Example:

local pawn = Board:GetPawn(0) 
pawn:SetWeaponLimitedUses(1, 1)