diff --git a/data/sql/updates/pending_db_world/rev_1658293185077751500.sql b/data/sql/updates/pending_db_world/rev_1658293185077751500.sql new file mode 100644 index 000000000..63dbb7fb1 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1658293185077751500.sql @@ -0,0 +1,5 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id` = 25371 AND `ScriptName` = 'spell_consume_aq20'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (25371, 'spell_consume_aq20'); +DELETE FROM `spell_script_names` WHERE `spell_id` = 25373 AND `ScriptName` = 'spell_gen_10pct_count_pct_from_max_hp'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (25373, 'spell_gen_10pct_count_pct_from_max_hp'); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 51d16c953..9b4af72b0 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -4472,6 +4472,55 @@ class spell_gen_remove_impairing_auras : public SpellScript } }; +enum AQSpells +{ + SPELL_CONSUME_LEECH_AQ20 = 25373, + SPELL_CONSUME_LEECH_HEAL_AQ20 = 25378 +}; + +class spell_gen_consume : public AuraScript +{ + PrepareAuraScript(spell_gen_consume); + +public: + spell_gen_consume(uint32 spellId1, uint32 spellId2) : AuraScript(), _spellId1(spellId1), _spellId2(spellId2) { } + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ _spellId1, _spellId2 }); + } + + void HandleProc(AuraEffect* /*aurEff*/) + { + if (Unit* caster = GetCaster()) + { + caster->CastSpell(GetUnitOwner(), _spellId1, true); + } + } + + void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + // Final heal only on duration end + if (GetTargetApplication() && GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_DEATH) + { + if (Unit* caster = GetCaster()) + { + caster->CastSpell(caster, _spellId2, true); + } + } + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_consume::AfterRemove, EFFECT_1, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_consume::HandleProc, EFFECT_2, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + +private: + uint32 _spellId1; + uint32 _spellId2; +}; + void AddSC_generic_spell_scripts() { RegisterSpellScript(spell_silithyst); @@ -4569,6 +4618,7 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_teleporting); RegisterSpellScript(spell_gen_ds_flush_knockback); RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_default_count_pct_from_max_hp"); + RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_10pct_count_pct_from_max_hp", 10); RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_50pct_count_pct_from_max_hp", 50); RegisterSpellScriptWithArgs(spell_gen_count_pct_from_max_hp, "spell_gen_100pct_count_pct_from_max_hp", 100); RegisterSpellScript(spell_gen_despawn_self); @@ -4605,4 +4655,5 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_holiday_buff_food); RegisterSpellScript(spell_gen_arcane_charge); RegisterSpellScript(spell_gen_remove_impairing_auras); + RegisterSpellScriptWithArgs(spell_gen_consume, "spell_consume_aq20", SPELL_CONSUME_LEECH_AQ20, SPELL_CONSUME_LEECH_HEAL_AQ20); }