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();
22 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
23 * Sets the 'warmup' global variable.
31 if(cvar("g_arena_warmup"))
32 warmup = time + cvar("g_arena_warmup");
34 lms_lowest_lives = 999;
35 lms_next_place = player_count;
39 for(self = world; (self = nextent(self)); )
40 if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
42 if(self.classname == STR_ITEM_KH_KEY)
44 kh_Key_AssignTo(self, world);
46 // kh_Key_DropAll(self.owner, TRUE);
49 else if(self.classname == "droppedweapon" // cleanup
50 || self.classname == "gib"
51 || self.classname == "body")
55 else if(self.items & (IT_KEY1 | IT_KEY2))
57 DropFlag(self, world, world);
60 else if(self.classname == "rune")
63 if(self.owner.classname != "runematch_spawn_point")
64 DropAllRunes(self.owner);
67 else if(self.classname == "dom_controlpoint")
69 dom_controlpoint_setup();
71 else if(self.flags & FL_ITEM) // reset items
75 self.model = string_null;
76 self.solid = SOLID_NOT;
80 self.model = self.mdl;
81 self.solid = SOLID_TRIGGER;
83 setorigin (self, self.origin);
84 self.think = SUB_Null;
87 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
89 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
96 else if(self.classname == "onslaught_generator")
98 onslaught_generator_reset();
100 else if(self.classname == "onslaught_controlpoint")
102 onslaught_controlpoint_reset();
104 // TODO properly reset Assault
105 // General teambased game modes
106 else if(self.classname == "info_player_deathmatch")
108 self.team = self.team_saved;
112 // Waypoints come LAST (keyhunt keys reference them)
113 for(self = world; (self = nextent(self)); )
114 if(self.classname == "sprite_waypoint")
116 if(self.health | g_keyhunt)
117 WaypointSprite_Kill(self);
120 // Moving the player reset code here since the player-reset depends
121 // on spawnpoint entities which have to be reset first --blub
122 FOR_EACH_CLIENT(self) {
123 if(self.flags & FL_CLIENT) // reset all players
130 PutObserverInServer();
135 only reset players if a restart countdown is active
136 this can either be due to cvar sv_ready_restart_after_countdown having set
137 restart_mapalreadyrestarted to 1 after the countdown ended or when
138 sv_ready_restart_after_countdown is not used and countdown is still running
140 if (restart_mapalreadyrestarted || (time < game_starttime))
142 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
143 if (self.classname == "player") {
144 PlayerScore_Clear(self);
146 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
148 //stop the player from moving so that he stands still once he gets respawned
149 self.velocity = '0 0 0';
150 self.avelocity = '0 0 0';
151 self.movement = '0 0 0';
160 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
164 UpdateFrags(champion, +1);
169 void Spawnqueue_Insert(entity e)
173 dprint(strcat("Into queue: ", e.netname, "\n"));
174 e.spawnqueue_in = TRUE;
175 e.spawnqueue_prev = spawnqueue_last;
176 e.spawnqueue_next = world;
178 spawnqueue_last.spawnqueue_next = e;
180 if(!spawnqueue_first)
181 spawnqueue_first = e;
184 void Spawnqueue_Remove(entity e)
188 dprint(strcat("Out of queue: ", e.netname, "\n"));
189 e.spawnqueue_in = FALSE;
190 if(e == spawnqueue_first)
191 spawnqueue_first = e.spawnqueue_next;
192 if(e == spawnqueue_last)
193 spawnqueue_last = e.spawnqueue_prev;
194 if(e.spawnqueue_prev)
195 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
196 if(e.spawnqueue_next)
197 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
198 e.spawnqueue_next = world;
199 e.spawnqueue_prev = world;
202 void Spawnqueue_Unmark(entity e)
207 numspawned = numspawned - 1;
210 void Spawnqueue_Mark(entity e)
215 numspawned = numspawned + 1;
219 * If roundbased arena game mode is active, it centerprints the texts for the
220 * player when player is waiting for the countdown to finish.
221 * Blocks the players movement while countdown is active.
222 * Unblocks the player once the countdown is over.
224 * Called in PlayerPostThink()
231 if(!g_arena || !arena_roundbased || (time < game_starttime))
234 f = rint(warmup - time);
237 if(time < warmup && self.spawned)
240 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
243 msg = strcat(msg, "Round will start in ", ftos(f));
247 msg = strcat(msg, "^1Fight!");
250 centerprint(self, msg);
253 self.movetype = MOVETYPE_NONE;
255 self.velocity = '0 0 0';
256 self.avelocity = '0 0 0';
257 self.movement = '0 0 0';
258 //self.fixangle = TRUE;
260 else if(self.movetype == MOVETYPE_NONE)
262 self.movetype = MOVETYPE_WALK;
263 centerprint(self, "\n");
271 * This function finds out whether an arena round is over 1 player is left.
272 * It determines the last player who's still alive and saves it's entity reference
273 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
275 * Gets called in StartFrame()
277 void Spawnqueue_Check()
279 if(time < warmup + 1)
282 //extend next_round if it isn't set yet and only 1 player is spawned
285 next_round = time + 3;
287 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
293 champion = find(world, classname, "player");
294 while(champion && champion.deadflag)
295 champion = find(champion, classname, "player");
299 while(numspawned < maxspawned && spawnqueue_first)
301 self = spawnqueue_first;
303 bprint ("^4", self.netname, "^4 is the next challenger\n");
305 Spawnqueue_Remove(self);
306 Spawnqueue_Mark(self);
308 self.classname = "player";