diff options
-rw-r--r-- | sql/base/world_database.sql | 1 | ||||
-rw-r--r-- | sql/updates/10815_world_spell_script_names.sql | 3 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_item.cpp | 56 |
3 files changed, 60 insertions, 0 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index 0e705852df0..aca1a4b2c5f 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -26908,6 +26908,7 @@ INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES ( 14537, 'spell_item_six_demon_bag'), ( 59640, 'spell_item_underbelly_elixir'), ( 71905, 'spell_item_shadowmourne'), +( 67533, 'spell_item_red_rider_air_rifle'), -- warrior ( 12975, 'spell_warr_last_stand'), -- paladin diff --git a/sql/updates/10815_world_spell_script_names.sql b/sql/updates/10815_world_spell_script_names.sql new file mode 100644 index 00000000000..ee041b30e0a --- /dev/null +++ b/sql/updates/10815_world_spell_script_names.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `spell_id`=67533 AND `ScriptName`='spell_item_red_rider_air_rifle'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(67533, 'spell_item_red_rider_air_rifle'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 2092735d2f8..db095f048a8 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -741,6 +741,61 @@ public: } }; +enum AirRifleSpells +{ + SPELL_AIR_RIFLE_HOLD_VISUAL = 65582, + SPELL_AIR_RIFLE_SHOOT = 67532, + SPELL_AIR_RIFLE_SHOOT_SELF = 65577, +}; + +class spell_item_red_rider_air_rifle : public SpellScriptLoader +{ + public: + spell_item_red_rider_air_rifle() : SpellScriptLoader("spell_item_red_rider_air_rifle") { } + + class spell_item_red_rider_air_rifle_SpellScript : public SpellScript + { + PrepareSpellScript(spell_item_red_rider_air_rifle_SpellScript); + + bool Validate(SpellEntry const* /*spell*/) + { + if (!sSpellStore.LookupEntry(SPELL_AIR_RIFLE_HOLD_VISUAL)) + return false; + if (!sSpellStore.LookupEntry(SPELL_AIR_RIFLE_SHOOT)) + return false; + if (!sSpellStore.LookupEntry(SPELL_AIR_RIFLE_SHOOT_SELF)) + return false; + return true; + } + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; + + GetCaster()->CastSpell(GetCaster(), SPELL_AIR_RIFLE_HOLD_VISUAL, true); + // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) + if (Player* player = GetCaster()->ToPlayer()) + player->RemoveGlobalCooldown(GetSpellInfo()); + if (urand(0, 4)) + GetCaster()->CastSpell(GetHitUnit(), SPELL_AIR_RIFLE_SHOOT, false); + else + GetCaster()->CastSpell(GetCaster(), SPELL_AIR_RIFLE_SHOOT_SELF, false); + } + + void Register() + { + OnEffect += SpellEffectFn(spell_item_red_rider_air_rifle_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_item_red_rider_air_rifle_SpellScript(); + } +}; + enum eGenericData { SPELL_ARCANITE_DRAGONLING = 19804, @@ -771,4 +826,5 @@ void AddSC_item_spell_scripts() new spell_item_six_demon_bag(); new spell_item_underbelly_elixir(); new spell_item_shadowmourne(); + new spell_item_red_rider_air_rifle(); } |