Add spell bonus coefficients from classic.

This commit is contained in:
ratkosrb
2020-05-16 03:20:51 +03:00
parent 6293b1193c
commit dc91bbfab5
17 changed files with 25735 additions and 377 deletions
+19 -27
View File
@@ -4070,7 +4070,7 @@ int32 WorldObject::CalculateSpellDamage(Unit const* target, SpellEntry const* sp
return value;
}
void WorldObject::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType, Spell* spell)
void WorldObject::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, WeaponAttackType attackType, Spell* spell)
{
SpellSchoolMask damageSchoolMask = GetSchoolMask(damageInfo->school);
Unit* pVictim = damageInfo->target;
@@ -4094,8 +4094,8 @@ void WorldObject::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 da
case SPELL_DAMAGE_CLASS_MELEE:
{
//Calculate damage bonus
damage = MeleeDamageBonusDone(pVictim, damage, attackType, spellInfo, SPELL_DIRECT_DAMAGE, 1, spell);
damage = pVictim->MeleeDamageBonusTaken(this, damage, attackType, spellInfo, SPELL_DIRECT_DAMAGE, 1, spell);
damage = MeleeDamageBonusDone(pVictim, damage, attackType, spellInfo, effectIndex, SPELL_DIRECT_DAMAGE, 1, spell);
damage = pVictim->MeleeDamageBonusTaken(this, damage, attackType, spellInfo, effectIndex, SPELL_DIRECT_DAMAGE, 1, spell);
// if crit add critical bonus
if (crit)
@@ -4110,8 +4110,8 @@ void WorldObject::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 da
case SPELL_DAMAGE_CLASS_MAGIC:
{
// Calculate damage bonus
damage = SpellDamageBonusDone(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE, 1, spell);
damage = pVictim->SpellDamageBonusTaken(this, spellInfo, damage, SPELL_DIRECT_DAMAGE, 1, spell);
damage = SpellDamageBonusDone(pVictim, spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE, 1, spell);
damage = pVictim->SpellDamageBonusTaken(this, spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE, 1, spell);
// If crit add critical bonus
if (crit)
@@ -4139,7 +4139,7 @@ void WorldObject::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 da
* Calculates caster part of melee damage bonuses,
* also includes different bonuses dependent from target auras
*/
uint32 WorldObject::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack, Spell* spell, bool flat)
uint32 WorldObject::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, SpellEffectIndex effectIndex, DamageEffectType damagetype, uint32 stack, Spell* spell, bool flat)
{
if (!pVictim)
return pdamage;
@@ -4245,7 +4245,7 @@ uint32 WorldObject::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAt
if (!isWeaponDamageBasedSpell)
{
// apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties
DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneFlat, APbonus, damagetype, true, this, spell);
DoneTotal = SpellBonusWithCoeffs(spellProto, effectIndex, DoneTotal, DoneFlat, APbonus, damagetype, true, this, spell);
}
// weapon damage based spells
else if (APbonus || DoneFlat)
@@ -4297,21 +4297,23 @@ uint32 WorldObject::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAt
* Calculates caster part of healing spell bonuses,
* also includes different bonuses dependent from target auras
*/
uint32 WorldObject::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack, Spell* spell)
uint32 WorldObject::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, SpellEffectIndex effectIndex, int32 healamount, DamageEffectType damagetype, uint32 stack, Spell* spell)
{
Unit* pUnit = ToUnit();
// For totems get healing bonus from owner (statue isn't totem in fact)
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE)
if (Unit* owner = pUnit->GetOwner())
return owner->SpellHealingBonusDone(pVictim, spellProto, healamount, damagetype, stack, spell);
return owner->SpellHealingBonusDone(pVictim, spellProto, effectIndex, healamount, damagetype, stack, spell);
// No heal amount for this class spells
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellProto->Custom & SPELL_CUSTOM_FIXED_DAMAGE)
if (((spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE) && spellProto->HasAttribute(SPELL_ATTR_PASSIVE)) ||
(spellProto->Custom & SPELL_CUSTOM_FIXED_DAMAGE))
{
//DEBUG_UNIT(this, DEBUG_SPELLS_DAMAGE, "SpellHealingBonusDone[spell=%u]: has fixed damage (SPELL_DAMAGE_CLASS_NONE)", spellProto->Id);
return healamount < 0 ? 0 : healamount;
}
// Healing Done
// Done total percent damage auras
float DoneTotalMod = 1.0f;
@@ -4352,7 +4354,7 @@ uint32 WorldObject::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spell
int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(spellProto->GetSpellSchoolMask());
// apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties
DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, this, spell);
DoneTotal = SpellBonusWithCoeffs(spellProto, effectIndex, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, this, spell);
// use float as more appropriate for negative values and percent applying
float heal = (healamount + DoneTotal * int32(stack)) * DoneTotalMod;
@@ -4400,7 +4402,7 @@ int32 WorldObject::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
* Calculates caster part of spell damage bonuses,
* also includes different bonuses dependent from target auras
*/
uint32 WorldObject::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack, Spell* spell)
uint32 WorldObject::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, SpellEffectIndex effectIndex, uint32 pdamage, DamageEffectType damagetype, uint32 stack, Spell* spell)
{
if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE)
return pdamage;
@@ -4418,7 +4420,7 @@ uint32 WorldObject::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellP
if (pUnit && GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE)
{
if (Unit* owner = pUnit->GetOwner())
return owner->SpellDamageBonusDone(pVictim, spellProto, pdamage, damagetype, stack, spell);
return owner->SpellDamageBonusDone(pVictim, spellProto, effectIndex, pdamage, damagetype, stack, spell);
}
float DoneTotalMod = 1.0f;
@@ -4514,7 +4516,7 @@ uint32 WorldObject::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellP
DoneAdvertisedBenefit += ((Pet*)this)->GetBonusDamage();
// apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties
DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, this, spell);
DoneTotal = SpellBonusWithCoeffs(spellProto, effectIndex, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, this, spell);
float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod;
// apply spellmod to Done damage (flat and pct)
@@ -4562,7 +4564,7 @@ int32 WorldObject::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
return DoneAdvertisedBenefit;
}
int32 WorldObject::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, WorldObject* pCaster, Spell* spell) const
int32 WorldObject::SpellBonusWithCoeffs(SpellEntry const* spellProto, SpellEffectIndex effectIndex, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, WorldObject* pCaster, Spell* spell) const
{
// Distribute Damage over multiple effects, reduce by AoE
float coeff = 0.0f;
@@ -4572,18 +4574,8 @@ int32 WorldObject::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 tota
//if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->IsPet())
// coeff = 1.0f;
// Check for table values
if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id))
{
coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage;
// apply ap bonus at done part calculation only (it flat total mod so common with taken)
if (donePart && (bonus->ap_bonus || bonus->ap_dot_bonus))
{
float const ap_bonus = damagetype == DOT ? bonus->ap_dot_bonus : bonus->ap_bonus;
float const total_ap = IsUnit() ? static_cast<Unit const*>(this)->GetTotalAttackPowerValue(spellProto->IsSpellRequiresRangedAP() ? RANGED_ATTACK : BASE_ATTACK) : 0;
total += int32(ap_bonus * (total_ap + ap_benefit));
}
}
if (spellProto->EffectBonusCoefficient[effectIndex] >= 0)
coeff = spellProto->EffectBonusCoefficient[effectIndex];
// Calculate default coefficient
else if (benefit)
coeff = spellProto->CalculateDefaultCoefficient(damagetype);