diff options
author | Shauren <shauren.trinity@gmail.com> | 2013-08-15 19:04:09 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2013-08-15 19:04:09 +0200 |
commit | 7aff234ada2a64f07d10fe5fc9880bc2b3f647ec (patch) | |
tree | a65d3d239910bfa1e163335e488cf819979a87cd | |
parent | 284952613702e45ac3501fbf39c1275621499585 (diff) |
Core/Spells: Fixed cast time calculation in many places
-rw-r--r-- | src/server/game/Entities/Totem/Totem.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.h | 2 |
5 files changed, 13 insertions, 11 deletions
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 9784f6194ee..907a6fa725f 100644 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -74,7 +74,7 @@ void Totem::InitStats(uint32 duration) // Get spell cast by totem if (SpellInfo const* totemSpell = sSpellMgr->GetSpellInfo(GetSpell())) - if (totemSpell->CalcCastTime()) // If spell has cast time -> its an active totem + if (totemSpell->CalcCastTime(getLevel())) // If spell has cast time -> its an active totem m_type = TOTEM_ACTIVE; m_duration = duration; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4f98312f3d0..67417ca809b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12438,7 +12438,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u } case SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK: // Skip melee hits or instant cast spells - if (procSpell && procSpell->CalcCastTime() != 0) + if (procSpell && procSpell->CalcCastTime(getLevel()) > 0) takeCharges = true; break; case SPELL_AURA_REFLECT_SPELLS_SCHOOL: @@ -12956,7 +12956,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectTyp if (overTime > 0 && CastingTime > 0 && DirectDamage) { // mainly for DoTs which are 3500 here otherwise - uint32 OriginalCastTime = spellProto->CalcCastTime(); + uint32 OriginalCastTime = spellProto->CalcCastTime(getLevel()); if (OriginalCastTime > 7000) OriginalCastTime = 7000; if (OriginalCastTime < 1500) OriginalCastTime = 1500; // Portion to Over Time @@ -13045,7 +13045,7 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffect DotFactor /= DotTicks; } - int32 CastingTime = spellInfo->IsChanneled() ? spellInfo->GetDuration() : spellInfo->CalcCastTime(); + int32 CastingTime = spellInfo->IsChanneled() ? spellInfo->GetDuration() : spellInfo->CalcCastTime(getLevel()); // Distribute Damage over multiple effects, reduce by AoE CastingTime = GetCastingTimeForBonus(spellInfo, damagetype, CastingTime); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 965bbfd7a4c..ef30e99dcfc 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3057,14 +3057,14 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered { m_caster->ToPlayer()->SetSpellModTakingSpell(this, true); // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail) - m_casttime = m_spellInfo->CalcCastTime(m_caster, this); + m_casttime = m_spellInfo->CalcCastTime(m_caster->getLevel(), this); m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); } else m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled. } else - m_casttime = m_spellInfo->CalcCastTime(m_caster, this); + m_casttime = m_spellInfo->CalcCastTime(m_caster->getLevel(), this); // don't allow channeled spells / spells with cast time to be casted while moving // (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index e0b4355a37f..4254be1c968 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -2238,16 +2238,18 @@ int32 SpellInfo::GetMaxDuration() const return (DurationEntry->Duration[2] == -1) ? -1 : abs(DurationEntry->Duration[2]); } -uint32 SpellInfo::CalcCastTime(Unit* caster /*= NULL*/, Spell* spell /*= NULL*/) const +uint32 SpellInfo::CalcCastTime(uint8 level, Spell* spell /*= NULL*/) const { int32 castTime = 0; + if (!level && spell) + level = spell->GetCaster()->getLevel(); // not all spells have cast time index and this is all is pasiive abilities - if (caster && CastTimeMax > 0) + if (level && CastTimeMax > 0) { castTime = CastTimeMax; - if (CastTimeMaxLevel > int32(caster->getLevel())) - castTime = CastTimeMin + int32(caster->getLevel() - 1) * (CastTimeMax - CastTimeMin) / (CastTimeMaxLevel - 1); + if (CastTimeMaxLevel > level) + castTime = CastTimeMin + int32(level - 1) * (CastTimeMax - CastTimeMin) / (CastTimeMaxLevel - 1); } else if (CastTimeEntry) castTime = CastTimeEntry->CastTime; diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 0ee8571196f..a7021dbabcc 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -495,7 +495,7 @@ public: uint32 GetMaxTicks() const; - uint32 CalcCastTime(Unit* caster = NULL, Spell* spell = NULL) const; + uint32 CalcCastTime(uint8 level = 0, Spell* spell = NULL) const; uint32 GetRecoveryTime() const; int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const; |