Jump to content

What am I doing wrong? (Everything) SetMaterial, Finding Actors and other woes.


Synthorange

Recommended Posts

Try this:

function CheckforRangerInfoObject()
{
	local X2_SkyrangerCustomSettings RangerHolder;
	local XComGameState_HeadquartersXCom XcomHQ;
	local XComGameState NewGameState;
	local XcomGameStateHistory History;

	History = `XCOMHISTORY;
	XComHQ = `XCOMHQ;

	RangerHolder=X2_SkyrangerCustomSettings(XcomHQ.FindComponentObject(class'X2_SkyrangerCustomSettings'));

	if (RangerHolder == none)
	{
		// create change state 
		NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Adding Ranger Info Object");
		// make a copy of XcomHQ object which will be modified
		XComHQ = XComGameState_HeadquartersXCom(NewGameState.CreateStateObject(class'XComGameState_HeadquartersXCom', XComHQ.ObjectID));
		// instantiate new object
		RangerHolder = X2_SkyrangerCustomSettings(NewGameState.CreateStateObject(class'X2_SkyrangerCustomSettings'));
		RangerHolder.InitComponent();

		XcomHQ.AddComponentObject(RangerHolder);

		NewGameState.AddStateObject(XcomHQ);
		NewGameState.AddStateObject(RangerHolder);
		History.AddGameStateToHistory(NewGameState);
		`log("Creating Holder" @ RangerHolder);
	}
}
Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Oh man that worked! Thank you so much, this gamestate stuff was just killing me. :v

local X2_SkyrangerCustomSettings RangerHolder,newRangerHolder;
local XComGameState newGameState;
local XComGameStateContext_ChangeContainer changeContainer;
local XComGameStateHistory History;
local XComGameState_HeadquartersXCom XComHQ;

History = `XCOMHISTORY;
XComHQ = `XCOMHQ;

changeContainer = class'XComGameStateContext_ChangeContainer'.static.CreateEmptyChangeContainer("Adding Skyranger Settings"); 
newGameState = History.CreateNewGameState(true, changeContainer); 
newRangerHolder=new class'X2_SkyrangerCustomSettings'; 
newRangerHolder.InitComponent(); 
XComHQ.AddComponentObject(newRangerHolder); 
RangerHolder=X2_SkyrangerCustomSettings(XComHQ.FindComponentObject(class'X2_SkyrangerCustomSettings')); 
newGameState.AddStateObject(XComHQ); 
`log("Creating Holder" @ newRangerHolder @ RangerHolder); 
History.AddGameStateToHistory(newGameState);

I'd gotten this far before you showed up. So you have to add both the object and the component to the new gamestate? Eeesh.

Edited by Synthorange
Link to comment
Share on other sites

Yeah, I saw your post in the other thread, You got pretty close. And yes, you need to add both object states to the new gamestate. At least in this case. "AddComponentObject" method merely creates a link between the two (AFAIK).

Link to comment
Share on other sites

Oh boy fun stuff coming up. Apparently some users are crashing. Just to make sure I'm not messing things up I could use some checking:

event OnInit(UIScreen Screen)
{
	Sky = Screen.Movie.Pres.Spawn(class'Skyranger_Customizer');
	Sky.RangerSkin();
	Sky.Destroy();
}

This appears three times in my mod. Once at the start of battle, once at the avenger, and once if the skin select button is pressed. The one for battle and another button also have Sky.PlayMusic(); attached. That basically calls each skyranger and makes them PlaySound().

 

Is this the best way to do things? If I'm going to be calling it so many times, would it be better just to spawn it once and have it hang around to handle all calls?

 

Additionally are audiocomponents created by PlaySound disposed of automatically or will I have a whole bunch stuck to an actor, or freefloating audiocomponents?

Link to comment
Share on other sites

From some initial poking around, most stuff is destroyed when the screenlistener exits, it seems.

And, I thought that a check for none, followed by a spawn if it is none, caused crashes also?

 

I'd fill your code with logging data for now (literally, every step), leave that in, publish it, and have people who are crashing pastebin their logfile - then you can see exactly where it gets to when it's falling over.

Edited by zingfharn
Link to comment
Share on other sites

Same one, no?

 

 

My launch log has this:

 

[0028.19] ScriptLog: OnInit: UISpecialMissionHUD_0
[0028.19] ScriptLog: FowEFFECT: XComFOWEffect_0
[0028.19] ScriptLog: Doing it
[0028.19] ScriptLog: here we are
[0028.19] ScriptLog: here we are
[0028.19] ScriptLog: here we are
[0028.19] ScriptLog: Enabling
which is definitely my work. I know, because right now my mod is crashing:
[0033.97] Log: Dumping name table: (2168160)
[0033.97] Log: Dumping name table: 0x041c4000 (2168160)
[0037.30] Exit: Exiting.
[0037.31] Log: Log file closed, 03/29/16 03:45:41
so I'm doing the exact same thing ; )
Edited by zingfharn
Link to comment
Share on other sites

Hm problem. Only the SDK keeps logs though. I dont see any logs in the regular XCOM 2 file tree. Argh I'm going to have to chase this down myself.

 

It's not a hard crash either, stuff will still keep going on and pushing more events into the log, its your view getting stuck on the avenger belly or on the load screen. Dammit stupid difficult to track bugs.

Edited by Synthorange
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...