]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/impulse.qc
Merge branch 'martin-t/spec' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / impulse.qc
index 3d9a87a465f877d9a7ab68d8bef364d122af3f03..4be6e86bca66c6c02fcf2adbd3c7141721292647 100644 (file)
@@ -1,3 +1,4 @@
+#include "impulse.qh"
 // targeted (directional) mode
 void trigger_impulse_touch1(entity this, entity toucher)
 {
@@ -17,15 +18,11 @@ void trigger_impulse_touch1(entity this, entity toucher)
        if(!targ)
        {
                objerror(this, "trigger_force without a (valid) .target!\n");
-               remove(this);
+               delete(this);
                return;
        }
 
-#ifdef SVQC
        str = min(this.radius, vlen(this.origin - toucher.origin));
-#elif defined(CSQC)
-       str = min(this.radius, vlen(this.origin - toucher.move_origin));
-#endif
 
        if(this.falloff == 1)
                str = (str / this.radius) * this.strength;
@@ -41,35 +38,20 @@ void trigger_impulse_touch1(entity this, entity toucher)
 
        if(this.spawnflags & 64)
        {
-#ifdef SVQC
                float addspeed = str - toucher.velocity * normalize(targ.origin - this.origin);
                if (addspeed > 0)
                {
                        float accelspeed = min(8 * pushdeltatime * str, addspeed);
                        toucher.velocity += accelspeed * normalize(targ.origin - this.origin);
                }
-#elif defined(CSQC)
-               float addspeed = str - toucher.move_velocity * normalize(targ.origin - this.origin);
-               if (addspeed > 0)
-               {
-                       float accelspeed = min(8 * pushdeltatime * str, addspeed);
-                       toucher.move_velocity += accelspeed * normalize(targ.origin - this.origin);
-               }
-#endif
        }
        else
-#ifdef SVQC
                toucher.velocity = toucher.velocity + normalize(targ.origin - this.origin) * str * pushdeltatime;
-#elif defined(CSQC)
-               toucher.move_velocity = toucher.move_velocity + normalize(targ.origin - this.origin) * str * pushdeltatime;
-#endif
 
-#ifdef SVQC
        UNSET_ONGROUND(toucher);
 
+#ifdef SVQC
        UpdateCSQCProjectile(toucher);
-#elif defined(CSQC)
-       toucher.move_flags &= ~FL_ONGROUND;
 #endif
 }
 
@@ -92,12 +74,10 @@ void trigger_impulse_touch2(entity this, entity toucher)
        if(!pushdeltatime) return;
 
        // div0: ticrate independent, 1 = identity (not 20)
-#ifdef SVQC
-       toucher.velocity = toucher.velocity * pow(this.strength, pushdeltatime);
+       toucher.velocity = toucher.velocity * (this.strength ** pushdeltatime);
 
+#ifdef SVQC
        UpdateCSQCProjectile(toucher);
-#elif defined(CSQC)
-       toucher.move_velocity = toucher.move_velocity * pow(this.strength, pushdeltatime);
 #endif
 }
 
@@ -122,11 +102,7 @@ void trigger_impulse_touch3(entity this, entity toucher)
 
        setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
 
-#ifdef SVQC
        str = min(this.radius, vlen(this.origin - toucher.origin));
-#elif defined(CSQC)
-       str = min(this.radius, vlen(this.origin - toucher.move_origin));
-#endif
 
        if(this.falloff == 1)
                str = (1 - str / this.radius) * this.strength; // 1 in the inside
@@ -135,12 +111,10 @@ void trigger_impulse_touch3(entity this, entity toucher)
        else
                str = this.strength;
 
-#ifdef SVQC
        toucher.velocity = toucher.velocity + normalize(toucher.origin - this.origin) * str * pushdeltatime;
 
+#ifdef SVQC
        UpdateCSQCProjectile(toucher);
-#elif defined(CSQC)
-       toucher.move_velocity = toucher.move_velocity + normalize(toucher.move_origin - this.origin) * str * pushdeltatime;
 #endif
 }
 
@@ -207,7 +181,7 @@ spawnfunc(trigger_impulse)
                else
                {
                        if(!this.strength) this.strength = 0.9;
-                       this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
+                       this.strength = (this.strength ** autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
                        settouch(this, trigger_impulse_touch2);
                }
        }