Core/Auras: removed caster dependency from core

- Decoupled Unit logic: split of spell critical chance into done (caster bonuses) and taken (target bonuses), this allows to precalculate caster bonuses on aura apply and then check victim's auras on damage/healing calc
- Made static a bunch of methods (they no longer have this pointer because they are now called from periodic handlers which may or may not have an active caster in world)
- Simplified all AuraEffect bonuses into AuraEffect::_amount, no more duplicated code
- Critical chance and whether or not caster is player owned unit (for resilience calcs) is now saved one level upper, on Aura itself (it's impossible as of 3.3.5 to have different effects with different critical chances)
- Minor cleanup of SPELL_DAMAGE_CLASS_NONE and Arcane Potency (#18813) crit handling

Closes #19876
This commit is contained in:
ariel-
2018-01-13 06:45:21 -03:00
parent 1c60af6328
commit cb9e72e521
65 changed files with 955 additions and 889 deletions
+9 -9
View File
@@ -634,9 +634,9 @@ public:
if (target->IsAlive())
{
if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
handler->GetSession()->GetPlayer()->Kill(target);
Unit::Kill(handler->GetSession()->GetPlayer(), target);
else
handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
Unit::DealDamage(handler->GetSession()->GetPlayer(), target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
}
return true;
@@ -2334,7 +2334,7 @@ public:
// flat melee damage without resistence/etc reduction
if (!schoolStr)
{
handler->GetSession()->GetPlayer()->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
Unit::DealDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
if (target != handler->GetSession()->GetPlayer())
handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0);
return true;
@@ -2347,7 +2347,7 @@ public:
SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
if (Unit::IsDamageReducedByArmor(schoolmask))
damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, nullptr, BASE_ATTACK);
damage = Unit::CalcArmorReducedDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, BASE_ATTACK);
char* spellStr = strtok((char*)nullptr, " ");
@@ -2356,7 +2356,7 @@ public:
{
Player* attacker = handler->GetSession()->GetPlayer();
DamageInfo dmgInfo(attacker, target, damage, nullptr, schoolmask, SPELL_DIRECT_DAMAGE, BASE_ATTACK);
attacker->CalcAbsorbResist(dmgInfo);
Unit::CalcAbsorbResist(dmgInfo);
if (!dmgInfo.GetDamage())
return true;
@@ -2365,8 +2365,8 @@ public:
uint32 absorb = dmgInfo.GetAbsorb();
uint32 resist = dmgInfo.GetResist();
attacker->DealDamageMods(target, damage, &absorb);
attacker->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false);
Unit::DealDamageMods(target, damage, &absorb);
Unit::DealDamage(attacker, target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false);
attacker->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
return true;
}
@@ -2384,11 +2384,11 @@ public:
Player* attacker = handler->GetSession()->GetPlayer();
SpellNonMeleeDamage dmgInfo(attacker, target, spellid, spellInfo->GetSchoolMask());
damage = attacker->SpellDamageBonusDone(target, spellInfo, damage, SPELL_DIRECT_DAMAGE);
damage = attacker->SpellDamageBonusDone(target, spellInfo, damage, SPELL_DIRECT_DAMAGE, { });
damage = target->SpellDamageBonusTaken(attacker, spellInfo, damage, SPELL_DIRECT_DAMAGE);
attacker->CalculateSpellDamageTaken(&dmgInfo, damage, spellInfo);
attacker->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
attacker->SendSpellNonMeleeDamageLog(&dmgInfo);
attacker->DealSpellDamage(&dmgInfo, true);
return true;