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 dorespawn)
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)
71 // Moving the player reset code here since the player-reset depends
72 // on spawnpoint entities which have to be reset first --blub
74 FOR_EACH_CLIENT(self) {
75 if(self.flags & FL_CLIENT) // reset all players
82 PutObserverInServer();
87 only reset players if a restart countdown is active
88 this can either be due to cvar sv_ready_restart_after_countdown having set
89 restart_mapalreadyrestarted to 1 after the countdown ended or when
90 sv_ready_restart_after_countdown is not used and countdown is still running
92 if (restart_mapalreadyrestarted || (time < game_starttime))
94 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
95 if (self.classname == "player") {
96 //PlayerScore_Clear(self);
98 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
100 //stop the player from moving so that he stands still once he gets respawned
101 self.velocity = '0 0 0';
102 self.avelocity = '0 0 0';
103 self.movement = '0 0 0';
112 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+(game_starttime - time), "", kh_StartRound);
116 UpdateFrags(champion, +1);
121 void Spawnqueue_Insert(entity e)
125 dprint(strcat("Into queue: ", e.netname, "\n"));
126 e.spawnqueue_in = TRUE;
127 e.spawnqueue_prev = spawnqueue_last;
128 e.spawnqueue_next = world;
130 spawnqueue_last.spawnqueue_next = e;
132 if(!spawnqueue_first)
133 spawnqueue_first = e;
136 void Spawnqueue_Remove(entity e)
140 dprint(strcat("Out of queue: ", e.netname, "\n"));
141 e.spawnqueue_in = FALSE;
142 if(e == spawnqueue_first)
143 spawnqueue_first = e.spawnqueue_next;
144 if(e == spawnqueue_last)
145 spawnqueue_last = e.spawnqueue_prev;
146 if(e.spawnqueue_prev)
147 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
148 if(e.spawnqueue_next)
149 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
150 e.spawnqueue_next = world;
151 e.spawnqueue_prev = world;
154 void Spawnqueue_Unmark(entity e)
159 numspawned = numspawned - 1;
162 void Spawnqueue_Mark(entity e)
167 numspawned = numspawned + 1;
171 * If roundbased arena game mode is active, it centerprints the texts for the
172 * player when player is waiting for the countdown to finish.
173 * Blocks the players movement while countdown is active.
174 * Unblocks the player once the countdown is over.
176 * Called in PlayerPostThink()
183 if(!g_arena || !arena_roundbased || (time < game_starttime))
186 f = rint(warmup - time);
189 if(time < warmup && self.spawned)
192 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n");
195 msg = strcat(msg, "Round will start in ", ftos(f),"\n");
199 msg = strcat(msg, "^1Fight!\n");
202 centerprint(self, msg);
205 self.movetype = MOVETYPE_NONE;
207 self.velocity = '0 0 0';
208 self.avelocity = '0 0 0';
209 self.movement = '0 0 0';
210 //self.fixangle = TRUE;
212 else if(self.movetype == MOVETYPE_NONE)
214 self.movetype = MOVETYPE_WALK;
215 centerprint(self, "\n");
223 * This function finds out whether an arena round is over 1 player is left.
224 * It determines the last player who's still alive and saves it's entity reference
225 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
227 * Gets called in StartFrame()
229 void Spawnqueue_Check()
231 if(time < warmup + 1)
234 //extend next_round if it isn't set yet and only 1 player is spawned
237 next_round = time + 3;
239 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
245 champion = find(world, classname, "player");
246 while(champion && champion.deadflag)
247 champion = find(champion, classname, "player");
251 while(numspawned < maxspawned && spawnqueue_first)
253 self = spawnqueue_first;
255 bprint ("^4", self.netname, "^4 is the next challenger\n");
257 Spawnqueue_Remove(self);
258 Spawnqueue_Mark(self);
260 self.classname = "player";