Skip to content

Commit

Permalink
Aura: Adjust masked SPELL_AURA_MOD_HIT_CHANCE applying to wrong weapo…
Browse files Browse the repository at this point in the history
…n types

Only designation exists to melee vs ranged so not adding redundant main hand vs offhand granularity
  • Loading branch information
killerwife committed Nov 26, 2023
1 parent d2d9ec7 commit 517473c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10484,9 +10484,14 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
ApplyEquipCooldown(pItem);

if (slot == EQUIPMENT_SLOT_MAINHAND)
{
UpdateExpertise(BASE_ATTACK);
UpdateMeleeHitChances();
}
else if (slot == EQUIPMENT_SLOT_OFFHAND)
UpdateExpertise(OFF_ATTACK);
else if (slot == EQUIPMENT_SLOT_RANGED)
UpdateRangedHitChances();
}
else
{
Expand Down
30 changes: 28 additions & 2 deletions src/game/Entities/StatSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,39 @@ void Player::UpdateSpellCritChance(uint32 school)

void Player::UpdateMeleeHitChances()
{
m_modMeleeHitChance = GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
int32 meleeHitChance = 0;
Item* weapon = GetWeaponForAttack(BASE_ATTACK);

AuraList const& hitAura = GetAurasByType(SPELL_AURA_MOD_HIT_CHANCE);
for (auto hitAura : hitAura)
{
// item neutral spell
if (hitAura->GetSpellProto()->EquippedItemClass == -1)
meleeHitChance += hitAura->GetModifier()->m_amount;
// item dependent spell
else if (weapon && weapon->IsFitToSpellRequirements(hitAura->GetSpellProto()))
meleeHitChance += hitAura->GetModifier()->m_amount;
}
m_modMeleeHitChance = meleeHitChance;
m_modMeleeHitChance += GetRatingBonusValue(CR_HIT_MELEE);
}

void Player::UpdateRangedHitChances()
{
m_modRangedHitChance = GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
int32 rangedHitChance = 0;
Item* weapon = GetWeaponForAttack(RANGED_ATTACK);

AuraList const& hitAura = GetAurasByType(SPELL_AURA_MOD_HIT_CHANCE);
for (auto hitAura : hitAura)
{
// item neutral spell
if (hitAura->GetSpellProto()->EquippedItemClass == -1)
rangedHitChance += hitAura->GetModifier()->m_amount;
// item dependent spell
else if (weapon && weapon->IsFitToSpellRequirements(hitAura->GetSpellProto()))
rangedHitChance += hitAura->GetModifier()->m_amount;
}
m_modMeleeHitChance = rangedHitChance;
m_modRangedHitChance += GetRatingBonusValue(CR_HIT_RANGED);
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/Spells/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5863,10 +5863,10 @@ void Aura::HandleModHitChance(bool apply, bool /*Real*/)
{
Unit* target = GetTarget();

if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
((Player*)target)->UpdateMeleeHitChances();
((Player*)target)->UpdateRangedHitChances();
static_cast<Player*>(target)->UpdateMeleeHitChances();
static_cast<Player*>(target)->UpdateRangedHitChances();
}
else
{
Expand Down

0 comments on commit 517473c

Please sign in to comment.