feat: show out-of-range red tint on macro action bar buttons

The out-of-range indicator (red tint) only applied to SPELL-type action
bar slots. Macro buttons like /cast Frostbolt never turned red even when
the target was out of range. Now resolves the macro's primary spell via
the cached lookup and checks its max range against the target distance,
giving the same visual feedback as regular spell buttons.
This commit is contained in:
Kelsi 2026-03-20 08:27:10 -07:00
parent 3b20485c79
commit 1d53c35ed7

View file

@ -8746,23 +8746,28 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
const bool onGCD = gameHandler.isGCDActive() && !onCooldown && !slot.isEmpty(); const bool onGCD = gameHandler.isGCDActive() && !onCooldown && !slot.isEmpty();
// Out-of-range check: red tint when a targeted spell cannot reach the current target. // Out-of-range check: red tint when a targeted spell cannot reach the current target.
// Only applies to SPELL slots with a known max range (>5 yd) and an active target. // Applies to SPELL and MACRO slots with a known max range (>5 yd) and an active target.
// Item range is checked below after barItemDef is populated. // Item range is checked below after barItemDef is populated.
bool outOfRange = false; bool outOfRange = false;
if (!slot.isEmpty() && slot.type == game::ActionBarSlot::SPELL && slot.id != 0 {
&& !onCooldown && gameHandler.hasTarget()) { uint32_t rangeCheckSpellId = 0;
uint32_t maxRange = spellbookScreen.getSpellMaxRange(slot.id, assetMgr); if (slot.type == game::ActionBarSlot::SPELL && slot.id != 0)
if (maxRange > 5) { // >5 yd = not melee/self rangeCheckSpellId = slot.id;
auto& em = gameHandler.getEntityManager(); else if (slot.type == game::ActionBarSlot::MACRO && slot.id != 0)
auto playerEnt = em.getEntity(gameHandler.getPlayerGuid()); rangeCheckSpellId = resolveMacroPrimarySpellId(slot.id, gameHandler);
auto targetEnt = em.getEntity(gameHandler.getTargetGuid()); if (rangeCheckSpellId != 0 && !onCooldown && gameHandler.hasTarget()) {
if (playerEnt && targetEnt) { uint32_t maxRange = spellbookScreen.getSpellMaxRange(rangeCheckSpellId, assetMgr);
float dx = playerEnt->getX() - targetEnt->getX(); if (maxRange > 5) {
float dy = playerEnt->getY() - targetEnt->getY(); auto& em = gameHandler.getEntityManager();
float dz = playerEnt->getZ() - targetEnt->getZ(); auto playerEnt = em.getEntity(gameHandler.getPlayerGuid());
float dist = std::sqrt(dx * dx + dy * dy + dz * dz); auto targetEnt = em.getEntity(gameHandler.getTargetGuid());
if (dist > static_cast<float>(maxRange)) if (playerEnt && targetEnt) {
outOfRange = true; float dx = playerEnt->getX() - targetEnt->getX();
float dy = playerEnt->getY() - targetEnt->getY();
float dz = playerEnt->getZ() - targetEnt->getZ();
if (std::sqrt(dx*dx + dy*dy + dz*dz) > static_cast<float>(maxRange))
outOfRange = true;
}
} }
} }
} }