Skip to content

[CPLUS plus ex] Skill State

DasKeifer edited this page Sep 30, 2026 · 6 revisions

Skill State

Functions for checking skill states during gameplay.

Make sure you are familiar with the Key Concepts: Skill States

Table of Contents

getSkillsEnabled

  • table cplus_plus_ex:getSkillsEnabled()

Returns a set like table of all enabled skills.

Returns: {skillId = true, ...}

Example:

local enabledSkills = cplus_plus_ex:getSkillsEnabled()
for skillId in pairs(enabledSkills) do
    LOG("Enabled: " .. skillId)
end

isSkillEnabled

  • bool cplus_plus_ex:isSkillEnabled(skillId)
Argument name Type Description
skillId string Skill ID to check

Returns true if the skill is enabled in configuration and, as such, can be selected for pilots

Example:

if cplus_plus_ex:isSkillEnabled("Health") then
    LOG("Health skill is available")
end

getSkillsInRun

  • table cplus_plus_ex:getSkillsInRun()

Returns a table mapping skill IDs to pilot data for all skills in the current run.

Returns: {skillId = [{pilot, skillIndices}, ...], ...}

Example:

local inRunSkills = cplus_plus_ex:getSkillsInRun()
for skillId, pilotDataArray in pairs(inRunSkills) do
    LOG("Skill " .. skillId .. " is on " .. #pilotDataArray .. " pilot(s)")
    for _, data in ipairs(pilotDataArray) do
        LOG("  " .. data.pilot:getNameStr())
    end
end

getSkillObjsInRun

  • table cplus_plus_ex:getSkillObjsInRun(skillId)
Argument name Type Description
skillId string Skill ID to check

Returns an array of all Memhack PilotLvlUpSkill objects that are currently earned in the run

Example:

for _, skill in ipairs(cplus_plus_ex:getSkillObjsInRun("Reactor")) do
    LOG("Skill in Run: "..tostring(skill))
end

isSkillInRun

  • bool cplus_plus_ex:isSkillInRun(skillId)
Argument name Type Description
skillId string Skill ID to check

Returns true if the skill has been earned by at least one pilot in the run (in storage or piloting mechs).

Example:

if cplus_plus_ex:isSkillInRun("Reactor") then
    LOG("At least one pilot has Reactor this run")
end

getSkillsActive

  • table cplus_plus_ex:getSkillsActive()

Returns a table mapping skill IDs to mech data for all currently active skills.

Returns: {skillId = [{pawnId, pilot, skillIndices}, ...], ...}

Example:

local activeSkills = cplus_plus_ex:getSkillsActive()
for skillId, mechDataArray in pairs(activeSkills) do
    LOG("Active skill: " .. skillId)
    for _, data in ipairs(mechDataArray) do
        LOG("  Mech " .. data.pawnId .. ": " .. data.pilot:getNameStr())
    end
end

getSkillObjsActive

  • table cplus_plus_ex:getSkillObjsActive(skillId)
Argument name Type Description
skillId string Skill ID to check

Returns an array of all Memhack PilotLvlUpSkill objects that are currently earned on the pilots in the mechs

Example:

for _, skill in ipairs(cplus_plus_ex:getSkillObjsActive("Reactor")) do
    LOG("Skill Active: "..tostring(skill))
end

isSkillActive

  • bool cplus_plus_ex:isSkillActive(skillId)
Argument name Type Description
skillId string Skill ID to check

Returns true if the skill has been earned by at least one of the pilots currently piloting a mech.

Example:

if cplus_plus_ex:isSkillActive("Grid") then
    LOG("Grid skill is currently active on a mech")
end

getMechsWithSkill

  • table cplus_plus_ex:getMechsWithSkill(skillId, checkEarned)
Argument name Type Description
skillId string Skill ID to search for
checkEarned bool If true, only includes earned skills (Default: true)

Returns an array of mechs (squad pawns 0-2) whose pilots have the specified skill.

Returns: Array of {pawnId, pilot, skillIndices} where:

  • pawnId - Pawn ID (0-2)
  • pilot - memhack Pilot struct
  • skillIndices - Array of skill slot numbers

Example:

local mechsWithMove = cplus_plus_ex:getMechsWithSkill("Move")
for _, data in ipairs(mechsWithMove) do
    LOG("Mech " .. data.pawnId .. ": " .. data.pilot:getNameStr() .. " has Move")
end

isSkillOnPawn

  • bool cplus_plus_ex:isSkillOnPawn(skillId, pawn, checkEarned)
Argument name Type Description
skillId string Skill ID to check
pawn Pawn Pawn object
checkEarned bool If true, only returns true if pilot has earned the skill (Default: true)

Returns true if the pawn's pilot has the specified skill.

Example:

local pawn = Board:GetPawn(0)
if cplus_plus_ex:isSkillOnPawn("Health", pawn) then
    LOG("This pawn's pilot has Health skill")
end

-- Check if they have it at all, regardless of level
if cplus_plus_ex:isSkillOnPawn("Move", pawn, false) then
    LOG("Pilot has Move (may not be earned yet)")
end

getPilotsWithSkill

  • table cplus_plus_ex:getPilotsWithSkill(skillId, pilots, checkEarned)
Argument name Type Description
skillId string Skill ID to search for
pilots table Array of memhack Pilot structs (Default: nil - all pilots)
checkEarned bool If true, only includes earned skills (Default: true)

Returns an array of pilots that have the specified skill.

Returns: Array of {pilot, skillIndices} where:

  • pilot - memhack Pilot struct
  • skillIndices - Array of skill slot numbers: {1}, {2}, or {1, 2} if pilot has the skill in both slots

Example:

local pilotsWithHealth = cplus_plus_ex:getPilotsWithSkill("Health")
for _, data in ipairs(pilotsWithHealth) do
    local slots = table.concat(data.skillIndices, ", ")
    LOG(data.pilot:getNameStr() .. " has Health in slot(s): " .. slots)
end

-- Check only squad pilots
local squadPilots = Game:GetSquadPilots()
local pilotsWithMove = cplus_plus_ex:getPilotsWithSkill("Move", squadPilots)

getPilotEarnedSkillIndexes

  • table cplus_plus_ex:getPilotEarnedSkillIndexes(pilot)
Argument name Type Description
pilot Pilot memhack Pilot struct to get earned skill indexes of

Returns an array like table of the skill indexes earned by the pilot. Note virtual skills (idx 3+) are considered always earned

Example:

local pilot = Board:GetPawn(0):GetPilot()
for _, idx in ipairs(cplus_plus_ex:getPilotEarnedSkillIndexes(pilot)) do
    LOG(pilot:getNameStr() .. " has earned skill ".. pilot:getLvlUpSkill(idx).. " at index " .. idx)
end

getPilotEarnedSkillIds

  • table cplus_plus_ex:getPilotEarnedSkillIds(pilot, excludeSlotIndexes)
Argument name Type Description
pilot Pilot memhack Pilot struct
excludeSlotIndexes table/nil Optional set/list of slot indexes to skip

Returns an array of skill ID strings for earned skills on the pilot (including virtual slots).

Example:

local pilot = Game:GetSquadPilots()[1]
local ids = cplus_plus_ex:getPilotEarnedSkillIds(pilot)
for _, skillId in ipairs(ids) do
    LOG("Earned: " .. skillId)
end

getPilotSkillIndices

  • table cplus_plus_ex:getPilotSkillIndices(skillId, pilot, checkEarned)
Argument name Type Description
skillId String SkillId of the skill to get indexes of
pilot Pilot memhack Pilot struct to get earned skill indexes of
checkEarned bool If true, only returns indexes pilot has earned (Default: true)

Returns an array like table of the indexes of the specified skill for the passed pilot or empty if the pilot does not have the skill (or has not earned it if checkEarned is true)

Example:

local pilot = Board:GetPawn(0):GetPilot()
local indexes = table.concat(cplus_plus_ex:getPilotSkillIndices("Reactor", pilot), ", "))
LOG(pilot:getNameStr() .. " has earned reactor skill at indexes ".. indexes)

