]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_plats.qc
Merge remote-tracking branch 'origin/divVerent/allow-override-item-model'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_plats.qc
index ab121045b005392bdac38cfe20aacf5f953b5dd2..087a048c30c84177de7cb17e97a74e32b3158ede 100644 (file)
@@ -57,7 +57,17 @@ void plat_spawn_inside_trigger()
                tmax_y = tmin_y + 1;
        }
 
-       setsize (trigger, tmin, tmax);
+       if(tmin_x > tmax_x)
+               if(tmin_y > tmax_y)
+                       if(tmin_z > tmax_z)
+                       {
+                               setsize (trigger, tmin, tmax);
+                               return;
+                       }
+
+       // otherwise, something is fishy...
+       remove(trigger);
+       objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
 }
 
 void plat_hit_top()
@@ -175,11 +185,6 @@ void plat_reset()
 void spawnfunc_path_corner() { }
 void spawnfunc_func_plat()
 {
-       if (!self.t_length)
-               self.t_length = 80;
-       if (!self.t_width)
-               self.t_width = 10;
-
        if (self.sounds == 0)
                self.sounds = 2;
 
@@ -231,15 +236,19 @@ void spawnfunc_func_plat()
 
        if (!self.speed)
                self.speed = 150;
+       if (!self.lip)
+               self.lip = 16;
+       if (!self.height)
+               self.height = self.size_z - self.lip;
 
        self.pos1 = self.origin;
        self.pos2 = self.origin;
-       self.pos2_z = self.origin_z - self.size_z + 8;
-
-       plat_spawn_inside_trigger ();   // the "start moving" trigger
+       self.pos2_z = self.origin_z - self.height;
 
        self.reset = plat_reset;
        plat_reset();
+
+       plat_spawn_inside_trigger ();   // the "start moving" trigger
 }
 
 
@@ -2058,54 +2067,67 @@ 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(!WarpZoneLib_BoxTouchesBrush(other.absmin + '0 0 -1', other.absmax + '0 0 -1', self, other))
-               {
-                       other.flags &~= FL_ONGROUND;
-                       continue;
-               }
-               tracebox(other.origin, other.mins, other.maxs, other.origin + self.movedir * (self.speed * sys_frametime), MOVE_NORMAL, other);
-               if(trace_fraction > 0)
+               for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5); e; e = e.chain)
+                       if(!e.conveyor.state)
+                               if(isPushable(e))
+                               {
+                                       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
+                                                       e.conveyor = self;
+                               }
+
+               for(e = world; (e = findentity(e, conveyor, self)); )
                {
-                       if(other.flags & FL_CLIENT) // doing it via velocity has quite some advantages
-                       {
-                               float f = 1 - frametime * autocvar_sv_friction;
-                               if(f > 0)
-                                       other.velocity += self.movedir * self.speed * (1 / f - 1);
-                       }
-                       else
-                               setorigin(other, trace_endpos);
+                       if(e.flags & FL_CLIENT) // doing it via velocity has quite some advantages
+                               continue; // done in SV_PlayerPhysics
+
+                       setorigin(e, e.origin + self.movedir * sys_frametime);
+                       move_out_of_solid(e);
+                       UpdateCSQCProjectile(e);
+                       /*
+                       // 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;
@@ -2113,5 +2135,20 @@ void spawnfunc_func_conveyor()
                conveyor_reset();
        }
        else
-               self.nextthink = time;
+               self.state = 1;
+}
+
+void spawnfunc_trigger_conveyor()
+{
+       SetMovedir();
+       EXACTTRIGGER_INIT;
+       conveyor_init();
+}
+
+void spawnfunc_func_conveyor()
+{
+       SetMovedir();
+       InitMovingBrushTrigger();
+       self.movetype = MOVETYPE_NONE;
+       conveyor_init();
 }