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 | |
parent | b087741959c2c109c2863e8b83e4ccfa5677fdbe (diff) |
Scripts/Spells: Fixed Friend or Fowl achievement
-rw-r--r-- | sql/scripts/world_scripts_full.sql | 1 | ||||
-rw-r--r-- | sql/updates/world/2011_05_07_00_world_sai.sql | 7 | ||||
-rw-r--r-- | sql/updates/world/2011_05_07_00_world_spell_script_names.sql | 3 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 76 |
4 files changed, 87 insertions, 0 deletions
diff --git a/sql/scripts/world_scripts_full.sql b/sql/scripts/world_scripts_full.sql index 763ff8e3e8a..bad41ed0452 100644 --- a/sql/scripts/world_scripts_full.sql +++ b/sql/scripts/world_scripts_full.sql @@ -1892,6 +1892,7 @@ INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES ( 69892, 'spell_generic_clone_weapon'), ( 57593, 'spell_generic_clone_weapon'), ( 52408, 'spell_gen_seaforium_blast'), +( 25281, 'spell_gen_turkey_marker'), -- instances -- Black Temple ( 41475, 'spell_boss_lady_malande_shield'), diff --git a/sql/updates/world/2011_05_07_00_world_sai.sql b/sql/updates/world/2011_05_07_00_world_sai.sql new file mode 100644 index 00000000000..8f3ed2a213c --- /dev/null +++ b/sql/updates/world/2011_05_07_00_world_sai.sql @@ -0,0 +1,7 @@ +UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry` IN (23801,24746,29594); + +DELETE FROM `smart_scripts` WHERE `entryorguid` IN (23801,24746,29594); +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(23801,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Turkey - Cast Marker on death'), +(24746,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Fjord Turkey - Cast Marker on death'), +(29594,0,0,0,6,0,100,1,0,0,0,0,85,25281,2,0,0,0,0,7,0,0,0,0,0,0,0,'Angry Turkey - Cast Marker on death'); diff --git a/sql/updates/world/2011_05_07_00_world_spell_script_names.sql b/sql/updates/world/2011_05_07_00_world_spell_script_names.sql new file mode 100644 index 00000000000..caa7d2a407c --- /dev/null +++ b/sql/updates/world/2011_05_07_00_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_turkey_marker'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(25281, 'spell_gen_turkey_marker'); 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(); } |