1 #include "changelevel.qh"
3 .string chmap, gametype;
6 void target_changelevel_use(entity this, entity actor, entity trigger)
11 if(this.spawnflags & CHANGELEVEL_MULTIPLAYER)
13 // simply don't react if a non-player triggers it
14 if(!IS_PLAYER(actor)) { return; }
16 actor.chlevel_targ = this;
20 // let's not count bots
21 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
23 if(it.chlevel_targ == this)
26 if(plnum < ceil(realplnum * min(1, this.count))) // 70% of players
30 if(this.gametype != "")
31 MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype));
35 if(IS_REAL_CLIENT(actor) && autocvar_g_campaign) // only count it as a win if the player touched (TODO: bots ending stage/vehicles?)
36 campaign_forcewin = true; // this counts as beating the map in a campaign stage!
40 changelevel(this.chmap);
44 Target to change/end level
46 chmap: map to switch to, leave empty for endmatch
47 gametype: gametype for the next map
48 count: fraction of real players that need to trigger this entity for levelchange
50 CHANGELEVEL_MULTIPLAYER: multiplayer support
53 spawnfunc(target_changelevel)
55 this.use = target_changelevel_use;