Core/Auras:
Make Aura::ModStackAmount(1) an equivalent of reapplying the aura
Recalculate periodic aura timers on aura reapply.
This commit is contained in:
@@ -3158,9 +3158,6 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint
|
|||||||
*oldGUID = castItemGUID;
|
*oldGUID = castItemGUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh charges
|
|
||||||
foundAura->SetCharges(foundAura->CalcMaxCharges(caster));
|
|
||||||
|
|
||||||
// try to increase stack amount
|
// try to increase stack amount
|
||||||
foundAura->ModStackAmount(1);
|
foundAura->ModStackAmount(1);
|
||||||
return foundAura;
|
return foundAura;
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ m_baseAmount(baseAmount ? *baseAmount : m_spellProto->EffectBasePoints[m_effInde
|
|||||||
m_canBeRecalculated(true), m_spellmod(NULL), m_isPeriodic(false),
|
m_canBeRecalculated(true), m_spellmod(NULL), m_isPeriodic(false),
|
||||||
m_periodicTimer(0), m_tickNumber(0)
|
m_periodicTimer(0), m_tickNumber(0)
|
||||||
{
|
{
|
||||||
CalculatePeriodic(caster, true);
|
CalculatePeriodic(caster, true, false);
|
||||||
|
|
||||||
m_amount = CalculateAmount(caster);
|
m_amount = CalculateAmount(caster);
|
||||||
|
|
||||||
@@ -766,7 +766,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuraEffect::CalculatePeriodic(Unit * caster, bool create)
|
void AuraEffect::CalculatePeriodic(Unit * caster, bool create, bool load)
|
||||||
{
|
{
|
||||||
m_amplitude = m_spellProto->EffectAmplitude[m_effIndex];
|
m_amplitude = m_spellProto->EffectAmplitude[m_effIndex];
|
||||||
|
|
||||||
@@ -790,9 +790,7 @@ void AuraEffect::CalculatePeriodic(Unit * caster, bool create)
|
|||||||
break;
|
break;
|
||||||
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
|
case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
|
||||||
if (GetId() == 51912)
|
if (GetId() == 51912)
|
||||||
{
|
|
||||||
m_amplitude = 3000;
|
m_amplitude = 3000;
|
||||||
}
|
|
||||||
m_isPeriodic = true;
|
m_isPeriodic = true;
|
||||||
break;
|
break;
|
||||||
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
|
case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
|
||||||
@@ -840,19 +838,30 @@ void AuraEffect::CalculatePeriodic(Unit * caster, bool create)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create)
|
if (load) // aura loaded from db
|
||||||
{
|
{
|
||||||
// Start periodic on next tick or at aura apply
|
m_tickNumber = m_amplitude ? GetBase()->GetDuration() / m_amplitude : 0;
|
||||||
if (m_amplitude && !(m_spellProto->AttributesEx5 & SPELL_ATTR5_START_PERIODIC_AT_APPLY))
|
m_periodicTimer = m_amplitude ? GetBase()->GetDuration() % m_amplitude : 0;
|
||||||
m_periodicTimer += m_amplitude;
|
|
||||||
}
|
|
||||||
else if (m_amplitude) // load aura from character_aura
|
|
||||||
{
|
|
||||||
m_tickNumber = GetBase()->GetDuration() / m_amplitude;
|
|
||||||
m_periodicTimer = GetBase()->GetDuration() % m_amplitude;
|
|
||||||
if (m_spellProto->AttributesEx5 & SPELL_ATTR5_START_PERIODIC_AT_APPLY)
|
if (m_spellProto->AttributesEx5 & SPELL_ATTR5_START_PERIODIC_AT_APPLY)
|
||||||
++m_tickNumber;
|
++m_tickNumber;
|
||||||
}
|
}
|
||||||
|
else // aura just created or reapplied
|
||||||
|
{
|
||||||
|
m_tickNumber = 0;
|
||||||
|
// reset periodic timer on aura create or on reapply when aura isn't dot
|
||||||
|
// possibly we should not reset periodic timers only when aura is triggered by proc
|
||||||
|
// or maybe there's a spell attribute somewhere
|
||||||
|
bool resetPeriodicTimer = create
|
||||||
|
|| ((GetAuraType() != SPELL_AURA_PERIODIC_DAMAGE) && (GetAuraType() != SPELL_AURA_PERIODIC_DAMAGE_PERCENT));
|
||||||
|
|
||||||
|
if (resetPeriodicTimer)
|
||||||
|
{
|
||||||
|
m_periodicTimer = 0;
|
||||||
|
// Start periodic on next tick or at aura apply
|
||||||
|
if (m_amplitude && !(m_spellProto->AttributesEx5 & SPELL_ATTR5_START_PERIODIC_AT_APPLY))
|
||||||
|
m_periodicTimer += m_amplitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuraEffect::CalculateSpellMod()
|
void AuraEffect::CalculateSpellMod()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class AuraEffect
|
|||||||
void SetPeriodicTimer(int32 periodicTimer) { m_periodicTimer = periodicTimer; }
|
void SetPeriodicTimer(int32 periodicTimer) { m_periodicTimer = periodicTimer; }
|
||||||
|
|
||||||
int32 CalculateAmount(Unit * caster);
|
int32 CalculateAmount(Unit * caster);
|
||||||
void CalculatePeriodic(Unit * caster, bool create = false);
|
void CalculatePeriodic(Unit * caster, bool create = false, bool load = false);
|
||||||
void CalculateSpellMod();
|
void CalculateSpellMod();
|
||||||
void ChangeAmount(int32 newAmount, bool mark = true, bool onStackOrReapply = false);
|
void ChangeAmount(int32 newAmount, bool mark = true, bool onStackOrReapply = false);
|
||||||
void RecalculateAmount() { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(GetCaster()), false); }
|
void RecalculateAmount() { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(GetCaster()), false); }
|
||||||
|
|||||||
@@ -726,6 +726,16 @@ void Aura::RefreshDuration()
|
|||||||
m_timeCla = 1 * IN_MILLISECONDS;
|
m_timeCla = 1 * IN_MILLISECONDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Aura::RefreshTimers()
|
||||||
|
{
|
||||||
|
m_maxDuration = CalcMaxDuration();
|
||||||
|
RefreshDuration();
|
||||||
|
Unit * caster = GetCaster();
|
||||||
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
|
if (HasEffect(i))
|
||||||
|
GetEffect(i)->CalculatePeriodic(caster, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
void Aura::SetCharges(uint8 charges)
|
void Aura::SetCharges(uint8 charges)
|
||||||
{
|
{
|
||||||
if (m_procCharges == charges)
|
if (m_procCharges == charges)
|
||||||
@@ -802,7 +812,12 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode)
|
|||||||
SetStackAmount(stackAmount);
|
SetStackAmount(stackAmount);
|
||||||
|
|
||||||
if (refresh)
|
if (refresh)
|
||||||
RefreshDuration();
|
{
|
||||||
|
RefreshTimers();
|
||||||
|
|
||||||
|
// reset charges
|
||||||
|
SetCharges(CalcMaxCharges());
|
||||||
|
}
|
||||||
SetNeedClientUpdateForTargets();
|
SetNeedClientUpdateForTargets();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -871,7 +886,7 @@ void Aura::SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint
|
|||||||
{
|
{
|
||||||
m_effects[i]->SetAmount(amount[i]);
|
m_effects[i]->SetAmount(amount[i]);
|
||||||
m_effects[i]->SetCanBeRecalculated(recalculateMask & (1<<i));
|
m_effects[i]->SetCanBeRecalculated(recalculateMask & (1<<i));
|
||||||
m_effects[i]->CalculatePeriodic(caster);
|
m_effects[i]->CalculatePeriodic(caster, false, true);
|
||||||
m_effects[i]->CalculateSpellMod();
|
m_effects[i]->CalculateSpellMod();
|
||||||
m_effects[i]->RecalculateAmount(caster);
|
m_effects[i]->RecalculateAmount(caster);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ class Aura
|
|||||||
int32 GetDuration() const { return m_duration; }
|
int32 GetDuration() const { return m_duration; }
|
||||||
void SetDuration(int32 duration, bool withMods = false);
|
void SetDuration(int32 duration, bool withMods = false);
|
||||||
void RefreshDuration();
|
void RefreshDuration();
|
||||||
|
void RefreshTimers();
|
||||||
bool IsExpired() const { return !GetDuration();}
|
bool IsExpired() const { return !GetDuration();}
|
||||||
bool IsPermanent() const { return GetMaxDuration() == -1; }
|
bool IsPermanent() const { return GetMaxDuration() == -1; }
|
||||||
|
|
||||||
|
|||||||
@@ -1427,9 +1427,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
|||||||
|
|
||||||
if (m_originalCaster)
|
if (m_originalCaster)
|
||||||
{
|
{
|
||||||
bool refresh;
|
|
||||||
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
|
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
|
||||||
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, 0, &refresh);
|
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem);
|
||||||
if (m_spellAura)
|
if (m_spellAura)
|
||||||
{
|
{
|
||||||
// Set aura stack amount to desired value
|
// Set aura stack amount to desired value
|
||||||
@@ -1437,8 +1436,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
|||||||
m_spellAura->SetStackAmount(m_spellValue->AuraStackAmount);
|
m_spellAura->SetStackAmount(m_spellValue->AuraStackAmount);
|
||||||
|
|
||||||
// Now Reduce spell duration using data received at spell hit
|
// Now Reduce spell duration using data received at spell hit
|
||||||
// if we're refreshing aura, recalculate max duration, to avoid applying mods twice
|
int32 duration = m_spellAura->GetMaxDuration();
|
||||||
int32 duration = refresh ? m_spellAura->CalcMaxDuration() : m_spellAura->GetMaxDuration();
|
|
||||||
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup, aurSpellInfo);
|
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup, aurSpellInfo);
|
||||||
float diminishMod = unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel, limitduration);
|
float diminishMod = unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel, limitduration);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user