X2CommunityCore / X2WOTCCommunityHighlander

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

Flyover for stun caused by Stun Lance is sometimes wrong #1236

Open Iridar opened 1 year ago

Iridar commented 1 year ago

Even though the Stun Lance ability can stun for only one action point:

//  Stunned effect for 3 or 4 unblocked hit
StunnedEffect = class'X2StatusEffects'.static.CreateStunnedStatusEffect(1, 100, false);
StunnedEffect.MinStatContestResult = 3;
StunnedEffect.MaxStatContestResult = 4;
StunnedEffect.bRemoveWhenSourceDies = false;
Template.AddTargetEffect(StunnedEffect);

the flyover sometimes shows that the unit was stunned for 2 actions, even though the unit immediately recovers with one action point remaining once their turn starts.

20230806125851_1 20230806125903_1

The logic responsible for the flyover is in X2AbilityTag:

case 'STUNNEDACTIONPOINTS':
    TargetUnitState = XComGameState_Unit(ParseObj);
    if( TargetUnitState.StunnedActionPoints + TargetUnitState.StunnedThisTurn > 0 )
    {
        OutString = string(TargetUnitState.StunnedActionPoints + TargetUnitState.StunnedThisTurn);
    }
    else
    {
        // possible we were stunned, but it was immediately removed. Show the action points the stun consumed
        OutString = string(XComGameState_Unit(History.GetPreviousGameStateForObject(TargetUnitState)).ActionPoints.Length 
                           - TargetUnitState.ActionPoints.Length);
    }
    break;

The else part looks pretty fishy to me.

Iridar commented 1 year ago

Can confirm the issue with showing 2 action stun, but getting 1 action stun happens with Less Overwatch Lockups as well. I've also had ToggleUnlimitedAmmo console command active, as well as DeadEye. Not sure if they could be playing into this.