Skip to content

Commit

Permalink
Add trigger_timer and auto redirect start maps to the quake hub
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioSMB committed Oct 26, 2024
1 parent 1c49d97 commit 779812a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mod/quake/common/triggers/trigger/changelevel.qc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ spawnfunc(trigger_changelevel)
return;
}

// hack: any maps that aren't the main campaign auto redirect to our hub instead
if(this.map == "start")
{
if(world.model != "maps/e1m7.bsp" && world.model != "maps/e2m6.bsp" && world.model != "maps/e3m6.bsp" && world.model != "maps/e4m7.bsp")
this.map = "quake";
}

this.killstring = " tried to leave";

if(this.targetname && this.targetname != "" && !IsMGMap())
Expand Down
1 change: 1 addition & 0 deletions mod/quake/common/triggers/trigger/include.qc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "setskill.qc"
#include "shelter_portal.qc"
#include "teleport.qc"
#include "timer.qc"
#include "usekey.qc"
#include "viewloc.qc"
#include "waterfall.qc"
72 changes: 72 additions & 0 deletions mod/quake/common/triggers/trigger/timer.qc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifdef SVQC

.float rand;

void timer_think(entity this)
{
playercount_convert(this, count);

if(this.state == this.count)
{
//SUB_Remove();
return;
}

if(this.nextthink > time) // turn off again
{
this.nextthink = 0;
return;
}

this.nextthink = time + this.wait + random() * this.rand;
this.state += 1;
SUB_UseTargets(this, this.owner, this.enemy);
}

void timer_use(entity this, entity actor, entity trigger)
{
this.owner = actor;
this.enemy = trigger;
this.state = 0;
timer_think(this);
}

/*QUAKED trigger_timer (.5 .5 .5) (-16 -16 -16) (16 16 16) START_ON
Fires its targets once every "wait" seconds. If "count" is set, it will only fire that many times and then stop. Set "rand" to add a random extra delay to the wait interval.
SPAWNFLAGS
START_ON: do not wait until triggered to begin firing
*/
/*FGD
@PointClass size(32 32 32) color(160 0 160) base(Appearflags, Target, Targetname) = trigger_timer : "Trigger: Timer
Fires its targets once every 'wait' seconds once activated. If 'count' is set, it will only fire that many times and then stop. Set 'rand' to add a random extra delay to the wait interval."
[
spawnflags(flags) = [
1: "Start On" : 0
]
count(integer) : "Limit" : 0
wait(string) : "Interval"
rand(string) : "Random Extra Interval"
]
*/
spawnfunc(trigger_timer)
{
if(!this.wait)
this.wait = 1;
if(this.rand < 0)
this.rand = 0;

setthink(this, timer_think);
this.use = timer_use;

if(this.spawnflags & 1) // start on
{
this.nextthink = time + this.wait;
this.owner = nextent(NULL); // use first player as activator since we're never triggered by an activator
}

if(!this.count)
this.count = -1;
}

#endif

0 comments on commit 779812a

Please sign in to comment.