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) DropFlag;
16 void(entity e) ReturnFlag;
17 void(entity e) removedecor;
18 void dom_controlpoint_setup();
19 void onslaught_generator_reset();
20 void onslaught_controlpoint_reset();
23 * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
24 * Sets the 'warmup' global variable.
29 if(cvar("g_arena_warmup"))
30 warmup = time + cvar("g_arena_warmup");
32 lms_lowest_lives = 999;
33 lms_next_place = player_count;
37 self = nextent(world);
40 if(self.classname == STR_ITEM_KH_KEY)
42 kh_Key_AssignTo(self, world);
44 // kh_Key_DropAll(self.owner, TRUE);
47 else if(self.classname == "droppedweapon" // cleanup
48 || self.classname == "gib"
49 || self.classname == "body")
53 else if(self.items & (IT_KEY1 | IT_KEY2))
58 else if(self.classname == "rune")
61 if(self.owner.classname != "runematch_spawn_point")
62 DropAllRunes(self.owner);
65 else if(self.classname == "sprite_waypoint")
67 if(self.health | g_keyhunt)
68 WaypointSprite_Kill(self);
70 else if(self.classname == "dom_controlpoint")
72 dom_controlpoint_setup();
74 else if(self.flags & FL_ITEM) // reset items
76 self.model = self.mdl;
77 self.solid = SOLID_TRIGGER;
78 setorigin (self, self.origin);
79 self.think = SUB_Null;
82 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
84 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
91 else if(self.classname == "onslaught_generator")
93 onslaught_generator_reset();
95 else if(self.classname == "onslaught_controlpoint")
97 onslaught_controlpoint_reset();
99 // TODO properly reset Assault
100 // General teambased game modes
101 else if(self.classname == "info_player_deathmatch")
103 self.team = self.team_saved;
105 self = nextent(self);
108 // Moving the player reset code here since the player-reset depends
109 // on spawnpoint entities which have to be reset first --blub
110 FOR_EACH_CLIENT(self) {
111 if(self.flags & FL_CLIENT) // reset all players
118 PutObserverInServer();
123 only reset players if a restart countdown is active
124 this can either be due to cvar sv_ready_restart_after_countdown having set
125 restart_mapalreadyrestarted to 1 after the countdown ended or when
126 sv_ready_restart_after_countdown is not used and countdown is still running
128 if (restart_mapalreadyrestarted || (time < restart_countdown))
130 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
131 if (self.classname == "player") {
132 PlayerScore_Clear(self);
134 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
136 //stop the player from moving so that he stands still once he gets respawned
137 self.velocity = '0 0 0';
138 self.avelocity = '0 0 0';
139 self.movement = '0 0 0';
148 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+RESTART_COUNTDOWN, "", kh_StartRound);
152 UpdateFrags(champion, +1);
157 void Spawnqueue_Insert(entity e)
161 dprint(strcat("Into queue: ", e.netname, "\n"));
162 e.spawnqueue_in = TRUE;
163 e.spawnqueue_prev = spawnqueue_last;
164 e.spawnqueue_next = world;
166 spawnqueue_last.spawnqueue_next = e;
168 if(!spawnqueue_first)
169 spawnqueue_first = e;
172 void Spawnqueue_Remove(entity e)
176 dprint(strcat("Out of queue: ", e.netname, "\n"));
177 e.spawnqueue_in = FALSE;
178 if(e == spawnqueue_first)
179 spawnqueue_first = e.spawnqueue_next;
180 if(e == spawnqueue_last)
181 spawnqueue_last = e.spawnqueue_prev;
182 if(e.spawnqueue_prev)
183 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
184 if(e.spawnqueue_next)
185 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
186 e.spawnqueue_next = world;
187 e.spawnqueue_prev = world;
190 void Spawnqueue_Unmark(entity e)
195 numspawned = numspawned - 1;
198 void Spawnqueue_Mark(entity e)
203 numspawned = numspawned + 1;
207 * If roundbased arena game mode is active, it centerprints the texts for the
208 * player when player is waiting for the countdown to finish.
209 * Blocks the players movement while countdown is active.
210 * Unblocks the player once the countdown is over.
212 * Called in PlayerPostThink()
219 if(!g_arena || !arena_roundbased || (time < restart_countdown))
222 f = rint(warmup - time);
225 if(time < warmup && self.spawned)
228 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
231 msg = strcat(msg, "Round will start in ", ftos(f));
235 msg = strcat(msg, "^1Fight!");
238 centerprint(self, msg);
241 self.movetype = MOVETYPE_NONE;
243 self.velocity = '0 0 0';
244 self.avelocity = '0 0 0';
245 self.movement = '0 0 0';
246 //self.fixangle = TRUE;
248 else if(self.movetype == MOVETYPE_NONE)
250 self.movetype = MOVETYPE_WALK;
251 centerprint(self, "\n");
259 * This function finds out whether an arena round is over 1 player is left.
260 * It determines the last player who's still alive and saves it's entity reference
261 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
263 * Gets called in StartFrame()
265 void Spawnqueue_Check()
267 if(time < warmup + 1)
270 //extend next_round if it isn't set yet and only 1 player is spawned
273 next_round = time + 3;
275 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
281 champion = find(world, classname, "player");
282 while(champion && champion.deadflag)
283 champion = find(champion, classname, "player");
287 while(numspawned < maxspawned && spawnqueue_first)
289 self = spawnqueue_first;
291 bprint ("^4", self.netname, "^4 is the next challenger\n");
293 Spawnqueue_Remove(self);
294 Spawnqueue_Mark(self);
296 self.classname = "player";