Core/Spells: Fixed cast time calculation in many places

This commit is contained in:
Shauren
2013-08-15 19:04:09 +02:00
parent 2849526137
commit 7aff234ada
5 changed files with 13 additions and 11 deletions

View File

@@ -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;