]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/target/changelevel.qc
Merge branch 'master' into terencehill/tooltips_cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / target / changelevel.qc
1 #ifdef SVQC
2 .string chmap, gametype;
3 .entity chlevel_targ;
4
5
6 void target_changelevel_use()
7 {
8         SELFPARAM();
9         if(self.spawnflags & 2)
10         {
11                 // simply don't react if a non-player triggers it
12                 if(!IS_PLAYER(activator)) { return; }
13
14                 activator.chlevel_targ = self;
15
16                 entity head;
17                 int plnum = 0;
18                 int realplnum = 0;
19                 // let's not count bots
20                 FOR_EACH_REALPLAYER(head)
21                 {
22                         ++realplnum;
23                         if(head.chlevel_targ == self)
24                                 ++plnum;
25                 }
26                 if(plnum < ceil(realplnum * min(1, self.count))) // 70% of players
27                         return;
28         }
29
30         if(self.gametype != "")
31                 MapInfo_SwitchGameType(MapInfo_Type_FromString(self.gametype));
32
33         if (self.chmap == "")
34                 localcmd("endmatch\n");
35         else
36                 localcmd(strcat("changelevel ", self.chmap, "\n"));
37 }
38
39 spawnfunc(target_changelevel)
40 {
41         self.use = target_changelevel_use;
42
43         if(!self.count) { self.count = 0.7; }
44 }
45 #endif