*/
.float friction;
void SUB_Friction (void)
-{
+{SELFPARAM();
self.SUB_NEXTTHINK = time;
if(self.SUB_FLAGS & FL_ONGROUND)
self.SUB_VELOCITY = self.SUB_VELOCITY * (1 - frametime * self.friction);
}
void SUB_SetFade_Think (void)
-{
+{SELFPARAM();
if(self.alpha == 0)
self.alpha = 1;
self.SUB_THINK = SUB_SetFade_Think;
===============
*/
void SUB_CalcMoveDone (void)
-{
+{SELFPARAM();
// After moving, set origin to exact final destination
SUB_SETORIGIN (self, self.finaldest);
.float platmovetype_turn;
void SUB_CalcMove_controller_think (void)
-{
+{SELFPARAM();
entity oldself;
float traveltime;
float phasepos;
destangle_x = -destangle_x; // flip up / down orientation
// take the shortest distance for the angles
- SUB_ANGLES(self.owner)_x -= 360 * floor((SUB_ANGLES(self.owner)_x - destangle_x) / 360 + 0.5);
- SUB_ANGLES(self.owner)_y -= 360 * floor((SUB_ANGLES(self.owner)_y - destangle_y) / 360 + 0.5);
- SUB_ANGLES(self.owner)_z -= 360 * floor((SUB_ANGLES(self.owner)_z - destangle_z) / 360 + 0.5);
+ vector v = SUB_ANGLES(self.owner);
+ v.x -= 360 * floor((v.x - destangle_x) / 360 + 0.5);
+ v.y -= 360 * floor((v.y - destangle_y) / 360 + 0.5);
+ v.z -= 360 * floor((v.z - destangle_z) / 360 + 0.5);
+ SUB_ANGLES(self.owner) = v;
angloc = destangle - SUB_ANGLES(self.owner);
angloc = angloc * (1 / PHYS_INPUT_FRAMETIME); // so it arrives for the next frame
self.owner.SUB_AVELOCITY = angloc;
// derivative: delta + 2 * delta2 (e.g. for angle positioning)
oldself = self;
self.owner.SUB_THINK = self.think1;
- self = self.owner;
+ setself(self.owner);
remove(oldself);
self.SUB_THINK();
}
// TODO average too?
void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
float traveltime;
entity controller;
self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
// invoke controller
- self = controller;
+ setself(controller);
self.think();
- self = self.owner;
+ setself(self.owner);
}
void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
vector delta;
float traveltime;
}
void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
-{
- entity oldself;
-
- oldself = self;
- self = ent;
-
- SUB_CalcMove (tdest, tspeedtype, tspeed, func);
-
- self = oldself;
+{SELFPARAM();
+ WITH(entity, self, ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
}
/*
===============
*/
void SUB_CalcAngleMoveDone (void)
-{
+{SELFPARAM();
// After rotating, set angle to exact final angle
self.angles = self.finalangle;
self.SUB_AVELOCITY = '0 0 0';
// FIXME: I fixed this function only for rotation around the main axes
void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
vector delta;
float traveltime;
}
void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
-{
- entity oldself;
-
- oldself = self;
- self = ent;
-
- SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func);
-
- self = oldself;
+{SELFPARAM();
+ WITH(entity, self, ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
}