Core/Spells: ported SpellModOp definitions from master branch
This commit is contained in:
1 parent
3de0b005d5
commit
ef3632109d
20 files changed
+179
-229
No files matched your search
@@ -1062,7 +1062,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
|
||||
uint32 crit_bonus = damage;
|
||||
// Apply crit_damage bonus for melee spells
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SpellModOp::CritDamageAndHealing, crit_bonus);
|
||||
damage += crit_bonus;
|
||||
|
||||
// Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
|
||||
@@ -1225,7 +1225,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon
|
||||
uint32 damage = 0;
|
||||
damage += CalculateDamage(damageInfo->AttackType, false, true);
|
||||
// Add melee damage bonus
|
||||
damage = MeleeDamageBonusDone(damageInfo->Target, damage, damageInfo->AttackType, nullptr, true, SpellSchoolMask(damageInfo->DamageSchoolMask));
|
||||
damage = MeleeDamageBonusDone(damageInfo->Target, damage, damageInfo->AttackType, DIRECT_DAMAGE, nullptr, true, SpellSchoolMask(damageInfo->DamageSchoolMask));
|
||||
damage = damageInfo->Target->MeleeDamageBonusTaken(this, damage, damageInfo->AttackType, nullptr, SpellSchoolMask(damageInfo->DamageSchoolMask));
|
||||
|
||||
// Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations
|
||||
@@ -1554,7 +1554,7 @@ static float GetArmorReduction(float armor, uint8 attackerLevel)
|
||||
|
||||
if (spellInfo)
|
||||
if (Player* modOwner = attacker->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor);
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SpellModOp::TargetResistance, armor);
|
||||
|
||||
for (AuraEffect const* aurEff : attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST))
|
||||
{
|
||||
@@ -6354,7 +6354,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
spellPowerCoeff *= 100.0f;
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, spellPowerCoeff);
|
||||
modOwner->ApplySpellMod(spellProto->Id, SpellModOp::BonusCoefficient, spellPowerCoeff);
|
||||
spellPowerCoeff /= 100.0f;
|
||||
}
|
||||
|
||||
@@ -6365,7 +6365,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
|
||||
|
||||
// apply spellmod to Done damage (flat and pct)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage);
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SpellModOp::PeriodicHealingAndDamage : SpellModOp::HealingAndDamage, tmpDamage);
|
||||
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
}
|
||||
@@ -6722,7 +6722,7 @@ float Unit::SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask scho
|
||||
// percent done
|
||||
// only players use intelligence for critical chance computations
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance);
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SpellModOp::CritChance, crit_chance);
|
||||
|
||||
return std::max(crit_chance, 0.0f);
|
||||
}
|
||||
@@ -6964,7 +6964,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo,
|
||||
{
|
||||
// adds additional damage to critBonus (from talents)
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
|
||||
modOwner->ApplySpellMod(spellProto->Id, SpellModOp::CritDamageAndHealing, crit_bonus);
|
||||
}
|
||||
|
||||
crit_bonus += damage;
|
||||
@@ -7069,7 +7069,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
coeff *= 100.0f;
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff);
|
||||
modOwner->ApplySpellMod(spellProto->Id, SpellModOp::BonusCoefficient, coeff);
|
||||
coeff /= 100.0f;
|
||||
}
|
||||
|
||||
@@ -7094,7 +7094,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
|
||||
|
||||
// apply spellmod to Done amount
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SpellModOp::PeriodicHealingAndDamage : SpellModOp::HealingAndDamage, heal);
|
||||
|
||||
return uint32(std::max(heal, 0.0f));
|
||||
}
|
||||
@@ -7484,9 +7484,9 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Worl
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto /*= nullptr*/, bool useSpellBonusData /*= true*/, SpellSchoolMask damageSchoolMask /*= SPELL_SCHOOL_MASK_NORMAL*/)
|
||||
uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 damage, WeaponAttackType attType, DamageEffectType damagetype, SpellInfo const* spellProto /*= nullptr*/, bool useSpellBonusData /*= true*/, SpellSchoolMask damageSchoolMask /*= SPELL_SCHOOL_MASK_NORMAL*/)
|
||||
{
|
||||
if (!victim || pdamage == 0)
|
||||
if (!victim || damage == 0)
|
||||
return 0;
|
||||
|
||||
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
|
||||
@@ -7544,23 +7544,20 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
||||
if (!(schoolMask & SPELL_SCHOOL_MASK_NORMAL))
|
||||
{
|
||||
// Some spells don't benefit from pct done mods
|
||||
// mods for SPELL_SCHOOL_MASK_NORMAL are already factored in base melee damage calculation
|
||||
if (!spellProto || !spellProto->HasAttribute(SPELL_ATTR6_LIMIT_PCT_DAMAGE_MODS))
|
||||
{
|
||||
// mods for SPELL_SCHOOL_MASK_NORMAL are already factored in base melee damage calculation
|
||||
if (!(spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_NORMAL))
|
||||
float maxModDamagePercentSchool = 0.0f;
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
float maxModDamagePercentSchool = 0.0f;
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
for (uint32 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
|
||||
if (schoolMask & (1 << i))
|
||||
maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i));
|
||||
}
|
||||
else
|
||||
maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask());
|
||||
|
||||
DoneTotalMod *= maxModDamagePercentSchool;
|
||||
for (uint32 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
|
||||
if (schoolMask & (1 << i))
|
||||
maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i));
|
||||
}
|
||||
else
|
||||
maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask());
|
||||
|
||||
DoneTotalMod *= maxModDamagePercentSchool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7591,14 +7588,17 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
|
||||
}));
|
||||
}
|
||||
|
||||
// done scripted mod (take it from owner)
|
||||
// Unit* owner = GetOwner() ? GetOwner() : this;
|
||||
// AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||
float damageF = damage;
|
||||
|
||||
float tmpDamage = float(int32(pdamage) + DoneFlatBenefit) * DoneTotalMod;
|
||||
// apply spellmod to Done damage
|
||||
if (spellProto)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SpellModOp::PeriodicHealingAndDamage : SpellModOp::HealingAndDamage, damageF);
|
||||
|
||||
damageF = (damageF + DoneFlatBenefit) * DoneTotalMod;
|
||||
|
||||
// bonus result can be negative
|
||||
return uint32(std::max(tmpDamage, 0.0f));
|
||||
return uint32(std::max(damageF, 0.0f));
|
||||
}
|
||||
|
||||
uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto /*= nullptr*/, SpellSchoolMask damageSchoolMask /*= SPELL_SCHOOL_MASK_NORMAL*/)
|
||||
@@ -7779,7 +7779,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spe
|
||||
// Apply chance modifer aura
|
||||
if (spellProto)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM);
|
||||
modOwner->ApplySpellMod(spellProto->Id, SpellModOp::ProcFrequency, PPM);
|
||||
|
||||
return std::floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
|
||||
}
|
||||
@@ -12078,11 +12078,11 @@ float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, S
|
||||
if (!spellInfo && haveOffhandWeapon())
|
||||
missChance += 19.f;
|
||||
|
||||
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
|
||||
// Spellmod from SpellModOp::HitChance
|
||||
float resistMissChance = 100.0f;
|
||||
if (spellInfo)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_MISS_CHANCE, resistMissChance);
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SpellModOp::HitChance, resistMissChance);
|
||||
|
||||
missChance -= resistMissChance - 100.0f;
|
||||
|
||||
|
||||
Reference in new issue
Block a user