Jump to content

Added a new GameState object to all soldiers?


kosmo111

Recommended Posts

The redscreen says:

[0023.64] Warning: Redscreen: ***Game State Created but Never Added to History***
New Game State: CC Adding UnitStats to Unit -- XComGameState_1052
Pending Game States:
        ==> CC Adding UnitStats to Unit -- XComGameState_1051

Stack:
Script call stack:
        (Default__UIAddStatsToLeftWing) UIAddStatsToLeftWing::OnInit
        (UIMovie_2D_2) UIMovie::FlashRaiseInit
        (UIMovie_2D_2) UIMovie::FlashRaiseBatchedInit

But yea, fiddling seems to have gotten me over this hurdle for now-- hopefully it doesn't come back to bite me later heh

Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

I don't want to hijack this thread, exactly, but I also don't want to start a new thread for something so closely related. The simple mod "playable advent mec" from workshop has this bug, where each time you load a game, another playable mec is added to the armory. This bug exists, when the initial save game has no mods; and this is the only mod activated. In particular, the bug happens *even without* the other mod, to recover save games where a mod was deleted. I am not good enough at uc yet to solve the problem, but at least I can narrow it down. I have attached the key file from the mec mod (renamed to .txt so attaching works). Does the code look obviously wrong? Note I am not the author of that mod, but if we can figure out the solution, I will post it back to the author.

 

In case you want to see the context of the whole mod:

http://steamcommunity.com/sharedfiles/filedetails/?id=621061070&searchtext=playable

 

Activate the mod; load a game; look in the armory (one mec, the rookie at the bottom with no name); save the game; load your save; look in the armory (*two* rookies with no name)

Link to comment
Share on other sites

Ok, if it happens without any other mods then my theory about it being the load dlc mod is wrong and it might be either a vanilla bug or just a documentation error and the every load behavior is intended. In that case what Eladdv202 says should work.

 

In other cases where it isnt obvious from the game states whether a mod was applied or not (eg a mod that just added 5 to everyone's aim, you wouldn't be able to easily tell from the states if it was already applied) you can create a special game state type whose only purpose is to act as a marker. If you find it in the history the mod was already applied.

Link to comment
Share on other sites

It would actually be useful in some circumstances to be able to rely on a method being executed every time a mod is loaded. I haven't been able to reproduce this behaviour on my side though - When I load saves that were made after already loading one of my mods, it doesn't fire that method again.

Link to comment
Share on other sites

I don't want to sound like too much of a moron, just a little :laugh:. I am a professional programmer but I haven't used uc before. Can you point to an example which works correctly, or show the 5-6 lines of uc code which is required to look through the game history and determine if there is a unit with that template?

Link to comment
Share on other sites

@Kvalyr I need to try this myself too. I haven't used OnLoadedSaveGame in any of my mods and I'm currently only using QoL/cosmetic mods so haven't observed this myself, but should be able to put a quick log into one and see if it triggers reliably or not. The load dlc mod was my #1 suspect for this cause effectively removing the dlc marker from the save is what it is for. But could still be some other mod, I suppose. For the people it happens to, it seems to happen reliably.

 

I do agree that both a hook for first load and for all loads would be useful. So far I haven't been able to find a reliable way to add evac all to soldiers in the first in progress mission after install. What I need is a "game finished loading" event to listen for which AFAIK doesn't exist.

 

@davidlallen I'll try to post some later today when I'm not on mobile. You can also check the evac all code which does something similar looking for the ability template. https://github.com/tracktwo/EvacAll

Link to comment
Share on other sites

@Kvalyr I need to try this myself too. I haven't used OnLoadedSaveGame in any of my mods and I'm currently only using QoL/cosmetic mods so haven't observed this myself, but should be able to put a quick log into one and see if it triggers reliably or not. The load dlc mod was my #1 suspect for this cause effectively removing the dlc marker from the save is what it is for. But could still be some other mod, I suppose. For the people it happens to, it seems to happen reliably.

 

I do agree that both a hook for first load and for all loads would be useful. So far I haven't been able to find a reliable way to add evac all to soldiers in the first in progress mission after install. What I need is a "game finished loading" event to listen for which AFAIK doesn't exist.

I tested with some log statements earlier on out of curiosity and for me it was definitely only firing for saves made without the specific mod previously loaded. I use a version of the IgnoreMissingDLC mod bundled with some other utility mods when testing all of my own mods, and the behaviour was the same. (I don't think the IgnoreMissingDLC mod would affect this, anyway.)

 

IMO the best alternative to "Game Finished loading" is a UIScreenListener watching for the AvengerHUD ScreenClass. Fire off your code from the OnInit method of that screen listener (with a do-once condition if you only want it to happen once) there and it's as good as "Game finished loading" for most purposes.

 

If you mean that you want to fire stuff off during an already-started tactical mission, I'm sure there are other screen classes you could listen to for the same purpose. TacticalHUD is the UI for tactical missions as far as I recall. I personally tend towards advising mod users to only install mods on saves made in the strategic/avenger view though. Tactical has too much extra complexity with gamestate and stuff baked into the save to be a clean location to initalize a mod in my view.

Edited by Kvalyr
Link to comment
Share on other sites

Yeah that's what I recommend too, but people still install it while a tactical game is in progress and complain the mod is broken. I do hook the tactical HUD already, but the hooks fire before the history is rolled forward from the saved game, so any changes I make at that point are lost. The closest I can find is to hook the begin turn event and fire then, but that still doesn't fire on the turn you loaded into. Minor details, all in all.
Link to comment
Share on other sites

Yeah that's what I recommend too, but people still install it while a tactical game is in progress and complain the mod is broken. I do hook the tactical HUD already, but the hooks fire before the history is rolled forward from the saved game, so any changes I make at that point are lost. The closest I can find is to hook the begin turn event and fire then, but that still doesn't fire on the turn you loaded into. Minor details, all in all.

 

Gotcha, I see the problem.

 

As for users ignoring your advice.. Well.. There's only so much you can do if people insist on being stupid. :) It's nice to be able to code in a way that accounts for the worst case scenarios (such as users doing precisely what you tell them not to do), but there's only so much you can do before it starts to get in the way of getting things done.

 

I'd be inclined to just put checks into your mod along the lines of:

 

Are we loading for the first time? -> In tactical? -> Display a message to the user telling them that they're an idiot for ignoring your instructions -> Do nothing until returning to strategic.

 

I think that'd be more realistic than trying to fix the problem through manipulating already-loaded gamestates within tactical etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...