[Optimization] Optimize the judgment of attack targets

This commit is contained in:
yang
2024-05-29 15:50:26 +08:00
parent 3fec25599f
commit 07f31498d1

View File

@@ -45,10 +45,19 @@ Unit* RtiTargetValue::Calculate()
if (!guid) if (!guid)
return nullptr; return nullptr;
GuidVector attackers = context->GetValue<GuidVector >("attackers")->Get(); if (!bot->IsInCombat())
if (find(attackers.begin(), attackers.end(), guid) == attackers.end())
return nullptr; 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.
// GuidVector attackers = context->GetValue<GuidVector >("attackers")->Get();
// if (find(attackers.begin(), attackers.end(), guid) == attackers.end())
// return nullptr;
//
//////////////////////////////////////////////////////end: delete below check
Unit* unit = botAI->GetUnit(guid); Unit* unit = botAI->GetUnit(guid);
if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, unit), sPlayerbotAIConfig->sightDistance)) if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, unit), sPlayerbotAIConfig->sightDistance))
return nullptr; return nullptr;