From 437f816b15e99be828ac69288e7586506302a726 Mon Sep 17 00:00:00 2001 From: kadeshar Date: Tue, 3 Dec 2024 10:59:11 +0100 Subject: [PATCH] - fixed attack rti target action (#758) --- src/strategy/actions/ChooseTargetActions.cpp | 32 +++++++++++++++++++- src/strategy/actions/ChooseTargetActions.h | 2 ++ src/strategy/values/RtiTargetValue.cpp | 5 +-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index c06f675d..9d94c2cf 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -10,8 +10,8 @@ #include "LootObjectStack.h" #include "Playerbots.h" #include "PossibleRpgTargetsValue.h" -#include "ServerFacade.h" #include "PvpTriggers.h" +#include "ServerFacade.h" bool AttackEnemyPlayerAction::isUseful() { @@ -129,3 +129,33 @@ bool DpsAssistAction::isUseful() return true; } + +bool AttackRtiTargetAction::Execute(Event event) +{ + Unit* rtiTarget = AI_VALUE(Unit*, "rti target"); + + if (rtiTarget && rtiTarget->IsInWorld() && rtiTarget->GetMapId() == bot->GetMapId()) + { + botAI->GetAiObjectContext()->GetValue("prioritized targets")->Set({rtiTarget->GetGUID()}); + bool result = Attack(botAI->GetUnit(rtiTarget->GetGUID())); + if (result) + { + context->GetValue("pull target")->Set(rtiTarget->GetGUID()); + return true; + } + } + else + { + botAI->TellError("I dont see my rti attack target"); + } + + return false; +} + +bool AttackRtiTargetAction::isUseful() +{ + if (botAI->ContainsStrategy(STRATEGY_TYPE_HEAL)) + return false; + + return true; +} diff --git a/src/strategy/actions/ChooseTargetActions.h b/src/strategy/actions/ChooseTargetActions.h index 6b801a72..38307e09 100644 --- a/src/strategy/actions/ChooseTargetActions.h +++ b/src/strategy/actions/ChooseTargetActions.h @@ -69,6 +69,8 @@ public: AttackRtiTargetAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack rti target") {} std::string const GetTargetName() override { return "rti target"; } + bool Execute(Event event) override; + bool isUseful() override; }; class AttackEnemyFlagCarrierAction : public AttackAction diff --git a/src/strategy/values/RtiTargetValue.cpp b/src/strategy/values/RtiTargetValue.cpp index 99279f9d..6ce8d1d0 100644 --- a/src/strategy/values/RtiTargetValue.cpp +++ b/src/strategy/values/RtiTargetValue.cpp @@ -48,9 +48,6 @@ Unit* RtiTargetValue::Calculate() if (!guid) return nullptr; - if (!bot->IsInCombat()) - return nullptr; - //////////////////////////////////////////////////////begin: delete below check // Some units that need to be killed in battle are not on the list of attackers, // such as the Kor'kron Battle-Mage in Icecrown Citadel. @@ -62,7 +59,7 @@ Unit* RtiTargetValue::Calculate() //////////////////////////////////////////////////////end: delete below check Unit* unit = botAI->GetUnit(guid); - if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || !AttackersValue::IsValidTarget(unit, bot) || + if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || !AttackersValue::IsValidTarget(unit, bot) || sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, unit), sPlayerbotAIConfig->sightDistance)) return nullptr;