// if turning is enabled, the train will turn toward the next point while waiting
if(self.bezier_turn && !self.train_wait_turning)
{
- entity targ;
+ entity targ, cp;
vector org;
targ = find(world, targetname, self.target);
- if(self.spawnflags & 1) // bezier curves movement
+ if(self.spawnflags & 1 && targ.curve)
+ cp = find(world, targetname, targ.curve);
+ else
+ cp = world;
+
+ if(cp) // bezier curves movement
+ org = normalize(cp.origin - self.origin); // use the origin of the control point of the next path_corner
+ else // linear movement
+ org = normalize(targ.origin - self.origin); // use the origin of the next path_corner
+
+ if(self.wait >= 0) // slow turning
{
- 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);
- }
+ SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
+ self.train_wait_turning = TRUE;
+ return;
}
- else
+ else // instant turning
{
- 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);
- }
+ self.angles = vectoangles(org - self.origin);
}
}