X2CommunityCore / X2WOTCCommunityHighlander

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

XComGameStateContext_WillRoll.uc - prevent excessive will loss on multi-part missions #44

Closed korgano closed 6 years ago

korgano commented 6 years ago

This hasn't been solved for base WOTC yet, but since the Highlander is replacing the will roll script file anyway, I figure it would be easier to implement a fix here.

This is the code directly involved in the will roll on mission start:

if(RollInfo.MaxWillPercentageLostPerMission > 0)
        {
            // get the unit's will at the start of the mission
            History = `XCOMHISTORY;
            StartOfMissionUnit = XComGameState_Unit(History.GetGameStateForObjectID(InSourceUnit.ObjectID,, History.FindStartStateIndex()));
            MaximumWillLossPerMission = RollInfo.MaxWillPercentageLostPerMission * InSourceUnit.GetMaxStat(eStat_Will);
            MinimumAllowedWill = max(MinimumAllowedWill, StartOfMissionUnit.GetCurrentStat(eStat_Will) - MaximumWillLossPerMission);
        }

Here's a list of secondary and tertiary mission part names:

if(MissionTemplate == 'LostAndAbandonedC')
'LastGiftB'
'LastGiftC'
'ChosenShowdown_Assassin'
'ChosenShowdown_Warlock'
'ChosenShowdown_Hunter'
'AssaultFortressLeadup' (not sure if this is the first part)`
'DestroyAvatarProject'

I think changing if(RollInfo.MaxWillPercentageLostPerMission > 0) to if(RollInfo.MaxWillPercentageLostPerMission > 0 && MissionTemplate != 'LostAndAbandonedC' || etc...) might work, but that wouldn't easily expandable if modders implemented multi-part missions of their own.

robojumper commented 6 years ago

Sure, we can add a config flag to prevent it.

Some considerations:

robojumper commented 6 years ago

Possible solution: whenever the unit detects that it is spawned the first time in a mission sequence, it stores a Unit Value with its current will stat. If the config flag is not enabled, it stores it always when tactical play begins for this unit.

This unit value is then checked by XComGameStateContext_WillRoll instead of naively assuming that the start state contains the starting will.