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();
129 else if(self.classname == "target_assault_roundstart")
135 // Waypoints come LAST (keyhunt keys reference them)
136 for(self = world; (self = nextent(self)); )
137 if(self.classname == "sprite_waypoint")
139 if(self.health | g_keyhunt)
140 WaypointSprite_Kill(self);
143 // Moving the player reset code here since the player-reset depends
144 // on spawnpoint entities which have to be reset first --blub
145 FOR_EACH_CLIENT(self) {
146 if(self.flags & FL_CLIENT) // reset all players
153 PutObserverInServer();
158 only reset players if a restart countdown is active
159 this can either be due to cvar sv_ready_restart_after_countdown having set
160 restart_mapalreadyrestarted to 1 after the countdown ended or when
161 sv_ready_restart_after_countdown is not used and countdown is still running
163 if (restart_mapalreadyrestarted || (time < game_starttime))
165 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
166 if (self.classname == "player") {
167 PlayerScore_Clear(self);
169 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
171 //stop the player from moving so that he stands still once he gets respawned
172 self.velocity = '0 0 0';
173 self.avelocity = '0 0 0';
174 self.movement = '0 0 0';
183 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
187 UpdateFrags(champion, +1);
192 void Spawnqueue_Insert(entity e)
196 dprint(strcat("Into queue: ", e.netname, "\n"));
197 e.spawnqueue_in = TRUE;
198 e.spawnqueue_prev = spawnqueue_last;
199 e.spawnqueue_next = world;
201 spawnqueue_last.spawnqueue_next = e;
203 if(!spawnqueue_first)
204 spawnqueue_first = e;
207 void Spawnqueue_Remove(entity e)
211 dprint(strcat("Out of queue: ", e.netname, "\n"));
212 e.spawnqueue_in = FALSE;
213 if(e == spawnqueue_first)
214 spawnqueue_first = e.spawnqueue_next;
215 if(e == spawnqueue_last)
216 spawnqueue_last = e.spawnqueue_prev;
217 if(e.spawnqueue_prev)
218 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
219 if(e.spawnqueue_next)
220 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
221 e.spawnqueue_next = world;
222 e.spawnqueue_prev = world;
225 void Spawnqueue_Unmark(entity e)
230 numspawned = numspawned - 1;
233 void Spawnqueue_Mark(entity e)
238 numspawned = numspawned + 1;
242 * If roundbased arena game mode is active, it centerprints the texts for the
243 * player when player is waiting for the countdown to finish.
244 * Blocks the players movement while countdown is active.
245 * Unblocks the player once the countdown is over.
247 * Called in PlayerPostThink()
254 if(!g_arena || !arena_roundbased || (time < game_starttime))
257 f = rint(warmup - time);
260 if(time < warmup && self.spawned)
263 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
266 msg = strcat(msg, "Round will start in ", ftos(f));
270 msg = strcat(msg, "^1Fight!");
273 centerprint(self, msg);
276 self.movetype = MOVETYPE_NONE;
278 self.velocity = '0 0 0';
279 self.avelocity = '0 0 0';
280 self.movement = '0 0 0';
281 //self.fixangle = TRUE;
283 else if(self.movetype == MOVETYPE_NONE)
285 self.movetype = MOVETYPE_WALK;
286 centerprint(self, "\n");
294 * This function finds out whether an arena round is over 1 player is left.
295 * It determines the last player who's still alive and saves it's entity reference
296 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
298 * Gets called in StartFrame()
300 void Spawnqueue_Check()
302 if(time < warmup + 1)
305 //extend next_round if it isn't set yet and only 1 player is spawned
308 next_round = time + 3;
310 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
316 champion = find(world, classname, "player");
317 while(champion && champion.deadflag)
318 champion = find(champion, classname, "player");
322 while(numspawned < maxspawned && spawnqueue_first)
324 self = spawnqueue_first;
326 bprint ("^4", self.netname, "^4 is the next challenger\n");
328 Spawnqueue_Remove(self);
329 Spawnqueue_Mark(self);
331 self.classname = "player";