diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index da4880b4b6b..3702d1a94ad 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -986,6 +986,81 @@ class spell_gen_seaforium_blast : public SpellScriptLoader } }; +enum FriendOrFowl +{ + SPELL_TURKEY_VENGEANCE = 25285, +}; + +class spell_gen_turkey_marker : public SpellScriptLoader +{ + public: + spell_gen_turkey_marker() : SpellScriptLoader("spell_gen_turkey_marker") { } + + class spell_gen_turkey_marker_AuraScript : public AuraScript + { + PrepareAuraScript(spell_gen_turkey_marker_AuraScript); + + void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + // store stack apply times, so we can pop them while they expire + _applyTimes.push_back(getMSTime()); + + // on stack 15 cast the achievement crediting spell + if (GetStackAmount() >= 15) + GetTarget()->CastSpell(GetTarget(), SPELL_TURKEY_VENGEANCE, true, NULL, aurEff, GetCasterGUID()); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_STACK) + return; + + // find our new aura which replaces this one aura is inserted to m_ownedAuras before old removal takes place + Aura* newAura = GetTarget()->GetOwnedAura(GetId(), 0, 0, 0, GetAura()); + // this should never happen + if (!newAura) + return; + + std::list<AuraScript*> const& loadedScripts = newAura->m_loadedScripts; + + // find the new aura's script and give it our stored stack apply times + for (std::list<AuraScript*>::const_iterator itr = loadedScripts.begin(); itr != loadedScripts.end(); ++itr) + { + if (spell_gen_turkey_marker_AuraScript* scr = dynamic_cast<spell_gen_turkey_marker_AuraScript*>(*itr)) + { + scr->_applyTimes.splice(scr->_applyTimes.begin(), _applyTimes); + break; + } + } + } + + void OnPeriodic(AuraEffect const* /*aurEff*/) + { + if (_applyTimes.empty()) + return; + + // pop stack if it expired for us + if (_applyTimes.front() + GetMaxDuration() < getMSTime()) + if (ModStackAmount(-1)) + GetTarget()->RemoveOwnedAura(GetAura(), AURA_REMOVE_BY_EXPIRE); + } + + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_turkey_marker_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_turkey_marker_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + + std::list<uint32> _applyTimes; + }; + + AuraScript* GetAuraScript() const + { + return new spell_gen_turkey_marker_AuraScript(); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -1009,4 +1084,5 @@ void AddSC_generic_spell_scripts() new spell_generic_clone(); new spell_generic_clone_weapon(); new spell_gen_seaforium_blast(); + new spell_gen_turkey_marker(); } |