From 7ee5673f30485bb1feb91f3fb19cafd8baa71ff5 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 16 Feb 2017 23:54:27 +1000 Subject: [PATCH] Add a level warp target entity to allow maps to trigger skipping ahead in a campaign (SMB-style warp zones) --- qcsrc/common/triggers/target/_mod.inc | 1 + qcsrc/common/triggers/target/_mod.qh | 1 + qcsrc/common/triggers/target/include.qc | 1 + qcsrc/common/triggers/target/levelwarp.qc | 19 +++++++++++++++++++ qcsrc/common/triggers/target/levelwarp.qh | 1 + 5 files changed, 23 insertions(+) create mode 100644 qcsrc/common/triggers/target/levelwarp.qc create mode 100644 qcsrc/common/triggers/target/levelwarp.qh diff --git a/qcsrc/common/triggers/target/_mod.inc b/qcsrc/common/triggers/target/_mod.inc index 195d5e534..71bd8c11e 100644 --- a/qcsrc/common/triggers/target/_mod.inc +++ b/qcsrc/common/triggers/target/_mod.inc @@ -1,6 +1,7 @@ // generated file; do not modify #include #include +#include #include #include #include diff --git a/qcsrc/common/triggers/target/_mod.qh b/qcsrc/common/triggers/target/_mod.qh index a5462d497..6b06b75f1 100644 --- a/qcsrc/common/triggers/target/_mod.qh +++ b/qcsrc/common/triggers/target/_mod.qh @@ -1,6 +1,7 @@ // generated file; do not modify #include #include +#include #include #include #include diff --git a/qcsrc/common/triggers/target/include.qc b/qcsrc/common/triggers/target/include.qc index c53ea6d17..c643e4785 100644 --- a/qcsrc/common/triggers/target/include.qc +++ b/qcsrc/common/triggers/target/include.qc @@ -1,6 +1,7 @@ #include "include.qh" #include "changelevel.qc" +#include "levelwarp.qc" #include "location.qc" #include "music.qc" #include "spawn.qc" diff --git a/qcsrc/common/triggers/target/levelwarp.qc b/qcsrc/common/triggers/target/levelwarp.qc new file mode 100644 index 000000000..6cef53d6e --- /dev/null +++ b/qcsrc/common/triggers/target/levelwarp.qc @@ -0,0 +1,19 @@ +#include "levelwarp.qh" + +#ifdef SVQC +void target_levelwarp_use(entity this, entity actor, entity trigger) +{ + if(!autocvar_g_campaign) + return; // only in campaign + + if(this.cnt) + CampaignLevelWarp(this.cnt - 1); // specific level + else + CampaignLevelWarp(-1); // next level +} + +spawnfunc(target_levelwarp) +{ + this.use = target_levelwarp_use; +} +#endif diff --git a/qcsrc/common/triggers/target/levelwarp.qh b/qcsrc/common/triggers/target/levelwarp.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/triggers/target/levelwarp.qh @@ -0,0 +1 @@ +#pragma once -- 2.39.2