]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/target/changelevel.qc
Some new features and stuff for triggers (plus side-scrolling mode)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / target / changelevel.qc
index 1ec8cc9e730d626eeb800e69f261ee5a8ceac510..8e5c31bfea8a43ec01ea5b1ac53c4d0933e8cf0a 100644 (file)
@@ -1,7 +1,31 @@
 #ifdef SVQC
 .string chmap, gametype;
+.entity chlevel_targ;
+
+
 void spawnfunc_target_changelevel_use()
 {
+       if(self.spawnflags & 2)
+       {
+               // simply don't react if a non-player triggers it
+               if(!IS_PLAYER(activator)) { return; }
+
+               activator.chlevel_targ = self;
+
+               entity head;
+               int plnum = 0;
+               int realplnum = 0;
+               // let's not count bots
+               FOR_EACH_REALPLAYER(head)
+               {
+                       ++realplnum;
+                       if(head.chlevel_targ == self)
+                               ++plnum;
+               }
+               if(plnum < ceil(realplnum * min(1, self.count))) // 70% of players
+                       return;
+       }
+
        if(self.gametype != "")
                MapInfo_SwitchGameType(MapInfo_Type_FromString(self.gametype));
 
@@ -14,5 +38,7 @@ void spawnfunc_target_changelevel_use()
 void spawnfunc_target_changelevel()
 {
        self.use = spawnfunc_target_changelevel_use;
+
+       if(!self.count) { self.count = 0.7; }
 }
 #endif