]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
also add trigger_conveyor; new behaviour
authorRudolf Polzer <divverent@alientrap.org>
Thu, 29 Dec 2011 22:10:50 +0000 (23:10 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 29 Dec 2011 22:10:50 +0000 (23:10 +0100)
qcsrc/server/cl_physics.qc
qcsrc/server/defs.qh
qcsrc/server/t_plats.qc

index 9364d729418fd8069328085b640160350c010790..79087eb8a366e9a5ed91c67de9024d058ef3140f 100644 (file)
@@ -882,25 +882,9 @@ void SV_PlayerPhysics()
                swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
        }
 
-       // conveyors: check if we still convey stuff
-       float conveyor_broken = FALSE;
-       if(self.groundentity.classname == "func_conveyor")
-       if(self.groundentity.nextthink)
-       {
-               if(!WarpZoneLib_BoxTouchesBrush(self.absmin + '0 0 -1', self.absmax + '0 0 -1', self.groundentity, self))
-                       self.groundentity = world;
-       }
-       if(!self.groundentity)
-       {
-               tracebox(self.origin + '0 0 -1', self.mins, self.maxs, self.origin + '0 0 -1', MOVE_NORMAL, self);
-               if(trace_ent.classname == "func_conveyor")
-                       self.groundentity = trace_ent;
-       }
-
        // conveyors: first fix velocity
-       if(self.groundentity.classname == "func_conveyor")
-               if(self.groundentity.nextthink)
-                       self.velocity -= self.groundentity.movedir;
+       if(self.conveyor.state)
+               self.velocity -= self.conveyor.movedir;
 
        if(self.classname != "player")
        {
@@ -1382,9 +1366,8 @@ void SV_PlayerPhysics()
                self.lastground = time;
 
        // conveyors: then break velocity again
-       if(self.groundentity.classname == "func_conveyor")
-               if(self.groundentity.nextthink)
-                       self.velocity += self.groundentity.movedir;
+       if(self.conveyor.state)
+               self.velocity += self.conveyor.movedir;
 
        self.lastflags = self.flags;
        self.lastclassname = self.classname;
index 4b2684c510a730cbaf0ecc9ce6cdab141b9b8779..68c1fb0586b4854e2eeecd644e9751ff3e60e72e 100644 (file)
@@ -671,3 +671,5 @@ void PlayerUseKey();
 
 typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
 .spawn_evalfunc_t spawn_evalfunc;
+
+.entity conveyor;
index 8af076ce2af89fdc8f4ce7c6f545a632e649c43f..6b85d209c2edab8efea30a28d17b60bc809a9b41 100644 (file)
@@ -2058,45 +2058,56 @@ void spawnfunc_func_vectormamamam()
 
 void conveyor_think()
 {
-       for(other = world; (other = findentity(other, groundentity, self)); )
+       entity e;
+
+       // set myself as current conveyor where possible
+       for(e = world; (e = findentity(e, conveyor, self)); )
+               e.conveyor = world;
+
+       if(self.state)
        {
-               if(other.flags & FL_CLIENT) // doing it via velocity has quite some advantages
-                       continue; // done in SV_PlayerPhysics
+               for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5); e; e = e.chain)
+                       if(!e.conveyor.state)
+                       {
+                               vector emin = e.absmin - '1 1 1';
+                               vector emax = e.absmax + '1 1 1';
+                               if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
+                                       if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
+                                               e.conveyor = self;
+                       }
+
+               for(e = world; (e = findentity(e, conveyor, self)); )
+               {
+                       if(e.flags & FL_CLIENT) // doing it via velocity has quite some advantages
+                               continue; // done in SV_PlayerPhysics
 
-               // stupid conveyor code
-               tracebox(other.origin, other.mins, other.maxs, other.origin + self.movedir * sys_frametime, MOVE_NORMAL, other);
-               if(trace_fraction > 0)
-                       setorigin(other, trace_endpos);
+                       // stupid conveyor code
+                       tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
+                       if(trace_fraction > 0)
+                               setorigin(e, trace_endpos);
+               }
        }
+
        self.nextthink = time;
 }
 
 void conveyor_use()
 {
-       if(self.nextthink)
-               self.nextthink = 0;
-       else
-               self.nextthink = time;
+       self.state = !self.state;
 }
 
 void conveyor_reset()
 {
-       if(self.spawnflags & 1)
-               self.nextthink = time;
-       else
-               self.nextthink = 0;
+       self.state = (self.spawnflags & 1);
 }
 
-void spawnfunc_func_conveyor()
+void conveyor_init()
 {
-       SetMovedir ();
-       if not(InitMovingBrushTrigger())
-               return;
-       self.movetype = MOVETYPE_NONE;
        if (!self.speed)
                self.speed = 200;
        self.movedir = self.movedir * self.speed;
        self.think = conveyor_think;
+       self.nextthink = time;
        IFTARGETED
        {
                self.use = conveyor_use;
@@ -2104,5 +2115,19 @@ void spawnfunc_func_conveyor()
                conveyor_reset();
        }
        else
-               self.nextthink = time;
+               self.state = 1;
+}
+
+void spawnfunc_trigger_conveyor()
+{
+       EXACTTRIGGER_INIT;
+       conveyor_init();
+}
+
+void spawnfunc_func_conveyor()
+{
+       SetMovedir();
+       InitMovingBrushTrigger();
+       self.movetype = MOVETYPE_NONE;
+       conveyor_init();
 }