]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Basic support for winning the level in campaigns when activating a target_changelevel
authorMario <mario@smbclan.net>
Tue, 7 May 2019 00:28:05 +0000 (10:28 +1000)
committerMario <mario@smbclan.net>
Tue, 7 May 2019 00:28:05 +0000 (10:28 +1000)
qcsrc/common/mapobjects/target/changelevel.qc
qcsrc/server/campaign.qc
qcsrc/server/campaign.qh

index 114fd871818a14e4ea3df07f52584aa88802ec65..7166e46ca66ef0906aa0b653b831e6e6caa759dd 100644 (file)
@@ -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
index e90d6660352a28d0f62415cdd2d769110e8495d7..ddc7e47fa6c31386d3ff17c3d9b2d6e0a441ecbc 100644 (file)
@@ -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.
index 6feb07c4541965366aa850ee8aaf2b984200e253..df25c6c6ac5430581e13b7bb293446159e38b1d6 100644 (file)
@@ -17,3 +17,5 @@ void CampaignLevelWarp(float n);
  * in other game modes, this is ignored
  */
 bool campaign_bots_may_start;
+
+bool campaign_forcewin;