hasPilotEarnedSkillIndex

  • bool cplus_plus_ex:hasPilotEarnedSkillIndex(pilot, skillIndex)
Argument name Type Description
pilot Pilot memhack Pilot struct to get earned skill indexes of
skillIndex int skill index to check if earned

Returns true if the pilot has earned the skill at the passed index or false otherwise

Example:

local pilot = Board:GetPawn(0):GetPilot()
if cplus_plus_ex:hasPilotEarnedSkillIndex(pilot, 2) then
    LOG(pilot:getNameStr() .. " has earned skill ".. pilot:getLvlUpSkill(idx).. " at index 2")
end

isSkillOnPilot

  • bool cplus_plus_ex:isSkillOnPilot(skillId, pilot, checkEarned)
Argument name Type Description
skillId string Skill ID to check
pilot Pilot memhack Pilot struct
checkEarned bool If true, only returns true if pilot has earned the skill (Default: true)

Returns true if the pilot has the specified skill.

Example:

local pawn = Board:GetPawn(0)
local pilot = pawn:GetPilot()

if cplus_plus_ex:isSkillOnPilot("Reactor", pilot) then
    LOG(pilot:getNameStr() .. " has Reactor")
end

isSkillOnPilots

  • bool cplus_plus_ex:isSkillOnPilots(skillId, pilots, checkEarned)
