Core/Auras: Use recalculated aura max duration on spell hit for duration calculations.
This commit is contained in:
@@ -3113,7 +3113,10 @@ void Unit::DeMorph()
|
||||
|
||||
Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
|
||||
{
|
||||
ASSERT(casterGUID);
|
||||
ASSERT(casterGUID || caster);
|
||||
if (!casterGUID)
|
||||
casterGUID = caster->GetGUID();
|
||||
|
||||
// passive and Incanter's Absorption and auras with different type can stack with themselves any number of times
|
||||
if (!IsPassiveSpell(newAura) && newAura->Id != 44413)
|
||||
{
|
||||
|
||||
@@ -334,24 +334,13 @@ m_isRemoved(false), m_isSingleTarget(false)
|
||||
if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
|
||||
m_timeCla = 1 * IN_MILLISECONDS;
|
||||
|
||||
Player* modOwner = NULL;
|
||||
|
||||
if (caster)
|
||||
{
|
||||
modOwner = caster->GetSpellModOwner();
|
||||
m_maxDuration = caster->CalcSpellDuration(m_spellProto);
|
||||
}
|
||||
else
|
||||
m_maxDuration = GetSpellDuration(m_spellProto);
|
||||
|
||||
if (IsPassive() && m_spellProto->DurationIndex == 0)
|
||||
m_maxDuration = -1;
|
||||
|
||||
if (!IsPermanent() && modOwner)
|
||||
modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxDuration);
|
||||
|
||||
m_maxDuration = CalcMaxDuration(caster);
|
||||
m_duration = m_maxDuration;
|
||||
|
||||
Player* modOwner = NULL;
|
||||
if (caster)
|
||||
modOwner = caster->GetSpellModOwner();
|
||||
|
||||
m_procCharges = m_spellProto->procCharges;
|
||||
if (modOwner)
|
||||
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
|
||||
@@ -700,6 +689,27 @@ void Aura::Update(uint32 diff, Unit * caster)
|
||||
}
|
||||
}
|
||||
|
||||
int32 Aura::CalcMaxDuration(Unit* caster) const
|
||||
{
|
||||
Player* modOwner = NULL;
|
||||
int32 maxDuration;
|
||||
|
||||
if (caster)
|
||||
{
|
||||
modOwner = caster->GetSpellModOwner();
|
||||
maxDuration = caster->CalcSpellDuration(m_spellProto);
|
||||
}
|
||||
else
|
||||
maxDuration = GetSpellDuration(m_spellProto);
|
||||
|
||||
if (IsPassive() && m_spellProto->DurationIndex == 0)
|
||||
maxDuration = -1;
|
||||
|
||||
if (!IsPermanent() && modOwner)
|
||||
modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
|
||||
return maxDuration;
|
||||
}
|
||||
|
||||
void Aura::SetDuration(int32 duration, bool withMods)
|
||||
{
|
||||
if (withMods)
|
||||
|
||||
@@ -121,6 +121,8 @@ class Aura
|
||||
time_t GetApplyTime() const { return m_applyTime; }
|
||||
int32 GetMaxDuration() const { return m_maxDuration; }
|
||||
void SetMaxDuration(int32 duration) { m_maxDuration = duration; }
|
||||
int32 CalcMaxDuration() const { return CalcMaxDuration(GetCaster()); }
|
||||
int32 CalcMaxDuration(Unit * caster) const;
|
||||
int32 GetDuration() const { return m_duration; }
|
||||
void SetDuration(int32 duration, bool withMods = false);
|
||||
void RefreshDuration();
|
||||
|
||||
@@ -1427,8 +1427,9 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
|
||||
if (m_originalCaster)
|
||||
{
|
||||
bool refresh;
|
||||
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
|
||||
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem);
|
||||
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, 0, &refresh);
|
||||
if (m_spellAura)
|
||||
{
|
||||
// Set aura stack amount to desired value
|
||||
@@ -1436,7 +1437,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
m_spellAura->SetStackAmount(m_spellValue->AuraStackAmount);
|
||||
|
||||
// Now Reduce spell duration using data received at spell hit
|
||||
int32 duration = m_spellAura->GetMaxDuration();
|
||||
// if we're refreshing aura, recalculate max duration, to avoid applying mods twice
|
||||
int32 duration = refresh ? m_spellAura->CalcMaxDuration() : m_spellAura->GetMaxDuration();
|
||||
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup, aurSpellInfo);
|
||||
float diminishMod = unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel, limitduration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user