X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fimpulse.qc;h=cdf4a72918b79c9ab5326814dd1040e12f061620;hp=b4b146c7f315292c3e7a44968b280e8e3821e7ac;hb=7666560c6a475aefe6b55ff74a20444f328e0093;hpb=66189615a05cc66dd0ee544a2bbc841c4f426193 diff --git a/qcsrc/common/triggers/trigger/impulse.qc b/qcsrc/common/triggers/trigger/impulse.qc index b4b146c7f3..cdf4a72918 100644 --- a/qcsrc/common/triggers/trigger/impulse.qc +++ b/qcsrc/common/triggers/trigger/impulse.qc @@ -1,146 +1,119 @@ // 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 } @@ -179,63 +152,60 @@ bool trigger_impulse_send(entity this, entity to, int sf) return true; } -void trigger_impulse_link() +void trigger_impulse_link(entity this) { - SELFPARAM(); - trigger_link(self, trigger_impulse_send); + trigger_link(this, trigger_impulse_send); } spawnfunc(trigger_impulse) { - self.active = ACTIVE_ACTIVE; + this.active = ACTIVE_ACTIVE; - trigger_init(self); + trigger_init(this); - if(self.radius) + if(this.radius) { - if(!self.strength) self.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier; - setorigin(self, self.origin); - setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius); - self.touch = trigger_impulse_touch3; + 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); + settouch(this, trigger_impulse_touch3); } else { - if(self.target) + if(this.target) { - if(!self.strength) self.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier; - self.touch = trigger_impulse_touch1; + if(!this.strength) this.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier; + settouch(this, trigger_impulse_touch1); } else { - if(!self.strength) self.strength = 0.9; - self.strength = pow(self.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier; - self.touch = trigger_impulse_touch2; + if(!this.strength) this.strength = 0.9; + this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier; + settouch(this, trigger_impulse_touch2); } } - trigger_impulse_link(); + trigger_impulse_link(this); } #elif defined(CSQC) NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew) { - self.spawnflags = ReadInt24_t(); - self.radius = ReadCoord(); - self.strength = ReadCoord(); - self.falloff = ReadByte(); - self.active = ReadByte(); + this.spawnflags = ReadInt24_t(); + this.radius = ReadCoord(); + this.strength = ReadCoord(); + this.falloff = ReadByte(); + this.active = ReadByte(); - trigger_common_read(true); + trigger_common_read(this, true); return = true; - self.classname = "trigger_impulse"; - self.solid = SOLID_TRIGGER; - self.entremove = trigger_remove_generic; - //self.draw = trigger_draw_generic; - self.drawmask = MASK_NORMAL; - self.move_time = time; + this.classname = "trigger_impulse"; + this.solid = SOLID_TRIGGER; + this.entremove = trigger_remove_generic; + this.move_time = time; - if(self.radius) { self.move_touch = trigger_impulse_touch3; } - else if(self.target) { self.move_touch = trigger_impulse_touch1; } - else { self.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