X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftarget%2Fchangelevel.qc;h=d4bc850de11eef0766ec3aeeefca3aca59ac75e6;hb=3220cab5a7b69ced4a641504a6a5f4eccf2d3bfc;hp=1ec8cc9e730d626eeb800e69f261ee5a8ceac510;hpb=924ba9b521119651b5667c0280868df9f95ca488;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/target/changelevel.qc b/qcsrc/common/triggers/target/changelevel.qc index 1ec8cc9e7..d4bc850de 100644 --- a/qcsrc/common/triggers/target/changelevel.qc +++ b/qcsrc/common/triggers/target/changelevel.qc @@ -1,18 +1,41 @@ #ifdef SVQC .string chmap, gametype; -void spawnfunc_target_changelevel_use() +.entity chlevel_targ; + +void target_changelevel_use(entity this, entity actor, entity trigger) { - if(self.gametype != "") - MapInfo_SwitchGameType(MapInfo_Type_FromString(self.gametype)); + if(this.spawnflags & 2) + { + // simply don't react if a non-player triggers it + if(!IS_PLAYER(actor)) { return; } + + actor.chlevel_targ = this; + + int plnum = 0; + int realplnum = 0; + // let's not count bots + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { + ++realplnum; + if(it.chlevel_targ == this) + ++plnum; + }); + if(plnum < ceil(realplnum * min(1, this.count))) // 70% of players + return; + } - if (self.chmap == "") + if(this.gametype != "") + MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype)); + + if (this.chmap == "") localcmd("endmatch\n"); else - localcmd(strcat("changelevel ", self.chmap, "\n")); + localcmd(strcat("changelevel ", this.chmap, "\n")); } -void spawnfunc_target_changelevel() +spawnfunc(target_changelevel) { - self.use = spawnfunc_target_changelevel_use; + this.use = target_changelevel_use; + + if(!this.count) { this.count = 0.7; } } #endif