This commit is contained in:
aozhiwei 2021-09-18 08:48:44 +00:00
parent 5806ccc629
commit c97f7ab12c

View File

@ -889,16 +889,14 @@ Human* Room::GetWatchWarTarget(Human* hum)
target = players[rand() % players.size()];
} else if (!humans.empty()) {
target = humans[rand() % humans.size()];
#ifdef DEBUG
#ifdef DEBUG1
{
target = humans[0];
for (auto h : humans) {
if (target != h) {
if (target->GetPos().Distance(hum->GetPos()) > h->GetPos().Distance(hum->GetPos())) {
target = h;
}
}
}
std::sort(humans.begin(), humans.end(),
[hum] (Human* a, Human *b) -> bool
{
return (hum->GetPos()-a->GetPos()).Norm() < (hum->GetPos()-b->GetPos()).Norm();
});
target = humans[rand() % std::min(humans.size(), (size_t)3)];
}
#endif
}