In my quest to recreate the Escort game mode from AA3, I've finally figured out to have a victory condition check rank. I've left in some of my incomplete efforts regarding getting rank name, but this works off the rank number(?) ("8" for CUSTOM1). I've left the print statements for debugging purposes commented out. This is based on the tutorial by UselessFodder and example code from Bohemia found here: https://community.bistudio.com/wiki/Arma_Reforger:Action_Context_Setup
class MyScriptedUserAction : ScriptedUserAction
{
//------------------------------------------------------------------------------------------------
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(pUserEntity);
Faction faction = character.GetFaction();
//string factionName = faction.GetFactionName();
//Print(factionName);
string characterName = character.GetName();
//Print(characterName);
ECharacterRank rank = SCR_CharacterRankComponent.GetCharacterRank(pUserEntity);
string rankNumber = rank.ToString();
//string rankName = SCR_CharacterRank.GetRankName(pUserEntity);
//string rankName = SCR_CharacterRankComponent.GetCharacterRankNameUpperCase(pUserEntity);
//Print(rankNumber);
if (faction)
{
if (rankNumber == "8")
{
VIPExtractVictory(faction);
}
}
}
void VIPExtractVictory(Faction faction)
{
SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode());
int factionIndex = GetGame().GetFactionManager().GetFactionIndex(faction);
gameMode.EndGameMode(SCR_GameModeEndData.CreateSimple(SCR_GameModeEndData.ENDREASON_EDITOR_FACTION_VICTORY, -1, factionIndex));
}
};