Open darkshade9 opened 1 year ago
The latter condition may not work in some cases since I think there are cases in vanilla where spectators have 100 health... I think, at least. It's also going to be highly dependent on the mod in question.
Also, pers.spectator is their wanted spectator status, not their current spectator status.
The filter I used in Quake II re-release for the trigger_coop_relay
is such:
inline bool trigger_coop_relay_filter(edict_t *player)
{
return (player->health <= 0 || player->deadflag || player->movetype == MOVETYPE_NOCLIP ||
player->client->resp.spectator || player->s.modelindex != MODELINDEX_PLAYER);
}
Would this cover 99% of cases as a bit of a syntactic sugar shortener?
#define IS_ALIVE(ent) ((ent)->solid != SOLID_NOT && (ent)->deadflag == false)
!IS_ALIVE(ent)
would mean they are both SOLID_NOT
and deadflag
is true
I think so but I can't say for sure; the modelindex one will also allow it to avoid catching gibs and spectators.
Perhaps not necessarily an extension, but a potentially useful macro to reduce the toil of checking all of the constraints around whether a player is alive or not, sharing this to potentially incorporate into mods or extensions.
#define IS_ALIVE(ent) (((ent)->solid != SOLID_NOT && (ent)->deadflag == false) || (ent)->health > 0 || (ent)->client->pers.spectator == false)
This should check if
entity
:deadflag
isfalse
ORhealth
is more than0
ORspectator
We could remove some constraints here, and just go for simply
(ent)-> solid != SOLID_NOT && (ent)->deadflag == false
for simplicity's sake?