XCOM: Chimera Squad

XCOM: Chimera Squad

Create and Share Mods
Create your own enemies, characters, weapons, maps, and other content to expand XCOM: Chimera Squad. Mods are created by and for the XCOM community and are not officially supported by Firaxis or 2K.
Need help refreshing unit's soldier template / training on load
I have a mod nearly ready that includes custom training programs for Shelter. I'm adding these trainings to the character's soldier template like so:

class GimmeShelter_TrainableSoldier extends X2SoldierClassTemplate; // SoldierTemplate.SoldierRanks is protected, can only access within a subclass static function bool AddTrainingAtLevel(X2SoldierClassTemplate SoldierTemplate, name ProgramTemplateName, int Level) { SoldierTemplate.SoldierRanks[Level].TrainingPrograms.AddItem(ProgramTemplateName); return true; }

This works, and when starting up a new game with the mod all is well, the custom training programs are available at the associated levels.

However when I load a game that didn't have my mod enabled when the game was created, the trainings are not available. I think the unit is using the prior soldier template that doesn't include the training.

I'm looking for a way to force the unit to reload its soldier template.

In XComGameState_Unit there is a promising function,
SetSoldierClassTemplate()
, however this requires getting a reference to Shelter's XComGameState_Unit first, I'm not sure how to do that.

Also not sure if this is the best approach...looking for any hints or recommendations on how to reassociate the unit to a modified SoldierClassTemplate or otherwise get it to recognize the trainings that were added to the soldier class without being destructive to the unit.

As in, I could live with needing to re-rankup abilities, but I don't want the unit to lose out on their previously trained abilities.
< >
Showing 1-4 of 4 comments
chair5768 8 23 May, 2020 @ 10:28pm 
The macro: `DIOHQ will give you a link to the game's current XComGameState_HeadquartersDio

Diohq has an array called Squad, which contains a reference to every agent the player has.
InverseFalcon 1 24 May, 2020 @ 7:36am 
Perfect, just what I'm looking for, hadn't seen the hq classes! Thank you!
InverseFalcon 1 24 May, 2020 @ 3:25pm 
Verified via testing that the soldier class template for Shelter's unit is my modified one on load, so there's no need to replace it. The issue is that available training programs are only populated on level up and just for the new level, not prior ones. I need a way to unlock all prior training programs (that aren't already available or completed).

I'm pretty sure I have something that works (or at least I'm in a good position to test out a few different approaches), but the OnLoadedSavedGame() callback (first time with DLC) doesn't appear to be triggering at all.

class X2DownloadableContentInfo_GimmeShelter extends X2DownloadableContentInfo; static event OnLoadedSavedGame() { `RedScreen("OnLoadedSavedGame()"); class'GimmeShelter_TrainingPrograms'.static.ReloadShelterTrainingPrograms(); }

I first started up the app normally with no DLCs enabled and created and saved a game for later testing. It wasn't created with the mod, so when I load this with my mod it should trigger the OnLoadedSavedGame() callback.

Then I quit out, recompiled and launched the mod (confirmed via redscreen that it was loaded), then loaded the save game. Should have seen redscreens at least confirming these lifecycle callbacks are being executed, but not seeing a thing.

(and yes this is the same class that contains my working OnPostTemplatesCreated() function...THAT callback is working, but others aren't)

Kind of puzzled here.
Last edited by InverseFalcon; 24 May, 2020 @ 3:42pm
InverseFalcon 1 24 May, 2020 @ 4:23pm 
Okay, so while redscreens aren't triggering (weird), code IS executing. My code to restore prior trainings (that aren't already completed) is working.

Just a bit more testing, then I think I'm ready for publishing.
< >
Showing 1-4 of 4 comments
Per page: 1530 50