This commit is contained in:
aozhiwei 2021-08-25 13:11:39 +08:00
parent 6156cbd243
commit 949a89eb0e

View File

@ -923,12 +923,21 @@ Human* Room::GetWatchWarTarget(Human* hum)
return member;
}
}
std::vector<Human*> players;
std::vector<Human*> humans;
for (auto& pair : human_hash_) {
if (pair.first != hum->GetUniId() && !pair.second->dead) {
humans.push_back(pair.second);
if (pair.second->IsPlayer()) {
players.push_back(pair.second);
} else {
humans.push_back(pair.second);
}
}
}
if (!players.empty()) {
Human* target = players[rand() % players.size()];
return target;
}
if (!humans.empty()) {
Human* target = humans[rand() % humans.size()];
return target;