From 84cfcdcddcd63700fa0f7ead008345884905f18b Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 18 Nov 2023 21:48:32 -0500 Subject: [PATCH] Override triggers for doors and plats --- conduit.fgd | 2 ++ defs.qc | 2 ++ doors.qc | 23 +++++++++++++++++++---- plats.qc | 17 +++++++++++++++-- todo | 3 +-- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/conduit.fgd b/conduit.fgd index 69f6155..89c964b 100644 --- a/conduit.fgd +++ b/conduit.fgd @@ -402,6 +402,7 @@ message(string) : "Message if touched" health(integer) : "Health (shootable)" : 0 squad(string) : "Explicitly link doors" : "" + trig_override(target_source) : "Override trigger" spawnflags(flags) = [ 1 : "Starts Open" : 0 @@ -488,6 +489,7 @@ ] speed(integer) : "Speed" : 150 height(integer) : "Travel altitude (can be negative)" : 0 + trig_override(target_source) : "Override trigger" sounds(choices) : "Sound" : 1 = [ 0: "None" diff --git a/defs.qc b/defs.qc index 868d476..b2416c9 100644 --- a/defs.qc +++ b/defs.qc @@ -574,6 +574,8 @@ float AS_MISSILE = 4; .vector pos1, pos2; // top and bottom positions .float height; +.string trig_override; + // // sounds // diff --git a/doors.qc b/doors.qc index 08c2f31..99eaf9b 100644 --- a/doors.qc +++ b/doors.qc @@ -344,15 +344,26 @@ entity(vector fmins, vector fmaxs) spawn_field = entity trigger; vector t1, t2; - trigger = spawn(); + if (self.trig_override != "") { + trigger = find(world, targetname, self.trig_override); + if (!trigger) { + objerror("Invalid override trigger"); + } + } else { + trigger = spawn(); + } + trigger.movetype = MOVETYPE_NONE; trigger.solid = SOLID_TRIGGER; trigger.owner = self; trigger.touch = door_trigger_touch; - t1 = fmins; - t2 = fmaxs; - setsize(trigger, t1 - '60 60 8', t2 + '60 60 8'); + if (self.trig_override == "") { + t1 = fmins; + t2 = fmaxs; + setsize(trigger, t1 - '60 60 8', t2 + '60 60 8'); + } + return(trigger); }; @@ -404,6 +415,10 @@ void() LinkDoors = { self.owner = starte; // master door + if (self.trig_override != "") { + self.owner.trig_override = self.trig_override; + } + if (self.health) starte.health = self.health; if (self.targetname) diff --git a/plats.qc b/plats.qc index 3859260..efd1191 100644 --- a/plats.qc +++ b/plats.qc @@ -34,12 +34,24 @@ void() plat_spawn_inside_trigger = // // middle trigger // - trigger = spawn(); + if (self.trig_override != "") { + trigger = find(world, targetname, self.trig_override); + if (!trigger) { + objerror("Invalid override trigger"); + } + } else { + trigger = spawn(); + } + trigger.touch = plat_center_touch; trigger.movetype = MOVETYPE_NONE; trigger.solid = SOLID_TRIGGER; trigger.enemy = self; + if (self.trig_override != "") { + return; + } + tmin = self.mins + '25 25 0'; tmax = self.maxs - '25 25 -8'; tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8); @@ -214,7 +226,8 @@ void() func_plat = self.use = plat_trigger_use; - plat_spawn_inside_trigger(); // the "start moving" trigger + self.think = plat_spawn_inside_trigger; // the "start moving" trigger + self.nextthink = self.ltime + 0.1; if (self.targetname) { diff --git a/todo b/todo index 6099e30..7901629 100644 --- a/todo +++ b/todo @@ -1,5 +1,4 @@ * override triggers -* explobox2 * useless voreball code -* Fix func_train override +* Fix func_train crash-to-console