X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fimpulse.qc;h=4be6e86bca66c6c02fcf2adbd3c7141721292647;hb=78b0634a8cfc4d1b6d24af825ac15d27d607e593;hp=91381f4877c9954ccc54ca618640503cd32bd058;hpb=3220cab5a7b69ced4a641504a6a5f4eccf2d3bfc;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/impulse.qc b/qcsrc/common/triggers/trigger/impulse.qc index 91381f487..4be6e86bc 100644 --- a/qcsrc/common/triggers/trigger/impulse.qc +++ b/qcsrc/common/triggers/trigger/impulse.qc @@ -1,5 +1,6 @@ +#include "impulse.qh" // targeted (directional) mode -void trigger_impulse_touch1(entity this) +void trigger_impulse_touch1(entity this, entity toucher) { entity targ; float pushdeltatime; @@ -8,24 +9,20 @@ void trigger_impulse_touch1(entity this) if (this.active != ACTIVE_ACTIVE) return; - if (!isPushable(other)) + if (!isPushable(toucher)) return; - EXACTTRIGGER_TOUCH; + EXACTTRIGGER_TOUCH(this, toucher); targ = find(NULL, targetname, this.target); 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 - other.origin)); -#elif defined(CSQC) - str = min(this.radius, vlen(this.origin - other.move_origin)); -#endif + str = min(this.radius, vlen(this.origin - toucher.origin)); if(this.falloff == 1) str = (str / this.radius) * this.strength; @@ -34,75 +31,58 @@ void trigger_impulse_touch1(entity this) else 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(this.spawnflags & 64) { -#ifdef SVQC - float addspeed = str - other.velocity * normalize(targ.origin - this.origin); + float addspeed = str - toucher.velocity * normalize(targ.origin - this.origin); if (addspeed > 0) { float accelspeed = min(8 * pushdeltatime * str, addspeed); - other.velocity += accelspeed * normalize(targ.origin - this.origin); + toucher.velocity += accelspeed * normalize(targ.origin - this.origin); } -#elif defined(CSQC) - float addspeed = str - other.move_velocity * normalize(targ.origin - this.origin); - if (addspeed > 0) - { - float accelspeed = min(8 * pushdeltatime * str, addspeed); - other.move_velocity += accelspeed * normalize(targ.origin - this.origin); - } -#endif } else -#ifdef SVQC - other.velocity = other.velocity + normalize(targ.origin - this.origin) * str * pushdeltatime; -#elif defined(CSQC) - other.move_velocity = other.move_velocity + normalize(targ.origin - this.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(entity this) +void trigger_impulse_touch2(entity this, entity toucher) { float pushdeltatime; 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(this.strength, pushdeltatime); + toucher.velocity = toucher.velocity * (this.strength ** pushdeltatime); - UpdateCSQCProjectile(other); -#elif defined(CSQC) - other.move_velocity = other.move_velocity * pow(this.strength, pushdeltatime); +#ifdef SVQC + UpdateCSQCProjectile(toucher); #endif } // Spherical (gravity/repulsor) mode -void trigger_impulse_touch3(entity this) +void trigger_impulse_touch3(entity this, entity toucher) { float pushdeltatime; float str; @@ -110,23 +90,19 @@ void trigger_impulse_touch3(entity this) 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(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius); -#ifdef SVQC - str = min(this.radius, vlen(this.origin - other.origin)); -#elif defined(CSQC) - str = min(this.radius, vlen(this.origin - other.move_origin)); -#endif + str = min(this.radius, vlen(this.origin - toucher.origin)); 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) else str = this.strength; -#ifdef SVQC - other.velocity = other.velocity + normalize(other.origin - this.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 - this.origin) * str * pushdeltatime; +#ifdef SVQC + UpdateCSQCProjectile(toucher); #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); } }