From: Mario Date: Tue, 7 May 2019 00:28:05 +0000 (+1000) Subject: Basic support for winning the level in campaigns when activating a target_changelevel X-Git-Tag: xonotic-v0.8.5~1511 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ecbae65d152803c3d5e5aee671c0a7e0a6b234b1;p=xonotic%2Fxonotic-data.pk3dir.git Basic support for winning the level in campaigns when activating a target_changelevel --- diff --git a/qcsrc/common/mapobjects/target/changelevel.qc b/qcsrc/common/mapobjects/target/changelevel.qc index 114fd8718..7166e46ca 100644 --- a/qcsrc/common/mapobjects/target/changelevel.qc +++ b/qcsrc/common/mapobjects/target/changelevel.qc @@ -5,6 +5,9 @@ void target_changelevel_use(entity this, entity actor, entity trigger) { + if(game_stopped) + return; + if(this.spawnflags & CHANGELEVEL_MULTIPLAYER) { // simply don't react if a non-player triggers it @@ -28,9 +31,13 @@ void target_changelevel_use(entity this, entity actor, entity trigger) MapInfo_SwitchGameType(MapInfo_Type_FromString(this.gametype)); if (this.chmap == "") - localcmd("endmatch\n"); + { + if(IS_REAL_CLIENT(actor) && autocvar_g_campaign) // only count it as a win if the player touched (TODO: bots ending stage/vehicles?) + campaign_forcewin = true; // this counts as beating the map in a campaign stage! + NextLevel(); + } else - localcmd(strcat("changelevel ", this.chmap, "\n")); + changelevel(this.chmap); } /*target_changelevel diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index e90d66603..ddc7e47fa 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -99,6 +99,8 @@ void CampaignPreInit() if(baseskill < 0) baseskill = 0; + campaign_forcewin = false; + cvar_set("sv_public", "0"); cvar_set("pausable", "1"); @@ -206,6 +208,11 @@ void CampaignPreIntermission() campaign_won = 1; bprint("Campaign test run, advancing level.\n"); } + else if(campaign_forcewin) + { + campaign_won = 1; + bprint("The current level has been WON.\n"); + } else if(won == 1 && lost == 0 && checkrules_equality == 0) { if(autocvar_timelimit != 0 && autocvar_fraglimit != 0 && time > autocvar_timelimit * 60) // checks if the timelimit has expired. diff --git a/qcsrc/server/campaign.qh b/qcsrc/server/campaign.qh index 6feb07c45..df25c6c6a 100644 --- a/qcsrc/server/campaign.qh +++ b/qcsrc/server/campaign.qh @@ -17,3 +17,5 @@ void CampaignLevelWarp(float n); * in other game modes, this is ignored */ bool campaign_bots_may_start; + +bool campaign_forcewin;