diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 03bd9769d2..0ee1efb9f0 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5199,121 +5199,6 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType SendAttackStateUpdate(&dmgInfo); } -/*bool Unit::HandleAuraProcOnPowerAmount(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) -{ - // Get triggered aura spell info - SpellInfo const* auraSpellInfo = triggeredByAura->GetSpellInfo(); - - // Get effect index used for the proc - uint32 effIndex = triggeredByAura->GetEffIndex(); - - // Power amount required to proc the spell - int32 powerAmountRequired = triggeredByAura->GetAmount(); - // Power type required to proc - Powers powerRequired = Powers(auraSpellInfo->Effects[triggeredByAura->GetEffIndex()].MiscValue); - - // Set trigger spell id, target, custom basepoints - uint32 trigger_spell_id = auraSpellInfo->Effects[triggeredByAura->GetEffIndex()].TriggerSpell; - - Unit* target = NULL; - int32 basepoints0 = 0; - - Item* castItem = triggeredByAura->GetBase()->GetCastItemGUID() && GetTypeId() == TYPEID_PLAYER - ? ToPlayer()->GetItemByGuid(triggeredByAura->GetBase()->GetCastItemGUID()) : NULL; - - // All ok. Check current trigger spell - SpellInfo const* triggerEntry = sSpellMgr->GetSpellInfo(trigger_spell_id); - if (triggerEntry == NULL) - { - // Not cast unknown spell - // TC_LOG_ERROR("Unit::HandleAuraProcOnPowerAmount: Spell %u have 0 in EffectTriggered[%d], not handled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex()); - return false; - } - - // not allow proc extra attack spell at extra attack - if (m_extraAttacks && triggerEntry->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS)) - return false; - - if (!powerRequired || !powerAmountRequired) - { - TC_LOG_ERROR("spells", "Unit::HandleAuraProcOnPowerAmount: Spell %u have 0 powerAmountRequired in EffectAmount[%d] or 0 powerRequired in EffectMiscValue, not handled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex()); - return false; - } - - if (GetPower(powerRequired) != powerAmountRequired) - return false; - - // Custom requirements (not listed in procEx) Warning! damage dealing after this - // Custom triggered spells - switch (auraSpellInfo->SpellFamilyName) - { - case SPELLFAMILY_DRUID: - { - // Eclipse Mastery Driver Passive - if (auraSpellInfo->Id == 79577) - { - uint32 solarEclipseMarker = 67483; - uint32 lunarEclipseMarker = 67484; - - switch (effIndex) - { - case 0: - { - if (HasAura(trigger_spell_id)) - return false; - - // Do not proc if proc spell isnt starfire and starsurge - if (procSpell->Id != 2912 && procSpell->Id != 78674) - return false; - - if (HasAura(solarEclipseMarker)) - { - RemoveAurasDueToSpell(solarEclipseMarker); - CastSpell(this, lunarEclipseMarker, true); - } - break; - } - case 1: - { - if (HasAura(trigger_spell_id)) - return false; - - // Do not proc if proc spell isnt wrath and starsurge - if (procSpell->Id != 5176 && procSpell->Id != 78674) - return false; - - if (HasAura(lunarEclipseMarker)) - { - RemoveAurasDueToSpell(lunarEclipseMarker); - CastSpell(this, solarEclipseMarker, true); - } - - break; - } - } - } - break; - } - } - - if (cooldown && GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSpellHistory()->HasCooldown(trigger_spell_id)) - return false; - - // try detect target manually if not set - if (target == NULL) - target = !(procFlag & (PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS)) && triggerEntry && triggerEntry->IsPositive() ? this : victim; - - if (basepoints0) - CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); - else - CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura); - - if (cooldown && GetTypeId() == TYPEID_PLAYER) - ToPlayer()->GetSpellHistory()->AddCooldown(trigger_spell_id, 0, std::chrono::seconds(cooldown)); - - return true; -}*/ - void Unit::setPowerType(Powers new_powertype) { if (getPowerType() == new_powertype) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 4d299807a9..0486cb7405 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -386,7 +386,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleUnused, //325 unused (4.3.4) &AuraEffect::HandlePhaseGroup, //326 SPELL_AURA_PHASE_GROUP &AuraEffect::HandleUnused, //327 unused (4.3.4) - &AuraEffect::HandleNoImmediateEffect, //328 SPELL_AURA_PROC_ON_POWER_AMOUNT implemented in Unit::HandleAuraProcOnPowerAmount + &AuraEffect::HandleNoImmediateEffect, //328 SPELL_AURA_PROC_ON_POWER_AMOUNT implemented in AuraEffect::HandleProc &AuraEffect::HandleNULL, //329 SPELL_AURA_MOD_RUNE_REGEN_SPEED &AuraEffect::HandleNoImmediateEffect, //330 SPELL_AURA_CAST_WHILE_WALKING &AuraEffect::HandleAuraForceWeather, //331 SPELL_AURA_FORCE_WEATHER @@ -1124,6 +1124,7 @@ bool AuraEffect::CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventIn break; case SPELL_AURA_PROC_TRIGGER_SPELL: case SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE: + case SPELL_AURA_PROC_ON_POWER_AMOUNT: { // Don't proc extra attacks while already processing extra attack spell uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell; @@ -1172,6 +1173,9 @@ void AuraEffect::HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) case SPELL_AURA_RAID_PROC_FROM_CHARGE_WITH_VALUE: HandleRaidProcFromChargeWithValueAuraProc(aurApp, eventInfo); break; + case SPELL_AURA_PROC_ON_POWER_AMOUNT: + HandleProcOnPowerAmountAuraProc(aurApp, eventInfo); + break; default: break; } @@ -6239,6 +6243,33 @@ void AuraEffect::HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurA target->CastCustomSpell(target, triggerSpellId, &value, NULL, NULL, true, NULL, this, GetCasterGUID()); } +void AuraEffect::HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) +{ + Unit* triggerCaster = aurApp->GetTarget(); + Unit* triggerTarget = eventInfo.GetProcTarget(); + + int32 powerAmountRequired = GetAmount(); + Powers powerRequired = Powers(GetMiscValue()); + + if (!powerRequired || !powerAmountRequired) + { + TC_LOG_ERROR("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Spell %u have 0 powerAmountRequired in EffectAmount[%d] or 0 powerRequired in EffectMiscValue, not handled custom case?", GetId(), GetEffIndex()); + return; + } + + if (triggerCaster->GetPower(powerRequired) != powerAmountRequired) + return; + + uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell; + if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId)) + { + TC_LOG_DEBUG("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Triggering spell %u from aura %u proc", triggeredSpellInfo->Id, GetId()); + triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this); + } + else + TC_LOG_ERROR("spells", "AuraEffect::HandleProcOnPowerAmountAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId()); +} + void AuraEffect::HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mode, bool apply) const { if (!(mode & AURA_EFFECT_HANDLE_REAL)) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 7cba9937f4..35621de20d 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -319,6 +319,7 @@ class TC_GAME_API AuraEffect void HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); void HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); void HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); }; namespace Trinity diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index bc4cdceffd..547f392691 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1273,11 +1273,6 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b caster->CastSpell(target, 61634, true); } } - switch (GetId()) - { - default: - break; - } break; case SPELLFAMILY_PRIEST: if (!caster) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index aafdc8e36b..fa0ae5c000 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1760,6 +1760,7 @@ void SpellMgr::LoadSpellProcs() isTriggerAura[SPELL_AURA_MOD_HIT_CHANCE] = true; isTriggerAura[SPELL_AURA_MOD_WEAPON_CRIT_PERCENT] = true; isTriggerAura[SPELL_AURA_MOD_BLOCK_PERCENT] = true; + isTriggerAura[SPELL_AURA_PROC_ON_POWER_AMOUNT] = true; isAlwaysTriggeredAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true; isAlwaysTriggeredAura[SPELL_AURA_MOD_STEALTH] = true;