]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/arena.qc
Add Arena to the mutator system, making use of round_handler. Also add support for...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / arena.qc
1 void PutClientInServer();
2
3 /**
4  * Resets the state of all clients, items, flags, runes, keys, weapons, waypoints, ... of the map.
5  */
6 void reset_map(float dorespawn)
7 {
8         entity oldself;
9         oldself = self;
10
11         if(time <= game_starttime && round_handler_IsActive())
12                 round_handler_Reset(game_starttime + 1);
13
14         if(g_race || g_cts)
15                 race_ReadyRestart();
16         else MUTATOR_CALLHOOK(reset_map_global);
17
18         lms_lowest_lives = 999;
19         lms_next_place = player_count;
20
21         for(self = world; (self = nextent(self)); )
22         if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
23         {
24                 if(self.reset)
25                 {
26                         self.reset();
27                         continue;
28                 }
29
30                 if(self.team_saved)
31                         self.team = self.team_saved;
32
33                 if(self.flags & FL_PROJECTILE) // remove any projectiles left
34                         remove(self);
35         }
36
37         // Waypoints and assault start come LAST
38         for(self = world; (self = nextent(self)); )
39         if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
40         {
41                 if(self.reset2)
42                 {
43                         self.reset2();
44                         continue;
45                 }
46         }
47
48         // Moving the player reset code here since the player-reset depends
49         // on spawnpoint entities which have to be reset first --blub
50         if(dorespawn)
51         if(!MUTATOR_CALLHOOK(reset_map_players))
52         FOR_EACH_CLIENT(self) {
53                 if(self.flags & FL_CLIENT)                              // reset all players
54                 {
55                         {
56                                 /*
57                                 only reset players if a restart countdown is active
58                                 this can either be due to cvar sv_ready_restart_after_countdown having set
59                                 restart_mapalreadyrestarted to 1 after the countdown ended or when
60                                 sv_ready_restart_after_countdown is not used and countdown is still running
61                                 */
62                                 if (restart_mapalreadyrestarted || (time < game_starttime))
63                                 {
64                                         //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
65                                         if (self.classname == "player") {
66                                                 //PlayerScore_Clear(self);
67                                                 if(g_lms)
68                                                         PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
69                                                 self.killcount = 0;
70                                                 //stop the player from moving so that he stands still once he gets respawned
71                                                 self.velocity = '0 0 0';
72                                                 self.avelocity = '0 0 0';
73                                                 self.movement = '0 0 0';
74                                                 PutClientInServer();
75                                         }
76                                 }
77                         }
78                 }
79         }
80
81         if(g_keyhunt)
82                 kh_Controller_SetThink_NoMsg(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), kh_StartRound);
83
84         self = oldself;
85 }
86