diff options
| author | Shauren <shauren.trinity@gmail.com> | 2011-05-07 11:40:15 +0200 | 
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2011-05-07 11:40:15 +0200 | 
| commit | 49aeb3ae5a57cb7a6c2eef9ff3a7df31dec399a9 (patch) | |
| tree | f6335d4635cc440b4041b01bf920e73253fdd663 /src/server/scripts/Spells | |
| parent | b087741959c2c109c2863e8b83e4ccfa5677fdbe (diff) | |
Scripts/Spells: Fixed Friend or Fowl achievement
Diffstat (limited to 'src/server/scripts/Spells')
| -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();  } | 
