]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_plats.qc
Fix some important mistakes in the last commit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_plats.qc
index beab82ae58449fef0b797b40899e93bb87dbc7a7..f27bb2b9ff617d14a7c9973b66591c5d47cd81a2 100644 (file)
@@ -298,17 +298,40 @@ void train_wait()
        self = oldself;
        self.enemy = world;
 
-       // if using bezier curves and turning is enabled, the train will turn toward the next point while waiting
-       if(!self.train_wait_turning)
-       if(self.spawnflags & 1 && self.bezier_turn && self.wait >= 0)
+       // if turning is enabled, the train will turn toward the next point while waiting
+       if(self.bezier_turn && !self.train_wait_turning)
        {
                entity targ;
                vector org;
                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;
+               if(self.spawnflags & 1) // bezier curves movement
+               {
+                       org = normalize(targ.origin);
+                       if(self.wait >= 0)
+                       {
+                               SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
+                               self.train_wait_turning = TRUE;
+                               return;
+                       }
+                       else
+                       {
+                               self.angles = vectoangles(targ.origin - self.origin);
+                       }
+               }
+               else
+               {
+                       org = normalize(targ.origin);
+                       if(self.wait >= 0)
+                       {
+                               SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
+                               self.train_wait_turning = TRUE;
+                               return;
+                       }
+                       else
+                       {
+                               self.angles = vectoangles(targ.origin - self.origin);
+                       }
+               }
        }
 
        if(self.noise != "")
@@ -335,12 +358,13 @@ void train_next()
        self.target = targ.target;
        if (self.spawnflags & 1)
        {
-               cp = find(world, target, targ.targetname); // get the previous corner first
-               cp = find(world, targetname, cp.curve); // now get its second target (the control point)
-               if(cp.targetname == "")
-                       cp_org = targ.origin - self.mins; // no control point found, assume a straight line to the destination
+               if(targ.curve)
+               {
+                       cp = find(world, targetname, targ.curve); // 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
-                       cp_org = cp.origin - self.mins;
+                       cp = world; // no cp
        }
        if (!self.target)
                objerror("train_next: no next target");
@@ -363,14 +387,14 @@ void train_next()
 
        if (targ.speed)
        {
-               if (self.spawnflags & 1)
+               if (cp)
                        SUB_CalcMove_Bezier(cp_org, targ.origin - self.mins, TSPEED_LINEAR, targ.speed, train_wait);
                else
                        SUB_CalcMove(targ.origin - self.mins, TSPEED_LINEAR, targ.speed, train_wait);
        }
        else
        {
-               if (self.spawnflags & 1)
+               if (cp)
                        SUB_CalcMove_Bezier(cp_org, targ.origin - self.mins, TSPEED_LINEAR, self.speed, train_wait);
                else
                        SUB_CalcMove(targ.origin - self.mins, TSPEED_LINEAR, self.speed, train_wait);