Make bots stop attacking player after disconnect

Bots did not notice player disconnected, so they kept attacking
the last known position.

Checking if entity is valid in BotEntityVisible might fix other
similar issues too.
This commit is contained in:
Zack Middleton 2017-06-07 21:11:50 -05:00
parent 9aae0948ab
commit c99281a0da

View file

@ -2830,8 +2830,12 @@ float BotEntityVisible(int viewer, vec3_t eye, vec3_t viewangles, float fov, int
aas_entityinfo_t entinfo; aas_entityinfo_t entinfo;
vec3_t dir, entangles, start, end, middle; vec3_t dir, entangles, start, end, middle;
//calculate middle of bounding box
BotEntityInfo(ent, &entinfo); BotEntityInfo(ent, &entinfo);
if (!entinfo.valid) {
return 0;
}
//calculate middle of bounding box
VectorAdd(entinfo.mins, entinfo.maxs, middle); VectorAdd(entinfo.mins, entinfo.maxs, middle);
VectorScale(middle, 0.5, middle); VectorScale(middle, 0.5, middle);
VectorAdd(entinfo.origin, middle, middle); VectorAdd(entinfo.origin, middle, middle);