Skip to content

Commit ff5ce5c

Browse files
committed
Fix IsRangedAutoAttackSpell to test the autorepeat flag
The check tested Attributes bit 1 (RANGED), which every ranged ability sets -- so Aimed Shot and Multi-Shot wrongly counted as ranged auto-attacks. The two auto-repeat spells (Auto Shot, Shoot) are the ones with SPELL_ATTR_EX2_AUTOREPEAT_FLAG (AttributesEx2 bit 5, 0x20). Verified from Spell.dbc: Auto Shot (75) and Shoot (5019) carry Ex2 0x20; Aimed Shot (19434) and Multi-Shot (2643) set only RANGED, not the flag.
1 parent 47b6a66 commit ff5ce5c

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/spell/AutoAttack.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
// vs. on-next-swing abilities like Heroic Strike or Maul. We test
2020
// against the engine constant directly.
2121
//
22-
// Ranged — both vanilla ranged auto-attacks (`75` Auto Shot, `5019`
23-
// Shoot wand) set bit 1 of `Spell.dbc.Attributes` (the
24-
// `SPELL_ATTR_AUTO_REPEAT` flag at value `0x02`). Verified empirically
25-
// against the in-game cache: Attr `0x00050012` (Auto Shot) and
26-
// `0x00000012` (Shoot) share that bit; on-next-swing Heroic Strike
27-
// (`0x00050014`) and other ranged spells like Aimed Shot / Fireball do
28-
// NOT. The attribute check naturally extends to any future
22+
// Ranged — the two vanilla ranged auto-attacks (`75` Auto Shot, `5019`
23+
// Shoot wand) are exactly the spells carrying SPELL_ATTR_EX2_AUTOREPEAT_FLAG
24+
// (AttributesEx2 bit 5, `0x20`). Verified from Spell.dbc: Auto Shot and
25+
// Shoot have Ex2 `0x20`; the on-cast ranged abilities (Aimed Shot 19434,
26+
// Multi-Shot 2643) do NOT — they only set the generic RANGED bit
27+
// (Attributes bit 1), which is why an earlier RANGED test wrongly matched
28+
// them. The AUTOREPEAT flag is the exact signal and extends to any future
2929
// auto-repeating spell a private server might add.
3030

3131
#include "Lookup.h"
@@ -42,7 +42,7 @@ namespace Spell::AutoAttack {
4242
namespace {
4343

4444
constexpr int SPELL_AUTO_ATTACK = 6603;
45-
constexpr uint32_t SPELL_ATTR_AUTO_REPEAT = 0x00000002;
45+
constexpr uint32_t SPELL_ATTR_EX2_AUTOREPEAT_FLAG = 0x00000020;
4646

4747
bool IsMelee(int spellID) {
4848
return spellID == SPELL_AUTO_ATTACK;
@@ -56,9 +56,9 @@ bool IsRanged(int spellID) {
5656
static_cast<uint32_t>(spellID));
5757
if (rec == nullptr)
5858
return false;
59-
const uint32_t attr = *reinterpret_cast<const uint32_t *>(
60-
rec + Offsets::OFF_SPELL_RECORD_ATTRIBUTES);
61-
return (attr & SPELL_ATTR_AUTO_REPEAT) != 0;
59+
const uint32_t attrEx2 = *reinterpret_cast<const uint32_t *>(
60+
rec + Offsets::OFF_SPELL_RECORD_ATTRIBUTES_EX2);
61+
return (attrEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) != 0;
6262
}
6363

6464
int ReadSpellID(void *L) {

0 commit comments

Comments
 (0)