Skip to content

Commit

Permalink
Issue #1305 - add GetAttackingDamageModifier_CH()
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2guides authored and Iridar committed Mar 3, 2024
1 parent 2372204 commit 70f9d85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,17 @@ simulated function GetDamagePreview(StateObjectReference TargetRef, XComGameStat
EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
EffectTemplate = EffectState.GetX2Effect();

EffectDmg = EffectTemplate.GetAttackingDamageModifier(EffectState, SourceUnit, Damageable(TargetUnit), AbilityState, TestEffectParams, MinDamagePreview.Damage);
// Single line for Issue #1305 - use the Highlander version of GetAttackingDamageModifier().
EffectDmg = EffectTemplate.GetAttackingDamageModifier_CH(EffectState, SourceUnit, Damageable(TargetUnit), AbilityState, TestEffectParams, MinDamagePreview.Damage, self);
MinDamagePreview.Damage += EffectDmg;
if( EffectDmg != 0 )
{
DamageModInfo.SourceEffectRef = EffectState.ApplyEffectParameters.EffectRef;
DamageModInfo.Value = EffectDmg;
MinDamagePreview.BonusDamageInfo.AddItem(DamageModInfo);
}
EffectDmg = EffectTemplate.GetAttackingDamageModifier(EffectState, SourceUnit, Damageable(TargetUnit), AbilityState, TestEffectParams, MaxDamagePreview.Damage);
// Single line for Issue #1305 - use the Highlander version of GetAttackingDamageModifier().
EffectDmg = EffectTemplate.GetAttackingDamageModifier_CH(EffectState, SourceUnit, Damageable(TargetUnit), AbilityState, TestEffectParams, MaxDamagePreview.Damage, self);
MaxDamagePreview.Damage += EffectDmg;
if( EffectDmg != 0 )
{
Expand Down Expand Up @@ -1001,7 +1003,9 @@ simulated function int CalculateDamageAmount(const out EffectAppliedData ApplyEf

EffectState = XComGameState_Effect(History.GetGameStateForObjectID(EffectRef.ObjectID));
EffectTemplate = EffectState.GetX2Effect();
EffectDmg = EffectTemplate.GetAttackingDamageModifier(EffectState, kSourceUnit, kTarget, kAbility, ApplyEffectParameters, WeaponDamage, NewGameState);

// Single line for Issue #1305 - use the Highlander version of GetAttackingDamageModifier().
EffectDmg = EffectTemplate.GetAttackingDamageModifier_CH(EffectState, kSourceUnit, kTarget, kAbility, ApplyEffectParameters, WeaponDamage, self, NewGameState);
if (EffectDmg != 0)
{
WeaponDamage += EffectDmg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,18 @@ function GetToHitAsTargetModifiers(XComGameState_Effect EffectState, XComGameSta
// CHL issue #467: function added to allow mods to modify the outcome of X2AbilityToHitCalc_StatCheck
function GetToHitAsTargetModifiersForStatCheck(XComGameState_Effect EffectState, XComGameState_Unit Attacker, XComGameState_Unit Target, XComGameState_Ability AbilityState, class<X2AbilityToHitCalc> ToHitType, out array<ShotModifierInfo> ShotModifiers);
function bool UniqueToHitAsTargetModifiers() { return false; }

// Start Issue #1305
/// HL-Docs: feature:DamageEffectForDamageModifierHooks; issue:1305; tags:tactical
/// Adds an improved version of GetAttackingDamageModifier() that always gets the Damage Effect.
/// The regular version of the hook gets the Damage Effect only when the effect is getting applied,
/// which prevents the hook from being able to provide an accurate contextual damage preview.
function int GetAttackingDamageModifier_CH(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, X2Effect_ApplyWeaponDamage WeaponDamageEffect, optional XComGameState NewGameState)
{
return GetAttackingDamageModifier(EffectState, Attacker, TargetDamageable, AbilityState, AppliedData, CurrentDamage, NewGameState);
}
// End Issue #1305

function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState) { return 0; }
function int GetDefendingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, X2Effect_ApplyWeaponDamage WeaponDamageEffect, optional XComGameState NewGameState) { return 0; }
function int GetBaseDefendingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int BaseDamage, X2Effect_ApplyWeaponDamage WeaponDamageEffect, optional XComGameState NewGameState) { return 0; }
Expand Down

0 comments on commit 70f9d85

Please sign in to comment.