3 float arena_roundbased;
5 .entity spawnqueue_next;
6 .entity spawnqueue_prev;
8 entity spawnqueue_first;
9 entity spawnqueue_last;
13 void PutObserverInServer();
14 void PutClientInServer();
19 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
20 * Sets the 'warmup' global variable.
22 void reset_map(float dorespawn)
27 if(time <= game_starttime && round_handler_IsActive())
28 round_handler_Reset(game_starttime + 1);
32 warmup = max(time, game_starttime);
33 if(autocvar_g_arena_warmup > 0)
34 warmup += autocvar_g_arena_warmup;
36 else if(g_race || g_cts)
38 else MUTATOR_CALLHOOK(reset_map_global);
40 lms_lowest_lives = 999;
41 lms_next_place = player_count;
43 for(self = world; (self = nextent(self)); )
44 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
53 self.team = self.team_saved;
55 if(self.flags & FL_PROJECTILE) // remove any projectiles left
59 // Waypoints and assault start come LAST
60 for(self = world; (self = nextent(self)); )
61 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
70 // Moving the player reset code here since the player-reset depends
71 // on spawnpoint entities which have to be reset first --blub
73 if(!MUTATOR_CALLHOOK(reset_map_players))
74 FOR_EACH_CLIENT(self) {
75 if(self.flags & FL_CLIENT) // reset all players
82 PutObserverInServer();
87 only reset players if a restart countdown is active
88 this can either be due to cvar sv_ready_restart_after_countdown having set
89 restart_mapalreadyrestarted to 1 after the countdown ended or when
90 sv_ready_restart_after_countdown is not used and countdown is still running
92 if (restart_mapalreadyrestarted || (time < game_starttime))
94 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
95 if (self.classname == "player") {
96 //PlayerScore_Clear(self);
98 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
100 //stop the player from moving so that he stands still once he gets respawned
101 self.velocity = '0 0 0';
102 self.avelocity = '0 0 0';
103 self.movement = '0 0 0';
112 kh_Controller_SetThink_NoMsg(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), kh_StartRound);
115 if(champion && champion.classname == "player" && player_count > 1)
116 UpdateFrags(champion, +1);
121 void Spawnqueue_Insert(entity e)
125 dprint(strcat("Into queue: ", e.netname, "\n"));
126 e.spawnqueue_in = TRUE;
127 e.spawnqueue_prev = spawnqueue_last;
128 e.spawnqueue_next = world;
130 spawnqueue_last.spawnqueue_next = e;
132 if(!spawnqueue_first)
133 spawnqueue_first = e;
136 void Spawnqueue_Remove(entity e)
140 dprint(strcat("Out of queue: ", e.netname, "\n"));
141 e.spawnqueue_in = FALSE;
142 if(e == spawnqueue_first)
143 spawnqueue_first = e.spawnqueue_next;
144 if(e == spawnqueue_last)
145 spawnqueue_last = e.spawnqueue_prev;
146 if(e.spawnqueue_prev)
147 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
148 if(e.spawnqueue_next)
149 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
150 e.spawnqueue_next = world;
151 e.spawnqueue_prev = world;
154 void Spawnqueue_Unmark(entity e)
159 numspawned = numspawned - 1;
162 void Spawnqueue_Mark(entity e)
167 numspawned = numspawned + 1;
171 * If roundbased arena game mode is active, it centerprints the texts for the
172 * player when player is waiting for the countdown to finish.
173 * Blocks the players movement while countdown is active.
174 * Unblocks the player once the countdown is over.
176 * Called in StartFrame()
178 float roundStartTime_prev; // prevent networkspam
188 FOR_EACH_REALCLIENT(e)
189 centerprint(e, strcat("The Champion is ", champion.netname));
194 if(time < game_starttime)
197 f = ceil(warmup - time);
199 if(time < warmup && !inWarmupStage)
203 FOR_EACH_REALCLIENT(e)
204 centerprint(e, strcat("The Champion is ", champion.netname));
207 if(f != roundStartTime_prev) {
208 roundStartTime_prev = f;
211 Announce("prepareforbattle");
219 FOR_EACH_REALCLIENT(e)
220 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
225 if(e.spawned && e.classname == "player")
226 e.player_blocked = 1;
229 else if(f > -1 && f != roundStartTime_prev && !inWarmupStage)
231 roundStartTime_prev = f;
234 FOR_EACH_REALCLIENT(e)
235 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
240 e.player_blocked = 0;
244 // clear champion to avoid centerprinting again the champion msg
250 * This function finds out whether an arena round is over 1 player is left.
251 * It determines the last player who's still alive and saves it's entity reference
252 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
254 * Gets called in StartFrame()
256 void Spawnqueue_Check()
258 if(time < warmup + 1 || inWarmupStage || intermission_running)
261 //extend next_round if it isn't set yet and only 1 player is spawned
264 next_round = time + 3;
266 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
272 champion = find(world, classname, "player");
273 while(champion && champion.deadflag)
274 champion = find(champion, classname, "player");
278 while(numspawned < maxspawned && spawnqueue_first)
280 self = spawnqueue_first;
282 bprint ("^4", self.netname, "^4 is the next challenger\n");
284 Spawnqueue_Remove(self);
285 Spawnqueue_Mark(self);
287 self.classname = "player";