[9895] Move DotFactor+GetSpellCastTimeForBonus call to CalculateDefaultCoefficient

* This coeff used if not spell_bonus_data provided for spell
* Continue prev. commit line expected that creature casts not affected by DotFactor

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
nos4r2zod 2010-05-15 06:03:16 +04:00 committed by VladimirMangos
parent 4951f846dd
commit e880e7d236
4 changed files with 33 additions and 79 deletions

View file

@ -222,6 +222,25 @@ uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo)
return 6; return 6;
} }
float CalculateDefaultCoefficient(SpellEntry const *spellProto, DamageEffectType const damagetype)
{
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if (damagetype == DOT)
{
if (!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
if (uint16 DotTicks = GetSpellAuraMaxTicks(spellProto))
DotFactor /= DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE
float coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f;
return coeff * DotFactor;
}
WeaponAttackType GetWeaponAttackType(SpellEntry const *spellInfo) WeaponAttackType GetWeaponAttackType(SpellEntry const *spellInfo)
{ {
if(!spellInfo) if(!spellInfo)

View file

@ -111,6 +111,7 @@ SpellSpecific GetSpellSpecific(uint32 spellId);
inline float GetSpellRadius(SpellRadiusEntry const *radius) { return (radius ? radius->Radius : 0); } inline float GetSpellRadius(SpellRadiusEntry const *radius) { return (radius ? radius->Radius : 0); }
uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL); uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL);
uint32 GetSpellCastTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype ); uint32 GetSpellCastTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype );
float CalculateDefaultCoefficient(SpellEntry const *spellProto, DamageEffectType const damagetype);
inline float GetSpellMinRange(SpellRangeEntry const *range, bool friendly = false) inline float GetSpellMinRange(SpellRangeEntry const *range, bool friendly = false)
{ {
if(!range) if(!range)

View file

@ -9177,26 +9177,15 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u
// Default calculation // Default calculation
else if (DoneAdvertisedBenefit) else if (DoneAdvertisedBenefit)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if (damagetype == DOT)
{
if (!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
if (uint16 DotTicks = GetSpellAuraMaxTicks(spellProto))
DoneAdvertisedBenefit = DoneAdvertisedBenefit / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
DoneTotal += int32(DoneAdvertisedBenefit * coeff * DotFactor * LvlPenalty * SpellModSpellDamage); DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage);
} }
float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod; float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod;
@ -9279,26 +9268,15 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto,
// Default calculation // Default calculation
else if (TakenAdvertisedBenefit) else if (TakenAdvertisedBenefit)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if (damagetype == DOT)
{
if (!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
if (uint16 DotTicks = GetSpellAuraMaxTicks(spellProto))
TakenAdvertisedBenefit = TakenAdvertisedBenefit / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet()) if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
TakenTotal+= int32(TakenAdvertisedBenefit * coeff * DotFactor * LvlPenalty); TakenTotal+= int32(TakenAdvertisedBenefit * coeff * LvlPenalty);
} }
float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod; float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod;
@ -9724,26 +9702,15 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto,
// Default calculation // Default calculation
else if (DoneAdvertisedBenefit) else if (DoneAdvertisedBenefit)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if(damagetype == DOT)
{
if(!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
uint16 DotTicks = GetSpellAuraMaxTicks(spellProto);
if(DotTicks)
DoneAdvertisedBenefit = DoneAdvertisedBenefit / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
DoneTotal += int32(DoneAdvertisedBenefit * coeff * DotFactor * LvlPenalty * SpellModSpellDamage * 1.88f); DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage * 1.88f);
} }
// use float as more appropriate for negative values and percent applying // use float as more appropriate for negative values and percent applying
@ -9803,26 +9770,15 @@ uint32 Unit::SpellHealingBonusTaken(Unit *pCaster, SpellEntry const *spellProto,
// Default calculation // Default calculation
else if (TakenAdvertisedBenefit) else if (TakenAdvertisedBenefit)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if(damagetype == DOT)
{
if(!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
uint16 DotTicks = GetSpellAuraMaxTicks(spellProto);
if(DotTicks)
TakenAdvertisedBenefit = TakenAdvertisedBenefit / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
TakenTotal += int32(TakenAdvertisedBenefit * coeff * DotFactor * LvlPenalty * 1.88f); TakenTotal += int32(TakenAdvertisedBenefit * coeff * LvlPenalty * 1.88f);
} }
AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED); AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED);
@ -10221,26 +10177,15 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType
// Default calculation // Default calculation
else if (DoneFlat) else if (DoneFlat)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if(damagetype == DOT)
{
if(!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
uint16 DotTicks = GetSpellAuraMaxTicks(spellProto);
if(DotTicks)
DoneFlat = DoneFlat / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
DoneFlat *= coeff * DotFactor * LvlPenalty; DoneFlat *= coeff * LvlPenalty;
} }
} }
// weapon damage based spells // weapon damage based spells
@ -10381,26 +10326,15 @@ uint32 Unit::MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackTyp
// Default calculation // Default calculation
else if (TakenFlat) else if (TakenFlat)
{ {
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
if(damagetype == DOT)
{
if(!IsChanneledSpell(spellProto))
DotFactor = GetSpellDuration(spellProto) / 15000.0f;
uint16 DotTicks = GetSpellAuraMaxTicks(spellProto);
if(DotTicks)
TakenFlat = TakenFlat / DotTicks;
}
// Distribute Damage over multiple effects, reduce by AoE // Distribute Damage over multiple effects, reduce by AoE
// Not apply this to creature casted spells // Not apply this to creature casted spells
float coeff; float coeff;
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet()) if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
coeff = 1.0f; coeff = 1.0f;
else else
coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; coeff = CalculateDefaultCoefficient(spellProto, damagetype);
TakenFlat*= coeff * DotFactor * LvlPenalty; TakenFlat*= coeff * LvlPenalty;
} }
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9894" #define REVISION_NR "9895"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__