From 6eca140f8f461d8965367ab28f0f8ccdb284bb29 Mon Sep 17 00:00:00 2001 From: bo Date: Sat, 21 Mar 2026 16:25:44 -0500 Subject: [PATCH] spell target reach --- .../playerbot/strategy/actions/GenericSpellActions.h | 1 + .../playerbot/strategy/actions/ReachTargetActions.h | 12 +++++++++++- .../Bots/playerbot/strategy/values/ValueContext.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h index 34b290689..039e5e76c 100644 --- a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h +++ b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h @@ -97,6 +97,7 @@ namespace ai } else if (range > ATTACK_DISTANCE) { + context->GetValue("reach spell distance")->Set(range); return NextAction::merge( NextAction::array(0, new NextAction("reach spell"), NULL), Action::getPrerequisites()); } else diff --git a/src/modules/Bots/playerbot/strategy/actions/ReachTargetActions.h b/src/modules/Bots/playerbot/strategy/actions/ReachTargetActions.h index 426e72ec9..947aaccb5 100644 --- a/src/modules/Bots/playerbot/strategy/actions/ReachTargetActions.h +++ b/src/modules/Bots/playerbot/strategy/actions/ReachTargetActions.h @@ -52,6 +52,16 @@ namespace ai class ReachSpellAction : public ReachTargetAction { public: - ReachSpellAction(PlayerbotAI* ai, float distance = sPlayerbotAIConfig.spellDistance) : ReachTargetAction(ai, "reach spell", distance) {} + ReachSpellAction(PlayerbotAI* ai) : ReachTargetAction(ai, "reach spell", sPlayerbotAIConfig.spellDistance) {} + virtual bool Execute(Event event) + { + distance = AI_VALUE(float, "reach spell distance"); + return ReachTargetAction::Execute(event); + } + virtual bool isUseful() + { + distance = AI_VALUE(float, "reach spell distance"); + return ReachTargetAction::isUseful(); + } }; } diff --git a/src/modules/Bots/playerbot/strategy/values/ValueContext.h b/src/modules/Bots/playerbot/strategy/values/ValueContext.h index eae61e3df..853d25e4b 100644 --- a/src/modules/Bots/playerbot/strategy/values/ValueContext.h +++ b/src/modules/Bots/playerbot/strategy/values/ValueContext.h @@ -139,10 +139,12 @@ namespace ai creators["bag space"] = &ValueContext::bag_space; creators["enemy healer target"] = &ValueContext::enemy_healer_target; creators["item usage"] = &ValueContext::item_usage; + creators["reach spell distance"] = &ValueContext::reach_spell_distance; } private: static UntypedValue* item_usage(PlayerbotAI* ai) { return new ItemUsageValue(ai); } + static UntypedValue* reach_spell_distance(PlayerbotAI* ai) { return new ManualSetValue(ai, sPlayerbotAIConfig.spellDistance, "reach spell distance"); } static UntypedValue* mana_save_level(PlayerbotAI* ai) { return new ManaSaveLevelValue(ai); } static UntypedValue* invalid_target(PlayerbotAI* ai) { return new InvalidTargetValue(ai); } static UntypedValue* balance(PlayerbotAI* ai) { return new BalancePercentValue(ai); }