Core/Script: Implement CalcCritChance hooks for spell and aura scripts
Port From (https://github.com/TrinityCore/TrinityCore/commit/f8255b15419cd1efdd2ccaf77298c8598322288f)
This commit is contained in:
@@ -647,13 +647,14 @@ namespace Game.Entities
|
||||
return (uint)Math.Max(heal, 0.0f);
|
||||
}
|
||||
|
||||
public bool IsSpellCrit(Unit victim, SpellInfo spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
|
||||
public bool IsSpellCrit(Unit victim, Spell spell, AuraEffect aurEff, SpellSchoolMask schoolMask, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
|
||||
{
|
||||
return RandomHelper.randChance(GetUnitSpellCriticalChance(victim, spellProto, schoolMask, attackType));
|
||||
return RandomHelper.randChance(GetUnitSpellCriticalChance(victim, spell, aurEff, schoolMask, attackType));
|
||||
}
|
||||
|
||||
public float GetUnitSpellCriticalChance(Unit victim, SpellInfo spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
|
||||
public float GetUnitSpellCriticalChance(Unit victim, Spell spell, AuraEffect aurEff, SpellSchoolMask schoolMask, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
|
||||
{
|
||||
SpellInfo spellProto = spell.GetSpellInfo() ?? aurEff.GetSpellInfo();
|
||||
//! Mobs can't crit with spells. Player Totems can
|
||||
//! Fire Elemental (from totem) can too - but this part is a hack and needs more research
|
||||
if (GetGUID().IsCreatureOrVehicle() && !(IsTotem() && GetOwnerGUID().IsPlayer()) && GetEntry() != 15438)
|
||||
@@ -779,6 +780,12 @@ namespace Game.Entities
|
||||
crit_chance += victim.GetTotalAuraModifier(AuraType.ModCritChanceForCasterPet, aurEff => aurEff.GetCasterGUID() == tempSummon.GetSummonerGUID());
|
||||
}
|
||||
|
||||
// call script handlers
|
||||
if (spell)
|
||||
spell.CallScriptCalcCritChanceHandlers(victim, ref crit_chance);
|
||||
else
|
||||
aurEff.GetBase().CallScriptEffectCalcCritChanceHandlers(aurEff, aurEff.GetBase().GetApplicationOfTarget(victim.GetGUID()), victim, ref crit_chance);
|
||||
|
||||
return Math.Max(crit_chance, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user