X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fimpulse.qc;h=c2b59a3e0b40b348b25b8ca6f09f8b61955e54e5;hb=f281ed110c47171745b6ebd0b14bcc6ea6fd9405;hp=926268e7c52af97fc345ca458c2480628bf8a951;hpb=fd8a3cfbe15df4e9854dbb288157fe863276a696;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/impulse.qc b/qcsrc/common/triggers/trigger/impulse.qc index 926268e7c..c2b59a3e0 100644 --- a/qcsrc/common/triggers/trigger/impulse.qc +++ b/qcsrc/common/triggers/trigger/impulse.qc @@ -1,6 +1,6 @@ // targeted (directional) mode void trigger_impulse_touch1() -{ +{SELFPARAM(); entity targ; float pushdeltatime; float str; @@ -21,7 +21,11 @@ void trigger_impulse_touch1() 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 if(self.falloff == 1) str = (str / self.radius) * self.strength; @@ -35,16 +39,43 @@ void trigger_impulse_touch1() other.lastpushtime = time; if(!pushdeltatime) return; - other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime; - other.flags &= ~FL_ONGROUND; + if(self.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); + if (addspeed > 0) + { + float accelspeed = min(8 * pushdeltatime * str, addspeed); + other.move_velocity += accelspeed * normalize(targ.origin - self.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 + #ifdef SVQC + UNSET_ONGROUND(other); + UpdateCSQCProjectile(other); +#elif defined(CSQC) + other.move_flags &= ~FL_ONGROUND; #endif } // Directionless (accelerator/decelerator) mode void trigger_impulse_touch2() -{ +{SELFPARAM(); float pushdeltatime; if (self.active != ACTIVE_ACTIVE) @@ -61,15 +92,18 @@ void trigger_impulse_touch2() if(!pushdeltatime) return; // div0: ticrate independent, 1 = identity (not 20) - other.velocity = other.velocity * pow(self.strength, pushdeltatime); #ifdef SVQC + other.velocity = other.velocity * pow(self.strength, pushdeltatime); + UpdateCSQCProjectile(other); +#elif defined(CSQC) + other.move_velocity = other.move_velocity * pow(self.strength, pushdeltatime); #endif } // Spherical (gravity/repulsor) mode void trigger_impulse_touch3() -{ +{SELFPARAM(); float pushdeltatime; float str; @@ -88,7 +122,11 @@ void trigger_impulse_touch3() setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.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 if(self.falloff == 1) str = (1 - str / self.radius) * self.strength; // 1 in the inside @@ -97,12 +135,17 @@ void trigger_impulse_touch3() else str = self.strength; - other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime; #ifdef SVQC + other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime; + UpdateCSQCProjectile(other); +#elif defined(CSQC) + other.move_velocity = other.move_velocity + normalize(other.move_origin - self.origin) * str * pushdeltatime; #endif } +REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_IMPULSE) + /*QUAKED spawnfunc_trigger_impulse (.5 .5 .5) ? -------- KEYS -------- target : If this is set, this points to the spawnfunc_target_position to which the player will get pushed. @@ -121,30 +164,32 @@ Use a brush textured with common/origin in the trigger entity to determine the o in directional and sperical mode. For damper/accelerator mode this is not nessesary (and has no effect). */ #ifdef SVQC -bool trigger_impulse_send(entity to, int sf) +bool trigger_impulse_send(entity this, entity to, int sf) { - WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE); + WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE); - WriteCoord(MSG_ENTITY, self.radius); - WriteCoord(MSG_ENTITY, self.strength); - WriteByte(MSG_ENTITY, self.falloff); - WriteByte(MSG_ENTITY, self.active); + WriteInt24_t(MSG_ENTITY, this.spawnflags); + WriteCoord(MSG_ENTITY, this.radius); + WriteCoord(MSG_ENTITY, this.strength); + WriteByte(MSG_ENTITY, this.falloff); + WriteByte(MSG_ENTITY, this.active); - trigger_common_write(true); + trigger_common_write(this, true); return true; } void trigger_impulse_link() { - //Net_LinkEntity(self, 0, false, trigger_impulse_send); + trigger_link(self, trigger_impulse_send); } -void spawnfunc_trigger_impulse() +spawnfunc(trigger_impulse) { self.active = ACTIVE_ACTIVE; - EXACTTRIGGER_INIT; + trigger_init(self); + if(self.radius) { if(!self.strength) self.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier; @@ -170,25 +215,26 @@ void spawnfunc_trigger_impulse() trigger_impulse_link(); } #elif defined(CSQC) -void ent_trigger_impulse() +NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew) { + self.spawnflags = ReadInt24_t(); self.radius = ReadCoord(); self.strength = ReadCoord(); self.falloff = ReadByte(); self.active = ReadByte(); trigger_common_read(true); - + return = true; self.classname = "trigger_impulse"; self.solid = SOLID_TRIGGER; self.entremove = trigger_remove_generic; - self.draw = trigger_draw_generic; + //self.draw = trigger_draw_generic; self.drawmask = MASK_NORMAL; self.move_time = time; - if(self.radius) { self.trigger_touch = trigger_impulse_touch3; } - else if(self.target) { self.trigger_touch = trigger_impulse_touch1; } - else { self.trigger_touch = trigger_impulse_touch2; } + 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; } } #endif