Core/Items: Implemented spell penetration stat on items and use it from enchantments, original patch by zergtmn
This commit is contained in:
@@ -567,6 +567,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
||||
m_baseFeralAP = 0;
|
||||
m_baseManaRegen = 0;
|
||||
m_baseHealthRegen = 0;
|
||||
m_spellPenetrationItemMod = 0;
|
||||
|
||||
// Honor System
|
||||
m_lastHonorUpdateTime = time(NULL);
|
||||
@@ -7566,7 +7567,11 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
|
||||
case ITEM_MOD_HEALTH_REGEN:
|
||||
ApplyHealthRegenBonus(int32(val), apply);
|
||||
break;
|
||||
// depricated item mods
|
||||
case ITEM_MOD_SPELL_PENETRATION:
|
||||
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -val, apply);
|
||||
m_spellPenetrationItemMod += apply ? val : -val;
|
||||
break;
|
||||
// deprecated item mods
|
||||
case ITEM_MOD_SPELL_HEALING_DONE:
|
||||
case ITEM_MOD_SPELL_DAMAGE_DONE:
|
||||
break;
|
||||
@@ -7575,18 +7580,14 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
|
||||
|
||||
// Apply Spell Power from ScalingStatValue if set
|
||||
if (ssv)
|
||||
{
|
||||
if (int32 spellbonus = ssv->getSpellBonus(proto->ScalingStatValue))
|
||||
ApplySpellPowerBonus(spellbonus, apply);
|
||||
}
|
||||
|
||||
// If set ScalingStatValue armor get it or use item armor
|
||||
uint32 armor = proto->Armor;
|
||||
if (ssv)
|
||||
{
|
||||
if (uint32 ssvarmor = ssv->getArmorMod(proto->ScalingStatValue))
|
||||
armor = ssvarmor;
|
||||
}
|
||||
|
||||
if (armor)
|
||||
{
|
||||
@@ -13488,6 +13489,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
|
||||
break;
|
||||
case ITEM_MOD_SPELL_PENETRATION:
|
||||
ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, enchant_amount, apply);
|
||||
m_spellPenetrationItemMod += apply ? int32(enchant_amount) : -int32(enchant_amount);
|
||||
sLog->outDebug("+ %u SPELL_PENETRATION", enchant_amount);
|
||||
break;
|
||||
case ITEM_MOD_BLOCK_VALUE:
|
||||
|
||||
@@ -1801,6 +1801,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
float GetRatingCoefficient(CombatRating cr) const;
|
||||
float GetRatingBonusValue(CombatRating cr) const;
|
||||
uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; }
|
||||
int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; }
|
||||
|
||||
float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
|
||||
void UpdateBlockPercentage();
|
||||
@@ -2539,6 +2540,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 m_baseFeralAP;
|
||||
uint32 m_baseManaRegen;
|
||||
uint32 m_baseHealthRegen;
|
||||
int32 m_spellPenetrationItemMod;
|
||||
|
||||
SpellModList m_spellMods[MAX_SPELLMOD];
|
||||
//uint32 m_pad;
|
||||
|
||||
@@ -1555,12 +1555,14 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
|
||||
// Magic damage, check for resists
|
||||
if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
|
||||
{
|
||||
float baseVictimResistance = (float) pVictim->GetResistance(GetFirstSchoolInMask(schoolMask));
|
||||
float ignoredResistance = (float) GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask);
|
||||
float baseVictimResistance = float(pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)));
|
||||
float ignoredResistance = float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask));
|
||||
if (Player* player = ToPlayer())
|
||||
ignoredResistance += float(player->GetSpellPenetrationItemMod());
|
||||
float victimResistance = baseVictimResistance + ignoredResistance;
|
||||
|
||||
uint32 BOSS_LEVEL = 83;
|
||||
float BOSS_RESISTANCE_CONSTANT = 510.0;
|
||||
static const uint32 BOSS_LEVEL = 83;
|
||||
static const float BOSS_RESISTANCE_CONSTANT = 510.0;
|
||||
uint32 level = getLevel();
|
||||
float resistanceConstant = 0.0f;
|
||||
|
||||
@@ -1571,7 +1573,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
|
||||
|
||||
float averageResist = victimResistance / (victimResistance + resistanceConstant);
|
||||
float discreteResistProbability[11];
|
||||
for (int i = 0; i < 11; i++)
|
||||
for (uint32 i = 0; i < 11; ++i)
|
||||
{
|
||||
discreteResistProbability[i] = 0.5f - 2.5f * fabs(0.1f * i - averageResist);
|
||||
if (discreteResistProbability[i] < 0.0f)
|
||||
@@ -1585,32 +1587,25 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
|
||||
discreteResistProbability[2] = 2.5f * averageResist;
|
||||
}
|
||||
|
||||
float r = (float)rand_norm();
|
||||
int i = 0;
|
||||
float r = float(rand_norm());
|
||||
uint32 i = 0;
|
||||
float probabilitySum = discreteResistProbability[0];
|
||||
|
||||
while (r >= probabilitySum && i < 10)
|
||||
{
|
||||
i++;
|
||||
probabilitySum += discreteResistProbability[i];
|
||||
}
|
||||
probabilitySum += discreteResistProbability[++i];
|
||||
|
||||
float damageResisted = float(damage * i / 10);
|
||||
|
||||
AuraEffectList const &ResIgnoreAurasAb = GetAuraEffectsByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
|
||||
for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j)
|
||||
{
|
||||
if ((*j)->GetMiscValue() & schoolMask
|
||||
&& (*j)->IsAffectedOnSpell(spellInfo))
|
||||
if (((*j)->GetMiscValue() & schoolMask) && (*j)->IsAffectedOnSpell(spellInfo))
|
||||
AddPctN(damageResisted, -(*j)->GetAmount());
|
||||
}
|
||||
|
||||
AuraEffectList const &ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
|
||||
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
|
||||
{
|
||||
if ((*j)->GetMiscValue() & schoolMask)
|
||||
AddPctN(damageResisted, -(*j)->GetAmount());
|
||||
}
|
||||
|
||||
dmgInfo.ResistDamage(uint32(damageResisted));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user