}
}
+
+entity eliminatedPlayers;
+.float(entity) isEliminated;
+float EliminatedPlayers_SendEntity(entity to, float sendflags)
+{
+ float i, f, b;
+ entity e;
+ WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
+ WriteByte(MSG_ENTITY, sendflags);
+
+ if(sendflags & 1)
+ {
+ for(i = 1; i <= maxclients; i += 8)
+ {
+ for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
+ {
+ if(eliminatedPlayers.isEliminated(e))
+ f |= b;
+ }
+ WriteByte(MSG_ENTITY, f);
+ }
+ }
+
+ return TRUE;
+}
+
+void EliminatedPlayers_Init(float(entity) isEliminated_func)
+{
+ if(eliminatedPlayers)
+ {
+ backtrace("Can't spawn eliminatedPlayers again!");
+ return;
+ }
+ Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+ eliminatedPlayers.isEliminated = isEliminated_func;
+}
+
+
void adaptor_think2touch()
{
entity o;
return 0;
}
-float EliminatedPlayers_SendEntity(entity to, float sendflags)
+float ca_isEliminated(entity e)
{
- float i, f, b;
- entity e;
- WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
- WriteByte(MSG_ENTITY, sendflags);
-
- if(sendflags & 1)
- {
- for(i = 1; i <= maxclients; i += 8)
- {
- for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
- {
- if(e.caplayer == 0.5 || (e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER)))
- f |= b;
- }
- WriteByte(MSG_ENTITY, f);
- }
- }
-
- return TRUE;
-}
-
-void EliminatedPlayers_Init()
-{
- Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+ if(e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER))
+ return TRUE;
+ if(e.caplayer == 0.5)
+ return TRUE;
+ return FALSE;
}
-
MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
{
self.caplayer = 1;
addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
- EliminatedPlayers_Init();
+ EliminatedPlayers_Init(ca_isEliminated);
}
MUTATOR_DEFINITION(gamemode_ca)