Better too close distance calculation

This commit is contained in:
Yunfan Li
2023-12-24 11:54:34 +08:00
parent f5f91c808f
commit 98c87300b0
3 changed files with 7 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ It's essential to note that there is still a significant amount of work to be do
For enhanced control over the bots and to simplify command usage, you can also make use of our addon: [Unbot Addon](https://github.com/liyunfan1223/unbot-addon). Currently, this addon offers better support only for Simplified Chinese client. For enhanced control over the bots and to simplify command usage, you can also make use of our addon: [Unbot Addon](https://github.com/liyunfan1223/unbot-addon). Currently, this addon offers better support only for Simplified Chinese client.
## FAQ (Frequently Asked Questions) ## Frequently Asked Questions
**Why won't my bot cast spells?** **Why won't my bot cast spells?**

View File

@@ -79,7 +79,6 @@ void GenericHunterStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
{ {
CombatStrategy::InitTriggers(triggers); CombatStrategy::InitTriggers(triggers);
// triggers.push_back(new TriggerNode("enemy too close for auto shot", NextAction::array(0, new NextAction("switch to melee", ACTION_HIGH), nullptr)));
triggers.push_back(new TriggerNode("enemy is close", triggers.push_back(new TriggerNode("enemy is close",
NextAction::array(0, NextAction::array(0,
new NextAction("wing clip", ACTION_HIGH + 1), new NextAction("wing clip", ACTION_HIGH + 1),

View File

@@ -4,6 +4,7 @@
#include "RangeTriggers.h" #include "RangeTriggers.h"
#include "MoveSplineInit.h" #include "MoveSplineInit.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "ServerFacade.h" #include "ServerFacade.h"
@@ -17,7 +18,7 @@ bool EnemyTooCloseForSpellTrigger::IsActive()
Unit* target = AI_VALUE(Unit*, "current target"); Unit* target = AI_VALUE(Unit*, "current target");
return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) &&
target->GetObjectSize() <= 10.0f && target->GetObjectSize() <= 10.0f &&
AI_VALUE2(float, "distance", "current target") <= sPlayerbotAIConfig->tooCloseDistance; target->IsWithinCombatRange(bot, MIN_MELEE_REACH);
// Unit* target = AI_VALUE(Unit*, "current target"); // Unit* target = AI_VALUE(Unit*, "current target");
// if (!target) { // if (!target) {
// return false; // return false;
@@ -79,7 +80,9 @@ bool EnemyTooCloseForAutoShotTrigger::IsActive()
bool EnemyTooCloseForShootTrigger::IsActive() bool EnemyTooCloseForShootTrigger::IsActive()
{ {
Unit* target = AI_VALUE(Unit*, "current target"); Unit* target = AI_VALUE(Unit*, "current target");
return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && AI_VALUE2(float, "distance", "current target") <= sPlayerbotAIConfig->shootDistance; // target->IsWithinCombatRange()
return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && target->IsWithinCombatRange(bot, MIN_MELEE_REACH);
// Unit* target = AI_VALUE(Unit*, "current target"); // Unit* target = AI_VALUE(Unit*, "current target");
// if (!target) // if (!target)