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