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();
25 if(cvar("g_arena_warmup"))
26 warmup = time + cvar("g_arena_warmup");
28 lms_lowest_lives = 999;
29 lms_next_place = player_count;
31 self = nextent(world);
34 if(self.classname == STR_ITEM_KH_KEY)
36 kh_Key_AssignTo(self, world);
38 // kh_Key_DropAll(self.owner, TRUE);
41 else if(self.classname == "droppedweapon" // cleanup
42 || self.classname == "gib"
43 || self.classname == "body")
47 else if(self.items & (IT_KEY1 | IT_KEY2))
52 else if(self.classname == "rune")
55 if(self.owner.classname != "runematch_spawn_point")
56 DropAllRunes(self.owner);
59 else if(self.classname == "sprite_waypoint")
61 if(self.health | g_keyhunt)
62 WaypointSprite_Kill(self);
64 else if(self.classname == "dom_controlpoint")
66 dom_controlpoint_setup();
68 else if(self.flags & FL_ITEM) // reset items
70 self.model = self.mdl;
71 self.solid = SOLID_TRIGGER;
72 setorigin (self, self.origin);
73 self.think = SUB_Null;
76 else if(self.flags & FL_PROJECTILE) // remove any projectiles left
78 sound(self, CHAN_BODY, "misc/null.wav", 1, ATTN_NORM);
85 // TODO properly reset Onslaught
86 else if(self.classname == "onslaught_generator")
88 onslaught_generator_reset();
90 else if(self.classname == "onslaught_controlpoint")
92 onslaught_controlpoint_reset();
94 // TODO properly reset Assault
95 // General teambased game modes
96 else if(self.classname == "info_player_deathmatch")
98 self.team = self.team_saved;
100 self = nextent(self);
103 // Moving the player reset code here since the player-reset depends
104 // on spawnpoint entities which have to be reset first --blub
105 FOR_EACH_CLIENT(self) {
106 if(self.flags & FL_CLIENT) // reset all players
108 if(time < restart_countdown)
110 self.frags = (g_lms)?LMS_NewPlayerLives():0;
113 self.classname = "player";
121 PutObserverInServer();
127 kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round")+RESTART_COUNTDOWN, "", kh_StartRound);
131 UpdateFrags(champion, +1);
134 void Spawnqueue_Insert(entity e)
138 dprint(strcat("Into queue: ", e.netname, "\n"));
139 e.spawnqueue_in = TRUE;
140 e.spawnqueue_prev = spawnqueue_last;
141 e.spawnqueue_next = world;
143 spawnqueue_last.spawnqueue_next = e;
145 if(!spawnqueue_first)
146 spawnqueue_first = e;
149 void Spawnqueue_Remove(entity e)
153 dprint(strcat("Out of queue: ", e.netname, "\n"));
154 e.spawnqueue_in = FALSE;
155 if(e == spawnqueue_first)
156 spawnqueue_first = e.spawnqueue_next;
157 if(e == spawnqueue_last)
158 spawnqueue_last = e.spawnqueue_prev;
159 if(e.spawnqueue_prev)
160 e.spawnqueue_prev.spawnqueue_next = e.spawnqueue_next;
161 if(e.spawnqueue_next)
162 e.spawnqueue_next.spawnqueue_prev = e.spawnqueue_prev;
163 e.spawnqueue_next = world;
164 e.spawnqueue_prev = world;
167 void Spawnqueue_Unmark(entity e)
172 numspawned = numspawned - 1;
175 void Spawnqueue_Mark(entity e)
180 numspawned = numspawned + 1;
188 if(!g_arena || !arena_roundbased || (time < restart_countdown))
191 f = rint(warmup - time);
194 if(time < warmup && self.spawned)
197 msg = strcat(msg, "The Champion is ", champion.netname, "^7\n\n\n");
200 msg = strcat(msg, "Round will start in ", ftos(f));
204 msg = strcat(msg, "^1Fight!");
207 centerprint(self, msg);
210 self.movetype = MOVETYPE_NONE;
212 self.velocity = '0 0 0';
213 self.avelocity = '0 0 0';
214 self.movement = '0 0 0';
215 //self.fixangle = TRUE;
217 else if(self.movetype == MOVETYPE_NONE)
219 self.movetype = MOVETYPE_WALK;
220 centerprint(self, "\n");
226 void Spawnqueue_Check()
228 if(time < warmup + 1)
233 next_round = time + 3;
235 if(!arena_roundbased || (next_round && next_round < time && player_count > 1))
241 champion = find(world, classname, "player");
242 while(champion && champion.deadflag)
243 champion = find(champion, classname, "player");
247 while(numspawned < maxspawned && spawnqueue_first)
249 self = spawnqueue_first;
251 bprint ("^4", self.netname, "^4 is the next challenger\n");
253 Spawnqueue_Remove(self);
254 Spawnqueue_Mark(self);
256 self.classname = "player";