Skip to content

Commit

Permalink
Bring back the original implementation of GetAttackingDamageModifier()
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2guides committed Feb 27, 2024
1 parent c390c98 commit cf92a10
Showing 1 changed file with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ var int BonusDmg;

// Start Issue #612
/// HL-Docs: ref:Bugfixes; issue:612
/// Use `GetAttackingDamageModifier_CH()` to gain access to the damage effect
/// during the damage preview step, so that damage preview remains accurate.
/// Use `GetAttackingDamageModifier_CH()` for the purposes of damage preview.
/// Use the original `GetAttackingDamageModifier()` for the actual damage bonus,
/// so it can still be correctly applied by custom damage effects from mods
/// that do not call `GetAttackingDamageModifier_CH()`.
function int GetAttackingDamageModifier_CH(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, X2Effect_ApplyWeaponDamage DamageEffect, optional XComGameState NewGameState)
{
// Proceed only when called for damage preview.
if (NewGameState != none)
return 0;

if (!class'XComGameStateContext_Ability'.static.IsHitResultHit(AppliedData.AbilityResultContext.HitResult) || CurrentDamage == 0)
return 0;

Expand All @@ -36,34 +42,36 @@ function int GetAttackingDamageModifier_CH(XComGameState_Effect EffectState, XCo

return 0;
}
// Issue #612 - original implementation commented out.
// function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
// {
// local X2Effect_ApplyWeaponDamage DamageEffect;
//
// if (!class'XComGameStateContext_Ability'.static.IsHitResultHit(AppliedData.AbilityResultContext.HitResult) || CurrentDamage == 0)
// return 0;
//
// // only limit this when actually applying damage (not previewing)
// if( NewGameState != none )
// {
// // only add the bonus damage when the damage effect is applying the weapon's base damage
// DamageEffect = X2Effect_ApplyWeaponDamage(class'X2Effect'.static.GetX2Effect(AppliedData.EffectRef));
// if( DamageEffect == none || DamageEffect.bIgnoreBaseDamage )
// {
// return 0;
// }
// }
//
// if( AbilityState.SourceWeapon == EffectState.ApplyEffectParameters.ItemStateObjectRef )
// {
// return BonusDmg;
// }
//
// return 0;
// }
// End Issue #612

function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
{
local X2Effect_ApplyWeaponDamage DamageEffect;

if (!class'XComGameStateContext_Ability'.static.IsHitResultHit(AppliedData.AbilityResultContext.HitResult) || CurrentDamage == 0)
return 0;

// Start Issue #612
// Do not apply the bonus during damage preview.
if (NewGameState == none)
return 0;
// End Issue #612

// only add the bonus damage when the damage effect is applying the weapon's base damage
DamageEffect = X2Effect_ApplyWeaponDamage(class'X2Effect'.static.GetX2Effect(AppliedData.EffectRef));
if( DamageEffect == none || DamageEffect.bIgnoreBaseDamage )
{
return 0;
}

if( AbilityState.SourceWeapon == EffectState.ApplyEffectParameters.ItemStateObjectRef )
{
return BonusDmg;
}

return 0;
}

defaultproperties
{
bDisplayInSpecialDamageMessageUI = true
Expand Down

0 comments on commit cf92a10

Please sign in to comment.