[Solved] Can't seem to cast to Long War classes?

For technical discussions and help
Post Reply
Houndie
Posts: 2
Joined: Sat May 13, 2017 1:26 am

[Solved] Can't seem to cast to Long War classes?

Post by Houndie »

Hey, I'm super new to this so I've probably just messed something up here, but I can't seem to downcast to long war declared classes. Casting to base game classes works fine.

Example!

This causes massive amounts of redscreen errors on startup and a crash when loading a game:

Code: Select all

class TestScreenListener extends UIScreenListener;

event OnInit(UIScreen screen)
{
	local UIOutpostManagement baby;

	if(screen.IsA('UIOutpostManagement'))
	{
		baby = UIOutpostManagement(screen);
	}
}

defaultproperties
{
ScreenClass = none;
}
This works fine:

Code: Select all

class TestScreenListener extends UIScreenListener;

event OnInit(UIScreen screen)
{
	local UIStrategyMap baby;

	if(screen.IsA('UIStrategyMap'))
	{
		baby = UIStrategyMap(screen);
	}
}

defaultproperties
{
ScreenClass = none;
}
I've noticed this happening in all sorts of cases, this is just the one that I found easiest. Long war IS definitely being loaded, and, while I wouldn't think it would matter, it's definitely being loaded first too. This is the workshop version of Long War 2.

I'm seeing nothing useful at all in the log so I'm kind of at a loss. Help from anyone would be very appreciated if you have a moment.

EDIT: I should also note that for some reason, this class is a bit temperamental and failing in ways the documentation says it should work as well, so it's possible not all is right with the world here. Setting ScreenClass to anything other than `none` causes a failure, and casting anything outside of the `IsA` block also doesn't work well. I have my environment set up as per here: https://www.reddit.com/r/xcom2mods/comm ... ong_war_2/

EDIT2: Okay so I reinstalled the SDK and created a non-lw2 based mod and the problems mentioned in the edit went away so there's almost certainly something wonky going on with my build process here, and perhaps the steps mentioned in the reddit post above might not work quite right. I'll update as I go for documentation, but it no longer looks like a bug with lw2 modding specifically, and more my specific set-up.

EDIT3: It seems the problem comes when I add the unrealengine lines. So I guess the problem is I'm somehow not building my LW2 dependencies correctly?
Last edited by Houndie on Sat May 13, 2017 7:42 pm, edited 1 time in total.
Houndie
Posts: 2
Joined: Sat May 13, 2017 1:26 am

Re: Can't seem to cast to Long War classes?

Post by Houndie »

Solved it! It was an ordering issue. Apparently even with the alternative mod launcher, Long War from the workshop will be loaded after home mods. The solution is to install long war from the nexus to put it on the same priority level, and then make sure it loads before my mod with other load order tricks (the easiest being the "priority" setting in the alternative mod launcher)
Post Reply