]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make a generic trigger touch function
authorMario <zacjardine@y7mail.com>
Mon, 5 Jan 2015 12:27:04 +0000 (23:27 +1100)
committerMario <zacjardine@y7mail.com>
Mon, 5 Jan 2015 12:27:04 +0000 (23:27 +1100)
qcsrc/client/Main.qc
qcsrc/server/t_halflife.qc
qcsrc/server/t_jumppads.qc

index aff71b806b3f0f51c5db53bb447f8359764e2786..fcb25246f560c9e1b5455a4c48ad0d3d625fc981 100644 (file)
@@ -331,6 +331,27 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
 // --------------------------------------------------------------------------
 // BEGIN OPTIONAL CSQC FUNCTIONS
+void trigger_touch_generic(void() touchfunc)
+{
+       entity e;
+       for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
+       if(e.isplayermodel)
+       {
+               vector emin = e.absmin, emax = e.absmax;
+               if(self.solid == SOLID_BSP)
+               {
+                       emin -= '1 1 1';
+                       emax += '1 1 1';
+               }
+               if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
+               if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
+               {
+                       other = e;
+                       touchfunc();
+               }
+       }
+}
+
 void Ent_RemoveEntCS()
 {
        entcs_receiver[self.sv_entnum] = world;
index 961ecdc0e84847a52b577286317d2287e8179830..1f45f9c8241ec6f7b9f8a52dbd0bc2e291e8bbf2 100644 (file)
@@ -119,25 +119,7 @@ void func_ladder_draw()
        self.move_time = time;
        if(dt <= 0) { return; }
 
-       entity e;
-
-               for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
-                               if(e.isplayermodel)
-                               {
-                                       vector emin = e.absmin;
-                                       vector emax = e.absmax;
-                                       if(self.solid == SOLID_BSP)
-                                       {
-                                               emin -= '1 1 1';
-                                               emax += '1 1 1';
-                                       }
-                                       if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
-                                               if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
-                                               {
-                                                       other = e;
-                                                       func_ladder_touch();
-                                               }
-                               }
+       trigger_touch_generic(func_ladder_touch);
 }
 
 void ent_func_ladder()
index d45879491525dca01c4c587fcf7c47fcd97b02f5..fa2f4fe50a5ae8c8c4e72fc483c64d6fb8f2eeae 100644 (file)
@@ -456,19 +456,11 @@ void spawnfunc_target_position() { target_push_link(); }
 #ifdef CSQC
 void trigger_push_draw()
 {
-       /*float dt = time - self.move_time;
+       float dt = time - self.move_time;
        self.move_time = time;
-       if(dt <= 0)
-               return;*/
+       if(dt <= 0) { return; }
 
-       tracebox(self.origin, self.mins, self.maxs, self.origin, MOVE_NORMAL, self);
-
-       //if(trace_fraction < 1)
-       if(trace_ent)
-       {
-               other = trace_ent;
-               trigger_push_touch();
-       }
+       trigger_touch_generic(trigger_push_touch);
 }
 
 void ent_trigger_push()