diff --git a/sql/updates/world/3.3.5/2017_07_18_03_world.sql b/sql/updates/world/3.3.5/2017_07_18_03_world.sql new file mode 100644 index 00000000000..17bcc875f61 --- /dev/null +++ b/sql/updates/world/3.3.5/2017_07_18_03_world.sql @@ -0,0 +1,3 @@ +-- +DELETE FROM `spell_script_names` WHERE `scriptname`='spell_item_nitro_boosts_backfire'; +INSERT INTO `spell_script_names` (`spell_id`,`scriptname`) VALUES (54621,'spell_item_nitro_boosts_backfire'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 34fd046d193..66612e424c6 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -3332,7 +3332,8 @@ class spell_item_brewfest_mount_transformation : public SpellScriptLoader enum NitroBoosts { SPELL_NITRO_BOOSTS_SUCCESS = 54861, - SPELL_NITRO_BOOSTS_BACKFIRE = 46014, + SPELL_NITRO_BOOSTS_BACKFIRE = 54621, + SPELL_NITRO_BOOSTS_PARACHUTE = 54649, }; class spell_item_nitro_boosts : public SpellScriptLoader @@ -3380,6 +3381,54 @@ class spell_item_nitro_boosts : public SpellScriptLoader } }; +class spell_item_nitro_boosts_backfire : public SpellScriptLoader +{ + public: + spell_item_nitro_boosts_backfire() : SpellScriptLoader("spell_item_nitro_boosts_backfire") { } + + class spell_item_nitro_boosts_backfire_AuraScript : public AuraScript + { + PrepareAuraScript(spell_item_nitro_boosts_backfire_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_NITRO_BOOSTS_PARACHUTE }); + } + + void HandleApply(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/) + { + lastZ = GetTarget()->GetPositionZ(); + } + + void HandlePeriodicDummy(AuraEffect const* effect) + { + PreventDefaultAction(); + float curZ = GetTarget()->GetPositionZ(); + if (curZ < lastZ) + { + if (roll_chance_i(80)) // we don't have enough sniffs to verify this, guesstimate + GetTarget()->CastSpell(GetTarget(), SPELL_NITRO_BOOSTS_PARACHUTE, true, nullptr, effect); + GetAura()->Remove(); + } + else + lastZ = curZ; + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_item_nitro_boosts_backfire_AuraScript::HandleApply, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_item_nitro_boosts_backfire_AuraScript::HandlePeriodicDummy, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + + float lastZ = INVALID_HEIGHT; + }; + + AuraScript* GetAuraScript() const override + { + return new spell_item_nitro_boosts_backfire_AuraScript(); + } +}; + enum TeachLanguage { SPELL_LEARN_GNOMISH_BINARY = 50242, @@ -4708,6 +4757,7 @@ void AddSC_item_spell_scripts() new spell_item_impale_leviroth(); new spell_item_brewfest_mount_transformation(); new spell_item_nitro_boosts(); + new spell_item_nitro_boosts_backfire(); new spell_item_teach_language(); new spell_item_rocket_boots(); new spell_item_pygmy_oil();