[Tank target] Improve main tank target selection

This commit is contained in:
Yunfan Li
2024-09-26 20:00:09 +08:00
parent 0d9f2ee7ba
commit d1a744fca3

View File

@@ -73,6 +73,15 @@ public:
bool IsBetter(Unit* new_unit, Unit* old_unit)
{
Player* bot = botAI->GetBot();
// if group has multiple tanks, main tank just focus on the current target
Unit* currentTarget = botAI->GetAiObjectContext()->GetValue<Unit*>("current target")->Get();
if (currentTarget && botAI->IsMainTank(bot) && botAI->GetGroupTankNum(bot) > 1)
{
if (old_unit == currentTarget)
return false;
if (new_unit == currentTarget)
return true;
}
float new_threat = new_unit->GetThreatMgr().GetThreat(bot);
float old_threat = old_unit->GetThreatMgr().GetThreat(bot);
float new_dis = bot->GetDistance(new_unit);