aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <qaston@gmail.com>2011-06-07 14:19:47 +0200
committerQAston <qaston@gmail.com>2011-06-07 14:19:47 +0200
commit9542077c38e98b9b7efa7f832b1f7ff13ee33560 (patch)
treed9988701183ac8f140b3151b34839d6fdac0be87 /src
parent3effdb2c23b9690e53376e9fcb77d48ebd91780e (diff)
Core/Auras: Use recalculated aura max duration on spell hit for duration calculations.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp5
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.cpp38
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.h2
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp6
4 files changed, 34 insertions, 17 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 9347c8ddf04..04b285ef334 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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)
{
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 9ca8cd3ffa4..592eb08a1c9 100755
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -334,23 +334,12 @@ m_isRemoved(false), m_isSingleTarget(false)
if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
m_timeCla = 1 * IN_MILLISECONDS;
- Player* modOwner = NULL;
+ m_maxDuration = CalcMaxDuration(caster);
+ m_duration = m_maxDuration;
+ 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_duration = m_maxDuration;
m_procCharges = m_spellProto->procCharges;
if (modOwner)
@@ -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)
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index d022fc3d85f..67f4eb30b27 100755
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -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();
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index b8bd908cd65..5b8d4cd42a6 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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);