]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_plats.qc
Modify rotation origins with self.mins. This commit fixes the last part of the new...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_plats.qc
index e4772323a38228f5bc69c27606c3d3c9cb2576ce..440e16c5c5193a617ce317f2779d60222d4cba83 100644 (file)
@@ -299,24 +299,31 @@ void train_wait()
        self.enemy = world;
 
        // if turning is enabled, the train will turn toward the next point while waiting
-       if(self.wait >= 0 && self.bezier_turn && !self.train_wait_turning)
+       if(self.platmovetype_turn && !self.train_wait_turning)
        {
-               entity targ;
+               entity targ, cp;
                vector org;
-               if(self.spawnflags & 1) // bezier curves movement
-               {
-                       targ = find(world, targetname, self.target);
-                       org = normalize(targ.origin);
-                       SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
-               }
+               targ = find(world, targetname, self.target);
+               if((self.spawnflags & 1) && targ.curvetarget)
+                       cp = find(world, targetname, targ.curvetarget);
                else
+                       cp = world;
+
+               if(cp) // bezier curves movement
+                       org = cp.origin - (self.origin + self.mins); // use the origin of the control point of the next path_corner
+               else // linear movement
+                       org = targ.origin - (self.origin + self.mins); // use the origin of the next path_corner
+               org_z = -org_z;
+               org = vectoangles(org);
+
+               if(self.wait >= 0) // slow turning
                {
-                       targ = find(world, targetname, self.target);
-                       org = normalize(targ.origin);
                        SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
+                       self.train_wait_turning = TRUE;
+                       return;
                }
-               self.train_wait_turning = TRUE;
-               return;
+               else // instant turning
+                       self.angles = org;
        }
 
        if(self.noise != "")
@@ -343,9 +350,9 @@ void train_next()
        self.target = targ.target;
        if (self.spawnflags & 1)
        {
-               if(targ.curve)
+               if(targ.curvetarget)
                {
-                       cp = find(world, targetname, targ.curve); // get its second target (the control point)
+                       cp = find(world, targetname, targ.curvetarget); // get its second target (the control point)
                        cp_org = cp.origin - self.mins; // no control point found, assume a straight line to the destination
                }
                else
@@ -416,7 +423,7 @@ void spawnfunc_func_train()
        if (!self.speed)
                self.speed = 100;
        if (self.spawnflags & 2)
-               self.bezier_turn = TRUE;
+               self.platmovetype_turn = TRUE;
 
        if not(InitMovingBrushTrigger())
                return;