Skip to content

Commit

Permalink
Spell/Wand: Make wands use weapon skill for hit and crit chance calc
Browse files Browse the repository at this point in the history
TODO: Confirm whether wanding hit shares die with resist in vanilla and tbc or separate die
  • Loading branch information
killerwife committed Sep 24, 2023
1 parent 9767be3 commit fcc3019
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,7 @@ float Unit::GetMissChance(const SpellEntry* entry, SpellSchoolMask schoolMask) c
if (!entry)
return 0.0f;

if (entry->HasAttribute(SPELL_ATTR_EX5_ADD_MELEE_HIT_RATING))
if (entry->HasAttribute(SPELL_ATTR_EX5_ADD_MELEE_HIT_RATING) || entry->HasAttribute(SPELL_ATTR_EX3_NORMAL_RANGED_ATTACK))
chance += GetMissChance(GetWeaponAttackType(entry));
else
{
Expand Down Expand Up @@ -3976,12 +3976,10 @@ float Unit::CalculateSpellCritChance(const Unit* victim, SpellSchoolMask schoolM

float chance = 0.0f;

switch (spellInfo->DmgClass)
{
case SPELL_DAMAGE_CLASS_MELEE:
case SPELL_DAMAGE_CLASS_RANGED:
return CalculateEffectiveCritChance(victim, GetWeaponAttackType(spellInfo), spellInfo);
}
// wands are spell attacks but qualify for ranged crit calculation
if (spellInfo->HasAttribute(SPELL_ATTR_EX3_NORMAL_RANGED_ATTACK) || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)
return CalculateEffectiveCritChance(victim, GetWeaponAttackType(spellInfo), spellInfo);

chance += GetCritChance(spellInfo, schoolMask);
// Own chance appears to be zero / below zero / unmeaningful for some reason (debuffs?): skip calculation, unit is incapable
if (chance < 0.005f)
Expand All @@ -4006,12 +4004,8 @@ float Unit::CalculateSpellMissChance(const Unit* victim, SpellSchoolMask schoolM
float chance = 0.0f;
const float minimum = 1.0f; // Pre-WotLK: unavoidable spell miss is at least 1%

switch (spell->DmgClass)
{
case SPELL_DAMAGE_CLASS_MELEE:
case SPELL_DAMAGE_CLASS_RANGED:
return CalculateEffectiveMissChance(victim, GetWeaponAttackType(spell), spell);
}
if (spell->HasAttribute(SPELL_ATTR_EX3_NORMAL_RANGED_ATTACK) || spell->DmgClass == SPELL_DAMAGE_CLASS_MELEE || spell->DmgClass == SPELL_DAMAGE_CLASS_RANGED)
return CalculateEffectiveMissChance(victim, GetWeaponAttackType(spell), spell);

chance += victim->GetMissChance(spell, schoolMask);
// Victim's own chance appears to be zero / below zero / unmeaningful for some reason (debuffs?): skip calculation, unit can't be missed
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/SpellMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ WeaponAttackType GetWeaponAttackType(SpellEntry const* spellInfo)
default:
{
// Wands
if (spellInfo->HasAttribute(SPELL_ATTR_EX2_AUTO_REPEAT))
if (spellInfo->HasAttribute(SPELL_ATTR_EX3_NORMAL_RANGED_ATTACK))
return RANGED_ATTACK;
if (spellInfo->HasAttribute(SPELL_ATTR_EX3_REQUIRES_OFFHAND_WEAPON))
return OFF_ATTACK;
Expand Down

0 comments on commit fcc3019

Please sign in to comment.