diff options
author | blub <Vincent_Michael@gmx.de> | 2013-07-18 15:34:45 -0700 |
---|---|---|
committer | blub <Vincent_Michael@gmx.de> | 2013-07-18 15:34:45 -0700 |
commit | 7dd26ce40ee92f3e8624ba2d232dbd40b6a9507c (patch) | |
tree | 23c5c58194dc41a26f0fbc5abe2c7ffe660494ee | |
parent | 922fba3a13cbb8b177c39f3f262ab0a6c6466a9a (diff) | |
parent | d52ce57e590d9703b34386469a2c4e9a5ad215ab (diff) |
Merge pull request #10306 from joschiwald/devourer_of_souls
Scripts/ForgeOfSouls: move "Mirrored Soul" into SpellScripts
-rw-r--r-- | sql/updates/world/2013_07_18_02_world_spell_script_names.sql | 5 | ||||
-rw-r--r-- | src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp | 173 |
2 files changed, 150 insertions, 28 deletions
diff --git a/sql/updates/world/2013_07_18_02_world_spell_script_names.sql b/sql/updates/world/2013_07_18_02_world_spell_script_names.sql new file mode 100644 index 00000000000..89463a861aa --- /dev/null +++ b/sql/updates/world/2013_07_18_02_world_spell_script_names.sql @@ -0,0 +1,5 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` IN (69051,69023,69048); +INSERT INTO `spell_script_names` (`spell_id` ,`ScriptName`) VALUES +(69051, 'spell_devourer_of_souls_mirrored_soul'), +(69023, 'spell_devourer_of_souls_mirrored_soul_proc'), +(69048, 'spell_devourer_of_souls_mirrored_soul_target_selector'); diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 173abfc2652..b1ecdc5904e 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -17,9 +17,11 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "forge_of_souls.h" #include "Player.h" #include "SpellInfo.h" +#include "SpellAuraEffects.h" +#include "SpellScript.h" +#include "forge_of_souls.h" /* * @todo @@ -48,7 +50,10 @@ enum Spells { SPELL_PHANTOM_BLAST = 68982, H_SPELL_PHANTOM_BLAST = 70322, - SPELL_MIRRORED_SOUL = 69051, + SPELL_MIRRORED_SOUL_PROC_AURA = 69023, + SPELL_MIRRORED_SOUL_DAMAGE = 69034, + SPELL_MIRRORED_SOUL_TARGET_SELECTOR = 69048, + SPELL_MIRRORED_SOUL_BUFF = 69051, SPELL_WELL_OF_SOULS = 68820, SPELL_UNLEASHED_SOULS = 68939, SPELL_WAILING_SOULS_STARTING = 68912, // Initial spell cast at begining of wailing souls phase @@ -145,7 +150,6 @@ class boss_devourer_of_souls : public CreatureScript summons.DespawnAll(); threeFaced = true; - mirroredSoulTarget = 0; instance->SetData(DATA_DEVOURER_EVENT, NOT_STARTED); } @@ -165,23 +169,6 @@ class boss_devourer_of_souls : public CreatureScript instance->SetData(DATA_DEVOURER_EVENT, IN_PROGRESS); } - void DamageTaken(Unit* /*pDoneBy*/, uint32 &uiDamage) OVERRIDE - { - if (mirroredSoulTarget && me->HasAura(SPELL_MIRRORED_SOUL)) - { - if (Player* player = Unit::GetPlayer(*me, mirroredSoulTarget)) - { - if (player->GetAura(SPELL_MIRRORED_SOUL)) - { - int32 mirrorDamage = (uiDamage* 45)/100; - me->CastCustomSpell(player, 69034, &mirrorDamage, 0, 0, true); - } - else - mirroredSoulTarget = 0; - } - } - } - void KilledUnit(Unit* victim) OVERRIDE { if (victim->GetTypeId() != TYPEID_PLAYER) @@ -270,12 +257,8 @@ class boss_devourer_of_souls : public CreatureScript events.ScheduleEvent(EVENT_PHANTOM_BLAST, 5000); break; case EVENT_MIRRORED_SOUL: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true)) - { - mirroredSoulTarget = target->GetGUID(); - DoCast(target, SPELL_MIRRORED_SOUL); - Talk(EMOTE_MIRRORED_SOUL); - } + DoCastAOE(SPELL_MIRRORED_SOUL_TARGET_SELECTOR); + Talk(EMOTE_MIRRORED_SOUL); events.ScheduleEvent(EVENT_MIRRORED_SOUL, urand(15000, 30000)); break; case EVENT_WELL_OF_SOULS: @@ -358,8 +341,6 @@ class boss_devourer_of_souls : public CreatureScript float beamAngle; float beamAngleDiff; int8 wailingSoulTick; - - uint64 mirroredSoulTarget; }; CreatureAI* GetAI(Creature* creature) const OVERRIDE @@ -368,6 +349,139 @@ class boss_devourer_of_souls : public CreatureScript } }; +// 69051 - Mirrored Soul +class spell_devourer_of_souls_mirrored_soul : public SpellScriptLoader +{ + public: + spell_devourer_of_souls_mirrored_soul() : SpellScriptLoader("spell_devourer_of_souls_mirrored_soul") { } + + class spell_devourer_of_souls_mirrored_soul_SpellScript : public SpellScript + { + PrepareSpellScript(spell_devourer_of_souls_mirrored_soul_SpellScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_MIRRORED_SOUL_PROC_AURA)) + return false; + return true; + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + target->CastSpell(GetCaster(), SPELL_MIRRORED_SOUL_PROC_AURA, true); + } + + void Register() OVERRIDE + { + OnEffectHitTarget += SpellEffectFn(spell_devourer_of_souls_mirrored_soul_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const OVERRIDE + { + return new spell_devourer_of_souls_mirrored_soul_SpellScript(); + } +}; + +// 69023 - Mirrored Soul (Proc) +class spell_devourer_of_souls_mirrored_soul_proc : public SpellScriptLoader +{ + public: + spell_devourer_of_souls_mirrored_soul_proc() : SpellScriptLoader("spell_devourer_of_souls_mirrored_soul_proc") { } + + class spell_devourer_of_souls_mirrored_soul_proc_AuraScript : public AuraScript + { + PrepareAuraScript(spell_devourer_of_souls_mirrored_soul_proc_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_MIRRORED_SOUL_DAMAGE)) + return false; + return true; + } + + bool Load() OVERRIDE + { + _procTarget = NULL; + return true; + } + + bool CheckProc(ProcEventInfo& /*eventInfo*/) + { + _procTarget = GetCaster(); + return _procTarget && _procTarget->IsAlive(); + } + + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), 45)); + GetTarget()->CastCustomSpell(SPELL_MIRRORED_SOUL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, _procTarget, true); + } + + void Register() OVERRIDE + { + DoCheckProc += AuraCheckProcFn(spell_devourer_of_souls_mirrored_soul_proc_AuraScript::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_devourer_of_souls_mirrored_soul_proc_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + + private: + Unit* _procTarget; + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_devourer_of_souls_mirrored_soul_proc_AuraScript(); + } +}; + +// 69048 - Mirrored Soul (Target Selector) +class spell_devourer_of_souls_mirrored_soul_target_selector : public SpellScriptLoader +{ + public: + spell_devourer_of_souls_mirrored_soul_target_selector() : SpellScriptLoader("spell_devourer_of_souls_mirrored_soul_target_selector") { } + + class spell_devourer_of_souls_mirrored_soul_target_selector_SpellScript : public SpellScript + { + PrepareSpellScript(spell_devourer_of_souls_mirrored_soul_target_selector_SpellScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_MIRRORED_SOUL_BUFF)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, SPELL_MIRRORED_SOUL_BUFF, false); + } + + void Register() OVERRIDE + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_devourer_of_souls_mirrored_soul_target_selector_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_devourer_of_souls_mirrored_soul_target_selector_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const OVERRIDE + { + return new spell_devourer_of_souls_mirrored_soul_target_selector_SpellScript(); + } +}; + class achievement_three_faced : public AchievementCriteriaScript { public: @@ -391,5 +505,8 @@ class achievement_three_faced : public AchievementCriteriaScript void AddSC_boss_devourer_of_souls() { new boss_devourer_of_souls(); + new spell_devourer_of_souls_mirrored_soul(); + new spell_devourer_of_souls_mirrored_soul_proc(); + new spell_devourer_of_souls_mirrored_soul_target_selector(); new achievement_three_faced(); } |