diff options
author | Shauren <krzysiek.7.5.4@gmail.com> | 2010-12-31 22:59:36 +0100 |
---|---|---|
committer | Shauren <krzysiek.7.5.4@gmail.com> | 2010-12-31 22:59:36 +0100 |
commit | cf62d7b776dcc29a9da2fadfd209c8445f6a9e6b (patch) | |
tree | 81954ba6b19296c00aaac6f21b600a921e53e61c /src | |
parent | 8ab453b4659da09126c329d00210ec189d3dee9b (diff) |
Core/Items: Implemented spell penetration stat on items and use it from enchantments, original patch by zergtmn
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 12 | ||||
-rwxr-xr-x | src/server/game/Entities/Player/Player.h | 2 | ||||
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 29 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_druid.cpp | 2 |
4 files changed, 22 insertions, 23 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9a102de874f..d063f4ba112 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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: diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 7d9838001e4..a1c57d4bb55 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -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; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3c8c5f670d6..6802974b7ac 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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)); } diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 0e5c1dd95ef..0d9ee4a8ec9 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -197,7 +197,7 @@ public: void Absorb(AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { - absorbAmount = int32(CalculatePctN(GetTarget()->GetTotalAttackPowerValue(BASE_ATTACK), absorbPct)); + absorbAmount = uint32(CalculatePctN(GetTarget()->GetTotalAttackPowerValue(BASE_ATTACK), absorbPct)); aurEff->SetAmount(0); } |