mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Core/Auras: periodics refactor part 2: Move UpdatePeriodic to AuraScripts
(cherry picked from commit 0510bf7afe)
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "ScriptedCreature.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "ScriptSystem.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellScript.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WorldSession.h"
|
||||
@@ -579,6 +580,23 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// 58549 Tenacity
|
||||
// 59911 Tenacity
|
||||
class spell_wintergrasp_tenacity_refresh : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_wintergrasp_tenacity_refresh);
|
||||
|
||||
void Refresh(AuraEffect* /*aurEff*/)
|
||||
{
|
||||
GetAura()->RefreshDuration();
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_wintergrasp_tenacity_refresh::Refresh, EFFECT_2, SPELL_AURA_PERIODIC_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
class condition_is_wintergrasp_horde : public ConditionScript
|
||||
{
|
||||
public:
|
||||
@@ -619,6 +637,7 @@ void AddSC_wintergrasp()
|
||||
new achievement_wg_didnt_stand_a_chance();
|
||||
new spell_wintergrasp_defender_teleport();
|
||||
new spell_wintergrasp_defender_teleport_trigger();
|
||||
RegisterAuraScript(spell_wintergrasp_tenacity_refresh);
|
||||
new condition_is_wintergrasp_horde();
|
||||
new condition_is_wintergrasp_alliance();
|
||||
}
|
||||
|
||||
@@ -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<int32>(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);
|
||||
|
||||
Reference in New Issue
Block a user