From 79f4f09e2d778877587d6559bfdf7832ec20f85c Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Mon, 6 Nov 2023 09:38:04 +0200 Subject: [PATCH] Multiple fixes for patch 1.6. Some things apply to newer patches as well. Went down of rabbit hole and kept discovering things that were broken. --- src/game/Handlers/SpellHandler.cpp | 16 +++- src/game/Objects/Unit.cpp | 131 +++++++++++------------------ src/game/Objects/Unit.h | 8 +- src/game/Spells/Spell.cpp | 11 --- src/game/Spells/SpellAuras.cpp | 4 + src/game/Spells/SpellDefines.h | 4 + src/game/Spells/SpellEffects.cpp | 42 +++++++-- src/game/StatSystem.cpp | 30 +++++-- src/game/UnitAuraProcHandler.cpp | 70 ++++++++++++++- 9 files changed, 201 insertions(+), 115 deletions(-) diff --git a/src/game/Handlers/SpellHandler.cpp b/src/game/Handlers/SpellHandler.cpp index e34af6aa0..40558fa6d 100644 --- a/src/game/Handlers/SpellHandler.cpp +++ b/src/game/Handlers/SpellHandler.cpp @@ -374,16 +374,14 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) uint32 spellId; recvPacket >> spellId; - // Buff MJ '.gm visible off'. - if (spellId == 16380 && !_player->IsGMVisible()) - return; - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); if (!spellInfo) return; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1 if (spellInfo->Attributes & SPELL_ATTR_NO_AURA_CANCEL) return; +#endif if (spellInfo->IsPassiveSpell()) return; @@ -413,6 +411,16 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) return; } + // World of Warcraft Client Patch 1.7.0 (2005-09-13) + // - Druids should now be able to shapeshift back into caster form while Feared. +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_6_1 + if (_player->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING | UNIT_FLAG_POSSESSED)) +#else + // confirmed you cant remove buffs while mind controlled on wotlk ptr + if (_player->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) +#endif + return; + // channeled spell case (it currently casted then) if (spellInfo->IsChanneledSpell()) { diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index 6282dc553..3caeda783 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -570,76 +570,37 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except) } } -// Nostalrius -void Unit::RemoveFearEffectsByDamageTaken(uint32 damage, uint32 exceptSpellId, DamageEffectType damagetype) +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 +void Unit::RemoveAurasByDamageTaken(uint32 damage, uint32 exceptSpellId) { - if (!HasAuraType(SPELL_AURA_MOD_FEAR)) - return; - - // Formula derived from Youfie's post here: - // https://forum.nostalrius.org/viewtopic.php?f=5&t=17424#p119432 - - // The chance to dispel an aura depends on the damage taken with respect to the caster's level. - uint32 max_dmg = GetLevel() > 8 ? 25 * GetLevel() - 150 : 50; - - // Players are 3x more likely to break fears -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 - if (IsPlayer()) -#else - // World of Warcraft Client Patch 1.11.0 (2006-06-20) - // - Fear: The calculations to determine if Fear effects should break due - // to receiving damage have been changed. In addition, Intimidating - // Shout now follows that player versus non - player distinction, while - // previously it did not. - if (IsPlayer() && !HasAura(5246)) -#endif - max_dmg *= 0.333f; - - // World of Warcraft Client Patch 1.11.0 (2006-06-20) - // - Fear: The calculations to determine if Fear effects should break due - // to receiving damage have been changed. In addition, the chance for a - // damage over time spell to break Fear is now significantly lower. -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 - // DOT spells are 3x less likely to break fears after 1.11 - if (damagetype == DOT) - max_dmg *= 3; -#endif - - // for players, this means max_dmg = 450 at level 60, or 1350 if the damage source is a dot - // for mobs, this means max_dmg = 1350 at level 60, or 4050 if the damage source is a dot - - float chance = float(damage) / float(max_dmg) * 100.0f; - - if (!roll_chance_f(chance)) - return; - - for (AuraList::const_iterator iter = m_modAuras[SPELL_AURA_MOD_FEAR].begin(); iter != m_modAuras[SPELL_AURA_MOD_FEAR].end();) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { - // skip `except` aura - if ((*iter)->GetId() == exceptSpellId) +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + if (iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST) && + iter->second->GetSpellProto()->procChance < 101) +#elif SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1 + if (iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) +#else + if (iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_CAN_BREAK_ON_DAMAGE)) +#endif { - ++iter; - continue; + if (iter->first != exceptSpellId) + { + uint32 max_dmg = GetLevel() > 8 ? 25 * GetLevel() - 150 : 50; + float chance = float(damage) / max_dmg * 100.0f; + if (roll_chance_f(chance)) + { + RemoveSpellAuraHolder(iter->second); + iter = m_spellAuraHolders.begin(); + continue; + } + } } - bool canRemoveAura = false; - switch ((*iter)->GetSpellProto()->Mechanic) - { - case MECHANIC_FEAR: - case MECHANIC_TURN: // [Turn Undead] #2878 - // only fears with proc flags mention that damage may interrupt the effect on tooltip - // example: Flash Bomb does not break on damage - canRemoveAura = (*iter)->GetSpellProto()->procFlags; - break; - } - if (!canRemoveAura) - { - ++iter; - continue; - } - RemoveAurasDueToSpell((*iter)->GetId()); - iter = m_modAuras[SPELL_AURA_MOD_FEAR].begin(); + + ++iter; } } +#endif void Unit::DoKillUnit(Unit* pVictim) { @@ -687,17 +648,11 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // Damage received under shield for example. if (cleanDamage->absorb) { - // Before 1.11 the calculation whether to break fear used base spell damage. - // Calling it from spell class for direct spell damage in this case. -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 - if (!spellProto || !spellProto->HasAura(SPELL_AURA_MOD_FEAR)) -#else - if (!spellProto || ((damagetype != SPELL_DIRECT_DAMAGE) && !spellProto->HasAura(SPELL_AURA_MOD_FEAR))) + // In patch 1.10 proc flags were added to CC auras to make them break on damage. + // Before that chance to break on damage was handled by attributes. +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + pVictim->RemoveAurasByDamageTaken(cleanDamage->absorb, spellProto ? spellProto->Id : 0); #endif - { - if (!(IsCreature() && ((Creature*)this)->IsWorldBoss())) - pVictim->RemoveFearEffectsByDamageTaken(cleanDamage->absorb, spellProto ? spellProto->Id : 0, damagetype); - } pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_DAMAGE_CANCELS, spellProto ? spellProto->Id : 0, true, SKIP_STEALTH); @@ -714,17 +669,11 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa return 0; } - // Before 1.11 the calculation whether to break fear used base spell damage. - // Calling it from spell class for direct spell damage in this case. -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 - if (!spellProto || !spellProto->HasAura(SPELL_AURA_MOD_FEAR)) -#else - if (!spellProto || ((damagetype != SPELL_DIRECT_DAMAGE) && !spellProto->HasAura(SPELL_AURA_MOD_FEAR))) + // In patch 1.10 proc flags were added to CC auras to make them break on damage. + // Before that chance to break on damage was handled by attributes. +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + pVictim->RemoveAurasByDamageTaken(damage, spellProto ? spellProto->Id : 0); #endif - { - if (!(IsCreature() && ((Creature*)this)->IsWorldBoss())) - pVictim->RemoveFearEffectsByDamageTaken(damage, spellProto ? spellProto->Id : 0, damagetype); - } uint32 health = pVictim->GetHealth(); // duel ends when player has 1 or less hp @@ -5891,6 +5840,7 @@ bool Unit::IsShapeShifted() const bool Unit::IsNoWeaponShapeShift() const { + // Mirroring clientside gameplay logic if (ShapeshiftForm form = GetShapeshiftForm()) if (SpellShapeshiftFormEntry const* entry = sSpellShapeshiftFormStore.LookupEntry(form)) @@ -5899,6 +5849,19 @@ bool Unit::IsNoWeaponShapeShift() const return false; } +bool Unit::IsAttackSpeedOverridenShapeShift() const +{ + switch (GetShapeshiftForm()) + { + case FORM_CAT: + case FORM_BEAR: + case FORM_DIREBEAR: + return true; + } + + return false; +} + bool Unit::IsInDisallowedMountForm() const { ShapeshiftForm form = GetShapeshiftForm(); diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 36a92dae3..8bf08a490 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -541,6 +541,7 @@ class Unit : public SpellCaster void SetShapeshiftForm(ShapeshiftForm form) { SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_SHAPESHIFT_FORM, form); } bool IsShapeShifted() const; // mirrors clientside logic, moonkin form not counted as shapeshift bool IsNoWeaponShapeShift() const; + bool IsAttackSpeedOverridenShapeShift() const; bool IsInDisallowedMountForm() const; uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } void SetDisplayId(uint32 displayId); @@ -737,7 +738,9 @@ class Unit : public SpellCaster void RemoveAuraTypeOnDeath(AuraType auraType); void RemoveAllAurasOnDeath(); bool RemoveAuraDueToDebuffLimit(SpellAuraHolder* currentAura); // Returns true if we remove 'currentAura' - void RemoveFearEffectsByDamageTaken(uint32 damage, uint32 exceptSpellId, DamageEffectType damagetype); +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + void RemoveAurasByDamageTaken(uint32 damage, uint32 exceptSpellId); +#endif uint32 GetNegativeAurasCount(); // Limit debuffs to 16 // removing specific aura FROM stack by diff reasons and selections @@ -860,6 +863,7 @@ class Unit : public SpellCaster SpellAuraProcResult HandleAddTargetTriggerAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleModResistanceAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleRemoveByDamageChanceProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleRemoveFearByDamageChanceProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleInvisibilityAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleModDamageAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleNULLProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* /*triggeredByAura*/, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) @@ -971,7 +975,7 @@ class Unit : public SpellCaster */ bool CanUseEquippedWeapon(WeaponAttackType attackType) const { - if (IsNoWeaponShapeShift()) + if (IsAttackSpeedOverridenShapeShift()) return false; switch(attackType) diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index d854d5279..339718e91 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -1562,17 +1562,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) damageInfo.spell = this; damageInfo.reflected = isReflected; - // World of Warcraft Client Patch 1.11.0 (2006-06-20) - // - Fear: The calculations to determine if Fear effects should break due - // to receiving damage have been changed.The old calculation used the - // base damage of the ability.The new calculation uses the final amount - // of damage dealt, after all modifiers. -#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_10_2 - // Has to be called from here instead of Unit::DealDamage to calculate with base damage. - if ((damage > 0) && unitTarget && !(m_caster->IsCreature() && static_cast(m_caster)->IsWorldBoss())) - unitTarget->RemoveFearEffectsByDamageTaken(damage, m_spellInfo->Id, SPELL_DIRECT_DAMAGE); -#endif - if (m_delayed) { damageInfo.damage = m_damage; diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index a2eb4d169..bc892e134 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -7651,7 +7651,11 @@ void SpellAuraHolder::SetAuraFlag(uint32 slot, bool add) { uint32 flags = AFLAG_NONE; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1 if (IsPositive() && !m_spellProto->HasAttribute(SPELL_ATTR_NO_AURA_CANCEL)) +#else + if (IsPositive()) +#endif flags |= AFLAG_CANCELABLE; if (GetAuraByEffectIndex(EFFECT_INDEX_0)) diff --git a/src/game/Spells/SpellDefines.h b/src/game/Spells/SpellDefines.h index a21d45acf..dba4caec8 100644 --- a/src/game/Spells/SpellDefines.h +++ b/src/game/Spells/SpellDefines.h @@ -741,7 +741,11 @@ enum SpellAttributes SPELL_ATTR_NOT_IN_COMBAT_ONLY_PEACEFUL = 0x10000000, // 28 Cannot be used in combat SPELL_ATTR_NO_IMMUNITIES = 0x20000000, // 29 Unaffected by invulnerability SPELL_ATTR_HEARTBEAT_RESIST = 0x40000000, // 30 Chance for spell effects to break early (heartbeat resist) +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1 SPELL_ATTR_NO_AURA_CANCEL = 0x80000000 // 31 Positive aura can't be canceled +#else + SPELL_ATTR_CAN_BREAK_ON_DAMAGE = 0x80000000 // 32 Taking damage has chance to remove the aura +#endif }; enum SpellAttributesEx diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index 827a8bbf9..0495a0cf1 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -1869,6 +1869,41 @@ void Spell::EffectDummy(SpellEffectIndex effIdx) unitTarget->CastCustomSpell(unitTarget, 25503, reductionMod, {}, {}, true); break; } +#endif +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_6_1 + // Ferocious Bite + case 22568: // Rank 1 + case 22827: // Rank 2 + case 22828: // Rank 3 + case 22829: // Rank 4 + { + if (!m_casterUnit || !unitTarget) + return; + + uint32 damageSpellId; + switch (m_spellInfo->Id) + { + case 22568: // Rank 1 + damageSpellId = 22851; + break; + case 22827: // Rank 2 + damageSpellId = 22853; + break; + case 22828: // Rank 3 + damageSpellId = 22861; + break; + case 22829: // Rank 4 + damageSpellId = 22862; + break; + default: + return; + } + + int32 dmg = m_casterUnit->GetPower(POWER_ENERGY) * m_spellInfo->DmgMultiplier[effIdx]; + m_casterUnit->CastCustomSpell(unitTarget, damageSpellId, dmg, {}, {}, true); + m_casterUnit->SetPower(POWER_ENERGY, 0); + break; + } #endif case 29201: // Loatheb Corrupted Mind triggered sub spells { @@ -6460,12 +6495,7 @@ void Spell::EffectDispelMechanic(SpellEffectIndex effIdx) next = iter; ++next; SpellEntry const* spell = iter->second->GetSpellProto(); - - // World of Warcraft Client Patch 1.7.0 (2005-09-13) - // - Escape Artist works with Frost Nova and Frost Trap again. - if (iter->second->HasMechanic(mechanic) && - // attribute removed from Frost Nova in 1.7, which likely means this effect ignores it - !spell->HasAttribute(SPELL_ATTR_NO_AURA_CANCEL)) + if (iter->second->HasMechanic(mechanic)) { unitTarget->RemoveAurasDueToSpell(spell->Id); if (Auras.empty()) diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index e4e657767..113dbcbcc 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -247,6 +247,7 @@ float Unit::GetAttackPowerFromStrengthAndAgility(bool ranged, float strength, fl case CLASS_DRUID: { ShapeshiftForm form = GetShapeshiftForm(); + //Check if Predatory Strikes is skilled float mLevelMult = 0.0; switch (form) @@ -254,7 +255,6 @@ float Unit::GetAttackPowerFromStrengthAndAgility(bool ranged, float strength, fl case FORM_CAT: case FORM_BEAR: case FORM_DIREBEAR: - case FORM_MOONKIN: { Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); for (const auto itr : mDummy) @@ -275,15 +275,16 @@ float Unit::GetAttackPowerFromStrengthAndAgility(bool ranged, float strength, fl switch (form) { case FORM_CAT: + // World of Warcraft Client Patch 1.7.0 (2005-09-13) + // - Cat Form - Each point of agility now adds 1 attack power. +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1 val2 = GetLevel() * mLevelMult + strength * 2.0f + agility - 20.0f; break; +#endif case FORM_BEAR: case FORM_DIREBEAR: val2 = GetLevel() * mLevelMult + strength * 2.0f - 20.0f; break; - case FORM_MOONKIN: - val2 = GetLevel() * mLevelMult + strength * 2.0f - 20.0f; - break; default: val2 = strength * 2.0f - 20.0f; break; @@ -377,7 +378,7 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl float weapon_mindamage = GetWeaponDamageRange(attType, MINDAMAGE, index); float weapon_maxdamage = GetWeaponDamageRange(attType, MAXDAMAGE, index); - if (IsNoWeaponShapeShift()) // check if player is in shapeshift which doesnt use weapon + if (IsAttackSpeedOverridenShapeShift()) // check if player is in shapeshift which doesnt use weapon { /* Druids don't use weapons so a weapon damage index > 0 should not affect their damage. Fixes crazy druid scaling @@ -395,8 +396,23 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl if (lvl > 60) lvl = 60; - weapon_mindamage = lvl * 0.85f * att_speed; - weapon_maxdamage = lvl * 1.25f * att_speed; + switch (GetShapeshiftForm()) + { + // World of Warcraft Client Patch 1.7.0 (2005-09-13) + // - Cat Form - The base weapon damage of the form has been increased. +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_6_1 + case FORM_CAT: + // guessed + weapon_mindamage = lvl * 0.60f * att_speed; + weapon_maxdamage = lvl * 1.00f * att_speed; + break; +#endif + default: + weapon_mindamage = lvl * 0.85f * att_speed; + weapon_maxdamage = lvl * 1.25f * att_speed; + break; + } + total_value = 0.0f; // remove benefit from weapon enchants } } diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp index b0a8733a6..c355c2aa6 100644 --- a/src/game/UnitAuraProcHandler.cpp +++ b/src/game/UnitAuraProcHandler.cpp @@ -38,7 +38,7 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS] = &Unit::HandleDummyAuraProc, // 4 SPELL_AURA_DUMMY &Unit::HandleNULLProc, // 5 SPELL_AURA_MOD_CONFUSE &Unit::HandleNULLProc, // 6 SPELL_AURA_MOD_CHARM - &Unit::HandleNULLProc, // 7 SPELL_AURA_MOD_FEAR + &Unit::HandleRemoveFearByDamageChanceProc, // 7 SPELL_AURA_MOD_FEAR &Unit::HandleNULLProc, // 8 SPELL_AURA_PERIODIC_HEAL &Unit::HandleNULLProc, // 9 SPELL_AURA_MOD_ATTACKSPEED &Unit::HandleNULLProc, // 10 SPELL_AURA_MOD_THREAT @@ -1946,6 +1946,74 @@ SpellAuraProcResult Unit::HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 d return SPELL_AURA_PROC_FAILED; } +SpellAuraProcResult Unit::HandleRemoveFearByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) +{ + if (!damage) + return SPELL_AURA_PROC_FAILED; + + switch (triggeredByAura->GetSpellProto()->Mechanic) + { + case MECHANIC_FEAR: + case MECHANIC_TURN: + break; + default: + return SPELL_AURA_PROC_FAILED; + } + + // Formula derived from Youfie's post here: + // https://forum.nostalrius.org/viewtopic.php?f=5&t=17424#p119432 + + // The chance to dispel an aura depends on the damage taken with respect to the caster's level. + uint32 max_dmg = GetLevel() > 8 ? 25 * GetLevel() - 150 : 50; + + // Players are 3x more likely to break fears +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 + if (IsPlayer()) +#else + // World of Warcraft Client Patch 1.11.0 (2006-06-20) + // - Fear: The calculations to determine if Fear effects should break due + // to receiving damage have been changed. In addition, Intimidating + // Shout now follows that player versus non - player distinction, while + // previously it did not. + if (IsPlayer() && !HasAura(5246)) +#endif + max_dmg *= 0.333f; + + // World of Warcraft Client Patch 1.11.0 (2006-06-20) + // - Fear: The calculations to determine if Fear effects should break due + // to receiving damage have been changed. In addition, the chance for a + // damage over time spell to break Fear is now significantly lower. +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 + // DOT spells are 3x less likely to break fears after 1.11 + if (procFlag & PROC_FLAG_TAKE_HARMFUL_PERIODIC) + max_dmg *= 3; +#endif + + // for players, this means max_dmg = 450 at level 60, or 1350 if the damage source is a dot + // for mobs, this means max_dmg = 1350 at level 60, or 4050 if the damage source is a dot + + // World of Warcraft Client Patch 1.11.0 (2006-06-20) + // - Fear: The calculations to determine if Fear effects should break due + // to receiving damage have been changed.The old calculation used the + // base damage of the ability.The new calculation uses the final amount + // of damage dealt, after all modifiers. +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_10_2 + if (procSpell && pVictim) + damage = pVictim->CalculateSpellEffectValue(this, procSpell, EFFECT_INDEX_0); +#endif + + float chance = float(damage) / float(max_dmg) * 100.0f; + if (roll_chance_f(chance)) + { + triggeredByAura->SetInUse(true); + RemoveAurasByCasterSpell(triggeredByAura->GetId(), triggeredByAura->GetCasterGuid()); + triggeredByAura->SetInUse(false); + return SPELL_AURA_PROC_OK; + } + + return SPELL_AURA_PROC_FAILED; +} + SpellAuraProcResult Unit::HandleInvisibilityAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { if (triggeredByAura->GetSpellProto()->HasAttribute(SPELL_ATTR_PASSIVE) || !triggeredByAura->GetSpellProto()->IsPositiveSpell())