From: Mario Date: Mon, 12 Aug 2019 14:45:35 +0000 (+1000) Subject: Experimental rough support for target_speed X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e77aff78e614257805ac11ce6c31abde9d32d7f2;p=xonotic%2Fxonotic-data.pk3dir.git Experimental rough support for target_speed --- diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 112a7f039..f9d474088 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -215,6 +215,57 @@ spawnfunc(target_fragsFilter) this.use = fragsfilter_use; } +// rough implementation of target_speed +const int TSPEED_PERCENTAGE = BIT(0); +const int TSPEED_ADD = BIT(1); +const int TSPEED_PLUSX = BIT(2); +const int TSPEED_MINUSX = BIT(3); +const int TSPEED_PLUSY = BIT(4); +const int TSPEED_MINUSY = BIT(5); +const int TSPEED_PLUSZ = BIT(6); +const int TSPEED_MINUSZ = BIT(7); +const int TSPEED_LAUNCHER = BIT(8); +// .speed .targetname + +float target_speed_getspeed(bool plusflag, int spflag, float vel, float spd) +{ + if(!plusflag) + spd = -spd; + if(spflag & TSPEED_ADD) + return vel + spd; + else if(spflag & TSPEED_PERCENTAGE) + return vel / spd; + else + return spd; +} + +void target_speed_use(entity this, entity actor, entity trigger) +{ + if(!IS_PLAYER(actor)) + return; + + bool launcher = (this.spawnflags & TSPEED_LAUNCHER); + +#define HAVE_ONE(flg, plusflg, minusflg) (((flg & plusflg) && !(flg & minusflg)) || ((flg & minusflg) && !(flg & plusflg))) + if(HAVE_ONE(this.spawnflags, TSPEED_PLUSX, TSPEED_MINUSX) && (actor.velocity_x || launcher)) + actor.velocity_x = target_speed_getspeed((this.spawnflags & TSPEED_PLUSX), this.spawnflags, actor.velocity_x, this.speed); + if(HAVE_ONE(this.spawnflags, TSPEED_PLUSY, TSPEED_MINUSY) && (actor.velocity_y || launcher)) + actor.velocity_y = target_speed_getspeed((this.spawnflags & TSPEED_PLUSY), this.spawnflags, actor.velocity_y, this.speed); + if(HAVE_ONE(this.spawnflags, TSPEED_PLUSZ, TSPEED_MINUSZ) && (actor.velocity_z || launcher)) + actor.velocity_z = target_speed_getspeed((this.spawnflags & TSPEED_PLUSZ), this.spawnflags, actor.velocity_z, this.speed); + actor.oldvelocity = actor.velocity; // even if speed isn't changed, don't do fall damage? +#undef HAVE_ONE +} + +spawnfunc(target_speed) +{ + if(!g_cts) { delete(this); return; } + + if(!this.speed) + this.speed = 100; + this.use = target_speed_use; +} + //spawnfunc(item_flight) /* handled by buffs mutator */ //spawnfunc(item_haste) /* handled by buffs mutator */ //spawnfunc(item_health) /* handled in t_quake.qc */