X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Ft_plats.qc;h=440e16c5c5193a617ce317f2779d60222d4cba83;hb=3dc59a4b8f4bcbad4d6f0485fb1751c6c65eaa26;hp=fcad92f69327665e080b3eb78108c41e8b7bb53e;hpb=5433e6502011a7397bf31551afdc29edc29b337c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index fcad92f69..440e16c5c 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -182,6 +182,7 @@ void plat_reset() } } +.float platmovetype_start_default, platmovetype_end_default; float set_platmovetype(entity e, string s) { // sets platmovetype_start and platmovetype_end based on a string consisting of two values @@ -297,17 +298,32 @@ 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.platmovetype_turn && !self.train_wait_turning) { - entity targ; + entity targ, cp; 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) && 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 + { + SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait); + self.train_wait_turning = TRUE; + return; + } + else // instant turning + self.angles = org; } if(self.noise != "") @@ -334,12 +350,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.curvetarget) + { + 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 - cp_org = cp.origin - self.mins; + cp = world; // no cp } if (!self.target) objerror("train_next: no next target"); @@ -347,22 +364,29 @@ void train_next() if (!self.wait) self.wait = 0.1; - // override train movement type if necessary - if(targ.platmovetype_start || targ.platmovetype_end) - set_platmovetype(self, targ.platmovetype); + if(targ.platmovetype) + { + // this path_corner contains a movetype overrider, apply it + self.platmovetype_start = targ.platmovetype_start; + self.platmovetype_end = targ.platmovetype_end; + } else - set_platmovetype(self, self.platmovetype); + { + // this path_corner doesn't contain a movetype overrider, use the train's defaults + self.platmovetype_start = self.platmovetype_start_default; + self.platmovetype_end = self.platmovetype_end_default; + } 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); @@ -399,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; @@ -417,7 +441,10 @@ void spawnfunc_func_train() self.dmgtime = 0.25; self.dmgtime2 = time; - set_platmovetype(self, self.platmovetype); + if(!set_platmovetype(self, self.platmovetype)) + return; + self.platmovetype_start_default = self.platmovetype_start; + self.platmovetype_end_default = self.platmovetype_end; // TODO make a reset function for this one }