X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftarget%2Fchangelevel.qc;h=114fd871818a14e4ea3df07f52584aa88802ec65;hb=b093c2ea2c367cb9bb4ce2c0468346080938270c;hp=69f444073f16ce31432628d63cc95fa05dfb24fb;hpb=f72821fdcebe3ca01181a99727a06198de65ea08;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/target/changelevel.qc b/qcsrc/common/triggers/target/changelevel.qc index 69f444073..114fd8718 100644 --- a/qcsrc/common/triggers/target/changelevel.qc +++ b/qcsrc/common/triggers/target/changelevel.qc @@ -1,43 +1,55 @@ +#include "changelevel.qh" #ifdef SVQC .string chmap, gametype; .entity chlevel_targ; - -void target_changelevel_use() +void target_changelevel_use(entity this, entity actor, entity trigger) { - SELFPARAM(); - if(self.spawnflags & 2) + if(this.spawnflags & CHANGELEVEL_MULTIPLAYER) { // 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; 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 == 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")); } +/*target_changelevel +Target to change/end level +KEYS: +chmap: map to switch to, leave empty for endmatch +gametype: gametype for the next map +count: fraction of real players that need to trigger this entity for levelchange +SPAWNFLAGS: +CHANGELEVEL_MULTIPLAYER: multiplayer support +*/ + spawnfunc(target_changelevel) { - self.use = target_changelevel_use; + this.use = target_changelevel_use; - if(!self.count) { self.count = 0.7; } + if(!this.count) + { + this.count = 0.7; + } } #endif