fix(Core/Spells): Master of Elements (#7102)

* Core/Spells: Master of Elements:

Proc now also from arcane spells.
Properly proc from periodic spells.
Fixed #6035.

* You shouldn't be there.

* Buildfix.

* missing sql.
This commit is contained in:
UltraNix
2021-08-02 01:02:38 +02:00
committed by GitHub
parent 80ff915f24
commit 9a820e2d26
7 changed files with 65 additions and 23 deletions

View File

@@ -950,14 +950,43 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetDamageInfo()->GetSpellInfo(); // eventInfo.GetSpellInfo()
_spellInfo = eventInfo.GetDamageInfo()->GetSpellInfo();
if (!_spellInfo)
{
return false;
}
bool selectCaster = false;
// Triggered spells cost no mana so we need triggering spellInfo
if (SpellInfo const* triggeredByAuraSpellInfo = eventInfo.GetTriggerAuraSpell())
{
_spellInfo = triggeredByAuraSpellInfo;
selectCaster = true;
}
// If spell is periodic, mana amount is divided by tick number
if (eventInfo.GetTriggerAuraEffectIndex() >= EFFECT_0)
{
if (Unit* caster = GetCaster())
{
if (Unit* target = (selectCaster ? eventInfo.GetActor() : eventInfo.GetActionTarget()))
{
if (AuraEffect const* aurEff = target->GetAuraEffect(_spellInfo->Id, eventInfo.GetTriggerAuraEffectIndex(), caster->GetGUID()))
{
ticksModifier = aurEff->GetTotalTicks();
}
}
}
}
return _spellInfo; // eventInfo.GetSpellInfo()
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 mana = int32(eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask()));
int32 mana = int32(_spellInfo->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask()) / ticksModifier);
mana = CalculatePct(mana, aurEff->GetAmount());
if (mana > 0)
@@ -969,6 +998,10 @@ public:
DoCheckProc += AuraCheckProcFn(spell_mage_master_of_elements_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_mage_master_of_elements_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
private:
SpellInfo const* _spellInfo = nullptr;
uint8 ticksModifier = 1;
};
AuraScript* GetAuraScript() const override