diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 874 |
1 files changed, 365 insertions, 509 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5e69d8ce72e..7d77b668af6 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -692,80 +692,69 @@ enum BreakShieldSpells SPELL_BREAK_SHIELD_TRIGGER_UNK = 66480 }; -class spell_gen_break_shield: public SpellScriptLoader +class spell_gen_break_shield: public SpellScript { - public: - spell_gen_break_shield(char const* name) : SpellScriptLoader(name) { } + PrepareSpellScript(spell_gen_break_shield); - class spell_gen_break_shield_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_break_shield_SpellScript); + void HandleScriptEffect(SpellEffIndex effIndex) + { + Unit* target = GetHitUnit(); - void HandleScriptEffect(SpellEffIndex effIndex) + switch (effIndex) + { + case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) { - Unit* target = GetHitUnit(); + uint32 spellId; - switch (effIndex) + switch (GetSpellInfo()->Id) { - case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual) - { - uint32 spellId; - - switch (GetSpellInfo()->Id) - { - case SPELL_BREAK_SHIELD_TRIGGER_UNK: - case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE: - spellId = SPELL_BREAK_SHIELD_DAMAGE_10K; - break; - case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS: - spellId = SPELL_BREAK_SHIELD_DAMAGE_2K; - break; - default: - return; - } - - if (Unit* rider = GetCaster()->GetCharmer()) - rider->CastSpell(target, spellId, false); - else - GetCaster()->CastSpell(target, spellId, false); + case SPELL_BREAK_SHIELD_TRIGGER_UNK: + case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE: + spellId = SPELL_BREAK_SHIELD_DAMAGE_10K; break; - } - case EFFECT_1: // On damaging spells, for removing a defend layer - { - Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); - for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - if (Aura* aura = itr->second->GetBase()) - { - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) - { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; - } - } - } + case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS: + spellId = SPELL_BREAK_SHIELD_DAMAGE_2K; break; - } default: - break; + return; } - } - void Register() override + if (Unit* rider = GetCaster()->GetCharmer()) + rider->CastSpell(target, spellId, false); + else + GetCaster()->CastSpell(target, spellId, false); + break; + } + case EFFECT_1: // On damaging spells, for removing a defend layer { - OnEffectHitTarget += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); + Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); + for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + if (Aura* aura = itr->second->GetBase()) + { + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } + } + } + break; } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_gen_break_shield_SpellScript(); + default: + break; } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gen_break_shield::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); + } }; // 46394 Brutallus Burn @@ -1106,42 +1095,28 @@ class spell_gen_clone_weapon_aura : public AuraScript uint32 prevItem = 0; }; -class spell_gen_count_pct_from_max_hp : public SpellScriptLoader +class spell_gen_count_pct_from_max_hp : public SpellScript { - public: - spell_gen_count_pct_from_max_hp(char const* name, int32 damagePct = 0) : SpellScriptLoader(name), _damagePct(damagePct) { } - - class spell_gen_count_pct_from_max_hp_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript); + PrepareSpellScript(spell_gen_count_pct_from_max_hp); - public: - spell_gen_count_pct_from_max_hp_SpellScript(int32 damagePct) : SpellScript(), _damagePct(damagePct) { } - - void RecalculateDamage() - { - if (!_damagePct) - _damagePct = GetHitDamage(); - - SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(_damagePct)); - } +public: + spell_gen_count_pct_from_max_hp(int32 damagePct = 0) : SpellScript(), _damagePct(damagePct) { } - void Register() override - { - OnHit += SpellHitFn(spell_gen_count_pct_from_max_hp_SpellScript::RecalculateDamage); - } + void RecalculateDamage() + { + if (!_damagePct) + _damagePct = GetHitDamage(); - private: - int32 _damagePct; - }; + SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(_damagePct)); + } - SpellScript* GetSpellScript() const override - { - return new spell_gen_count_pct_from_max_hp_SpellScript(_damagePct); - } + void Register() override + { + OnHit += SpellHitFn(spell_gen_count_pct_from_max_hp::RecalculateDamage); + } - private: - int32 _damagePct; +private: + int32 _damagePct; }; // 63845 - Create Lance @@ -1225,72 +1200,61 @@ enum DalaranDisguiseSpells SPELL_SILVER_COVENANT_DISGUISE_MALE = 70972 }; -class spell_gen_dalaran_disguise : public SpellScriptLoader +class spell_gen_dalaran_disguise : public SpellScript { - public: - spell_gen_dalaran_disguise(char const* name) : SpellScriptLoader(name) { } + PrepareSpellScript(spell_gen_dalaran_disguise); - class spell_gen_dalaran_disguise_SpellScript : public SpellScript + bool Validate(SpellInfo const* spellInfo) override + { + switch (spellInfo->Id) { - PrepareSpellScript(spell_gen_dalaran_disguise_SpellScript); - - bool Validate(SpellInfo const* spellInfo) override - { - switch (spellInfo->Id) + case SPELL_SUNREAVER_DISGUISE_TRIGGER: + return ValidateSpellInfo( { - case SPELL_SUNREAVER_DISGUISE_TRIGGER: - return ValidateSpellInfo( - { - SPELL_SUNREAVER_DISGUISE_FEMALE, - SPELL_SUNREAVER_DISGUISE_MALE - }); - case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: - return ValidateSpellInfo( - { - SPELL_SILVER_COVENANT_DISGUISE_FEMALE, - SPELL_SILVER_COVENANT_DISGUISE_MALE - }); - default: - break; - } - - return false; - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Player* player = GetHitPlayer()) + SPELL_SUNREAVER_DISGUISE_FEMALE, + SPELL_SUNREAVER_DISGUISE_MALE + }); + case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: + return ValidateSpellInfo( { - uint8 gender = player->GetNativeGender(); + SPELL_SILVER_COVENANT_DISGUISE_FEMALE, + SPELL_SILVER_COVENANT_DISGUISE_MALE + }); + default: + break; + } - uint32 spellId = GetSpellInfo()->Id; + return false; + } - switch (spellId) - { - case SPELL_SUNREAVER_DISGUISE_TRIGGER: - spellId = gender ? SPELL_SUNREAVER_DISGUISE_FEMALE : SPELL_SUNREAVER_DISGUISE_MALE; - break; - case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: - spellId = gender ? SPELL_SILVER_COVENANT_DISGUISE_FEMALE : SPELL_SILVER_COVENANT_DISGUISE_MALE; - break; - default: - break; - } + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Player* player = GetHitPlayer()) + { + uint8 gender = player->GetNativeGender(); - GetCaster()->CastSpell(player, spellId, true); - } - } + uint32 spellId = GetSpellInfo()->Id; - void Register() override + switch (spellId) { - OnEffectHitTarget += SpellEffectFn(spell_gen_dalaran_disguise_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + case SPELL_SUNREAVER_DISGUISE_TRIGGER: + spellId = gender ? SPELL_SUNREAVER_DISGUISE_FEMALE : SPELL_SUNREAVER_DISGUISE_MALE; + break; + case SPELL_SILVER_COVENANT_DISGUISE_TRIGGER: + spellId = gender ? SPELL_SILVER_COVENANT_DISGUISE_FEMALE : SPELL_SILVER_COVENANT_DISGUISE_MALE; + break; + default: + break; } - }; - SpellScript* GetSpellScript() const override - { - return new spell_gen_dalaran_disguise_SpellScript(); + GetCaster()->CastSpell(player, spellId, true); } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gen_dalaran_disguise::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } }; enum DamageReductionAura @@ -1336,60 +1300,45 @@ class spell_gen_damage_reduction_aura : public AuraScript } }; -class spell_gen_decay_over_time : public SpellScriptLoader +class spell_gen_decay_over_time_spell : public SpellScript { - public: - spell_gen_decay_over_time(char const* name) : SpellScriptLoader(name) { } + PrepareSpellScript(spell_gen_decay_over_time_spell); - SpellScript* GetSpellScript() const override - { - return new spell_gen_decay_over_time_SpellScript(); - } - - private: - class spell_gen_decay_over_time_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_decay_over_time_SpellScript); - - void ModAuraStack() - { - if (Aura* aur = GetHitAura()) - aur->SetStackAmount(static_cast<uint8>(GetSpellInfo()->StackAmount)); - } + void ModAuraStack() + { + if (Aura* aur = GetHitAura()) + aur->SetStackAmount(static_cast<uint8>(GetSpellInfo()->StackAmount)); + } - void Register() override - { - AfterHit += SpellHitFn(spell_gen_decay_over_time_SpellScript::ModAuraStack); - } - }; + void Register() override + { + AfterHit += SpellHitFn(spell_gen_decay_over_time_spell::ModAuraStack); + } +}; - protected: - class spell_gen_decay_over_time_AuraScript : public AuraScript - { - protected: - PrepareAuraScript(spell_gen_decay_over_time_AuraScript); +class spell_gen_decay_over_time_aura : public AuraScript +{ + PrepareAuraScript(spell_gen_decay_over_time_aura); - bool CheckProc(ProcEventInfo& eventInfo) - { - return (eventInfo.GetSpellInfo() == GetSpellInfo()); - } +protected: + spell_gen_decay_over_time_aura() = default; - void Decay(ProcEventInfo& /*eventInfo*/) - { - PreventDefaultAction(); - ModStackAmount(-1); - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_gen_decay_over_time_AuraScript::CheckProc); - OnProc += AuraProcFn(spell_gen_decay_over_time_AuraScript::Decay); - } + bool CheckProc(ProcEventInfo& eventInfo) + { + return (eventInfo.GetSpellInfo() == GetSpellInfo()); + } - ~spell_gen_decay_over_time_AuraScript() = default; - }; + void Decay(ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + ModStackAmount(-1); + } - ~spell_gen_decay_over_time() = default; + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_gen_decay_over_time_aura::CheckProc); + OnProc += AuraProcFn(spell_gen_decay_over_time_aura::Decay); + } }; enum FungalDecay @@ -1399,53 +1348,31 @@ enum FungalDecay }; // 32065 - Fungal Decay -class spell_gen_decay_over_time_fungal_decay : public spell_gen_decay_over_time +class spell_gen_decay_over_time_fungal_decay : public spell_gen_decay_over_time_aura { - public: - spell_gen_decay_over_time_fungal_decay() : spell_gen_decay_over_time("spell_gen_decay_over_time_fungal_decay") { } - - class spell_gen_decay_over_time_fungal_decay_AuraScript : public spell_gen_decay_over_time_AuraScript - { - PrepareAuraScript(spell_gen_decay_over_time_fungal_decay_AuraScript); + PrepareAuraScript(spell_gen_decay_over_time_fungal_decay); - void ModDuration(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - // only on actual reapply, not on stack decay - if (GetDuration() == GetMaxDuration()) - { - SetMaxDuration(AURA_DURATION); - SetDuration(AURA_DURATION); - } - } - - void Register() override - { - spell_gen_decay_over_time_AuraScript::Register(); - OnEffectApply += AuraEffectApplyFn(spell_gen_decay_over_time_fungal_decay_AuraScript::ModDuration, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - } - }; - - AuraScript* GetAuraScript() const override + void ModDuration(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + // only on actual reapply, not on stack decay + if (GetDuration() == GetMaxDuration()) { - return new spell_gen_decay_over_time_fungal_decay_AuraScript(); + SetMaxDuration(AURA_DURATION); + SetDuration(AURA_DURATION); } + } + + void Register() override + { + spell_gen_decay_over_time_aura::Register(); + OnEffectApply += AuraEffectApplyFn(spell_gen_decay_over_time_fungal_decay::ModDuration, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } }; // 36659 - Tail Sting -class spell_gen_decay_over_time_tail_sting : public spell_gen_decay_over_time +class spell_gen_decay_over_time_tail_sting : public spell_gen_decay_over_time_aura { - public: - spell_gen_decay_over_time_tail_sting() : spell_gen_decay_over_time("spell_gen_decay_over_time_tail_sting") { } - - class spell_gen_decay_over_time_tail_sting_AuraScript : public spell_gen_decay_over_time_AuraScript - { - PrepareAuraScript(spell_gen_decay_over_time_tail_sting_AuraScript); - }; - - AuraScript* GetAuraScript() const override - { - return new spell_gen_decay_over_time_tail_sting_AuraScript(); - } + PrepareAuraScript(spell_gen_decay_over_time_tail_sting); }; enum DefendVisuals @@ -2036,49 +1963,35 @@ enum GenericLifebloom SPELL_FACTION_CHAMPIONS_DRU_LIFEBLOOM_FINAL_HEAL = 66094 }; -class spell_gen_lifebloom : public SpellScriptLoader +class spell_gen_lifebloom : public AuraScript { - public: - spell_gen_lifebloom(char const* name, uint32 spellId) : SpellScriptLoader(name), _spellId(spellId) { } - - class spell_gen_lifebloom_AuraScript : public AuraScript - { - PrepareAuraScript(spell_gen_lifebloom_AuraScript); - - public: - spell_gen_lifebloom_AuraScript(uint32 spellId) : AuraScript(), _spellId(spellId) { } - - private: - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ _spellId }); - } + PrepareAuraScript(spell_gen_lifebloom); - void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - // final heal only on duration end or dispel - if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL) - return; +public: + spell_gen_lifebloom(uint32 spellId) : AuraScript(), _spellId(spellId) { } - // final heal - GetTarget()->CastSpell(GetTarget(), _spellId, { aurEff, GetCasterGUID() }); - } +private: + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ _spellId }); + } - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_gen_lifebloom_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); - } + void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + // final heal only on duration end or dispel + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL) + return; - uint32 _spellId; - }; + // final heal + GetTarget()->CastSpell(GetTarget(), _spellId, { aurEff, GetCasterGUID() }); + } - AuraScript* GetAuraScript() const override - { - return new spell_gen_lifebloom_AuraScript(_spellId); - } + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_lifebloom::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); + } - private: - uint32 _spellId; + uint32 _spellId; }; enum Mounts @@ -2135,118 +2048,98 @@ enum Mounts SPELL_X53_TOURING_ROCKET_310 = 76154 }; -class spell_gen_mount : public SpellScriptLoader +class spell_gen_mount : public SpellScript { - public: - spell_gen_mount(char const* name, uint32 mount0 = 0, uint32 mount60 = 0, uint32 mount100 = 0, uint32 mount150 = 0, uint32 mount280 = 0, uint32 mount310 = 0) : SpellScriptLoader(name), - _mount0(mount0), _mount60(mount60), _mount100(mount100), _mount150(mount150), _mount280(mount280), _mount310(mount310) { } + PrepareSpellScript(spell_gen_mount); - class spell_gen_mount_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_mount_SpellScript); +public: + spell_gen_mount(uint32 mount0 = 0, uint32 mount60 = 0, uint32 mount100 = 0, uint32 mount150 = 0, uint32 mount280 = 0, uint32 mount310 = 0) : SpellScript(), + _mount0(mount0), _mount60(mount60), _mount100(mount100), _mount150(mount150), _mount280(mount280), _mount310(mount310) { } - public: - spell_gen_mount_SpellScript(uint32 mount0, uint32 mount60, uint32 mount100, uint32 mount150, uint32 mount280, uint32 mount310) : SpellScript(), - _mount0(mount0), _mount60(mount60), _mount100(mount100), _mount150(mount150), _mount280(mount280), _mount310(mount310) { } +private: + bool Validate(SpellInfo const* /*spellInfo*/) override + { + bool result = true; + if (_mount0) + result &= ValidateSpellInfo({ _mount0 }); + if (_mount60) + result &= ValidateSpellInfo({ _mount60 }); + if (_mount100) + result &= ValidateSpellInfo({ _mount100 }); + if (_mount150) + result &= ValidateSpellInfo({ _mount150 }); + if (_mount280) + result &= ValidateSpellInfo({ _mount280 }); + if (_mount310) + result &= ValidateSpellInfo({ _mount310 }); - private: - bool Validate(SpellInfo const* /*spellInfo*/) override - { - bool result = true; - if (_mount0) - result &= ValidateSpellInfo({ _mount0 }); - if (_mount60) - result &= ValidateSpellInfo({ _mount60 }); - if (_mount100) - result &= ValidateSpellInfo({ _mount100 }); - if (_mount150) - result &= ValidateSpellInfo({ _mount150 }); - if (_mount280) - result &= ValidateSpellInfo({ _mount280 }); - if (_mount310) - result &= ValidateSpellInfo({ _mount310 }); - - return result; - } + return result; + } - void HandleMount(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); + void HandleMount(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); - if (Player* target = GetHitPlayer()) - { - // Prevent stacking of mounts and client crashes upon dismounting - target->RemoveAurasByType(SPELL_AURA_MOUNTED, ObjectGuid::Empty, GetHitAura()); + if (Player* target = GetHitPlayer()) + { + // Prevent stacking of mounts and client crashes upon dismounting + target->RemoveAurasByType(SPELL_AURA_MOUNTED, ObjectGuid::Empty, GetHitAura()); - // Triggered spell id dependent on riding skill and zone - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_mount150); - uint32 zoneid, areaid; - target->GetZoneAndAreaId(zoneid, areaid); - bool const canFly = spellInfo && (spellInfo->CheckLocation(target->GetMapId(), zoneid, areaid, target) == SPELL_CAST_OK); + // Triggered spell id dependent on riding skill and zone + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_mount150); + uint32 zoneid, areaid; + target->GetZoneAndAreaId(zoneid, areaid); + bool const canFly = spellInfo && (spellInfo->CheckLocation(target->GetMapId(), zoneid, areaid, target) == SPELL_CAST_OK); - uint32 mount = 0; - switch (target->GetBaseSkillValue(SKILL_RIDING)) + uint32 mount = 0; + switch (target->GetBaseSkillValue(SKILL_RIDING)) + { + case 0: + mount = _mount0; + break; + case 75: + mount = _mount60; + break; + case 150: + mount = _mount100; + break; + case 225: + if (canFly) + mount = _mount150; + else + mount = _mount100; + break; + case 300: + if (canFly) { - case 0: - mount = _mount0; - break; - case 75: - mount = _mount60; - break; - case 150: - mount = _mount100; - break; - case 225: - if (canFly) - mount = _mount150; - else - mount = _mount100; - break; - case 300: - if (canFly) - { - if (_mount310 && target->Has310Flyer(false)) - mount = _mount310; - else - mount = _mount280; - } - else - mount = _mount100; - break; - default: - break; + if (_mount310 && target->Has310Flyer(false)) + mount = _mount310; + else + mount = _mount280; } - - if (mount) - target->CastSpell(target, mount, true); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_gen_mount_SpellScript::HandleMount, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); + else + mount = _mount100; + break; + default: + break; } - uint32 _mount0; - uint32 _mount60; - uint32 _mount100; - uint32 _mount150; - uint32 _mount280; - uint32 _mount310; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_gen_mount_SpellScript(_mount0, _mount60, _mount100, _mount150, _mount280, _mount310); + if (mount) + target->CastSpell(target, mount, true); } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gen_mount::HandleMount, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); + } - private: - uint32 _mount0; - uint32 _mount60; - uint32 _mount100; - uint32 _mount150; - uint32 _mount280; - uint32 _mount310; + uint32 _mount0; + uint32 _mount60; + uint32 _mount100; + uint32 _mount150; + uint32 _mount280; + uint32 _mount310; }; /* DOCUMENTATION: Charge spells @@ -2750,39 +2643,28 @@ class spell_gen_paralytic_poison : public AuraScript } }; -class spell_gen_proc_below_pct_damaged : public SpellScriptLoader +class spell_gen_proc_below_pct_damaged : public AuraScript { - public: - spell_gen_proc_below_pct_damaged(char const* name) : SpellScriptLoader(name) { } - - class spell_gen_proc_below_pct_damaged_AuraScript : public AuraScript - { - PrepareAuraScript(spell_gen_proc_below_pct_damaged_AuraScript); - - bool CheckProc(ProcEventInfo& eventInfo) - { - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - if (!damageInfo || !damageInfo->GetDamage()) - return false; + PrepareAuraScript(spell_gen_proc_below_pct_damaged); - int32 pct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); + bool CheckProc(ProcEventInfo& eventInfo) + { + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return false; - if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage())) - return true; + int32 pct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - return false; - } + if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage())) + return true; - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_gen_proc_below_pct_damaged_AuraScript::CheckProc); - } - }; + return false; + } - AuraScript* GetAuraScript() const override - { - return new spell_gen_proc_below_pct_damaged_AuraScript(); - } + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_gen_proc_below_pct_damaged::CheckProc); + } }; class spell_gen_proc_charge_drop_only : public AuraScript @@ -3250,55 +3132,41 @@ enum SummonElemental SPELL_SUMMON_EARTH_ELEMENTAL = 19704 }; -class spell_gen_summon_elemental : public SpellScriptLoader +class spell_gen_summon_elemental : public AuraScript { - public: - spell_gen_summon_elemental(char const* name, uint32 spellId) : SpellScriptLoader(name), _spellId(spellId) { } - - class spell_gen_summon_elemental_AuraScript : public AuraScript - { - PrepareAuraScript(spell_gen_summon_elemental_AuraScript); + PrepareAuraScript(spell_gen_summon_elemental); - public: - spell_gen_summon_elemental_AuraScript(uint32 spellId) : AuraScript(), _spellId(spellId) { } - - private: - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ _spellId }); - } - - void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetCaster()) - if (Unit* owner = GetCaster()->GetOwner()) - owner->CastSpell(owner, _spellId, true); - } +public: + spell_gen_summon_elemental(uint32 spellId) : AuraScript(), _spellId(spellId) { } - void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetCaster()) - if (Unit* owner = GetCaster()->GetOwner()) - if (owner->GetTypeId() == TYPEID_PLAYER) /// @todo this check is maybe wrong - owner->ToPlayer()->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true); - } +private: + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ _spellId }); + } - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_gen_summon_elemental_AuraScript::AfterApply, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_gen_summon_elemental_AuraScript::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } + void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetCaster()) + if (Unit* owner = GetCaster()->GetOwner()) + owner->CastSpell(owner, _spellId, true); + } - uint32 _spellId; - }; + void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetCaster()) + if (Unit* owner = GetCaster()->GetOwner()) + if (owner->GetTypeId() == TYPEID_PLAYER) /// @todo this check is maybe wrong + owner->ToPlayer()->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true); + } - AuraScript* GetAuraScript() const override - { - return new spell_gen_summon_elemental_AuraScript(_spellId); - } + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_gen_summon_elemental::AfterApply, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_summon_elemental::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } - private: - uint32 _spellId; + uint32 _spellId; }; enum TournamentMountsSpells @@ -3455,56 +3323,44 @@ enum PvPTrinketTriggeredSpells }; template <uint32 TriggeredSpellId> -class spell_pvp_trinket_wotf_shared_cd : public SpellScriptLoader +class spell_pvp_trinket_wotf_shared_cd : public SpellScript { - public: - spell_pvp_trinket_wotf_shared_cd(char const* ScriptName) : SpellScriptLoader(ScriptName) { } - - template <uint32 Triggered> - class spell_pvp_trinket_wotf_shared_cd_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pvp_trinket_wotf_shared_cd_SpellScript); + PrepareSpellScript(spell_pvp_trinket_wotf_shared_cd); - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ Triggered }); - } - - void HandleScript() - { - /* - * @workaround: PendingCast flag normally means 'triggered' spell, however - * if the spell is cast triggered, the core won't send SMSG_SPELL_GO packet - * so client never registers the cooldown (see Spell::IsNeedSendToClient) - * - * ServerToClient: SMSG_SPELL_GO (0x0132) Length: 42 ConnIdx: 0 Time: 07/19/2010 02:32:35.000 Number: 362675 - * Caster GUID: Full: Player - * Caster Unit GUID: Full: Player - * Cast Count: 0 - * Spell ID: 72752 (72752) - * Cast Flags: PendingCast, Unknown3, Unknown7 (265) - * Time: 3901468825 - * Hit Count: 1 - * [0] Hit GUID: Player - * Miss Count: 0 - * Target Flags: Unit (2) - * Target GUID: 0x0 - */ - - // Spell flags need further research, until then just cast not triggered - GetCaster()->CastSpell(nullptr, Triggered, false); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ TriggeredSpellId }); + } - void Register() override - { - AfterCast += SpellCastFn(spell_pvp_trinket_wotf_shared_cd_SpellScript::HandleScript); - } - }; + void HandleScript() + { + /* + * @workaround: PendingCast flag normally means 'triggered' spell, however + * if the spell is cast triggered, the core won't send SMSG_SPELL_GO packet + * so client never registers the cooldown (see Spell::IsNeedSendToClient) + * + * ServerToClient: SMSG_SPELL_GO (0x0132) Length: 42 ConnIdx: 0 Time: 07/19/2010 02:32:35.000 Number: 362675 + * Caster GUID: Full: Player + * Caster Unit GUID: Full: Player + * Cast Count: 0 + * Spell ID: 72752 (72752) + * Cast Flags: PendingCast, Unknown3, Unknown7 (265) + * Time: 3901468825 + * Hit Count: 1 + * [0] Hit GUID: Player + * Miss Count: 0 + * Target Flags: Unit (2) + * Target GUID: 0x0 + */ + + // Spell flags need further research, until then just cast not triggered + GetCaster()->CastSpell(nullptr, TriggeredSpellId, false); + } - SpellScript* GetSpellScript() const override - { - return new spell_pvp_trinket_wotf_shared_cd_SpellScript<TriggeredSpellId>(); - } + void Register() override + { + AfterCast += SpellCastFn(spell_pvp_trinket_wotf_shared_cd::HandleScript); + } }; enum FriendOrFowl @@ -4482,8 +4338,8 @@ void AddSC_generic_spell_scripts() RegisterAuraScript(spell_gen_blood_reserve); RegisterAuraScript(spell_gen_blade_warding); RegisterSpellScript(spell_gen_bonked); - new spell_gen_break_shield("spell_gen_break_shield"); - new spell_gen_break_shield("spell_gen_tournament_counterattack"); + RegisterSpellScriptWithArgs(spell_gen_break_shield, "spell_gen_break_shield"); + RegisterSpellScriptWithArgs(spell_gen_break_shield, "spell_gen_tournament_counterattack"); RegisterAuraScript(spell_gen_burn_brutallus); RegisterAuraScript(spell_gen_burning_depths_necrolyte_image); RegisterSpellScript(spell_gen_cannibalize); @@ -4494,15 +4350,15 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_clone); RegisterSpellScript(spell_gen_clone_weapon); RegisterAuraScript(spell_gen_clone_weapon_aura); - new spell_gen_count_pct_from_max_hp("spell_gen_default_count_pct_from_max_hp"); - new spell_gen_count_pct_from_max_hp("spell_gen_50pct_count_pct_from_max_hp", 50); + RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_default_count_pct_from_max_hp"); + RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_50pct_count_pct_from_max_hp", 50); RegisterSpellScript(spell_gen_create_lance); RegisterAuraScript(spell_gen_creature_permanent_feign_death); - new spell_gen_dalaran_disguise("spell_gen_sunreaver_disguise"); - new spell_gen_dalaran_disguise("spell_gen_silver_covenant_disguise"); + RegisterSpellScriptWithArgs(spell_gen_dalaran_disguise, "spell_gen_sunreaver_disguise"); + RegisterSpellScriptWithArgs(spell_gen_dalaran_disguise, "spell_gen_silver_covenant_disguise"); RegisterAuraScript(spell_gen_damage_reduction_aura); - new spell_gen_decay_over_time_fungal_decay(); - new spell_gen_decay_over_time_tail_sting(); + RegisterSpellAndAuraScriptPair(spell_gen_decay_over_time_fungal_decay, spell_gen_decay_over_time_spell); + RegisterSpellAndAuraScriptPair(spell_gen_decay_over_time_tail_sting, spell_gen_decay_over_time_spell); RegisterAuraScript(spell_gen_defend); RegisterSpellScript(spell_gen_despawn_self); RegisterSpellScript(spell_gen_divine_storm_cd_reset); @@ -4521,20 +4377,20 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_lich_pet_onsummon); RegisterSpellScript(spell_gen_lich_pet_aura_remove); RegisterAuraScript(spell_gen_lifeblood); - new spell_gen_lifebloom("spell_hexlord_lifebloom", SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL); - new spell_gen_lifebloom("spell_tur_ragepaw_lifebloom", SPELL_TUR_RAGEPAW_LIFEBLOOM_FINAL_HEAL); - new spell_gen_lifebloom("spell_cenarion_scout_lifebloom", SPELL_CENARION_SCOUT_LIFEBLOOM_FINAL_HEAL); - new spell_gen_lifebloom("spell_twisted_visage_lifebloom", SPELL_TWISTED_VISAGE_LIFEBLOOM_FINAL_HEAL); - new spell_gen_lifebloom("spell_faction_champion_dru_lifebloom", SPELL_FACTION_CHAMPIONS_DRU_LIFEBLOOM_FINAL_HEAL); - new spell_gen_mount("spell_magic_broom", 0, SPELL_MAGIC_BROOM_60, SPELL_MAGIC_BROOM_100, SPELL_MAGIC_BROOM_150, SPELL_MAGIC_BROOM_280); - new spell_gen_mount("spell_headless_horseman_mount", 0, SPELL_HEADLESS_HORSEMAN_MOUNT_60, SPELL_HEADLESS_HORSEMAN_MOUNT_100, SPELL_HEADLESS_HORSEMAN_MOUNT_150, SPELL_HEADLESS_HORSEMAN_MOUNT_280); - new spell_gen_mount("spell_winged_steed_of_the_ebon_blade", 0, 0, 0, SPELL_WINGED_STEED_150, SPELL_WINGED_STEED_280); - new spell_gen_mount("spell_big_blizzard_bear", 0, SPELL_BIG_BLIZZARD_BEAR_60, SPELL_BIG_BLIZZARD_BEAR_100); - new spell_gen_mount("spell_big_love_rocket", SPELL_BIG_LOVE_ROCKET_0, SPELL_BIG_LOVE_ROCKET_60, SPELL_BIG_LOVE_ROCKET_100, SPELL_BIG_LOVE_ROCKET_150, SPELL_BIG_LOVE_ROCKET_310); - new spell_gen_mount("spell_invincible", 0, SPELL_INVINCIBLE_60, SPELL_INVINCIBLE_100, SPELL_INVINCIBLE_150, SPELL_INVINCIBLE_310); - new spell_gen_mount("spell_blazing_hippogryph", 0, 0, 0, SPELL_BLAZING_HIPPOGRYPH_150, SPELL_BLAZING_HIPPOGRYPH_280); - new spell_gen_mount("spell_celestial_steed", 0, SPELL_CELESTIAL_STEED_60, SPELL_CELESTIAL_STEED_100, SPELL_CELESTIAL_STEED_150, SPELL_CELESTIAL_STEED_280, SPELL_CELESTIAL_STEED_310); - new spell_gen_mount("spell_x53_touring_rocket", 0, 0, 0, SPELL_X53_TOURING_ROCKET_150, SPELL_X53_TOURING_ROCKET_280, SPELL_X53_TOURING_ROCKET_310); + RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_hexlord_lifebloom", SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL); + RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_tur_ragepaw_lifebloom", SPELL_TUR_RAGEPAW_LIFEBLOOM_FINAL_HEAL); + RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_cenarion_scout_lifebloom", SPELL_CENARION_SCOUT_LIFEBLOOM_FINAL_HEAL); + RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_twisted_visage_lifebloom", SPELL_TWISTED_VISAGE_LIFEBLOOM_FINAL_HEAL); + RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_faction_champion_dru_lifebloom", SPELL_FACTION_CHAMPIONS_DRU_LIFEBLOOM_FINAL_HEAL); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_magic_broom", 0, SPELL_MAGIC_BROOM_60, SPELL_MAGIC_BROOM_100, SPELL_MAGIC_BROOM_150, SPELL_MAGIC_BROOM_280); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_headless_horseman_mount", 0, SPELL_HEADLESS_HORSEMAN_MOUNT_60, SPELL_HEADLESS_HORSEMAN_MOUNT_100, SPELL_HEADLESS_HORSEMAN_MOUNT_150, SPELL_HEADLESS_HORSEMAN_MOUNT_280); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_winged_steed_of_the_ebon_blade", 0, 0, 0, SPELL_WINGED_STEED_150, SPELL_WINGED_STEED_280); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_big_blizzard_bear", 0, SPELL_BIG_BLIZZARD_BEAR_60, SPELL_BIG_BLIZZARD_BEAR_100); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_big_love_rocket", SPELL_BIG_LOVE_ROCKET_0, SPELL_BIG_LOVE_ROCKET_60, SPELL_BIG_LOVE_ROCKET_100, SPELL_BIG_LOVE_ROCKET_150, SPELL_BIG_LOVE_ROCKET_310); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_invincible", 0, SPELL_INVINCIBLE_60, SPELL_INVINCIBLE_100, SPELL_INVINCIBLE_150, SPELL_INVINCIBLE_310); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_blazing_hippogryph", 0, 0, 0, SPELL_BLAZING_HIPPOGRYPH_150, SPELL_BLAZING_HIPPOGRYPH_280); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_celestial_steed", 0, SPELL_CELESTIAL_STEED_60, SPELL_CELESTIAL_STEED_100, SPELL_CELESTIAL_STEED_150, SPELL_CELESTIAL_STEED_280, SPELL_CELESTIAL_STEED_310); + RegisterSpellScriptWithArgs(spell_gen_mount, "spell_x53_touring_rocket", 0, 0, 0, SPELL_X53_TOURING_ROCKET_150, SPELL_X53_TOURING_ROCKET_280, SPELL_X53_TOURING_ROCKET_310); RegisterSpellScript(spell_gen_mounted_charge); RegisterAuraScript(spell_gen_moss_covered_feet); RegisterAuraScript(spell_gen_negative_energy_periodic); @@ -4546,12 +4402,12 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_oracle_wolvar_reputation); RegisterSpellScript(spell_gen_orc_disguise); RegisterAuraScript(spell_gen_paralytic_poison); - new spell_gen_proc_below_pct_damaged("spell_item_soul_harvesters_charm"); - new spell_gen_proc_below_pct_damaged("spell_item_commendation_of_kaelthas"); - new spell_gen_proc_below_pct_damaged("spell_item_corpse_tongue_coin"); - new spell_gen_proc_below_pct_damaged("spell_item_corpse_tongue_coin_heroic"); - new spell_gen_proc_below_pct_damaged("spell_item_petrified_twilight_scale"); - new spell_gen_proc_below_pct_damaged("spell_item_petrified_twilight_scale_heroic"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_soul_harvesters_charm"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_commendation_of_kaelthas"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_corpse_tongue_coin"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_corpse_tongue_coin_heroic"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_petrified_twilight_scale"); + RegisterSpellScriptWithArgs(spell_gen_proc_below_pct_damaged, "spell_item_petrified_twilight_scale_heroic"); RegisterAuraScript(spell_gen_proc_charge_drop_only); RegisterAuraScript(spell_gen_parachute); RegisterSpellScript(spell_gen_pet_summoned); @@ -4566,15 +4422,15 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_seaforium_blast); RegisterSpellScript(spell_gen_spectator_cheer_trigger); RegisterSpellScript(spell_gen_spirit_healer_res); - new spell_gen_summon_elemental("spell_gen_summon_fire_elemental", SPELL_SUMMON_FIRE_ELEMENTAL); - new spell_gen_summon_elemental("spell_gen_summon_earth_elemental", SPELL_SUMMON_EARTH_ELEMENTAL); + RegisterSpellScriptWithArgs(spell_gen_summon_elemental, "spell_gen_summon_fire_elemental", SPELL_SUMMON_FIRE_ELEMENTAL); + RegisterSpellScriptWithArgs(spell_gen_summon_elemental, "spell_gen_summon_earth_elemental", SPELL_SUMMON_EARTH_ELEMENTAL); RegisterSpellScript(spell_gen_summon_tournament_mount); RegisterSpellScript(spell_gen_throw_shield); RegisterSpellScript(spell_gen_tournament_duel); RegisterAuraScript(spell_gen_tournament_pennant); RegisterSpellScript(spell_gen_teleporting); - new spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER>("spell_pvp_trinket_shared_cd"); - new spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF>("spell_wotf_shared_cd"); + RegisterSpellScriptWithArgs(spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER>, "spell_pvp_trinket_shared_cd"); + RegisterSpellScriptWithArgs(spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF>, "spell_wotf_shared_cd"); RegisterAuraScript(spell_gen_turkey_marker); RegisterSpellScript(spell_gen_upper_deck_create_foam_sword); RegisterAuraScript(spell_gen_vampiric_touch); |