Jump to content
Supernova187

Code Snippet for Interaction Rank Based Victory Check

Recommended Posts

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));
	}

};

 

  • Like 2

Share this post


Link to post
Share on other sites

Hey @Supernova187!

In general, it is a very good idea to share code snippets of the solutions you have found, precisely because the Biki currently offers very little in this regard. I will try to do this in the future as well.
However, it would be better to share the snippets here:

 

https://forums.bohemia.net/forums/forum/415-arma-reforger-configs-scripting/

Share this post


Link to post
Share on other sites

Yes, I meant to post it there but didn't realize I was in the Workbench subforum when I started the post. :3

Share this post


Link to post
Share on other sites
45 minutes ago, Supernova187 said:

Yes, I meant to post it there but didn't realize I was in the Workbench subforum when I started the post. :3

 

You can report your first post by clicking on the "Report Post" link in the upper right corner. If you write there that you want this thread to be moved, a moderator will take over this task.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×