X2CommunityCore / X2WOTCCommunityHighlander

https://steamcommunity.com/workshop/filedetails/?id=1134256495
MIT License
60 stars 68 forks source link

Modify X2TacticalGameRuleset to treat certain gamestates as though they were tactical transient on EndTacticalPlay() #146

Closed RealityMachina closed 6 years ago

RealityMachina commented 6 years ago

Essentially, I have an issue with Item Durability where it will have a very negative reaction to random missions and basically make them uncompletable, which as far as I've been able to narrow down, is due to the gamestate components being treated like regular gamestates at end of tactical play.

Since I do not require my gamestate components to track anything during tactical play, my idea is to add an additional check in EndTacticalPlay():

    // iterate through all existing state objects and call EndTacticalPlay on them
    foreach CachedHistory.IterateByClassType(class'XComGameState_BaseObject', ObjectState)
    {
        if (!ObjectState.bTacticalTransient && class'CHHelpers'.static.IsValidClass(ObjectState))
        {
            NewObjectState = NewGameState.ModifyStateObject( ObjectState.Class, ObjectState.ObjectID );
            NewObjectState.EndTacticalPlay( NewGameState );
        }
        else
        {
            ObjectState.EndTacticalPlay( NewGameState );
        }       
    }

(The actual check will probably need a X2DLCInfo addition, so mods can just implement their own check for whatever they need.)

I think I have successfully tested this, with a save of a mission that had my crashing issue: After changing the gamestate to be a tactical transient, it successfully completed and went to Geoscape, with the repair times still intact despite being seemingly "thrown away" at the end of the mission.

And then I did another mission, and I realized the game just does its "remove all tactical transient states" stuff when it starts a mission.

RealityMachina commented 6 years ago

Nevermind, found non-highlander workaround for issue.