From 797fea90ed23a08efea3715cc308de60c64c7c8b Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:32:01 -0500 Subject: [PATCH] fix(spell): Resolve the has-range gate with a null target, as ActionHasRange does PlayerVsUnit passed the real target to GetMinMaxRange (0x6E3480), which folds both units' combat reach into every non-melee range row. Self-range spells (Hearthstone, totems, professions) came back with max ~3yd, passed the gate, and IsSpellInRange / IsItemInRange answered false instead of nil past melee distance. The engine's ActionSlotHasRange (via ActionHasRange 0x4E75D0) always resolves with a null target; EngineHasRange now does the same. --- src/spell/Range.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/spell/Range.cpp b/src/spell/Range.cpp index 5fc8a2e7..13d34205 100644 --- a/src/spell/Range.cpp +++ b/src/spell/Range.cpp @@ -34,7 +34,11 @@ using GetMinMaxRange_t = void(__fastcall *)(void *caster, uint32_t spellID, void *target); // The engine's own has-range notion, mirroring `ActionHasRange` -// (`0x4E75D0`): either bound at or above the near-zero epsilon counts as +// (`0x4E75D0` → `ActionSlotHasRange`): resolve with a NULL target, then +// either bound at or above the near-zero epsilon counts as ranged. The +// null target is load-bearing: given a unit target, the resolver folds +// both units' combat reach into every non-melee row, so a self-range +// (0/0) spell like Hearthstone comes back with max ~3yd and reads as // ranged. The negated `<` (rather than `>=`) reproduces the engine's // `fcomp` + `test ah,5; jp` exactly — a NaN bound counts as ranged, // matching vanilla. Unlike the raw `SpellRange.dbc` read this replaces, @@ -51,10 +55,10 @@ void EngineMinMax(void *caster, int spellID, void *target, float &minRange, target); } -bool EngineHasRange(void *caster, int spellID, void *target) { +bool EngineHasRange(void *caster, int spellID) { float minRange; float maxRange; - EngineMinMax(caster, spellID, target, minRange, maxRange); + EngineMinMax(caster, spellID, nullptr, minRange, maxRange); const float epsilon = Game::Read( static_cast(Offsets::VAR_HAS_RANGE_EPSILON)); return !(std::fabs(minRange) < epsilon) || @@ -66,11 +70,8 @@ bool EngineHasRange(void *caster, int spellID, void *target) { bool SpellIDHasRange(int spellID) { if (spellID <= 0) return false; - // Null target: the engine falls back to the caster's current-target - // GUID (`[caster+0xC48]`), else the caster itself, for the reach fold. // A null caster zeroes both bounds, which reads as rangeless. - return EngineHasRange(Unit::Position::ResolveToken("player"), spellID, - nullptr); + return EngineHasRange(Unit::Position::ResolveToken("player"), spellID); } void CasterMinMax(void *caster, int spellID, float &minRange, float &maxRange) { @@ -90,7 +91,7 @@ int PlayerVsUnit(int spellID, const char *unitToken) { if (caster == nullptr || target == nullptr) return -1; // Rangeless spell (self buff, etc.) has no meaningful "in range" answer. - if (!EngineHasRange(caster, spellID, target)) + if (!EngineHasRange(caster, spellID)) return -1; // Guard positions before handing the objects to the engine core: