[9894] Move GetCastingTimeForBonus and some other code to GetSpellCastTimeForBonus.

Important changes:

* Chaged way caluclation "-5% of total per any additional effect" to percent
  apply instead use raw value that correct only for 3500 cast time spells.
* GetSpellCastTimeForBonus result now alwasy not applied to creature casted spells
  Before it not applied only to instant spells. Please test if this ok in all cases.
* Leech effect modify spell casting time move into GetCastingTimeForBonus and then called
  also for melee spells. But only creature spells exist with melee class damage and its
  not affected by GetCastingTimeForBonus anyway now.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
nos4r2zod 2010-05-15 05:23:51 +04:00 committed by VladimirMangos
parent 34a1cc31d0
commit 4951f846dd
5 changed files with 157 additions and 153 deletions

View file

@ -95,6 +95,107 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell)
return (castTime > 0) ? uint32(castTime) : 0;
}
uint32 GetSpellCastTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype )
{
uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto);
if (CastingTime > 7000) CastingTime = 7000;
if (CastingTime < 1500) CastingTime = 1500;
if(damagetype == DOT && !IsChanneledSpell(spellProto))
CastingTime = 3500;
int32 overTime = 0;
uint8 effects = 0;
bool DirectDamage = false;
bool AreaEffect = false;
for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
if (IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i])))
AreaEffect = true;
for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
switch (spellProto->Effect[i])
{
case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_POWER_DRAIN:
case SPELL_EFFECT_HEALTH_LEECH:
case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE:
case SPELL_EFFECT_POWER_BURN:
case SPELL_EFFECT_HEAL:
DirectDamage = true;
break;
case SPELL_EFFECT_APPLY_AURA:
switch (spellProto->EffectApplyAuraName[i])
{
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_LEECH:
if ( GetSpellDuration(spellProto) )
overTime = GetSpellDuration(spellProto);
break;
// Penalty for additional effects
case SPELL_AURA_DUMMY:
++effects;
break;
case SPELL_AURA_MOD_DECREASE_SPEED:
++effects;
break;
case SPELL_AURA_MOD_CONFUSE:
case SPELL_AURA_MOD_STUN:
case SPELL_AURA_MOD_ROOT:
// -10% per effect
effects += 2;
break;
default:
break;
}
default:
break;
}
}
// Combined Spells with Both Over Time and Direct Damage
if (overTime > 0 && CastingTime > 0 && DirectDamage)
{
// mainly for DoTs which are 3500 here otherwise
uint32 OriginalCastTime = GetSpellCastTime(spellProto);
if (OriginalCastTime > 7000) OriginalCastTime = 7000;
if (OriginalCastTime < 1500) OriginalCastTime = 1500;
// Portion to Over Time
float PtOT = (overTime / 15000.0f) / ((overTime / 15000.0f) + (OriginalCastTime / 3500.0f));
if (damagetype == DOT)
CastingTime = uint32(CastingTime * PtOT);
else if (PtOT < 1.0f)
CastingTime = uint32(CastingTime * (1 - PtOT));
else
CastingTime = 0;
}
// Area Effect Spells receive only half of bonus
if (AreaEffect)
CastingTime /= 2;
// 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
{
if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ||
spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)
{
CastingTime /= 2;
break;
}
}
// -5% of total per any additional effect (multiplicative)
for (int i = 0; i < effects; ++i)
CastingTime *= 0.95f;
return CastingTime;
}
uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo)
{
int32 DotDuration = GetSpellDuration(spellInfo);