Skip to content

Bot spell actions use actual DBC range instead of global spellDistance#268

Merged
billy1arm merged 1 commit intomangoszero:masterfrom
bozimmerman:bot_max_spell_range_tweek
Mar 9, 2026
Merged

Bot spell actions use actual DBC range instead of global spellDistance#268
billy1arm merged 1 commit intomangoszero:masterfrom
bozimmerman:bot_max_spell_range_tweek

Conversation

@bozimmerman
Copy link
Contributor

@bozimmerman bozimmerman commented Mar 8, 2026

This fixes an problem where the spell range stored in the DBC file was being ignored by bots in favor of a universal spellDistance value in the bot config. The spellDistance config would remain and be used only as a limit. Also ensures that bots run into melee when the range requires it.


This change is Reviewable

Looks up each spell's true max range from SpellRangeEntry at construction.
getPrerequisites() early-exits if already in range, avoiding movement when
unnecessary. spellDistance config remains a backstop for engagement distance.
Copilot AI review requested due to automatic review settings March 8, 2026 16:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies bot spell actions to use the actual spell range from DBC (game data) files instead of a global spellDistance configuration value. It also adds distance-aware logic to getPrerequisites() so bots avoid unnecessary movement when already in range.

Changes:

  • In the CastSpellAction constructor, the spell's DBC max range is looked up and used to set the range field instead of always using the config-based spellDistance.
  • In getPrerequisites(), a new early-return block checks if the bot is already within range and returns appropriate prerequisites (no movement for ranged, "reach melee" for melee spells).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +92
float currentDistance = AI_VALUE2(float, "distance", GetTargetName());

if (currentDistance <= range)
{
if (range > ATTACK_DISTANCE)
{
return Action::getPrerequisites();
}
else
{
return NextAction::merge(NextAction::array(0, new NextAction("reach melee"), NULL), Action::getPrerequisites());
}
}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "reach spell" action used in the existing fallback path (below this block, around line 100) always targets sPlayerbotAIConfig.spellDistance as its stopping distance (see ReachSpellAction in ReachTargetActions.h:55). With this PR, range is now set from DBC data and can be less than spellDistance (e.g., a 20-yard range spell when spellDistance defaults to 30). For spells where ATTACK_DISTANCE < range < spellDistance, the bot will use "reach spell" to move within spellDistance of the target, but the spell actually requires the bot to be within the smaller DBC range. The bot will stop too far away and isPossible() will fail, creating a situation where the bot never gets close enough to cast.

To fix this, either the "reach spell" action needs to be parameterized with the actual spell range, or the distance check and movement logic needs to account for the DBC range being smaller than spellDistance.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to say it, but this is actually a good point. That said, the behavior prior to the PR was even worse. This PR fixes the narrow problem of unnecessary movement, and I hope that improvement is good enough for now. I'll look into other ways of having each spell impact the reach distance individually.

@AppVeyorBot
Copy link

@billy1arm billy1arm merged commit df72862 into mangoszero:master Mar 9, 2026
11 of 12 checks passed
@bozimmerman bozimmerman deleted the bot_max_spell_range_tweek branch March 9, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants