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;
35 self = nextent(world);
38 if(self.classname == STR_ITEM_KH_KEY)
40 kh_Key_AssignTo(self, world);
42 // kh_Key_DropAll(self.owner, TRUE);
45 else if(self.classname == "droppedweapon" // cleanup
46 || self.classname == "gib"
47 || self.classname == "body")
51 else if(self.items & (IT_KEY1 | IT_KEY2))
56 else if(self.classname == "rune")
59 if(self.owner.classname != "runematch_spawn_point")
60 DropAllRunes(self.owner);
63 else if(self.classname == "sprite_waypoint")
65 if(self.health | g_keyhunt)
66 WaypointSprite_Kill(self);
68 else if(self.classname == "dom_controlpoint")
70 dom_controlpoint_setup();
72 else if(self.flags & FL_ITEM) // reset items
74 self.model = self.mdl;
75 self.solid = SOLID_TRIGGER;
76 setorigin (self, self.origin);
77 self.think = SUB_Null;
80 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
82 sound(self, CHAN_BODY, "misc/null.wav", 1, ATTN_NORM);
89 // TODO properly reset Onslaught
90 else if(self.classname == "onslaught_generator")
92 onslaught_generator_reset();
94 else if(self.classname == "onslaught_controlpoint")
96 onslaught_controlpoint_reset();
98 // TODO properly reset Assault
99 // General teambased game modes
100 else if(self.classname == "info_player_deathmatch")
102 self.team = self.team_saved;
104 self = nextent(self);
107 // Moving the player reset code here since the player-reset depends
108 // on spawnpoint entities which have to be reset first --blub
109 FOR_EACH_CLIENT(self) {
110 if(self.flags & FL_CLIENT) // reset all players
117 PutObserverInServer();
122 only reset players if a restart countdown is active
123 this can either be due to cvar sv_ready_restart_after_countdown having set
124 restart_mapalreadyrestarted to 1 after the countdown ended or when
125 sv_ready_restart_after_countdown is not used and countdown is still running
127 if (restart_mapalreadyrestarted || (time < restart_countdown))
129 //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
130 if (self.classname == "player") {
131 self.frags = (g_lms)?LMS_NewPlayerLives():0;
134 //stop the player from moving so that he stands still once he gets respawned
135 self.velocity = '0 0 0';
136 self.avelocity = '0 0 0';
137 self.movement = '0 0 0';
146 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+RESTART_COUNTDOWN, "", kh_StartRound);
150 UpdateFrags(champion, +1);
153 void Spawnqueue_Insert(entity e)
157 dprint(strcat("Into queue: ", e.netname, "\n"));
158 e.spawnqueue_in = TRUE;
159 e.spawnqueue_prev = spawnqueue_last;
160 e.spawnqueue_next = world;
162 spawnqueue_last.spawnqueue_next = e;
164 if(!spawnqueue_first)
165 spawnqueue_first = e;
168 void Spawnqueue_Remove(entity e)
172 dprint(strcat("Out of queue: ", e.netname, "\n"));
173 e.spawnqueue_in = FALSE;
174 if(e == spawnqueue_first)
175 spawnqueue_first = e.spawnqueue_next;
176 if(e == spawnqueue_last)
177 spawnqueue_last = e.spawnqueue_prev;
178 if(e.spawnqueue_prev)
179 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
180 if(e.spawnqueue_next)
181 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
182 e.spawnqueue_next = world;
183 e.spawnqueue_prev = world;
186 void Spawnqueue_Unmark(entity e)
191 numspawned = numspawned - 1;
194 void Spawnqueue_Mark(entity e)
199 numspawned = numspawned + 1;
203 * If roundbased arena game mode is active, it centerprints the texts for the
204 * player when player is waiting for the countdown to finish.
205 * Blocks the players movement while countdown is active.
206 * Unblocks the player once the countdown is over.
208 * Called in PlayerPostThink()
215 if(!g_arena || !arena_roundbased || (time < restart_countdown))
218 f = rint(warmup - time);
221 if(time < warmup && self.spawned)
224 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
227 msg = strcat(msg, "Round will start in ", ftos(f));
231 msg = strcat(msg, "^1Fight!");
234 centerprint(self, msg);
237 self.movetype = MOVETYPE_NONE;
239 self.velocity = '0 0 0';
240 self.avelocity = '0 0 0';
241 self.movement = '0 0 0';
242 //self.fixangle = TRUE;
244 else if(self.movetype == MOVETYPE_NONE)
246 self.movetype = MOVETYPE_WALK;
247 centerprint(self, "\n");
255 * This function finds out whether an arena round is over 1 player is left.
256 * It determines the last player who's still alive and saves it's entity reference
257 * in the global variable 'champion'. Then the new enemy/enemies are put into the server.
259 * Gets called in StartFrame()
261 void Spawnqueue_Check()
263 if(time < warmup + 1)
266 //extend next_round if it isn't set yet and only 1 player is spawned
269 next_round = time + 3;
271 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
277 champion = find(world, classname, "player");
278 while(champion && champion.deadflag)
279 champion = find(champion, classname, "player");
283 while(numspawned < maxspawned && spawnqueue_first)
285 self = spawnqueue_first;
287 bprint ("^4", self.netname, "^4 is the next challenger\n");
289 Spawnqueue_Remove(self);
290 Spawnqueue_Mark(self);
292 self.classname = "player";