Core/SpellScripts: implement Spell Proc Hooks and use it in old and new proc system
Hooks: - DoCheckProc: executed when aura checks if it can proc - DoPrepareProc: executed before aura procs (possibility to prevent charge drop/cooldown) - OnProc: executed when aura procs - OnEffectProc: executed when aura effect procs - AfterEffectProc: executed after aura effect proced - AfterProc: executed after aura proced and charges removed using PreventDefaultAction() in DoPrepareProc will prevent charge drop and cooldown default execution of a proc can prevented in OnEffectProc with PreventDefaultAction() Now we should be able to convert almost all procs from Unit::ProcDamageAndSpellFor to SpellScripts Notes to old proc system: - if a proc has a cooldown we must check it in spellscript and add it when we handle the proc - behavior with charge drops is possible undefined (use PreventDefaultAction() in OnEffectProc to notify that the script is executed)
This commit is contained in:
1 parent
5f28502c0a
commit
89490e4d7f
6 files changed
+281
-19
No files matched your search
@@ -14452,7 +14452,8 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
Unit* actionTarget = !isVictim ? target : this;
|
||||
|
||||
DamageInfo damageInfo = DamageInfo(actor, actionTarget, damage, procSpell, procSpell ? SpellSchoolMask(procSpell->SchoolMask) : SPELL_SCHOOL_MASK_NORMAL, SPELL_DIRECT_DAMAGE);
|
||||
ProcEventInfo eventInfo = ProcEventInfo(actor, actionTarget, target, procFlag, 0, 0, procExtra, NULL, &damageInfo, NULL /*HealInfo*/);
|
||||
HealInfo healInfo = HealInfo(actor, actionTarget, damage, procSpell, procSpell ? SpellSchoolMask(procSpell->SchoolMask) : SPELL_SCHOOL_MASK_NORMAL);
|
||||
ProcEventInfo eventInfo = ProcEventInfo(actor, actionTarget, target, procFlag, 0, 0, procExtra, NULL, &damageInfo, &healInfo);
|
||||
|
||||
ProcTriggeredList procTriggered;
|
||||
// Fill procTriggered list
|
||||
@@ -14483,6 +14484,10 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
|
||||
continue;
|
||||
|
||||
// AuraScript Hook
|
||||
if (!triggerData.aura->CallScriptCheckProcHandlers(itr->second, eventInfo))
|
||||
continue;
|
||||
|
||||
// Triggered spells not triggering additional spells
|
||||
bool triggered = !(spellProto->AttributesEx3 & SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED) ?
|
||||
(procExtra & PROC_EX_INTERNAL_TRIGGERED && !(procFlag & PROC_FLAG_DONE_TRAP_ACTIVATION)) : false;
|
||||
@@ -14531,15 +14536,21 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
SpellInfo const* spellInfo = i->aura->GetSpellInfo();
|
||||
uint32 Id = i->aura->GetId();
|
||||
|
||||
AuraApplication const* aurApp = i->aura->GetApplicationOfTarget(GetGUID());
|
||||
|
||||
bool prepare = i->aura->CallScriptPrepareProcHandlers(aurApp, eventInfo);
|
||||
|
||||
// For players set spell cooldown if need
|
||||
uint32 cooldown = 0;
|
||||
if (GetTypeId() == TYPEID_PLAYER && i->spellProcEvent && i->spellProcEvent->cooldown)
|
||||
if (prepare && GetTypeId() == TYPEID_PLAYER && i->spellProcEvent && i->spellProcEvent->cooldown)
|
||||
cooldown = i->spellProcEvent->cooldown;
|
||||
|
||||
// Note: must SetCantProc(false) before return
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_DISABLE_PROC)
|
||||
SetCantProc(true);
|
||||
|
||||
i->aura->CallScriptProcHandlers(aurApp, eventInfo);
|
||||
|
||||
// This bool is needed till separate aura effect procs are still here
|
||||
bool handled = false;
|
||||
if (HandleAuraProc(target, damage, i->aura, procSpell, procFlag, procExtra, cooldown, &handled))
|
||||
@@ -14558,6 +14569,13 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
AuraEffect* triggeredByAura = i->aura->GetEffect(effIndex);
|
||||
ASSERT(triggeredByAura);
|
||||
|
||||
bool prevented = i->aura->CallScriptEffectProcHandlers(triggeredByAura, aurApp, eventInfo);
|
||||
if (prevented)
|
||||
{
|
||||
takeCharges = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (triggeredByAura->GetAuraType())
|
||||
{
|
||||
case SPELL_AURA_PROC_TRIGGER_SPELL:
|
||||
@@ -14725,13 +14743,16 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
takeCharges = true;
|
||||
break;
|
||||
} // switch (triggeredByAura->GetAuraType())
|
||||
i->aura->CallScriptAfterEffectProcHandlers(triggeredByAura, aurApp, eventInfo);
|
||||
} // for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
|
||||
} // if (!handled)
|
||||
|
||||
// Remove charge (aura can be removed by triggers)
|
||||
if (useCharges && takeCharges)
|
||||
if (prepare && useCharges && takeCharges)
|
||||
i->aura->DropCharge();
|
||||
|
||||
i->aura->CallScriptAfterProcHandlers(aurApp, eventInfo);
|
||||
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_DISABLE_PROC)
|
||||
SetCantProc(false);
|
||||
}
|
||||
@@ -14752,7 +14773,7 @@ void Unit::GetProcAurasTriggeredOnEvent(std::list<AuraApplication*>& aurasTrigge
|
||||
if (!(*itr)->GetRemoveMode())
|
||||
if ((*itr)->GetBase()->IsProcTriggeredOnEvent(*itr, eventInfo))
|
||||
{
|
||||
(*itr)->GetBase()->PrepareProcToTrigger();
|
||||
(*itr)->GetBase()->PrepareProcToTrigger(*itr, eventInfo);
|
||||
aurasTriggeringProc.push_back(*itr);
|
||||
}
|
||||
}
|
||||
@@ -14764,7 +14785,7 @@ void Unit::GetProcAurasTriggeredOnEvent(std::list<AuraApplication*>& aurasTrigge
|
||||
{
|
||||
if (itr->second->GetBase()->IsProcTriggeredOnEvent(itr->second, eventInfo))
|
||||
{
|
||||
itr->second->GetBase()->PrepareProcToTrigger();
|
||||
itr->second->GetBase()->PrepareProcToTrigger(itr->second, eventInfo);
|
||||
aurasTriggeringProc.push_back(itr->second);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user