From a0313cb09d882959decd90e7080e62724b56cc53 Mon Sep 17 00:00:00 2001 From: SnapperRy Date: Sat, 15 Oct 2016 01:47:47 +0200 Subject: [PATCH] =?UTF-8?q?Core/Scripts:=20Gnomish=20Mind=20Control=20Cap?= =?UTF-8?q?=20and=20Gnomish=20Universal=20Re=E2=80=A6=20=E2=80=A6mote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../world/3.3.5/2016_09_09_20_world.sql | 7 ++ src/server/scripts/Spells/spell_item.cpp | 117 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 sql/updates/world/3.3.5/2016_09_09_20_world.sql diff --git a/sql/updates/world/3.3.5/2016_09_09_20_world.sql b/sql/updates/world/3.3.5/2016_09_09_20_world.sql new file mode 100644 index 00000000000..2a2b1ae3e8e --- /dev/null +++ b/sql/updates/world/3.3.5/2016_09_09_20_world.sql @@ -0,0 +1,7 @@ +-- Gnomish Mind Control Cap and Mind Amplification Dish script +DELETE FROM `spell_script_names` WHERE ScriptName IN ('spell_item_mind_control_cap','spell_item_universal_remote'); +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(67799, 'spell_item_mind_control_cap'), +(13180, 'spell_item_mind_control_cap'), +-- Gnomish Universal Remote script +(8344, 'spell_item_universal_remote'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 6fe6b40638a..2d62143afe1 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -2789,6 +2789,120 @@ class spell_item_taunt_flag_targeting : public SpellScriptLoader } }; + +// 13180 - Gnomish Mind Control Cap +enum MindControlCap +{ + ROLL_CHANCE_DULLARD = 32, + ROLL_CHANCE_NO_BACKFIRE = 95, + SPELL_GNOMISH_MIND_CONTROL_CAP = 13181, + SPELL_DULLARD = 67809 +}; + +class spell_item_mind_control_cap : public SpellScriptLoader +{ + public: + spell_item_mind_control_cap() : SpellScriptLoader("spell_item_mind_control_cap") { } + + class spell_item_mind_control_cap_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_mind_control_cap_SpellScript); + + bool Load() override + { + if (!GetCastItem()) + return false; + return true; + } + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_MIND_CONTROL_CAP) || !sSpellMgr->GetSpellInfo(SPELL_DULLARD)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /* effIndex */) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + if (roll_chance_i(ROLL_CHANCE_NO_BACKFIRE)) + caster->CastSpell(target, roll_chance_i(ROLL_CHANCE_DULLARD) ? SPELL_DULLARD : SPELL_GNOMISH_MIND_CONTROL_CAP, true, GetCastItem()); + else + target->CastSpell(caster, SPELL_GNOMISH_MIND_CONTROL_CAP, true); // backfire - 5% chance + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_mind_control_cap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_item_mind_control_cap_SpellScript(); + } +}; + +// 8344 - Universal Remote (Gnomish Universal Remote) +enum UniversalRemote +{ + SPELL_CONTROL_MACHINE = 8345, + SPELL_MOBILITY_MALFUNCTION = 8346, + SPELL_TARGET_LOCK = 8347 +}; + +class spell_item_universal_remote : public SpellScriptLoader +{ + public: + spell_item_universal_remote() : SpellScriptLoader("spell_item_universal_remote") { } + + class spell_item_universal_remote_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_universal_remote_SpellScript); + + bool Load() override + { + if (!GetCastItem()) + return false; + return true; + } + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_CONTROL_MACHINE) || !sSpellMgr->GetSpellInfo(SPELL_MOBILITY_MALFUNCTION) || !sSpellMgr->GetSpellInfo(SPELL_TARGET_LOCK)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + { + uint8 chance = urand(0, 99); + if (chance < 15) + GetCaster()->CastSpell(target, SPELL_TARGET_LOCK, true, GetCastItem()); + else if (chance < 25) + GetCaster()->CastSpell(target, SPELL_MOBILITY_MALFUNCTION, true, GetCastItem()); + else + GetCaster()->CastSpell(target, SPELL_CONTROL_MACHINE, true, GetCastItem()); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_universal_remote_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_item_universal_remote_SpellScript(); + } +}; + void AddSC_item_spell_scripts() { // 23074 Arcanite Dragonling @@ -2860,4 +2974,7 @@ void AddSC_item_spell_scripts() new spell_item_greatmothers_soulcatcher(); new spell_item_toy_train_set_pulse(); new spell_item_taunt_flag_targeting(); + + new spell_item_mind_control_cap(); + new spell_item_universal_remote(); }