Jump to content

Toolbox technical questions here, please


Amineri

Recommended Posts

I feel like an idiot for asking this, but how do I use the SetMaxSquadSize() function in XComGameState_LWToolboxPrototype/XComGameState_LWToolboxOptions? How do I call this thing so it actually makes changes to the Toolbox settings?

I've added LW_XCGS_ModOptions and LW_XCGS_ToolboxOptions to my mod along with the ModEditPackages lines in XcomEngine.ini. I tried implementing my own extension of XComGameState_LWToolboxPrototype and the best that got me was a blank box in the options screen. I've tried calling class' XComGameState_LWToolboxPrototype '.static.SetMaxSquadSize(maxSoldiers); from a screenlistener but that had no observable effect.

I had some luck modifying SoldierSlotCount with EventListeners but after trying every event triggered in the InitScreen() of UISquadSelect_LW the but the best I could do was 12 slots with the top row starting at the center and going off the screen to the right.

I'm trying to essentially make an updated/improved version of More Squad Size Upgrades that takes advantage of the Toolbox's 12-slot squad select screen (yes, I can purchase the upgrades and then manually increment the squad size counter but that completely breaks immersion and that's the whole point of this). This seems like something that should be easy but I'm completely out of idea's. Sorry, if this has been asked and answered elsewhere. Any assistance would be appreciated.

Update:

So I think I've maybe made some progress, I'm getting a redscreen error now:
Game State Created but Never Added to History
New Game State: CC API Change Squadsize -- XComGameState_33263
Pending Game States:
|==>CC Enter Squad Select Event Hook -- XComGameState_33262
Stack:
Script call stack:
...

I made a copy of SetMaxSquadSize() from XComGameState_LWToolboxOptions and attempted to implement the code in in a version of XComGameState_LWToolboxOptions in my mod:

 

 

//---------------------------------------------------------------------------------------
//  FILE:    XComGameState_LWModOptions.uc
//  AUTHOR:  Amineri / Long War Studios
//  PURPOSE: This is the abstract definition of the component extension for CampaignSettings GameStates, containing 
//				additional data used for mod configuration, plus UI control code.
//---------------------------------------------------------------------------------------
class XComGameState_LWToolboxOptions extends XComGameState_LWToolboxPrototype config(MoreSquadSizeUpgrades);

// holds the class type, used to ensure uniqueness of CampaignSettings components

// ***** SQUADSIZE CONFIGURATION ***** //
var int SquadSizeIndex;

static function SetMaxSquadSize(int NewSize)
{
	local XComGameState_LWToolboxPrototype ToolboxOptions;
	local XComGameState_LWToolboxOptions UpdatedToolboxOptions;
	local XComGameStateContext_ChangeContainer ChangeContainer;
	local XComGameState UpdateState;

	ChangeContainer = class'XComGameStateContext_ChangeContainer'.static.CreateEmptyChangeContainer("API Change Squadsize");
	UpdateState = `XCOMHISTORY.CreateNewGameState(true, ChangeContainer);

	ToolboxOptions = GetToolboxPrototype();
	UpdatedToolboxOptions = XComGameState_LWToolboxOptions(UpdateState.CreateStateObject(class'XComGameState_LWToolboxOptions'));

	UpdatedToolboxOptions.SquadSizeIndex = NewSize;
	UpdateState.AddStateObject(UpdatedToolboxOptions);
	`GAMERULES.SubmitGameState(UpdateState);
}

static function XComGameState_LWToolboxPrototype GetToolboxPrototype()
{
	local XComGameState_CampaignSettings CampaignSettingsStateObject;

	CampaignSettingsStateObject = XComGameState_CampaignSettings(`XCOMHISTORY.GetSingleGameStateObjectForClass(class'XComGameState_CampaignSettings', true));
	if(CampaignSettingsStateObject != none)
		return XComGameState_LWToolboxPrototype(CampaignSettingsStateObject.FindComponentObject(class'XComGameState_LWToolboxOptions'));
	return none;
} 

 

 

Calling SetMaxSquadSize() from an Event Listener:

 

 

function RegisterForEvents()
{
	local X2EventManager EventManager;
	local Object ThisObj;

	ThisObj = self;

	EventManager = `XEVENTMGR;

	EventManager.RegisterForEvent(ThisObj, 'EnterSquadSelect', SetMaxSoldiers);
}

function EventListenerReturn SetMaxSoldiers(Object EventData, Object EventSource, XComGameState NewGameState, Name InEventID)
{
	local int maxSoldiers;

	`Log("Event Triggered");

	maxSoldiers = 6;

	`Log("maxsoldiers from slots"@maxSoldiers);

	if(IsUpgradeUnlocked('SquadSizeIIIUnlock'))
		maxSoldiers++;
	if(IsUpgradeUnlocked('SquadSizeIVUnlock'))
		maxSoldiers++;
	if(IsUpgradeUnlocked('SquadSizeVUnlock'))
		maxSoldiers+=2;

	`Log("maxsoldiers from upgrades"@maxSoldiers);

	class'XComGameState_LWToolboxOptions'.static.SetMaxSquadSize(maxSoldiers);

	return ELR_NoInterrupt;
} 

 

 

The above code results in the above redscreen error, so I feel like I'm on the right track. There seems to be some inter-mod communication going on, but obviously something is not working.

 

Update 2:

Finally got it working. It was, as expected, quite simple but elusive:

 

 

function RegisterForEvents()
{
	local X2EventManager EventManager;
	local Object ThisObj;

	ThisObj = self;

	EventManager = `XEVENTMGR;

	EventManager.RegisterForEvent(ThisObj, 'EnterSquadSelect', SetMaxSoldiers);
}

function EventListenerReturn SetMaxSoldiers(Object EventData, Object EventSource, XComGameState NewGameState, Name InEventID)
{
	local int maxSoldiers;
	local object Toolbox;
	local XComGameState_LWToolboxPrototype LWToolbox;

	Toolbox = class'Engine'.static.FindClassDefaultObject("XComGameState_LWToolboxOptions");
	LWToolbox = XComGameState_LWToolboxPrototype(Toolbox);

	maxSoldiers = StartingSquadSize;
	`Log("starting soldier count:"@maxSoldiers);
	if(IsUpgradeUnlocked('SquadSizeIIIUnlock'))
		maxSoldiers++;
	if(IsUpgradeUnlocked('SquadSizeIVUnlock'))
		maxSoldiers++;
	if(IsUpgradeUnlocked('SquadSizeVUnlock'))
		maxSoldiers++;
	if(IsUpgradeUnlocked('SquadSizeVIUnlock'))
		maxSoldiers++;
	`Log("maxsoldiers from upgrades"@maxSoldiers);

	LWToolbox.static.SetMaxSquadSize(maxSoldiers);

	return ELR_NoInterrupt;
} 

 

 

Still getting more or less the same RedScreen error but it works nonetheless; the squad is the right size and properly positioned. All it needs is art and some more testing before release.

Edited by sqparadox
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...