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 == "sprite_waypoint")
69 if(self.health | g_keyhunt)
70 WaypointSprite_Kill(self);
72 else if(self.classname == "dom_controlpoint")
74 dom_controlpoint_setup();
76 else if(self.flags & FL_ITEM) // reset items
80 self.model = string_null;
81 self.solid = SOLID_NOT;
85 self.model = self.mdl;
86 self.solid = SOLID_TRIGGER;
88 setorigin (self, self.origin);
89 self.think = SUB_Null;
92 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
94 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
101 else if(self.classname == "onslaught_generator")
103 onslaught_generator_reset();
105 else if(self.classname == "onslaught_controlpoint")
107 onslaught_controlpoint_reset();
109 // TODO properly reset Assault
110 // General teambased game modes
111 else if(self.classname == "info_player_deathmatch")
113 self.team = self.team_saved;
117 // Moving the player reset code here since the player-reset depends
118 // on spawnpoint entities which have to be reset first --blub
119 FOR_EACH_CLIENT(self) {
120 if(self.flags & FL_CLIENT) // reset all players
127 PutObserverInServer();
132 only reset players if a restart countdown is active
133 this can either be due to cvar sv_ready_restart_after_countdown having set
134 restart_mapalreadyrestarted to 1 after the countdown ended or when
135 sv_ready_restart_after_countdown is not used and countdown is still running
137 if (restart_mapalreadyrestarted || (time < restart_countdown))
139 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
140 if (self.classname == "player") {
141 PlayerScore_Clear(self);
143 PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
145 //stop the player from moving so that he stands still once he gets respawned
146 self.velocity = '0 0 0';
147 self.avelocity = '0 0 0';
148 self.movement = '0 0 0';
157 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+RESTART_COUNTDOWN, "", kh_StartRound);
161 UpdateFrags(champion, +1);
166 void Spawnqueue_Insert(entity e)
170 dprint(strcat("Into queue: ", e.netname, "\n"));
171 e.spawnqueue_in = TRUE;
172 e.spawnqueue_prev = spawnqueue_last;
173 e.spawnqueue_next = world;
175 spawnqueue_last.spawnqueue_next = e;
177 if(!spawnqueue_first)
178 spawnqueue_first = e;
181 void Spawnqueue_Remove(entity e)
185 dprint(strcat("Out of queue: ", e.netname, "\n"));
186 e.spawnqueue_in = FALSE;
187 if(e == spawnqueue_first)
188 spawnqueue_first = e.spawnqueue_next;
189 if(e == spawnqueue_last)
190 spawnqueue_last = e.spawnqueue_prev;
191 if(e.spawnqueue_prev)
192 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
193 if(e.spawnqueue_next)
194 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
195 e.spawnqueue_next = world;
196 e.spawnqueue_prev = world;
199 void Spawnqueue_Unmark(entity e)
204 numspawned = numspawned - 1;
207 void Spawnqueue_Mark(entity e)
212 numspawned = numspawned + 1;
216 * If roundbased arena game mode is active, it centerprints the texts for the
217 * player when player is waiting for the countdown to finish.
218 * Blocks the players movement while countdown is active.
219 * Unblocks the player once the countdown is over.
221 * Called in PlayerPostThink()
228 if(!g_arena || !arena_roundbased || (time < restart_countdown))
231 f = rint(warmup - time);
234 if(time < warmup && self.spawned)
237 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
240 msg = strcat(msg, "Round will start in ", ftos(f));
244 msg = strcat(msg, "^1Fight!");
247 centerprint(self, msg);
250 self.movetype = MOVETYPE_NONE;
252 self.velocity = '0 0 0';
253 self.avelocity = '0 0 0';
254 self.movement = '0 0 0';
255 //self.fixangle = TRUE;
257 else if(self.movetype == MOVETYPE_NONE)
259 self.movetype = MOVETYPE_WALK;
260 centerprint(self, "\n");
268 * This function finds out whether an arena round is over 1 player is left.
269 * It determines the last player who's still alive and saves it's entity reference
270 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
272 * Gets called in StartFrame()
274 void Spawnqueue_Check()
276 if(time < warmup + 1)
279 //extend next_round if it isn't set yet and only 1 player is spawned
282 next_round = time + 3;
284 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
290 champion = find(world, classname, "player");
291 while(champion && champion.deadflag)
292 champion = find(champion, classname, "player");
296 while(numspawned < maxspawned && spawnqueue_first)
298 self = spawnqueue_first;
300 bprint ("^4", self.netname, "^4 is the next challenger\n");
302 Spawnqueue_Remove(self);
303 Spawnqueue_Mark(self);
305 self.classname = "player";