Argument name Type Description
skillId string Skill ID to check
pilots table Array of memhack Pilot structs to check for skill in (Default: nil - all pilots)
checkEarned bool If true, only returns true if at least one pilot has earned the skill (Default: true)

Returns true if ANY of the pilots has the specified skill.

Example:

-- Check all available pilots
if cplus_plus_ex:isSkillOnPilots("Grid") then
    LOG("At least one available pilot has Grid")
end

-- Check specific pilots
local squadPilots = Game:GetSquadPilots()
if cplus_plus_ex:isSkillOnPilots("Move", squadPilots) then
    LOG("At least one squad pilot has Move")
end

getVirtualSkills

  • table cplus_plus_ex:getVirtualSkills(pilot)
Argument name Type Description
pilot Pilot memhack Pilot struct (looked up by pilot:getUidStr())

Returns an array of skill IDs for all virtual skills (slot 3+) assigned to the pilot. Order matches virtual slot order (slot index = 2 + i). Passing a string errors and returns {}.

Example:

local pilot = Game:GetSquadPilots()[1]
local virtualSkills = cplus_plus_ex:getVirtualSkills(pilot)
if #virtualSkills > 0 then
    LOG(pilot:getNameStr() .. " has " .. #virtualSkills .. " virtual skills:")
    for i, skillId in ipairs(virtualSkills) do
        local slotNum = 2 + i  -- Slot 3, 4, 5, etc.
        LOG(string.format("  Slot %d: %s", slotNum, skillId))
    end
else
    LOG(pilot:getNameStr() .. " has no virtual skills")
end

getVirtualSkillObjects

  • table cplus_plus_ex:getVirtualSkillObjects(pilot)
Argument name Type Description
pilot Pilot memhack Pilot struct

Returns an array of memhack PilotLvlUpSkill struct objects for all virtual skills. These objects function identically to vanilla skill objects and can be used for reading bonuses, skill properties, etc.

Example:

local pilot = Game:GetSquadPilots()[1]
local virtualObjs = cplus_plus_ex:getVirtualSkillObjects(pilot)

for i, skillObj in ipairs(virtualObjs) do
    local skillId = skillObj:getIdStr()
    local earned = skillObj:getEarned()
    LOG(string.format("Virtual slot %d: %s (earned: %s)", 
        2 + i, skillId, tostring(earned)))
end

getVirtualSkillObject

  • table|nil cplus_plus_ex:getVirtualSkillObject(pilot, slotIndex)
Argument name Type Description
pilot Pilot memhack Pilot struct
slotIndex int 1 for first virtual skill (slot 3), 2 for second (slot 4), etc.

Returns the memhack PilotLvlUpSkill struct object for the passed virtual skill slot or nil if there is none.

Example:

local pilot = Game:GetSquadPilots()[1]
local virtualObj = cplus_plus_ex:getVirtualSkillObject(pilot, 1)

if virtualObj then
    local skillId = virtualObj:getIdStr()
    local earned = virtualObj:getEarned()
    LOG(string.format("Virtual slot %d: %s (earned: %s)", 
        1, skillId, tostring(earned)))
end

getTotalSkillCount

  • int cplus_plus_ex:getTotalSkillCount(pilot)
Argument name Type Description
pilot Pilot memhack Pilot struct

Returns the number of skills total the pilot has (virtual and regular) regardless of if they are earned or not.

Example:

local pilot = Game:GetSquadPilots()[1]
local skillCount = cplus_plus_ex:getTotalSkillCount(pilot)

LOG(pilot:getNameStr() .. " has " .. skillCount .. " total skills")

getAllSkills

  • table cplus_plus_ex:getAllSkills(pilot)
Argument name Type Description
pilot Pilot memhack Pilot struct

Returns an array containing ALL skill IDs for the pilot, including both real skills (slots 1-2) and virtual skills (slots 3+). The order is: [real skill 1, real skill 2, virtual skill 1, virtual skill 2, ...]

This is the recommended way to get a complete list of a pilot's skills.

Example:

local pilot = Game:GetSquadPilots()[1]
local allSkills = cplus_plus_ex:getAllSkills(pilot)

LOG(pilot:getNameStr() .. " has " .. #allSkills .. " total skills:")
for i, skillId in ipairs(allSkills) do
    if i <= cplus_plus_ex.MAX_SKILL_SLOTS then
        LOG(string.format("  Slot %d (real): %s", i, skillId))
    else
        LOG(string.format("  Slot %d (virtual): %s", i, skillId))
    end
end

Clone this wiki locally