]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/impulse.qc
Remove .move_* fields and MOVETYPE_PUSH logic (doesn't work)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / impulse.qc
index cd98627c82ff39091cd2e9ee8d419a45a6d66cc3..cdf4a72918b79c9ab5326814dd1040e12f061620 100644 (file)
 // targeted (directional) mode
-void trigger_impulse_touch1()
-{SELFPARAM();
+void trigger_impulse_touch1(entity this, entity toucher)
+{
        entity targ;
        float pushdeltatime;
        float str;
 
-       if (self.active != ACTIVE_ACTIVE)
+       if (this.active != ACTIVE_ACTIVE)
                return;
 
-       if (!isPushable(other))
+       if (!isPushable(toucher))
                return;
 
-       EXACTTRIGGER_TOUCH;
+       EXACTTRIGGER_TOUCH(this, toucher);
 
-       targ = find(world, targetname, self.target);
+       targ = find(NULL, targetname, this.target);
        if(!targ)
        {
-               objerror("trigger_force without a (valid) .target!\n");
-               remove(self);
+               objerror(this, "trigger_force without a (valid) .target!\n");
+               remove(this);
                return;
        }
 
-#ifdef SVQC
-       str = min(self.radius, vlen(self.origin - other.origin));
-#elif defined(CSQC)
-       str = min(self.radius, vlen(self.origin - other.move_origin));
-#endif
+       str = min(this.radius, vlen(this.origin - toucher.origin));
 
-       if(self.falloff == 1)
-               str = (str / self.radius) * self.strength;
-       else if(self.falloff == 2)
-               str = (1 - (str / self.radius)) * self.strength;
+       if(this.falloff == 1)
+               str = (str / this.radius) * this.strength;
+       else if(this.falloff == 2)
+               str = (1 - (str / this.radius)) * this.strength;
        else
-               str = self.strength;
+               str = this.strength;
 
-       pushdeltatime = time - other.lastpushtime;
+       pushdeltatime = time - toucher.lastpushtime;
        if (pushdeltatime > 0.15) pushdeltatime = 0;
-       other.lastpushtime = time;
+       toucher.lastpushtime = time;
        if(!pushdeltatime) return;
 
-       if(self.spawnflags & 64)
+       if(this.spawnflags & 64)
        {
-#ifdef SVQC
-               float addspeed = str - other.velocity * normalize(targ.origin - self.origin);
-               if (addspeed > 0)
-               {
-                       float accelspeed = min(8 * pushdeltatime * str, addspeed);
-                       other.velocity += accelspeed * normalize(targ.origin - self.origin);
-               }
-#elif defined(CSQC)
-               float addspeed = str - other.move_velocity * normalize(targ.origin - self.origin);
+               float addspeed = str - toucher.velocity * normalize(targ.origin - this.origin);
                if (addspeed > 0)
                {
                        float accelspeed = min(8 * pushdeltatime * str, addspeed);
-                       other.move_velocity += accelspeed * normalize(targ.origin - self.origin);
+                       toucher.velocity += accelspeed * normalize(targ.origin - this.origin);
                }
-#endif
        }
        else
-#ifdef SVQC
-               other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
-#elif defined(CSQC)
-               other.move_velocity = other.move_velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
-#endif
+               toucher.velocity = toucher.velocity + normalize(targ.origin - this.origin) * str * pushdeltatime;
 
-#ifdef SVQC
-       UNSET_ONGROUND(other);
+       UNSET_ONGROUND(toucher);
 
-       UpdateCSQCProjectile(other);
-#elif defined(CSQC)
-       other.move_flags &= ~FL_ONGROUND;
+#ifdef SVQC
+       UpdateCSQCProjectile(toucher);
 #endif
 }
 
 // Directionless (accelerator/decelerator) mode
-void trigger_impulse_touch2()
-{SELFPARAM();
+void trigger_impulse_touch2(entity this, entity toucher)
+{
        float pushdeltatime;
 
-       if (self.active != ACTIVE_ACTIVE)
+       if (this.active != ACTIVE_ACTIVE)
                return;
 
-       if (!isPushable(other))
+       if (!isPushable(toucher))
                return;
 
-       EXACTTRIGGER_TOUCH;
+       EXACTTRIGGER_TOUCH(this, toucher);
 
-       pushdeltatime = time - other.lastpushtime;
+       pushdeltatime = time - toucher.lastpushtime;
        if (pushdeltatime > 0.15) pushdeltatime = 0;
-       other.lastpushtime = time;
+       toucher.lastpushtime = time;
        if(!pushdeltatime) return;
 
        // div0: ticrate independent, 1 = identity (not 20)
-#ifdef SVQC
-       other.velocity = other.velocity * pow(self.strength, pushdeltatime);
+       toucher.velocity = toucher.velocity * pow(this.strength, pushdeltatime);
 
-       UpdateCSQCProjectile(other);
-#elif defined(CSQC)
-       other.move_velocity = other.move_velocity * pow(self.strength, pushdeltatime);
+#ifdef SVQC
+       UpdateCSQCProjectile(toucher);
 #endif
 }
 
 // Spherical (gravity/repulsor) mode
-void trigger_impulse_touch3()
-{SELFPARAM();
+void trigger_impulse_touch3(entity this, entity toucher)
+{
        float pushdeltatime;
        float str;
 
-       if (self.active != ACTIVE_ACTIVE)
+       if (this.active != ACTIVE_ACTIVE)
                return;
 
-       if (!isPushable(other))
+       if (!isPushable(toucher))
                return;
 
-       EXACTTRIGGER_TOUCH;
+       EXACTTRIGGER_TOUCH(this, toucher);
 
-       pushdeltatime = time - other.lastpushtime;
+       pushdeltatime = time - toucher.lastpushtime;
        if (pushdeltatime > 0.15) pushdeltatime = 0;
-       other.lastpushtime = time;
+       toucher.lastpushtime = time;
        if(!pushdeltatime) return;
 
-       setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius);
+       setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
 
-#ifdef SVQC
-       str = min(self.radius, vlen(self.origin - other.origin));
-#elif defined(CSQC)
-       str = min(self.radius, vlen(self.origin - other.move_origin));
-#endif
+       str = min(this.radius, vlen(this.origin - toucher.origin));
 
-       if(self.falloff == 1)
-               str = (1 - str / self.radius) * self.strength; // 1 in the inside
-       else if(self.falloff == 2)
-               str = (str / self.radius) * self.strength; // 0 in the inside
+       if(this.falloff == 1)
+               str = (1 - str / this.radius) * this.strength; // 1 in the inside
+       else if(this.falloff == 2)
+               str = (str / this.radius) * this.strength; // 0 in the inside
        else
-               str = self.strength;
+               str = this.strength;
 
-#ifdef SVQC
-       other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime;
+       toucher.velocity = toucher.velocity + normalize(toucher.origin - this.origin) * str * pushdeltatime;
 
-       UpdateCSQCProjectile(other);
-#elif defined(CSQC)
-       other.move_velocity = other.move_velocity + normalize(other.move_origin - self.origin) * str * pushdeltatime;
+#ifdef SVQC
+       UpdateCSQCProjectile(toucher);
 #endif
 }
 
@@ -195,20 +168,20 @@ spawnfunc(trigger_impulse)
                if(!this.strength) this.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
                setorigin(this, this.origin);
                setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
-               this.touch = trigger_impulse_touch3;
+               settouch(this, trigger_impulse_touch3);
        }
        else
        {
                if(this.target)
                {
                        if(!this.strength) this.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
-                       this.touch = trigger_impulse_touch1;
+                       settouch(this, trigger_impulse_touch1);
                }
                else
                {
                        if(!this.strength) this.strength = 0.9;
                        this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
-                       this.touch = trigger_impulse_touch2;
+                       settouch(this, trigger_impulse_touch2);
                }
        }
 
@@ -229,12 +202,10 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
        this.classname = "trigger_impulse";
        this.solid = SOLID_TRIGGER;
        this.entremove = trigger_remove_generic;
-       //this.draw = trigger_draw_generic;
-       this.drawmask = MASK_NORMAL;
        this.move_time = time;
 
-       if(this.radius) { this.move_touch = trigger_impulse_touch3; }
-       else if(this.target) { this.move_touch = trigger_impulse_touch1; }
-       else { this.move_touch = trigger_impulse_touch2; }
+       if (this.radius) { settouch(this, trigger_impulse_touch3); }
+       else if (this.target) { settouch(this, trigger_impulse_touch1); }
+       else { settouch(this, trigger_impulse_touch2); }
 }
 #endif