-
Notifications
You must be signed in to change notification settings - Fork 373
Bot spell actions use actual DBC range instead of global spellDistance #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; }; | ||
|
|
@@ -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
|
||
|
|
||
| if (range > sPlayerbotAIConfig.spellDistance) | ||
| { | ||
| return NULL; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.