]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/subs.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / subs.qc
index b313c49996046e1dec57d08169a891a44fdff6c9..7d6ea9de981ce038ea9d9603e6cd1258e00946f1 100644 (file)
@@ -1,8 +1,7 @@
-void SUB_NullThink(void) { }
+void SUB_NullThink() { }
 
 void()  SUB_CalcMoveDone;
 void() SUB_CalcAngleMoveDone;
-//void() SUB_UseTargets;
 
 /*
 ==================
@@ -12,7 +11,7 @@ Applies some friction to self
 ==================
 */
 .float friction;
-void SUB_Friction (void)
+void SUB_Friction ()
 {SELFPARAM();
        self.SUB_NEXTTHINK = time;
        if(self.SUB_FLAGS & FL_ONGROUND)
@@ -45,17 +44,17 @@ void SUB_VanishOrRemove (entity ent)
        }
 }
 
-void SUB_SetFade_Think (void)
+void SUB_SetFade_Think ()
 {SELFPARAM();
-       if(self.alpha == 0)
-               self.alpha = 1;
-       self.SUB_THINK = SUB_SetFade_Think;
-       self.SUB_NEXTTHINK = time;
-       self.alpha -= frametime * self.fade_rate;
-       if (self.alpha < 0.01)
-               SUB_VanishOrRemove(self);
+       if(this.alpha == 0)
+               this.alpha = 1;
+       this.SUB_THINK = SUB_SetFade_Think;
+       this.SUB_NEXTTHINK = time;
+       this.alpha -= frametime * this.fade_rate;
+       if (this.alpha < 0.01)
+               SUB_VanishOrRemove(this);
        else
-               self.SUB_NEXTTHINK = time;
+               this.SUB_NEXTTHINK = time;
 }
 
 /*
@@ -80,7 +79,7 @@ calculate self.SUB_VELOCITY and self.SUB_NEXTTHINK to reach dest from
 self.SUB_ORIGIN traveling at speed
 ===============
 */
-void SUB_CalcMoveDone (void)
+void SUB_CalcMoveDone ()
 {SELFPARAM();
        // After moving, set origin to exact final destination
 
@@ -92,7 +91,7 @@ void SUB_CalcMoveDone (void)
 }
 
 .float platmovetype_turn;
-void SUB_CalcMove_controller_think (void)
+void SUB_CalcMove_controller_think ()
 {SELFPARAM();
        entity oldself;
        float traveltime;
@@ -123,9 +122,11 @@ void SUB_CalcMove_controller_think (void)
                        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;
@@ -220,8 +221,7 @@ void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float
                return;
        }
 
-       controller = spawn();
-       controller.classname = "SUB_CalcMove_controller";
+       controller = new(SUB_CalcMove_controller);
        controller.owner = self;
        controller.platmovetype = self.platmovetype;
        controller.platmovetype_start = self.platmovetype_start;
@@ -294,7 +294,7 @@ void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
 
 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
 {SELFPARAM();
-       WITH(entity, self, ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
+       WITHSELF(ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
 }
 
 /*
@@ -307,7 +307,7 @@ self.angles rotating
 The calling function should make sure self.SUB_THINK is valid
 ===============
 */
-void SUB_CalcAngleMoveDone (void)
+void SUB_CalcAngleMoveDone ()
 {SELFPARAM();
        // After rotating, set angle to exact final angle
        self.angles = self.finalangle;
@@ -362,5 +362,5 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void()
 
 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
 {SELFPARAM();
-       WITH(entity, self, ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
+       WITHSELF(ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
 }