This commit is contained in:
aozhiwei 2023-04-02 14:19:09 +08:00
parent 4cfa4fb46e
commit 996c9316f6

View File

@ -3021,9 +3021,10 @@ std::shared_ptr<std::set<int>> Creature::CalcReporterList(const mt::Equip* weapo
case IS_RPG: case IS_RPG:
{ {
float nearest_distance = FLT_MAX; float nearest_distance = FLT_MAX;
Creature* nearest_hum = nullptr;
TraverseCreatures TraverseCreatures
( (
[] (Creature*c, bool& stop) [nearest_distance, nearest_hum] (Creature*c, bool& stop) mutable
{ {
if (!c->IsHuman()) { if (!c->IsHuman()) {
return; return;
@ -3034,6 +3035,15 @@ std::shared_ptr<std::set<int>> Creature::CalcReporterList(const mt::Equip* weapo
if (c->dead) { if (c->dead) {
return; return;
} }
float distance = std::fabs(c->GetPos().GetX() - c->GetPos().GetX()) + std::fabs(c->GetPos().GetZ() - c->GetPos().GetZ());
if (c->IsPlayer()) {
if (c->AsHuman()->socket_handle) {
if (distance < nearest_distance) {
nearest_distance = distance;
nearest_hum = c;
}
}
}
}); });
} }
break; break;