Core/Misc: Fixed resistance calculate for Mutated Transformation and Twilight Bloodbolt
Port From (https://github.com/TrinityCore/TrinityCore/commit/4110a06e8193329c31cb9d59d346294835fd51a5)
This commit is contained in:
@@ -42,6 +42,7 @@ namespace Framework.Constants
|
||||
CheckCast,
|
||||
BeforeCast,
|
||||
OnCast,
|
||||
OnResistAbsorbCalculation,
|
||||
AfterCast,
|
||||
CalcCritChance
|
||||
}
|
||||
|
||||
@@ -1925,7 +1925,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public void CalculateSpellDamageTaken(SpellNonMeleeDamage damageInfo, int damage, SpellInfo spellInfo, WeaponAttackType attackType = WeaponAttackType.BaseAttack, bool crit = false)
|
||||
public void CalculateSpellDamageTaken(SpellNonMeleeDamage damageInfo, int damage, SpellInfo spellInfo, WeaponAttackType attackType = WeaponAttackType.BaseAttack, bool crit = false, Spell spell = null)
|
||||
{
|
||||
if (damage < 0)
|
||||
return;
|
||||
@@ -2032,7 +2032,7 @@ namespace Game.Entities
|
||||
damageInfo.damage = (uint)damage;
|
||||
damageInfo.originalDamage = (uint)damage;
|
||||
DamageInfo dmgInfo = new(damageInfo, DamageEffectType.SpellDirect, WeaponAttackType.BaseAttack, ProcFlagsHit.None);
|
||||
CalcAbsorbResist(dmgInfo);
|
||||
CalcAbsorbResist(dmgInfo, spell);
|
||||
damageInfo.absorb = dmgInfo.GetAbsorb();
|
||||
damageInfo.resist = dmgInfo.GetResist();
|
||||
|
||||
|
||||
@@ -1982,7 +1982,7 @@ namespace Game.Entities
|
||||
else
|
||||
{
|
||||
var raceEntry = CliDB.ChrRacesStorage.LookupByKey(GetRace());
|
||||
return raceEntry.CreatureType;
|
||||
return (CreatureType)raceEntry.CreatureType;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3282,13 +3282,12 @@ namespace Game.Entities
|
||||
return victimResistance / (victimResistance + resistanceConstant);
|
||||
}
|
||||
|
||||
public static void CalcAbsorbResist(DamageInfo damageInfo)
|
||||
public static void CalcAbsorbResist(DamageInfo damageInfo, Spell spell = null)
|
||||
{
|
||||
if (!damageInfo.GetVictim() || !damageInfo.GetVictim().IsAlive() || damageInfo.GetDamage() == 0)
|
||||
return;
|
||||
|
||||
uint resistedDamage = CalcSpellResistedDamage(damageInfo.GetAttacker(), damageInfo.GetVictim(), damageInfo.GetDamage(), damageInfo.GetSchoolMask(), damageInfo.GetSpellInfo());
|
||||
damageInfo.ResistDamage(resistedDamage);
|
||||
|
||||
// Ignore Absorption Auras
|
||||
float auraAbsorbMod = 0f;
|
||||
@@ -3300,6 +3299,10 @@ namespace Game.Entities
|
||||
MathFunctions.RoundToInterval(ref auraAbsorbMod, 0.0f, 100.0f);
|
||||
|
||||
int absorbIgnoringDamage = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), auraAbsorbMod);
|
||||
if (spell != null)
|
||||
spell.CallScriptOnResistAbsorbCalculateHandlers(damageInfo, ref resistedDamage, ref absorbIgnoringDamage);
|
||||
|
||||
damageInfo.ResistDamage(resistedDamage);
|
||||
damageInfo.ModifyDamage(-absorbIgnoringDamage);
|
||||
|
||||
// We're going to call functions which can modify content of the list during iteration over it's elements
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace Game.Scripting
|
||||
// internal use classes & functions
|
||||
// DO NOT OVERRIDE THESE IN SCRIPTS
|
||||
public delegate SpellCastResult SpellCheckCastFnType();
|
||||
public delegate void SpellOnResistAbsorbCalculateFnType(DamageInfo damageInfo, ref uint resistAmount, ref int absorbAmount);
|
||||
public delegate void SpellEffectFnType(uint index);
|
||||
public delegate void SpellBeforeHitFnType(SpellMissInfo missInfo);
|
||||
public delegate void SpellHitFnType();
|
||||
@@ -184,6 +185,21 @@ namespace Game.Scripting
|
||||
SpellCheckCastFnType _checkCastHandlerScript;
|
||||
}
|
||||
|
||||
public class OnCalculateResistAbsorbHandler
|
||||
{
|
||||
public OnCalculateResistAbsorbHandler(SpellOnResistAbsorbCalculateFnType onResistAbsorbCalculateHandlerScript)
|
||||
{
|
||||
_onCalculateResistAbsorbHandlerScript = onResistAbsorbCalculateHandlerScript;
|
||||
}
|
||||
|
||||
public void Call(DamageInfo damageInfo, ref uint resistAmount, ref int absorbAmount)
|
||||
{
|
||||
_onCalculateResistAbsorbHandlerScript(damageInfo, ref resistAmount, ref absorbAmount);
|
||||
}
|
||||
|
||||
SpellOnResistAbsorbCalculateFnType _onCalculateResistAbsorbHandlerScript;
|
||||
}
|
||||
|
||||
public class EffectHandler : EffectHook
|
||||
{
|
||||
public EffectHandler(SpellEffectFnType pEffectHandlerScript, uint effIndex, SpellEffectName effName) : base(effIndex)
|
||||
@@ -498,6 +514,9 @@ namespace Game.Scripting
|
||||
// where function is SpellCastResult function()
|
||||
public List<CheckCastHandler> OnCheckCast = new();
|
||||
|
||||
// where function is void function(DamageInfo damageInfo, ref uint resistAmount, ref int absorbAmount)
|
||||
public List<OnCalculateResistAbsorbHandler> OnCalculateResistAbsorb = new();
|
||||
|
||||
// where function is void function(uint effIndex)
|
||||
public List<EffectHandler> OnEffectLaunch = new();
|
||||
public List<EffectHandler> OnEffectLaunchTarget = new();
|
||||
|
||||
@@ -7344,6 +7344,19 @@ namespace Game.Spells
|
||||
}
|
||||
}
|
||||
|
||||
public void CallScriptOnResistAbsorbCalculateHandlers(DamageInfo damageInfo, ref uint resistAmount, ref int absorbAmount)
|
||||
{
|
||||
foreach (var script in m_loadedScripts)
|
||||
{
|
||||
script._PrepareScriptCall(SpellScriptHookType.OnResistAbsorbCalculation);
|
||||
|
||||
foreach (var hook in script.OnCalculateResistAbsorb)
|
||||
hook.Call(damageInfo, ref resistAmount, ref absorbAmount);
|
||||
|
||||
script._FinishScriptCall();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckScriptEffectImplicitTargets(uint effIndex, uint effIndexToCheck)
|
||||
{
|
||||
// Skip if there are not any script
|
||||
|
||||
@@ -3112,6 +3112,15 @@ namespace Game.Entities
|
||||
spellEffectInfo.ApplyAuraName = AuraType.PeriodicTriggerSpell;
|
||||
});
|
||||
});
|
||||
|
||||
// Lich Pet
|
||||
ApplySpellFix(new [] { 70050 }, spellInfo =>
|
||||
{
|
||||
ApplySpellEffectFix(spellInfo, 0, spellEffectInfo =>
|
||||
{
|
||||
spellEffectInfo.TriggerSpell = 70049;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Allows those to crit
|
||||
@@ -3258,8 +3267,9 @@ namespace Game.Entities
|
||||
43109, // Throw Torch
|
||||
58552, // Return to Orgrimmar
|
||||
58533, // Return to Stormwind
|
||||
21855, // Challenge Flag
|
||||
51122 // Fierce Lightning Stike
|
||||
21855, // Challenge Flag
|
||||
51122, // Fierce Lightning Stike
|
||||
71848 // Toxic Wasteling Find Target
|
||||
}, spellInfo =>
|
||||
{
|
||||
spellInfo.MaxAffectedTargets = 1;
|
||||
@@ -3659,6 +3669,12 @@ namespace Game.Entities
|
||||
spellInfo.DurationEntry = CliDB.SpellDurationStorage.LookupByKey(4); // 2 minutes
|
||||
});
|
||||
|
||||
// Dark Conclave Ritualist Channel
|
||||
ApplySpellFix(new [] { 38469 }, spellInfo =>
|
||||
{
|
||||
spellInfo.RangeEntry = CliDB.SpellRangeStorage.LookupByKey(6); // 100yd
|
||||
});
|
||||
|
||||
//
|
||||
// VIOLET HOLD SPELLS
|
||||
//
|
||||
@@ -3927,13 +3943,6 @@ namespace Game.Entities
|
||||
});
|
||||
});
|
||||
|
||||
// Mutated Transformation (Professor Putricide)
|
||||
ApplySpellFix(new[] { 70402 }, spellInfo =>
|
||||
{
|
||||
// Resistance is calculated inside of SpellScript
|
||||
spellInfo.AttributesEx4 |= SpellAttr4.IgnoreResistances;
|
||||
});
|
||||
|
||||
// Empowered Flare (Blood Prince Council)
|
||||
ApplySpellFix(new[] { 71708 }, spellInfo =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user