This commit is contained in:
aozhiwei 2020-06-05 10:15:24 +08:00
parent 223b7fccce
commit 1ad7610ce7

View File

@ -262,23 +262,22 @@ void AndroidAI::UpdateNewBieRoomLogic()
} }
}); });
} else { } else {
std::vector<Human*> alive_humans;
hum->room->TouchHumanList hum->room->TouchHumanList
( (
a8::XParams(), a8::XParams(),
[hum, &alive_humans] (Human* huma, a8::XParams& param) [hum, &target] (Human* huma, a8::XParams& param)
{ {
if (!huma->dead && if (!huma->dead &&
huma->IsAndroid() && huma->IsAndroid() &&
hum->team_id != huma->team_id && hum->team_id != huma->team_id &&
!a8::HasBitFlag(huma->status, HS_Disable)) { !a8::HasBitFlag(huma->status, HS_Disable)) {
alive_humans.push_back(huma); if (hum->GetPos().ManhattanDistance(huma->GetPos()) <
hum->GetPos().ManhattanDistance(target->GetPos())) {
target = huma;
}
} }
return true; return true;
}); });
if (!alive_humans.empty()) {
target = alive_humans[rand() % alive_humans.size()];
}
} }
last_target_ = target; last_target_ = target;
} }