Skip to content

Commit

Permalink
Unit/Spell: Resolve weapon skill usage bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 23, 2023
1 parent 438bf17 commit 162cd3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3321,7 +3321,7 @@ float Unit::CalculateEffectiveDodgeChance(const Unit* attacker, WeaponAttackType
// Own chance appears to be zero / below zero / unmeaningful for some reason (debuffs?): skip calculation, unit is incapable
if (chance < 0.005f)
return 0.0f;
const bool weapon = (!ability || ability->EquippedItemClass == ITEM_CLASS_WEAPON);
const bool weapon = (!ability || IsSpellUseWeaponSkill(ability));
// Skill difference can be negative (and reduce our chance to mitigate an attack), which means:
// a) Attacker's level is higher
// b) Attacker has +skill bonuses
Expand Down Expand Up @@ -3352,7 +3352,7 @@ float Unit::CalculateEffectiveParryChance(const Unit* attacker, WeaponAttackType
// Own chance appears to be zero / below zero / unmeaningful for some reason (debuffs?): skip calculation, unit is incapable
if (chance < 0.005f)
return 0.0f;
const bool weapon = (!ability || ability->EquippedItemClass == ITEM_CLASS_WEAPON);
const bool weapon = (!ability || IsSpellUseWeaponSkill(ability));
// Skill difference can be negative (and reduce our chance to mitigate an attack), which means:
// a) Attacker's level is higher
// b) Attacker has +skill bonuses
Expand Down Expand Up @@ -3385,7 +3385,7 @@ float Unit::CalculateEffectiveBlockChance(const Unit* attacker, WeaponAttackType
// Own chance appears to be zero / below zero / unmeaningful for some reason (debuffs?): skip calculation, unit is incapable
if (chance < 0.005f)
return 0.0f;
const bool weapon = (!ability || ability->EquippedItemClass == ITEM_CLASS_WEAPON);
const bool weapon = (!ability || IsSpellUseWeaponSkill(ability));
// Skill difference can be negative (and reduce our chance to mitigate an attack), which means:
// a) Attacker's level is higher
// b) Attacker has +skill bonuses
Expand Down Expand Up @@ -3884,7 +3884,7 @@ float Unit::CalculateEffectiveCritChance(const Unit* victim, WeaponAttackType at
// Skip victim calculation if positive ability
if (ability && IsPositiveSpell(ability, this, victim))
return std::max(0.0f, std::min(chance, 100.0f));
const bool weapon = (!ability || ability->EquippedItemClass == ITEM_CLASS_WEAPON);
const bool weapon = (!ability || IsSpellUseWeaponSkill(ability));
// Skill difference can be both negative and positive.
// a) Positive means that attacker's level is higher or additional weapon +skill bonuses
// b) Negative means that victim's level is higher or additional +defense bonuses
Expand Down Expand Up @@ -3914,7 +3914,7 @@ float Unit::CalculateEffectiveMissChance(const Unit *victim, WeaponAttackType at
if (chance < 0.005f)
return 0.0f;
const bool ranged = (attType == RANGED_ATTACK);
const bool weapon = (!ability || ability->EquippedItemClass == ITEM_CLASS_WEAPON);
const bool weapon = (!ability || IsSpellUseWeaponSkill(ability));
// Check if dual wielding, add additional miss penalty - when mainhand has on next swing spell, offhand doesnt suffer penalty
if (!ability && !ranged && hasOffhandWeaponForAttack() && (!m_currentSpells[CURRENT_MELEE_SPELL] || !IsNextMeleeSwingSpell(m_currentSpells[CURRENT_MELEE_SPELL]->m_spellInfo)))
chance += 19.0f;
Expand Down
6 changes: 6 additions & 0 deletions src/game/Spells/SpellMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,12 @@ inline bool IsIgnoreRootSpell(SpellEntry const* spellInfo)
return false;
}

inline bool IsSpellUseWeaponSkill(SpellEntry const* spellInfo)
{
// note: this is not a mirror of client function - that function does not work for Bloodthirst edgecase
return spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED && spellInfo->HasAttribute(SPELL_ATTR_USES_RANGED_SLOT);
}

inline uint32 GetDispellMask(DispelType dispel)
{
// If dispell all
Expand Down

0 comments on commit 162cd3f

Please sign in to comment.