3 float arena_roundbased;
\r
5 .entity spawnqueue_next;
\r
6 .entity spawnqueue_prev;
\r
7 .float spawnqueue_in;
\r
8 entity spawnqueue_first;
\r
9 entity spawnqueue_last;
\r
12 float allowed_to_spawn;
\r
16 void PutObserverInServer();
\r
17 void PutClientInServer();
\r
18 void(entity e) ReturnFlag;
\r
19 void dom_controlpoint_setup();
\r
20 void onslaught_generator_reset();
\r
21 void onslaught_controlpoint_reset();
\r
22 void func_breakable_reset();
\r
23 void assault_objective_reset();
\r
24 void target_assault_roundend_reset();
\r
27 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
\r
28 * Sets the 'warmup' global variable.
\r
30 void reset_map(float dorespawn)
\r
35 if(g_arena && cvar("g_arena_warmup"))
\r
36 warmup = time + cvar("g_arena_warmup");
\r
38 warmup = time + cvar("g_ca_warmup");
\r
39 allowed_to_spawn = 1;
\r
42 lms_lowest_lives = 999;
\r
43 lms_next_place = player_count;
\r
45 race_ReadyRestart();
\r
47 for(self = world; (self = nextent(self)); )
\r
48 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
\r
57 self.team = self.team_saved;
\r
59 if(self.flags & FL_PROJECTILE) // remove any projectiles left
\r
61 stopsound(self, CHAN_PAIN);
\r
66 // Waypoints and assault start come LAST
\r
67 for(self = world; (self = nextent(self)); )
\r
68 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
\r
77 // Moving the player reset code here since the player-reset depends
\r
78 // on spawnpoint entities which have to be reset first --blub
\r
80 FOR_EACH_CLIENT(self) {
\r
81 if(self.flags & FL_CLIENT) // reset all players
\r
86 PutClientInServer();
\r
88 PutObserverInServer();
\r
90 else if(g_ca && self.caplayer) {
\r
91 self.classname = "player";
\r
92 PutClientInServer();
\r
97 only reset players if a restart countdown is active
\r
98 this can either be due to cvar sv_ready_restart_after_countdown having set
\r
99 restart_mapalreadyrestarted to 1 after the countdown ended or when
\r
100 sv_ready_restart_after_countdown is not used and countdown is still running
\r
102 if (restart_mapalreadyrestarted || (time < game_starttime))
\r
104 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
\r
105 if (self.classname == "player") {
\r
106 //PlayerScore_Clear(self);
\r
108 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
\r
109 self.killcount = 0;
\r
110 //stop the player from moving so that he stands still once he gets respawned
\r
111 self.velocity = '0 0 0';
\r
112 self.avelocity = '0 0 0';
\r
113 self.movement = '0 0 0';
\r
114 PutClientInServer();
\r
122 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
\r
124 if(g_arena || g_ca)
\r
125 if(champion && champion.classname == "player" && player_cnt > 1)
\r
126 UpdateFrags(champion, +1);
\r
131 void Spawnqueue_Insert(entity e)
\r
133 if(e.spawnqueue_in)
\r
135 dprint(strcat("Into queue: ", e.netname, "\n"));
\r
136 e.spawnqueue_in = TRUE;
\r
137 e.spawnqueue_prev = spawnqueue_last;
\r
138 e.spawnqueue_next = world;
\r
139 if(spawnqueue_last)
\r
140 spawnqueue_last.spawnqueue_next = e;
\r
141 spawnqueue_last = e;
\r
142 if(!spawnqueue_first)
\r
143 spawnqueue_first = e;
\r
146 void Spawnqueue_Remove(entity e)
\r
148 if(!e.spawnqueue_in)
\r
150 dprint(strcat("Out of queue: ", e.netname, "\n"));
\r
151 e.spawnqueue_in = FALSE;
\r
152 if(e == spawnqueue_first)
\r
153 spawnqueue_first = e.spawnqueue_next;
\r
154 if(e == spawnqueue_last)
\r
155 spawnqueue_last = e.spawnqueue_prev;
\r
156 if(e.spawnqueue_prev)
\r
157 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
\r
158 if(e.spawnqueue_next)
\r
159 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
\r
160 e.spawnqueue_next = world;
\r
161 e.spawnqueue_prev = world;
\r
164 void Spawnqueue_Unmark(entity e)
\r
169 numspawned = numspawned - 1;
\r
172 void Spawnqueue_Mark(entity e)
\r
177 numspawned = numspawned + 1;
\r
181 * If roundbased arena game mode is active, it centerprints the texts for the
\r
182 * player when player is waiting for the countdown to finish.
\r
183 * Blocks the players movement while countdown is active.
\r
184 * Unblocks the player once the countdown is over.
\r
186 * Called in PlayerPostThink()
\r
188 float roundStartTime_prev; // prevent networkspam
\r
189 void Arena_Warmup()
\r
194 if((!g_arena && !g_ca) || (g_arena && !arena_roundbased) || (time < game_starttime))
\r
197 f = floor(warmup - time + 1);
\r
199 allowed_to_spawn = 0;
\r
201 if(g_ca && (player_cnt < 2 || inWarmupStage))
\r
202 allowed_to_spawn = 1;
\r
205 if(time < warmup && !inWarmupStage)
\r
208 allowed_to_spawn = 1;
\r
209 if(champion && g_arena)
\r
210 msg = strcat("The Champion is ", champion.netname, "^7\n");
\r
211 //centerprint(self, strcat(msg, "The Champion is ", champion.netname, "^7\n"));
\r
213 if(f != roundStartTime_prev) {
\r
214 msg = strcat(msg, "Round will start in ", ftos(f),"\n");
\r
215 //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
\r
216 roundStartTime_prev = f;
\r
218 Announce("prepareforbattle");
\r
226 centerprint(self, msg);
\r
230 if(self.spawned && self.classname == "player"){}
\r
231 //self.movetype = MOVETYPE_NONE;
\r
233 self.velocity = '0 0 0';
\r
234 self.avelocity = '0 0 0';
\r
235 self.movement = '0 0 0';
\r
236 //self.fixangle = TRUE;
\r
240 else if(f > -1 && f != roundStartTime_prev)
\r
242 roundStartTime_prev = f;
\r
244 centerprint(self, "^1Begin!\n");
\r
245 Vore_Disconnect(); // undo vores that happened during warmup, which also prevents some issues
\r
250 FOR_EACH_CLIENT(self) {
\r
251 if (self.classname == "player")
\r
260 * This function finds out whether an arena round is over 1 player is left.
\r
261 * It determines the last player who's still alive and saves it's entity reference
\r
262 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
\r
264 * Gets called in StartFrame()
\r
266 void Spawnqueue_Check()
\r
268 if(time < warmup + 1 || inWarmupStage)
\r
272 // check the amount of spawned players in each team
\r
273 float redspawned, bluespawned;
\r
274 FOR_EACH_CLIENT(self) {
\r
275 if (self.classname == "player") {
\r
276 if (self.team == COLOR_TEAM1) redspawned += 1;
\r
277 else if (self.team == COLOR_TEAM2) bluespawned += 1;
\r
281 if(player_cnt < 2 && (redspawned && bluespawned)) {
\r
284 else if(player_cnt < 2) {
\r
285 FOR_EACH_CLIENT(self)
\r
286 if(self.classname == "player")
\r
287 centerprint(self, strcat("^1Need at least 2 players to play CA", "^7\n"));
\r
289 allowed_to_spawn = 1;
\r
292 else if(!next_round)
\r
293 if((redspawned && bluespawned == 0) || (bluespawned && redspawned == 0)) {
\r
294 next_round = time + 5;
\r
296 champion = find(world, classname, "player");
\r
297 string champion_team;
\r
298 if(champion.team == COLOR_TEAM1) {
\r
299 champion_team = "^1Red team";
\r
300 play2all("ctf/red_capture.wav");
\r
302 else if(champion.team == COLOR_TEAM2) {
\r
303 champion_team = "^4Blue team";
\r
304 play2all("ctf/blue_capture.wav");
\r
306 FOR_EACH_CLIENT(self) centerprint(self, strcat(champion_team, "^7 wins the round.", "^7\n"));
\r
307 else if(!redspawned && !bluespawned) {
\r
308 FOR_EACH_CLIENT(self) centerprint(self, strcat("^7Round tied.", "^7\n"));
\r
309 next_round = time + 5;
\r
313 if((next_round && next_round < time))
\r
319 //extend next_round if it isn't set yet and only 1 player is spawned
\r
322 next_round = time + 3;
\r
324 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
\r
328 if(arena_roundbased)
\r
330 champion = find(world, classname, "player");
\r
331 while(champion && champion.deadflag)
\r
332 champion = find(champion, classname, "player");
\r
336 while(numspawned < maxspawned && spawnqueue_first)
\r
338 self = spawnqueue_first;
\r
340 bprint ("^4", self.netname, "^4 is the next challenger\n");
\r
342 Spawnqueue_Remove(self);
\r
343 Spawnqueue_Mark(self);
\r
345 self.classname = "player";
\r
346 PutClientInServer();
\r