From 844a0e36d2fead4a0d12f95a9b358fc99eda7943 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sat, 7 Oct 2023 19:29:55 +0800 Subject: [PATCH] fix rndbot stuck bug --- src/strategy/values/TankTargetValue.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/strategy/values/TankTargetValue.cpp b/src/strategy/values/TankTargetValue.cpp index 817dbd50..1adc6326 100644 --- a/src/strategy/values/TankTargetValue.cpp +++ b/src/strategy/values/TankTargetValue.cpp @@ -18,27 +18,31 @@ class FindTargetForTankStrategy : public FindNonCcTargetStrategy } Player* bot = botAI->GetBot(); float threat = threatMgr->GetThreat(bot); + float dist = creature->GetDistance(bot); if (!result) { - minThreat = threat; + minDistance = dist; result = creature; } // neglect if victim is main tank, or no victim (for untauntable target) if (threatMgr->getCurrentVictim()) { // float max_threat = threatMgr->GetThreat(threatMgr->getCurrentVictim()->getTarget()); Unit* victim = threatMgr->getCurrentVictim()->getTarget(); - if (victim && victim->ToPlayer() && botAI->IsMainTank(victim->ToPlayer())) { + if (victim && victim->ToPlayer() && botAI->IsTank(victim->ToPlayer())) { return; } } - if (minThreat >= threat) + if (minDistance >= dist || badResult) { - minThreat = threat; + badResult = false; + minDistance = dist; result = creature; } } protected: float minThreat; + float minDistance; + bool badResult = true; }; Unit* TankTargetValue::Calculate()