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(entity e) removedecor;
17 void dom_controlpoint_setup();
18 void onslaught_generator_reset();
19 void onslaught_controlpoint_reset();
20 void func_breakable_reset();
21 void assault_objective_reset();
22 void target_assault_roundend_reset();
25 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
26 * Sets the 'warmup' global variable.
34 if(cvar("g_arena_warmup"))
35 warmup = time + cvar("g_arena_warmup");
37 lms_lowest_lives = 999;
38 lms_next_place = player_count;
42 for(self = world; (self = nextent(self)); )
43 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
52 self.team = self.team_saved;
54 if(self.use == SUB_DontUseTargets)
55 self.use = SUB_UseTargets;
57 if(self.classname == STR_ITEM_KH_KEY)
59 kh_Key_AssignTo(self, world);
61 // kh_Key_DropAll(self.owner, TRUE);
64 else if(self.classname == "droppedweapon" // cleanup
65 || self.classname == "gib"
66 || self.classname == "body")
70 else if(self.items & (IT_KEY1 | IT_KEY2))
72 DropFlag(self, world, world);
75 else if(self.classname == "rune")
78 if(self.owner.classname != "runematch_spawn_point")
79 DropAllRunes(self.owner);
82 else if(self.classname == "dom_controlpoint")
84 dom_controlpoint_setup();
86 else if(self.flags & FL_ITEM) // reset items
90 self.model = string_null;
91 self.solid = SOLID_NOT;
95 self.model = self.mdl;
96 self.solid = SOLID_TRIGGER;
98 setorigin (self, self.origin);
99 self.think = SUB_Null;
102 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
104 stopsound(self, CHAN_PROJECTILE);
107 else if(self.isdecor)
111 else if(self.classname == "onslaught_generator")
113 onslaught_generator_reset();
115 else if(self.classname == "onslaught_controlpoint")
117 onslaught_controlpoint_reset();
119 // TODO properly reset Assault
120 // General teambased game modes
121 else if(self.classname == "func_breakable")
123 func_breakable_reset();
125 else if(self.classname == "func_assault_destructible")
127 func_breakable_reset();
129 else if(self.classname == "target_objective")
131 assault_objective_reset();
133 else if(self.classname == "target_assault_roundend")
135 target_assault_roundend_reset();
139 // Waypoints and assault start come LAST
140 for(self = world; (self = nextent(self)); )
141 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
143 if(self.classname == "sprite_waypoint")
145 if(self.health | g_keyhunt)
146 WaypointSprite_Kill(self);
148 else if(self.classname == "target_assault_roundstart")
152 else if(self.classname == "trigger_gamestart")
156 self.think = self.use;
157 self.nextthink = game_starttime + self.wait;
164 // Moving the player reset code here since the player-reset depends
165 // on spawnpoint entities which have to be reset first --blub
166 FOR_EACH_CLIENT(self) {
167 if(self.flags & FL_CLIENT) // reset all players
174 PutObserverInServer();
179 only reset players if a restart countdown is active
180 this can either be due to cvar sv_ready_restart_after_countdown having set
181 restart_mapalreadyrestarted to 1 after the countdown ended or when
182 sv_ready_restart_after_countdown is not used and countdown is still running
184 if (restart_mapalreadyrestarted || (time < game_starttime))
186 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
187 if (self.classname == "player") {
188 PlayerScore_Clear(self);
190 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
192 //stop the player from moving so that he stands still once he gets respawned
193 self.velocity = '0 0 0';
194 self.avelocity = '0 0 0';
195 self.movement = '0 0 0';
204 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
208 UpdateFrags(champion, +1);
213 void Spawnqueue_Insert(entity e)
217 dprint(strcat("Into queue: ", e.netname, "\n"));
218 e.spawnqueue_in = TRUE;
219 e.spawnqueue_prev = spawnqueue_last;
220 e.spawnqueue_next = world;
222 spawnqueue_last.spawnqueue_next = e;
224 if(!spawnqueue_first)
225 spawnqueue_first = e;
228 void Spawnqueue_Remove(entity e)
232 dprint(strcat("Out of queue: ", e.netname, "\n"));
233 e.spawnqueue_in = FALSE;
234 if(e == spawnqueue_first)
235 spawnqueue_first = e.spawnqueue_next;
236 if(e == spawnqueue_last)
237 spawnqueue_last = e.spawnqueue_prev;
238 if(e.spawnqueue_prev)
239 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
240 if(e.spawnqueue_next)
241 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
242 e.spawnqueue_next = world;
243 e.spawnqueue_prev = world;
246 void Spawnqueue_Unmark(entity e)
251 numspawned = numspawned - 1;
254 void Spawnqueue_Mark(entity e)
259 numspawned = numspawned + 1;
263 * If roundbased arena game mode is active, it centerprints the texts for the
264 * player when player is waiting for the countdown to finish.
265 * Blocks the players movement while countdown is active.
266 * Unblocks the player once the countdown is over.
268 * Called in PlayerPostThink()
275 if(!g_arena || !arena_roundbased || (time < game_starttime))
278 f = rint(warmup - time);
281 if(time < warmup && self.spawned)
284 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
287 msg = strcat(msg, "Round will start in ", ftos(f));
291 msg = strcat(msg, "^1Fight!");
294 centerprint(self, msg);
297 self.movetype = MOVETYPE_NONE;
299 self.velocity = '0 0 0';
300 self.avelocity = '0 0 0';
301 self.movement = '0 0 0';
302 //self.fixangle = TRUE;
304 else if(self.movetype == MOVETYPE_NONE)
306 self.movetype = MOVETYPE_WALK;
307 centerprint(self, "\n");
315 * This function finds out whether an arena round is over 1 player is left.
316 * It determines the last player who's still alive and saves it's entity reference
317 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
319 * Gets called in StartFrame()
321 void Spawnqueue_Check()
323 if(time < warmup + 1)
326 //extend next_round if it isn't set yet and only 1 player is spawned
329 next_round = time + 3;
331 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
337 champion = find(world, classname, "player");
338 while(champion && champion.deadflag)
339 champion = find(champion, classname, "player");
343 while(numspawned < maxspawned && spawnqueue_first)
345 self = spawnqueue_first;
347 bprint ("^4", self.netname, "^4 is the next challenger\n");
349 Spawnqueue_Remove(self);
350 Spawnqueue_Mark(self);
352 self.classname = "player";