Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ namespace ai
range(sPlayerbotAIConfig.spellDistance)
{
this->spell = spell;
// Clamp range to actual spell's min/max range from DBC
uint32 spellId = AI_VALUE2(uint32, "spell id", spell);
if (spellId)
{
const SpellEntry* pSpellInfo = sSpellStore.LookupEntry(spellId);
if (pSpellInfo)
{
SpellRangeEntry const* spellRange = sSpellRangeStore.LookupEntry(pSpellInfo->rangeIndex);
if (spellRange)
{
float actualMaxRange = GetSpellMaxRange(spellRange);
if (actualMaxRange > 0) // Only clamp if spell has a defined range
range = actualMaxRange;
}
}
}
}

virtual string GetTargetName() { return "current target"; };
Expand All @@ -61,6 +77,20 @@ namespace ai

virtual NextAction** getPrerequisites()
{
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());
}
}
Comment on lines +80 to +92
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.


if (range > sPlayerbotAIConfig.spellDistance)
{
return NULL;
Expand Down
Loading