Jump to content

Added a new GameState object to all soldiers?


kosmo111

Recommended Posts

It is done.

 

I was able to access and modify templates for all the difficulties during application startup (even pre-TemplateValidation, which is kinda nice). Convincing XCom to accept CampaignSettings that early was like running through a game crash minefield for me though. This is what finaly worked for me.

local XComGameStateHistory History;
local XComGameStateContext_StrategyGameRule StrategyStartContext;
local XComGameState StartState;
local XComGameState_CampaignSettings Settings;

local X2CharacterTemplateManager Characters;
local X2CharacterTemplate soldier;
local int DifficultyIndex;

Characters = class'X2CharacterTemplateManager'.static.GetCharacterTemplateManager();
History = `XCOMHISTORY;

StrategyStartContext = XComGameStateContext_StrategyGameRule(class'XComGameStateContext_StrategyGameRule'.static.CreateXComGameStateContext());
StrategyStartContext.GameRuleType = eStrategyGameRule_StrategyGameStart;
StartState = History.CreateNewGameState(false, StrategyStartContext);
History.AddGameStateToHistory(StartState);

Settings = new class'XComGameState_CampaignSettings'; // Do not use CreateStateObject() here
StartState.AddStateObject(Settings);

for( DifficultyIndex = `MIN_DIFFICULTY_INDEX; DifficultyIndex <= `MAX_DIFFICULTY_INDEX; ++DifficultyIndex )
{
  Settings.SetDifficulty(DifficultyIndex);
  `log("Difficulty:"@string(class'XComGameState_CampaignSettings'.static.GetDifficultyFromSettings()));

  soldier = Characters.FindCharacterTemplate('Soldier');
  soldier.CharacterBaseStats[eStat_HP] = 10 + DifficultyIndex;
}

History.ResetHistory(); // yeah, lets do that, nothing happend anyway...

The key parts here are newing up the Settings instead of asking kindly for StateObject creation, since that always ended in proccess termination for me. And of course as Amineri mentioned, we have to mop up the History aferwards. We do not want anybody downstream to ask serious questions about that house of cards we build here to fool the TemplateManagers.

Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...