X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftarget%2Fchangelevel.qc;h=6c006d42a91610e70cd3984bc076cdc61312885c;hb=3018b03b7ad0decee85f2a659783d0b5309fe5a3;hp=8dc694e621e918e8e5a8049736f608f02da3950b;hpb=5b22584122d4354ab7819853d0fa5219d14d832e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/target/changelevel.qc b/qcsrc/common/triggers/target/changelevel.qc index 8dc694e62..6c006d42a 100644 --- a/qcsrc/common/triggers/target/changelevel.qc +++ b/qcsrc/common/triggers/target/changelevel.qc @@ -1,44 +1,42 @@ +#include "changelevel.qh" #ifdef SVQC .string chmap, gametype; .entity chlevel_targ; - -void spawnfunc_target_changelevel_use() -{SELFPARAM(); - if(self.spawnflags & 2) +void target_changelevel_use(entity this, entity actor, entity trigger) +{ + if(this.spawnflags & 2) { // simply don't react if a non-player triggers it - if(!IS_PLAYER(activator)) { return; } + if(!IS_PLAYER(actor)) { return; } - activator.chlevel_targ = self; + actor.chlevel_targ = this; - entity head; int plnum = 0; int realplnum = 0; // let's not count bots - FOR_EACH_REALPLAYER(head) - { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { ++realplnum; - if(head.chlevel_targ == self) + if(it.chlevel_targ == this) ++plnum; - } - if(plnum < ceil(realplnum * min(1, self.count))) // 70% of players + }); + if(plnum < ceil(realplnum * min(1, this.count))) // 70% of players return; } - if(self.gametype != "") - MapInfo_SwitchGameType(MapInfo_Type_FromString(self.gametype)); + if(this.gametype != "") + MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype)); - if (self.chmap == "") + if (this.chmap == "") localcmd("endmatch\n"); else - localcmd(strcat("changelevel ", self.chmap, "\n")); + localcmd(strcat("changelevel ", this.chmap, "\n")); } -void spawnfunc_target_changelevel() -{SELFPARAM(); - self.use = spawnfunc_target_changelevel_use; +spawnfunc(target_changelevel) +{ + this.use = target_changelevel_use; - if(!self.count) { self.count = 0.7; } + if(!this.count) { this.count = 0.7; } } #endif