fix rndbot stuck bug

This commit is contained in:
Yunfan Li
2023-10-07 19:29:55 +08:00
parent d492746d3b
commit 844a0e36d2

View File

@@ -18,27 +18,31 @@ class FindTargetForTankStrategy : public FindNonCcTargetStrategy
} }
Player* bot = botAI->GetBot(); Player* bot = botAI->GetBot();
float threat = threatMgr->GetThreat(bot); float threat = threatMgr->GetThreat(bot);
float dist = creature->GetDistance(bot);
if (!result) { if (!result) {
minThreat = threat; minDistance = dist;
result = creature; result = creature;
} }
// neglect if victim is main tank, or no victim (for untauntable target) // neglect if victim is main tank, or no victim (for untauntable target)
if (threatMgr->getCurrentVictim()) { if (threatMgr->getCurrentVictim()) {
// float max_threat = threatMgr->GetThreat(threatMgr->getCurrentVictim()->getTarget()); // float max_threat = threatMgr->GetThreat(threatMgr->getCurrentVictim()->getTarget());
Unit* victim = 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; return;
} }
} }
if (minThreat >= threat) if (minDistance >= dist || badResult)
{ {
minThreat = threat; badResult = false;
minDistance = dist;
result = creature; result = creature;
} }
} }
protected: protected:
float minThreat; float minThreat;
float minDistance;
bool badResult = true;
}; };
Unit* TankTargetValue::Calculate() Unit* TankTargetValue::Calculate()