Core/Entities: fix calculations for damage taken/done with negative values (should go into effect) and correctly implement SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS. small cleanup
This commit is contained in:
@@ -10407,6 +10407,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
|||||||
if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
|
if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet())
|
||||||
DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
|
DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
|
||||||
|
|
||||||
|
// Some spells don't benefit from pct done mods
|
||||||
|
if (!spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)
|
||||||
|
{
|
||||||
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||||
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
|
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -10423,6 +10426,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
|||||||
AddPctN(DoneTotalMod, (*i)->GetAmount());
|
AddPctN(DoneTotalMod, (*i)->GetAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
||||||
// Add flat bonus from spell damage versus
|
// Add flat bonus from spell damage versus
|
||||||
@@ -10792,12 +10796,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
|||||||
DoneTotalMod = 1.0f;
|
DoneTotalMod = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some spells don't benefit from pct done mods
|
|
||||||
// maybe should be implemented like SPELL_ATTR3_NO_DONE_BONUS,
|
|
||||||
// but then it may break spell power coeffs work on spell 31117
|
|
||||||
if (spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)
|
|
||||||
DoneTotalMod = 1.0f;
|
|
||||||
|
|
||||||
float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod;
|
float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod;
|
||||||
// apply spellmod to Done damage (flat and pct)
|
// apply spellmod to Done damage (flat and pct)
|
||||||
if (Player* modOwner = GetSpellModOwner())
|
if (Player* modOwner = GetSpellModOwner())
|
||||||
@@ -10918,7 +10916,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
|
|||||||
DoneAdvertisedBenefit += int32(CalculatePctN(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount()));
|
DoneAdvertisedBenefit += int32(CalculatePctN(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount()));
|
||||||
|
|
||||||
}
|
}
|
||||||
return DoneAdvertisedBenefit > 0 ? DoneAdvertisedBenefit : 0;
|
return DoneAdvertisedBenefit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
||||||
@@ -10930,7 +10928,7 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask)
|
|||||||
if (((*i)->GetMiscValue() & schoolMask) != 0)
|
if (((*i)->GetMiscValue() & schoolMask) != 0)
|
||||||
TakenAdvertisedBenefit += (*i)->GetAmount();
|
TakenAdvertisedBenefit += (*i)->GetAmount();
|
||||||
|
|
||||||
return TakenAdvertisedBenefit > 0 ? TakenAdvertisedBenefit : 0;
|
return TakenAdvertisedBenefit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const
|
bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const
|
||||||
@@ -11197,7 +11195,7 @@ uint32 Unit::SpellCriticalHealingBonus(SpellInfo const* spellProto, uint32 damag
|
|||||||
uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
|
uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
|
||||||
{
|
{
|
||||||
// For totems get healing bonus from owner (statue isn't totem in fact)
|
// For totems get healing bonus from owner (statue isn't totem in fact)
|
||||||
if (GetTypeId() == TYPEID_UNIT && ToCreature()->isTotem())
|
if (GetTypeId() == TYPEID_UNIT && isTotem())
|
||||||
if (Unit* owner = GetOwner())
|
if (Unit* owner = GetOwner())
|
||||||
return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, stack);
|
return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, stack);
|
||||||
|
|
||||||
@@ -11297,7 +11295,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
|
|||||||
{
|
{
|
||||||
// No bonus healing for SPELL_DAMAGE_CLASS_NONE class spells by default
|
// No bonus healing for SPELL_DAMAGE_CLASS_NONE class spells by default
|
||||||
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
|
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
|
||||||
return healamount < 0 ? 0 : healamount;
|
return healamount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default calculation
|
// Default calculation
|
||||||
@@ -11413,7 +11411,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u
|
|||||||
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
|
if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
|
||||||
{
|
{
|
||||||
healamount = int32(healamount * TakenTotalMod);
|
healamount = int32(healamount * TakenTotalMod);
|
||||||
return healamount < 0 ? 0 : healamount;
|
return healamount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11648,10 +11646,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
|||||||
|
|
||||||
uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto)
|
uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto)
|
||||||
{
|
{
|
||||||
if (!victim)
|
if (!victim || pdamage == 0)
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (pdamage == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
||||||
@@ -11708,7 +11703,9 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
|||||||
// Done total percent damage auras
|
// Done total percent damage auras
|
||||||
float DoneTotalMod = 1.0f;
|
float DoneTotalMod = 1.0f;
|
||||||
|
|
||||||
// ..done
|
// Some spells don't benefit from pct done mods
|
||||||
|
if (!spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)
|
||||||
|
{
|
||||||
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||||
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
|
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -11725,6 +11722,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
|
AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
|
||||||
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
|
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user