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)
45 if(self.classname == STR_ITEM_KH_KEY)
47 kh_Key_AssignTo(self, world);
49 // kh_Key_DropAll(self.owner, TRUE);
52 else if(self.classname == "droppedweapon" // cleanup
53 || self.classname == "gib"
54 || self.classname == "body")
58 else if(self.items & (IT_KEY1 | IT_KEY2))
60 DropFlag(self, world, world);
63 else if(self.classname == "rune")
66 if(self.owner.classname != "runematch_spawn_point")
67 DropAllRunes(self.owner);
70 else if(self.classname == "dom_controlpoint")
72 dom_controlpoint_setup();
74 else if(self.flags & FL_ITEM) // reset items
78 self.model = string_null;
79 self.solid = SOLID_NOT;
83 self.model = self.mdl;
84 self.solid = SOLID_TRIGGER;
86 setorigin (self, self.origin);
87 self.think = SUB_Null;
90 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
92 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
99 else if(self.classname == "onslaught_generator")
101 onslaught_generator_reset();
103 else if(self.classname == "onslaught_controlpoint")
105 onslaught_controlpoint_reset();
107 // TODO properly reset Assault
108 // General teambased game modes
109 else if(self.classname == "info_player_deathmatch")
111 self.team = self.team_saved;
113 else if(self.classname == "func_breakable")
115 func_breakable_reset();
117 else if(self.classname == "func_assault_destructible")
119 func_breakable_reset();
121 else if(self.classname == "target_objective")
123 assault_objective_reset();
125 else if(self.classname == "target_assault_roundend")
127 target_assault_roundend_reset();
131 // Waypoints and assault start come LAST
132 for(self = world; (self = nextent(self)); )
133 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
135 if(self.classname == "sprite_waypoint")
137 if(self.health | g_keyhunt)
138 WaypointSprite_Kill(self);
140 else if(self.classname == "target_assault_roundstart")
146 // Moving the player reset code here since the player-reset depends
147 // on spawnpoint entities which have to be reset first --blub
148 FOR_EACH_CLIENT(self) {
149 if(self.flags & FL_CLIENT) // reset all players
156 PutObserverInServer();
161 only reset players if a restart countdown is active
162 this can either be due to cvar sv_ready_restart_after_countdown having set
163 restart_mapalreadyrestarted to 1 after the countdown ended or when
164 sv_ready_restart_after_countdown is not used and countdown is still running
166 if (restart_mapalreadyrestarted || (time < game_starttime))
168 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
169 if (self.classname == "player") {
170 PlayerScore_Clear(self);
172 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
174 //stop the player from moving so that he stands still once he gets respawned
175 self.velocity = '0 0 0';
176 self.avelocity = '0 0 0';
177 self.movement = '0 0 0';
186 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
190 UpdateFrags(champion, +1);
195 void Spawnqueue_Insert(entity e)
199 dprint(strcat("Into queue: ", e.netname, "\n"));
200 e.spawnqueue_in = TRUE;
201 e.spawnqueue_prev = spawnqueue_last;
202 e.spawnqueue_next = world;
204 spawnqueue_last.spawnqueue_next = e;
206 if(!spawnqueue_first)
207 spawnqueue_first = e;
210 void Spawnqueue_Remove(entity e)
214 dprint(strcat("Out of queue: ", e.netname, "\n"));
215 e.spawnqueue_in = FALSE;
216 if(e == spawnqueue_first)
217 spawnqueue_first = e.spawnqueue_next;
218 if(e == spawnqueue_last)
219 spawnqueue_last = e.spawnqueue_prev;
220 if(e.spawnqueue_prev)
221 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
222 if(e.spawnqueue_next)
223 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
224 e.spawnqueue_next = world;
225 e.spawnqueue_prev = world;
228 void Spawnqueue_Unmark(entity e)
233 numspawned = numspawned - 1;
236 void Spawnqueue_Mark(entity e)
241 numspawned = numspawned + 1;
245 * If roundbased arena game mode is active, it centerprints the texts for the
246 * player when player is waiting for the countdown to finish.
247 * Blocks the players movement while countdown is active.
248 * Unblocks the player once the countdown is over.
250 * Called in PlayerPostThink()
257 if(!g_arena || !arena_roundbased || (time < game_starttime))
260 f = rint(warmup - time);
263 if(time < warmup && self.spawned)
266 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
269 msg = strcat(msg, "Round will start in ", ftos(f));
273 msg = strcat(msg, "^1Fight!");
276 centerprint(self, msg);
279 self.movetype = MOVETYPE_NONE;
281 self.velocity = '0 0 0';
282 self.avelocity = '0 0 0';
283 self.movement = '0 0 0';
284 //self.fixangle = TRUE;
286 else if(self.movetype == MOVETYPE_NONE)
288 self.movetype = MOVETYPE_WALK;
289 centerprint(self, "\n");
297 * This function finds out whether an arena round is over 1 player is left.
298 * It determines the last player who's still alive and saves it's entity reference
299 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
301 * Gets called in StartFrame()
303 void Spawnqueue_Check()
305 if(time < warmup + 1)
308 //extend next_round if it isn't set yet and only 1 player is spawned
311 next_round = time + 3;
313 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
319 champion = find(world, classname, "player");
320 while(champion && champion.deadflag)
321 champion = find(champion, classname, "player");
325 while(numspawned < maxspawned && spawnqueue_first)
327 self = spawnqueue_first;
329 bprint ("^4", self.netname, "^4 is the next challenger\n");
331 Spawnqueue_Remove(self);
332 Spawnqueue_Mark(self);
334 self.classname = "player";