Skip to content

Commit

Permalink
Implement Issue #579 - add a bool switch to make UI show minimum dama…
Browse files Browse the repository at this point in the history
…ge rather than maximum damage.
  • Loading branch information
ps2guides authored and Iridar committed Oct 29, 2023
1 parent 708b8ad commit 689735d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
5 changes: 5 additions & 0 deletions X2WOTCCommunityHighlander/Config/XComGame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,8 @@ bEnableVersionDisplay=true
; Set the chance of using a Character Pool character when Character Pool is in Mixed mode.
; A value between 0 and 100 is expected.
iMixedCharacterPoolChance = 50

;;; HL-Docs: ref:UseMinDamageForUnitFlagPreview
; Uncomment the following line to make the Unit Flag damage preview show minimum damage
; rather than maximum damage.
; bUseMinDamageForUnitFlagPreview = true
3 changes: 3 additions & 0 deletions X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ var config bool bDrawDebugLabels;
// Variable for Issue #599 - 0-100 chance of using a character pool character when CP is in Mixed mode.
var config int iMixedCharacterPoolChance;

// Variable for Issue #579 - makes UIUnitFlagManager use ability's minimum damage rather than maximum damage for the preview.
var config bool bUseMinDamageForUnitFlagPreview;

// Start Issue #885
enum EHLDelegateReturn
{
Expand Down
52 changes: 39 additions & 13 deletions X2WOTCCommunityHighlander/Src/XComGame/Classes/UIUnitFlagManager.uc
Original file line number Diff line number Diff line change
Expand Up @@ -648,23 +648,49 @@ simulated function SetAbilityDamagePreview(UIUnitFlag kFlag, XComGameState_Abili
FlagUnit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(kFlag.StoredObjectID));
shieldPoints = FlagUnit != none ? int(FlagUnit.GetCurrentStat(eStat_ShieldHP)) : 0;

possibleHPDamage = MaxDamageValue.Damage;
possibleShieldDamage = 0;

// MaxHP contains extra HP points given by shield
if( shieldPoints > 0 && AllowedShield > 0 )
// Start Issue #579
/// HL-Docs: feature:UseMinDamageForUnitFlagPreview; issue:579; tags:tactical,ui
/// Allows using ability's minimum damage rather than max damage for the unit flag damage preview.
if (class'CHHelpers'.default.bUseMinDamageForUnitFlagPreview)
{
possibleShieldDamage = min(shieldPoints, MaxDamageValue.Damage);
possibleShieldDamage = min(possibleShieldDamage, AllowedShield);
possibleHPDamage = MaxDamageValue.Damage - possibleShieldDamage;
possibleHPDamage = MinDamageValue.Damage;
possibleShieldDamage = 0;

// MaxHP contains extra HP points given by shield
if( shieldPoints > 0 && AllowedShield > 0 )
{
possibleShieldDamage = min(shieldPoints, MinDamageValue.Damage);
possibleShieldDamage = min(possibleShieldDamage, AllowedShield);
possibleHPDamage = MinDamageValue.Damage - possibleShieldDamage;
}

if( possibleHPDamage > 0 && !AbilityState.DamageIgnoresArmor() && FlagUnit != none )
possibleHPDamage -= max(0, FlagUnit.GetArmorMitigationForUnitFlag() - MinDamageValue.Pierce);

kFlag.SetShieldPointsPreview(possibleShieldDamage);
kFlag.SetHitPointsPreview(possibleHPDamage);
kFlag.SetArmorPointsPreview(MinDamageValue.Shred, MinDamageValue.Pierce);
}
else // End Issue #579
{
possibleHPDamage = MaxDamageValue.Damage;
possibleShieldDamage = 0;

if( possibleHPDamage > 0 && !AbilityState.DamageIgnoresArmor() && FlagUnit != none )
possibleHPDamage -= max(0, FlagUnit.GetArmorMitigationForUnitFlag() - MaxDamageValue.Pierce);
// MaxHP contains extra HP points given by shield
if( shieldPoints > 0 && AllowedShield > 0 )
{
possibleShieldDamage = min(shieldPoints, MaxDamageValue.Damage);
possibleShieldDamage = min(possibleShieldDamage, AllowedShield);
possibleHPDamage = MaxDamageValue.Damage - possibleShieldDamage;
}

kFlag.SetShieldPointsPreview(possibleShieldDamage);
kFlag.SetHitPointsPreview(possibleHPDamage);
kFlag.SetArmorPointsPreview(MaxDamageValue.Shred, MaxDamageValue.Pierce);
if( possibleHPDamage > 0 && !AbilityState.DamageIgnoresArmor() && FlagUnit != none )
possibleHPDamage -= max(0, FlagUnit.GetArmorMitigationForUnitFlag() - MaxDamageValue.Pierce);

kFlag.SetShieldPointsPreview(possibleShieldDamage);
kFlag.SetHitPointsPreview(possibleHPDamage);
kFlag.SetArmorPointsPreview(MaxDamageValue.Shred, MaxDamageValue.Pierce);
}
}

simulated function LockFlagToReticle(bool bShouldLock, UITargetingReticle kReticle, StateObjectReference ObjectRef)
Expand Down

0 comments on commit 689735d

Please sign in to comment.