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; }