Entity_FindClosest: Don't return any entity of class "player" if their health is equal or below 0.

This commit is contained in:
Marco Cawthorne 2022-06-08 17:35:56 -07:00
parent e947e35cd6
commit 80099317cb
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 5 additions and 1 deletions

View File

@ -62,6 +62,10 @@ entity Entity_FindClosest(entity target, string cname) {
bestdist = 9999999;
for (entity e = world; (e = find(e, classname, cname));) {
/* hack: don't ever return dead players. they're invisible. */
if (cname == "player" && e.health <= 0)
continue;
dist = vlen(target.origin - e.origin);
if (dist < bestdist) {
@ -110,4 +114,4 @@ entity Entity_SelectRandom(string cname)
/* we should have returned something valid now */
return spot;
}
}