From fd786c03a369b60bd29773e19f4213fd2e01624b Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 14 Dec 2017 12:43:32 -0300 Subject: Core/Auras: periodics refactor part 2: Move UpdatePeriodic to AuraScripts (cherry picked from commit 0510bf7afe9fa5ded572cda00f5a5a989a887146) --- src/server/scripts/Spells/spell_generic.cpp | 114 ++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'src/server/scripts/Spells') diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 496c7da3676..d1f1e6c7e18 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -201,6 +201,96 @@ class spell_gen_animal_blood : public AuraScript } }; +// 430 Drink +// 431 Drink +// 432 Drink +// 1133 Drink +// 1135 Drink +// 1137 Drink +// 10250 Drink +// 22734 Drink +// 27089 Drink +// 34291 Drink +// 43182 Drink +// 43183 Drink +// 46755 Drink +// 49472 Drink Coffee +// 57073 Drink +// 61830 Drink +// 72623 Drink +class spell_gen_arena_drink : public AuraScript +{ + PrepareAuraScript(spell_gen_arena_drink); + + bool Load() override + { + return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + void CalcPeriodic(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) + { + // Get SPELL_AURA_MOD_POWER_REGEN aura from spell + AuraEffect* regen = GetAura()->GetEffect(EFFECT_0); + if (!regen) + return; + + if (regen->GetAuraType() != SPELL_AURA_MOD_POWER_REGEN) + { + isPeriodic = false; + TC_LOG_ERROR("spells", "Aura %d structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN", GetId()); + } + else + { + // default case - not in arena + if (!GetCaster()->ToPlayer()->InArena()) + { + regen->ChangeAmount(aurEff->GetAmount()); + isPeriodic = false; + } + } + } + + void UpdatePeriodic(AuraEffect* aurEff) + { + AuraEffect* regen = GetAura()->GetEffect(EFFECT_0); + if (!regen) + return; + + // ********************************************** + // This feature used only in arenas + // ********************************************** + // Here need increase mana regen per tick (6 second rule) + // on 0 tick - 0 (handled in 2 second) + // on 1 tick - 166% (handled in 4 second) + // on 2 tick - 133% (handled in 6 second) + + // Apply bonus for 1 - 4 tick + switch (aurEff->GetTickNumber()) + { + case 1: // 0% + regen->ChangeAmount(0); + break; + case 2: // 166% + regen->ChangeAmount(aurEff->GetAmount() * 5 / 3); + break; + case 3: // 133% + regen->ChangeAmount(aurEff->GetAmount() * 4 / 3); + break; + default: // 100% - normal regen + regen->ChangeAmount(aurEff->GetAmount()); + // No need to update after 4th tick + aurEff->SetPeriodic(false); + break; + } + } + + void Register() override + { + DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_gen_arena_drink::CalcPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_arena_drink::UpdatePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + } +}; + // 41337 Aura of Anger class spell_gen_aura_of_anger : public AuraScript { @@ -610,6 +700,28 @@ class spell_gen_cannibalize : public SpellScript } }; +// 66020 Chains of Ice +class spell_gen_chains_of_ice : public AuraScript +{ + PrepareAuraScript(spell_gen_chains_of_ice); + + void UpdatePeriodic(AuraEffect* aurEff) + { + // Get 0 effect aura + AuraEffect* slow = GetAura()->GetEffect(EFFECT_0); + if (!slow) + return; + + int32 newAmount = std::min(slow->GetAmount() + aurEff->GetAmount(), 0); + slow->ChangeAmount(newAmount); + } + + void Register() override + { + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_chains_of_ice::UpdatePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + } +}; + enum ChaosBlast { SPELL_CHAOS_BLAST = 37675 @@ -3584,6 +3696,7 @@ void AddSC_generic_spell_scripts() RegisterAuraScript(spell_gen_adaptive_warding); RegisterSpellScript(spell_gen_allow_cast_from_item_only); RegisterAuraScript(spell_gen_animal_blood); + RegisterAuraScript(spell_gen_arena_drink); RegisterAuraScript(spell_gen_aura_of_anger); RegisterAuraScript(spell_gen_aura_service_uniform); RegisterAuraScript(spell_gen_av_drekthar_presence); @@ -3595,6 +3708,7 @@ void AddSC_generic_spell_scripts() RegisterAuraScript(spell_gen_burn_brutallus); RegisterAuraScript(spell_gen_burning_depths_necrolyte_image); RegisterSpellScript(spell_gen_cannibalize); + RegisterAuraScript(spell_gen_chains_of_ice); RegisterSpellScript(spell_gen_chaos_blast); RegisterSpellScript(spell_gen_clone); RegisterSpellScript(spell_gen_clone_weapon); -- cgit v1.2.3