diff options
author | ariel- <ariel-@users.noreply.github.com> | 2018-03-10 00:55:24 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2018-03-10 00:55:24 -0300 |
commit | bd3530dd1f71ce0cd4ce8368af3947cb525349b2 (patch) | |
tree | 04dca3e36a2af41805d7badb3043353b165d51d0 /src | |
parent | 6feee74c5aa5e5724e80bbbf546c4779ec1e648a (diff) |
Core/Spells: move m_preCastSpell logic to scripts
- Bad name because it was actaully executed after effects
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 48 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_mage.cpp | 54 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_paladin.cpp | 65 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_priest.cpp | 26 |
5 files changed, 141 insertions, 53 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 8604a7f67ca..6f8322332b8 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -588,7 +588,6 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO focusObject = nullptr; m_cast_count = 0; m_glyphIndex = 0; - m_preCastSpell = 0; m_triggeredByAuraSpell = nullptr; unitCaster = nullptr; _spellAura = nullptr; @@ -2805,30 +2804,6 @@ void Spell::DoSpellEffectHit(Unit* unit, uint8 effIndex, TargetInfo& hitInfo) void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask) { - // Apply additional spell effects to target - /// @todo move this code to scripts - if (m_preCastSpell) - { - // Paladin immunity shields - if (m_preCastSpell == 61988) - { - // Cast Forbearance - m_caster->CastSpell(unit, 25771, true); - // Cast Avenging Wrath Marker - unit->CastSpell(unit, 61987, true); - } - - // Avenging Wrath - if (m_preCastSpell == 61987) - // Cast the serverside immunity shield marker - m_caster->CastSpell(unit, 61988, true); - - // Blizz seems to just apply aura without bothering to cast - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(m_preCastSpell)) - if (Unit* unitCaster = m_caster->ToUnit()) - unitCaster->AddAura(spellInfo, MAX_EFFECT_MASK, unit); - } - // handle SPELL_AURA_ADD_TARGET_TRIGGER auras // this is executed after spell proc spells on target hit // spells are triggered for each hit spell target @@ -7901,29 +7876,6 @@ bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByA void Spell::PrepareTriggersExecutedOnHit() { - /// @todo move this to scripts - if (m_spellInfo->SpellFamilyName) - { - SpellInfo const* excludeCasterSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeCasterAuraSpell); - if (excludeCasterSpellInfo && !excludeCasterSpellInfo->IsPositive()) - m_preCastSpell = m_spellInfo->ExcludeCasterAuraSpell; - SpellInfo const* excludeTargetSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeTargetAuraSpell); - if (excludeTargetSpellInfo && !excludeTargetSpellInfo->IsPositive()) - m_preCastSpell = m_spellInfo->ExcludeTargetAuraSpell; - } - - /// @todo move this to scripts - switch (m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_MAGE: - { - // Permafrost - if (m_spellInfo->SpellFamilyFlags[1] & 0x00001000 || m_spellInfo->SpellFamilyFlags[0] & 0x00100220) - m_preCastSpell = 68391; - break; - } - } - Unit* unitCaster = m_caster->ToUnit(); if (!unitCaster) return; diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 39cf1beeb53..d585847f136 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -490,7 +490,6 @@ class TC_GAME_API Spell uint32 m_castItemEntry; uint8 m_cast_count; uint32 m_glyphIndex; - uint32 m_preCastSpell; SpellCastTargets m_targets; void AddComboPointGain(Unit* target, int8 amount) diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index a8b719afb93..9e9074f1fea 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -67,7 +67,8 @@ enum MageSpells SPELL_MAGE_T10_2P_BONUS_EFFECT = 70753, SPELL_MAGE_T8_4P_BONUS = 64869, SPELL_MAGE_MISSILE_BARRAGE = 44401, - SPELL_MAGE_FINGERS_OF_FROST_AURASTATE_AURA = 44544 + SPELL_MAGE_FINGERS_OF_FROST_AURASTATE_AURA = 44544, + SPELL_MAGE_PERMAFROST_AURA = 68391 }; enum MageSpellIcons @@ -656,6 +657,34 @@ class spell_mage_fire_frost_ward : public SpellScriptLoader } }; +// -44614 - Frostfire Bolt +class spell_mage_frostfire_bolt : public AuraScript +{ + PrepareAuraScript(spell_mage_frostfire_bolt); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_MAGE_PERMAFROST_AURA }); + } + + void ApplyPermafrost(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + caster->CastSpell(GetTarget(), SPELL_MAGE_PERMAFROST_AURA, aurEff); + } + + void RemovePermafrost(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->RemoveAurasDueToSpell(SPELL_MAGE_PERMAFROST_AURA); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_mage_frostfire_bolt::ApplyPermafrost, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_mage_frostfire_bolt::ApplyPermafrost, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL); + } +}; + // 54646 - Focus Magic class spell_mage_focus_magic : public SpellScriptLoader { @@ -966,6 +995,27 @@ class spell_mage_ice_barrier : public SpellScriptLoader } }; +// 45438 - Ice Block +class spell_mage_ice_block : public SpellScript +{ + PrepareSpellScript(spell_mage_ice_block); + + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellInfo({ spellInfo->ExcludeTargetAuraSpell }); + } + + void TriggerHypothermia() + { + GetCaster()->CastSpell(nullptr, GetSpellInfo()->ExcludeTargetAuraSpell, true); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_mage_ice_block::TriggerHypothermia); + } +}; + // -11119 - Ignite class spell_mage_ignite : public SpellScriptLoader { @@ -1360,6 +1410,7 @@ void AddSC_mage_spell_scripts() new spell_mage_empowered_fire(); new spell_mage_fingers_of_frost(); new spell_mage_fire_frost_ward(); + RegisterAuraScript(spell_mage_frostfire_bolt); new spell_mage_focus_magic(); new spell_mage_gen_extra_effects(); new spell_mage_glyph_of_polymorph(); @@ -1367,6 +1418,7 @@ void AddSC_mage_spell_scripts() new spell_mage_glyph_of_ice_block(); new spell_mage_hot_streak(); new spell_mage_ice_barrier(); + RegisterSpellScript(spell_mage_ice_block); new spell_mage_ignite(); new spell_mage_living_bomb(); new spell_mage_magic_absorption(); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 1eb5ca247a6..1e1ada38b7a 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -301,11 +301,13 @@ class spell_pal_avenging_wrath : public SpellScriptLoader return ValidateSpellInfo( { SPELL_PALADIN_SANCTIFIED_WRATH, - SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1 + SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1, + SPELL_PALADIN_AVENGING_WRATH_MARKER, + SPELL_PALADIN_IMMUNE_SHIELD_MARKER }); } - void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void HandleApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); if (AuraEffect const* aurEff = target->GetAuraEffectOfRankedSpell(SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1, EFFECT_2)) @@ -315,6 +317,11 @@ class spell_pal_avenging_wrath : public SpellScriptLoader .AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount()); target->CastSpell(target, SPELL_PALADIN_SANCTIFIED_WRATH, args); } + + target->CastSpell(nullptr, SPELL_PALADIN_AVENGING_WRATH_MARKER, aurEff); + + // Blizz seems to just apply aura without bothering to cast + target->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, target); } void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -324,7 +331,7 @@ class spell_pal_avenging_wrath : public SpellScriptLoader void Register() override { - OnEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); + AfterEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); AfterEffectRemove += AuraEffectRemoveFn(spell_pal_avenging_wrath_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); } }; @@ -1108,6 +1115,57 @@ public: } }; +// 498 - Divine Protection +// 642 - Divine Shield +// -1022 - Hand of Protection +class spell_pal_immunities : public SpellScript +{ + PrepareSpellScript(spell_pal_immunities); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_PALADIN_FORBEARANCE, + SPELL_PALADIN_AVENGING_WRATH_MARKER, + SPELL_PALADIN_IMMUNE_SHIELD_MARKER + }); + } + + SpellCastResult CheckCast() + { + Unit* caster = GetCaster(); + + // for HoP + Unit* target = GetExplTargetUnit(); + if (!target) + target = caster; + + // "Cannot be used within $61987d. of using Avenging Wrath." + if (target->HasAura(SPELL_PALADIN_FORBEARANCE) || target->HasAura(SPELL_PALADIN_AVENGING_WRATH_MARKER)) + return SPELL_FAILED_TARGET_AURASTATE; + + return SPELL_CAST_OK; + } + + void TriggerDebuffs() + { + if (Unit* target = GetHitUnit()) + { + // Blizz seems to just apply aura without bothering to cast + GetCaster()->AddAura(SPELL_PALADIN_FORBEARANCE, target); + GetCaster()->AddAura(SPELL_PALADIN_AVENGING_WRATH_MARKER, target); + GetCaster()->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, target); + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_immunities::CheckCast); + AfterHit += SpellHitFn(spell_pal_immunities::TriggerDebuffs); + } +}; + // Maybe this is incorrect // These spells should always be cast on login, regardless of whether the player has the talent or not @@ -2377,6 +2435,7 @@ void AddSC_paladin_spell_scripts() new spell_pal_heart_of_the_crusader(); new spell_pal_holy_shock(); new spell_pal_illumination(); + RegisterSpellScript(spell_pal_immunities); new spell_pal_improved_aura("spell_pal_improved_concentraction_aura", SPELL_PALADIN_IMPROVED_CONCENTRACTION_AURA); new spell_pal_improved_aura("spell_pal_improved_devotion_aura", SPELL_PALADIN_IMPROVED_DEVOTION_AURA); new spell_pal_improved_aura("spell_pal_sanctified_retribution", SPELL_PALADIN_SANCTIFIED_RETRIBUTION_AURA); diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index fc9991a55ae..6792128af2d 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -954,6 +954,32 @@ class spell_pri_power_word_shield : public SpellScriptLoader public: spell_pri_power_word_shield() : SpellScriptLoader("spell_pri_power_word_shield") { } + class spell_pri_power_word_shield_SpellScript : public SpellScript + { + PrepareSpellScript(spell_pri_power_word_shield_SpellScript); + + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellInfo({ spellInfo->ExcludeTargetAuraSpell }); + } + + void WeakenSoul() + { + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, GetSpellInfo()->ExcludeTargetAuraSpell, true); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_pri_power_word_shield_SpellScript::WeakenSoul); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_pri_power_word_shield_SpellScript(); + } + class spell_pri_power_word_shield_AuraScript : public AuraScript { PrepareAuraScript(spell_pri_power_word_shield_AuraScript); |