From 99716220934fc2b363c23ac61621740f4d84c0c2 Mon Sep 17 00:00:00 2001 From: Alex Dcnh <140754794+Wishmaster117@users.noreply.github.com> Date: Tue, 23 Dec 2025 19:42:29 +0000 Subject: [PATCH] Core - Fixe raid markers persists after target dead causes issue with bots running off (#1845) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes #1833 where bots could keep chasing a raid target icon (usually skull) across very large distances or even different maps after the mark was set. It replaces the previous attempt with a simpler design that keeps values generic and moves context logic into triggers/actions. Changes - RtiTargetValue now ignores RTI targets that are farther than sPlayerbotAIConfig->sightDistance from the bot or the master (same map only), while still using AttackersValue::IsValidTarget and LOS checks. - AttackersValue is reverted to its original behavior (no special RTI + IsInCombat logic). - RTI triggers only react to "rti target" in combat, as suggested in review (“that condition should be check in trigger…”). - AttackRtiTargetAction keeps a small local fallback: if "rti target" is null, it resolves the raid icon directly from the group so chat commands like “attack rti target” still work, including out of combat. Behavior - Bots no longer run across the world to chase a stale skull far away from the group. - When the group comes back near the marked mob (within sight distance), the skull is again used as a normal focus hint. - Automatic RTI behavior is limited to combat via triggers, while explicit chat commands still work out of combat. Testing - Marked a mob with skull, killed it, moved far away / changed zone, then let it respawn: bots did not chase it from afar. - In a normal dungeon/raid pack, bots still focus skull in combat. - Passing near a previously marked mob: bots only react once it is back within sight distance. --------- Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com> --- src/strategy/actions/ChooseTargetActions.cpp | 22 ++++++++++++++++---- src/strategy/triggers/RtiTriggers.cpp | 12 ++++++++++- src/strategy/values/RtiTargetValue.cpp | 10 +++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index f98360ff..ab533e71 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -10,6 +10,7 @@ #include "LootObjectStack.h" #include "NewRpgStrategy.h" #include "Playerbots.h" +#include "RtiTargetValue.h" #include "PossibleRpgTargetsValue.h" #include "PvpTriggers.h" #include "ServerFacade.h" @@ -87,9 +88,7 @@ bool DropTargetAction::Execute(Event event) { Spell const* spell = bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL); // Get the current spell being cast by the bot if (spell && spell->m_spellInfo->Id == 75) //Check spell is not nullptr before accessing m_spellInfo - { bot->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); // Interrupt Auto Shot - } } bot->AttackStop(); @@ -142,6 +141,23 @@ bool AttackRtiTargetAction::Execute(Event event) { Unit* rtiTarget = AI_VALUE(Unit*, "rti target"); + // Fallback: if the "rti target" value did not resolve a valid unit yet, + // try to resolve the raid icon directly from the group. + if (!rtiTarget) + { + if (Group* group = bot->GetGroup()) + { + std::string const rti = AI_VALUE(std::string, "rti"); + int32 const index = RtiTargetValue::GetRtiIndex(rti); + if (index >= 0) + { + ObjectGuid const guid = group->GetTargetIcon(index); + if (!guid.IsEmpty()) + rtiTarget = botAI->GetUnit(guid); + } + } + } + if (rtiTarget && rtiTarget->IsInWorld() && rtiTarget->GetMapId() == bot->GetMapId()) { botAI->GetAiObjectContext()->GetValue("prioritized targets")->Set({rtiTarget->GetGUID()}); @@ -153,9 +169,7 @@ bool AttackRtiTargetAction::Execute(Event event) } } else - { botAI->TellError("I dont see my rti attack target"); - } return false; } diff --git a/src/strategy/triggers/RtiTriggers.cpp b/src/strategy/triggers/RtiTriggers.cpp index bd83d09d..6158bc4d 100644 --- a/src/strategy/triggers/RtiTriggers.cpp +++ b/src/strategy/triggers/RtiTriggers.cpp @@ -7,4 +7,14 @@ #include "Playerbots.h" -bool NoRtiTrigger::IsActive() { return !AI_VALUE(Unit*, "rti target"); } +bool NoRtiTrigger::IsActive() +{ + // Do not auto-react to raid icons while out of combat. + // Out-of-combat RTI usage (explicit chat commands) is handled by chat triggers, + // not by this generic trigger. + if (!bot->IsInCombat()) + return false; + + Unit* target = AI_VALUE(Unit*, "rti target"); + return target != nullptr; +} diff --git a/src/strategy/values/RtiTargetValue.cpp b/src/strategy/values/RtiTargetValue.cpp index 040ce07b..205bcc3d 100644 --- a/src/strategy/values/RtiTargetValue.cpp +++ b/src/strategy/values/RtiTargetValue.cpp @@ -64,5 +64,15 @@ Unit* RtiTargetValue::Calculate() sPlayerbotAIConfig->sightDistance)) return nullptr; + // Also prevent chasing raid icon targets that are too far away from the master, + // even if they are technically visible to the bot. + if (Player* master = botAI->GetMaster()) + { + if (master->IsInWorld() && master->GetMapId() == unit->GetMapId() && + sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(master, unit), + sPlayerbotAIConfig->sightDistance)) + return nullptr; + } + return unit; }