mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[9896] Cleanup spell bonus coeff use code
* Avoid coeff calculation if target value is 0.0f * Avoid use spell_bonus_data coeffs for creature damage. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
e880e7d236
commit
b2b8ca1d70
2 changed files with 81 additions and 119 deletions
|
|
@ -9153,39 +9153,35 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u
|
||||||
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
|
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
|
||||||
DoneAdvertisedBenefit += ((Pet*)this)->GetBonusDamage();
|
DoneAdvertisedBenefit += ((Pet*)this)->GetBonusDamage();
|
||||||
|
|
||||||
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
if (DoneAdvertisedBenefit)
|
||||||
// Spellmod SpellDamage
|
|
||||||
float SpellModSpellDamage = 100.0f;
|
|
||||||
if(Player* modOwner = GetSpellModOwner())
|
|
||||||
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage);
|
|
||||||
SpellModSpellDamage /= 100.0f;
|
|
||||||
|
|
||||||
// Check for table values
|
|
||||||
if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
|
||||||
{
|
{
|
||||||
float coeff;
|
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
if (bonus->ap_bonus)
|
// Spellmod SpellDamage
|
||||||
DoneTotal += int32(bonus->ap_bonus * GetTotalAttackPowerValue(BASE_ATTACK));
|
float SpellModSpellDamage = 100.0f;
|
||||||
|
if(Player* modOwner = GetSpellModOwner())
|
||||||
|
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage);
|
||||||
|
SpellModSpellDamage /= 100.0f;
|
||||||
|
|
||||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * SpellModSpellDamage);
|
|
||||||
}
|
|
||||||
// Default calculation
|
|
||||||
else if (DoneAdvertisedBenefit)
|
|
||||||
{
|
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
float coeff;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||||
coeff = 1.0f;
|
coeff = 1.0f;
|
||||||
|
// Check for table values
|
||||||
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
|
{
|
||||||
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
|
|
||||||
|
if (bonus->ap_bonus)
|
||||||
|
DoneTotal += int32(bonus->ap_bonus * GetTotalAttackPowerValue(BASE_ATTACK));
|
||||||
|
}
|
||||||
|
// Default calculation
|
||||||
else
|
else
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
||||||
|
|
||||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage);
|
DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod;
|
float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod;
|
||||||
|
|
@ -9252,31 +9248,24 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto,
|
||||||
// Taken fixed damage bonus auras
|
// Taken fixed damage bonus auras
|
||||||
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(GetSpellSchoolMask(spellProto));
|
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(GetSpellSchoolMask(spellProto));
|
||||||
|
|
||||||
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
if (TakenAdvertisedBenefit)
|
||||||
|
|
||||||
// Check for table values
|
|
||||||
if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
|
||||||
{
|
{
|
||||||
float coeff;
|
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
TakenTotal += int32(TakenAdvertisedBenefit * coeff);
|
|
||||||
}
|
|
||||||
// Default calculation
|
|
||||||
else if (TakenAdvertisedBenefit)
|
|
||||||
{
|
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
float coeff;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
|
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
|
||||||
coeff = 1.0f;
|
coeff = 1.0f;
|
||||||
else
|
// Check for table values
|
||||||
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
|
// Default calculation
|
||||||
|
else
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
||||||
|
|
||||||
TakenTotal+= int32(TakenAdvertisedBenefit * coeff * LvlPenalty);
|
TakenTotal += int32(TakenAdvertisedBenefit * coeff * LvlPenalty);
|
||||||
}
|
}
|
||||||
|
|
||||||
float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod;
|
float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod;
|
||||||
|
|
@ -9677,40 +9666,35 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto,
|
||||||
// Done fixed damage bonus auras
|
// Done fixed damage bonus auras
|
||||||
int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto));
|
int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto));
|
||||||
|
|
||||||
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
if (DoneAdvertisedBenefit)
|
||||||
// Spellmod SpellDamage
|
|
||||||
float SpellModSpellDamage = 100.0f;
|
|
||||||
if(Player* modOwner = GetSpellModOwner())
|
|
||||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, SpellModSpellDamage);
|
|
||||||
SpellModSpellDamage /= 100.0f;
|
|
||||||
|
|
||||||
// Check for table values
|
|
||||||
SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id);
|
|
||||||
if (bonus)
|
|
||||||
{
|
{
|
||||||
float coeff;
|
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
if (bonus->ap_bonus)
|
// Spellmod SpellDamage
|
||||||
DoneTotal += int32(bonus->ap_bonus * GetTotalAttackPowerValue(BASE_ATTACK));
|
float SpellModSpellDamage = 100.0f;
|
||||||
|
if(Player* modOwner = GetSpellModOwner())
|
||||||
|
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, SpellModSpellDamage);
|
||||||
|
SpellModSpellDamage /= 100.0f;
|
||||||
|
|
||||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * SpellModSpellDamage);
|
|
||||||
}
|
|
||||||
// Default calculation
|
|
||||||
else if (DoneAdvertisedBenefit)
|
|
||||||
{
|
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
float coeff;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||||
coeff = 1.0f;
|
coeff = 1.0f;
|
||||||
else
|
// Check for table values
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
|
{
|
||||||
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
|
|
||||||
DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage * 1.88f);
|
if (bonus->ap_bonus)
|
||||||
|
DoneTotal += int32(bonus->ap_bonus * GetTotalAttackPowerValue(BASE_ATTACK));
|
||||||
|
}
|
||||||
|
// Default calculation
|
||||||
|
else
|
||||||
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * 1.88f;
|
||||||
|
|
||||||
|
DoneTotal += int32(DoneAdvertisedBenefit * coeff * LvlPenalty * SpellModSpellDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use float as more appropriate for negative values and percent applying
|
// use float as more appropriate for negative values and percent applying
|
||||||
|
|
@ -9753,32 +9737,24 @@ uint32 Unit::SpellHealingBonusTaken(Unit *pCaster, SpellEntry const *spellProto,
|
||||||
// Taken fixed damage bonus auras
|
// Taken fixed damage bonus auras
|
||||||
int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(GetSpellSchoolMask(spellProto));
|
int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(GetSpellSchoolMask(spellProto));
|
||||||
|
|
||||||
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
if (TakenAdvertisedBenefit)
|
||||||
|
|
||||||
// Check for table values
|
|
||||||
SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id);
|
|
||||||
if (bonus)
|
|
||||||
{
|
{
|
||||||
float coeff;
|
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
TakenTotal += int32(TakenAdvertisedBenefit * coeff);
|
|
||||||
}
|
|
||||||
// Default calculation
|
|
||||||
else if (TakenAdvertisedBenefit)
|
|
||||||
{
|
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
float coeff;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||||
coeff = 1.0f;
|
coeff = 1.0f;
|
||||||
|
// Check for table values
|
||||||
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
|
// Default calculation
|
||||||
else
|
else
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype) * 1.88f;
|
||||||
|
|
||||||
TakenTotal += int32(TakenAdvertisedBenefit * coeff * LvlPenalty * 1.88f);
|
TakenTotal += int32(TakenAdvertisedBenefit * coeff * LvlPenalty);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED);
|
AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED);
|
||||||
|
|
@ -10160,33 +10136,25 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType
|
||||||
{
|
{
|
||||||
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
float LvlPenalty = CalculateLevelPenalty(spellProto);
|
||||||
|
|
||||||
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
|
float coeff = 0.0f;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
|
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
||||||
|
coeff = 1.0f;
|
||||||
// Check for table values
|
// Check for table values
|
||||||
if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
{
|
{
|
||||||
float coeff;
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
if (bonus->ap_bonus)
|
if (bonus->ap_bonus)
|
||||||
DoneFlat += bonus->ap_bonus * (GetTotalAttackPowerValue(BASE_ATTACK) + APbonus);
|
DoneFlat += bonus->ap_bonus * (GetTotalAttackPowerValue(BASE_ATTACK) + APbonus);
|
||||||
|
|
||||||
DoneFlat *= coeff;
|
|
||||||
}
|
}
|
||||||
// Default calculation
|
// Default calculation
|
||||||
else if (DoneFlat)
|
else if (DoneFlat)
|
||||||
{
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
|
||||||
if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
|
|
||||||
coeff = 1.0f;
|
|
||||||
else
|
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
|
||||||
|
|
||||||
DoneFlat *= coeff * LvlPenalty;
|
DoneFlat *= coeff * LvlPenalty;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// weapon damage based spells
|
// weapon damage based spells
|
||||||
else if( APbonus || DoneFlat )
|
else if( APbonus || DoneFlat )
|
||||||
|
|
@ -10310,31 +10278,25 @@ uint32 Unit::MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackTyp
|
||||||
// scaling of non weapon based spells
|
// scaling of non weapon based spells
|
||||||
if (!isWeaponDamageBasedSpell)
|
if (!isWeaponDamageBasedSpell)
|
||||||
{
|
{
|
||||||
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
|
||||||
|
|
||||||
// Check for table values
|
if (TakenFlat)
|
||||||
if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
|
||||||
{
|
{
|
||||||
float coeff;
|
float LvlPenalty = pCaster->CalculateLevelPenalty(spellProto);
|
||||||
if (damagetype == DOT)
|
|
||||||
coeff = bonus->dot_damage * LvlPenalty;
|
|
||||||
else
|
|
||||||
coeff = bonus->direct_damage * LvlPenalty;
|
|
||||||
|
|
||||||
TakenFlat *= coeff;
|
|
||||||
}
|
|
||||||
// Default calculation
|
|
||||||
else if (TakenFlat)
|
|
||||||
{
|
|
||||||
// Distribute Damage over multiple effects, reduce by AoE
|
// Distribute Damage over multiple effects, reduce by AoE
|
||||||
// Not apply this to creature casted spells
|
|
||||||
float coeff;
|
float coeff;
|
||||||
|
|
||||||
|
// Not apply this to creature casted spells
|
||||||
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
|
if (pCaster->GetTypeId()==TYPEID_UNIT && !((Creature*)pCaster)->isPet())
|
||||||
coeff = 1.0f;
|
coeff = 1.0f;
|
||||||
else
|
// Check for table values
|
||||||
|
else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
|
||||||
|
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
|
||||||
|
// Default calculation
|
||||||
|
else if (TakenFlat)
|
||||||
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
coeff = CalculateDefaultCoefficient(spellProto, damagetype);
|
||||||
|
|
||||||
TakenFlat*= coeff * LvlPenalty;
|
TakenFlat *= coeff * LvlPenalty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9895"
|
#define REVISION_NR "9896"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue