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();
15 void(entity e) ReturnFlag;
16 void dom_controlpoint_setup();
17 void onslaught_generator_reset();
18 void onslaught_controlpoint_reset();
19 void func_breakable_reset();
20 void assault_objective_reset();
21 void target_assault_roundend_reset();
24 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
25 * Sets the 'warmup' global variable.
27 void reset_map(float norespawn)
33 if(cvar("g_arena_warmup"))
34 warmup = time + cvar("g_arena_warmup");
36 lms_lowest_lives = 999;
37 lms_next_place = player_count;
41 for(self = world; (self = nextent(self)); )
42 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
51 self.team = self.team_saved;
53 if(self.flags & FL_PROJECTILE) // remove any projectiles left
55 stopsound(self, CHAN_PAIN);
60 // Waypoints and assault start come LAST
61 for(self = world; (self = nextent(self)); )
62 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
70 if(self.classname == "sprite_waypoint")
72 if(self.health || g_keyhunt) // TODO remove this KH workaround somehow
73 WaypointSprite_Kill(self);
77 // Moving the player reset code here since the player-reset depends
78 // on spawnpoint entities which have to be reset first --blub
80 FOR_EACH_CLIENT(self) {
81 if(self.flags & FL_CLIENT) // reset all players
88 PutObserverInServer();
93 only reset players if a restart countdown is active
94 this can either be due to cvar sv_ready_restart_after_countdown having set
95 restart_mapalreadyrestarted to 1 after the countdown ended or when
96 sv_ready_restart_after_countdown is not used and countdown is still running
98 if (restart_mapalreadyrestarted || (time < game_starttime))
100 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
101 if (self.classname == "player") {
102 PlayerScore_Clear(self);
104 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
106 //stop the player from moving so that he stands still once he gets respawned
107 self.velocity = '0 0 0';
108 self.avelocity = '0 0 0';
109 self.movement = '0 0 0';
118 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
122 UpdateFrags(champion, +1);
127 void Spawnqueue_Insert(entity e)
131 dprint(strcat("Into queue: ", e.netname, "\n"));
132 e.spawnqueue_in = TRUE;
133 e.spawnqueue_prev = spawnqueue_last;
134 e.spawnqueue_next = world;
136 spawnqueue_last.spawnqueue_next = e;
138 if(!spawnqueue_first)
139 spawnqueue_first = e;
142 void Spawnqueue_Remove(entity e)
146 dprint(strcat("Out of queue: ", e.netname, "\n"));
147 e.spawnqueue_in = FALSE;
148 if(e == spawnqueue_first)
149 spawnqueue_first = e.spawnqueue_next;
150 if(e == spawnqueue_last)
151 spawnqueue_last = e.spawnqueue_prev;
152 if(e.spawnqueue_prev)
153 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
154 if(e.spawnqueue_next)
155 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
156 e.spawnqueue_next = world;
157 e.spawnqueue_prev = world;
160 void Spawnqueue_Unmark(entity e)
165 numspawned = numspawned - 1;
168 void Spawnqueue_Mark(entity e)
173 numspawned = numspawned + 1;
177 * If roundbased arena game mode is active, it centerprints the texts for the
178 * player when player is waiting for the countdown to finish.
179 * Blocks the players movement while countdown is active.
180 * Unblocks the player once the countdown is over.
182 * Called in PlayerPostThink()
189 if(!g_arena || !arena_roundbased || (time < game_starttime))
192 f = rint(warmup - time);
195 if(time < warmup && self.spawned)
198 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
201 msg = strcat(msg, "Round will start in ", ftos(f));
205 msg = strcat(msg, "^1Fight!");
208 centerprint(self, msg);
211 self.movetype = MOVETYPE_NONE;
213 self.velocity = '0 0 0';
214 self.avelocity = '0 0 0';
215 self.movement = '0 0 0';
216 //self.fixangle = TRUE;
218 else if(self.movetype == MOVETYPE_NONE)
220 self.movetype = MOVETYPE_WALK;
221 centerprint(self, "\n");
229 * This function finds out whether an arena round is over 1 player is left.
230 * It determines the last player who's still alive and saves it's entity reference
231 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
233 * Gets called in StartFrame()
235 void Spawnqueue_Check()
237 if(time < warmup + 1)
240 //extend next_round if it isn't set yet and only 1 player is spawned
243 next_round = time + 3;
245 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
251 champion = find(world, classname, "player");
252 while(champion && champion.deadflag)
253 champion = find(champion, classname, "player");
257 while(numspawned < maxspawned && spawnqueue_first)
259 self = spawnqueue_first;
261 bprint ("^4", self.netname, "^4 is the next challenger\n");
263 Spawnqueue_Remove(self);
264 Spawnqueue_Mark(self);
266 self.classname = "player";