+void SUB_CalcMove_controller_think (void)
+{
+ entity oldself;
+ float traveltime;
+ float phasepos;
+ float nexttick;
+ vector delta;
+ vector veloc;
+ vector nextpos;
+ if(time < self.animstate_endtime) {
+ delta = self.destvec;
+ nexttick = time + sys_frametime;
+
+ if(nexttick < self.animstate_endtime) {
+ traveltime = self.animstate_endtime - self.animstate_starttime;
+ phasepos = (nexttick - self.animstate_starttime) / traveltime; // range: [0, 1]
+ phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
+ phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1]
+ phasepos = phasepos + 1; // correct range to [0, 2]
+ phasepos = phasepos / 2; // correct range to [0, 1]
+ nextpos = self.origin + (delta * phasepos);
+
+ veloc = nextpos - self.owner.origin;
+ veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame
+
+ } else {
+ veloc = self.finaldest - self.owner.origin;
+ veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame
+ }
+ self.owner.velocity = veloc;
+ self.nextthink = nexttick;
+ } else {
+ oldself = self;
+ self.owner.think = self.think1;
+ self = self.owner;
+ remove(oldself);
+ self.think();
+ }
+}
+