From: Mario Date: Sat, 18 Jun 2016 23:49:18 +0000 (+1000) Subject: Move a shared raptor function into the main vehicle file X-Git-Tag: xonotic-v0.8.2~788 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=281f8a0e6e5e8f49bda72eeeb864da2c0fa727f2;p=xonotic%2Fxonotic-data.pk3dir.git Move a shared raptor function into the main vehicle file --- diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 16208ba63..6eca93643 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -124,6 +124,12 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) } } +float vehicle_altitude(entity this, float amax) +{ + tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * amax), MOVE_WORLDONLY, this); + return vlen(this.origin - trace_endpos); +} + vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power) { force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name)); diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index 8dcf18dc3..eded4f90b 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -106,6 +106,7 @@ void vehicles_exit(entity vehic, int eject); bool vehicle_initialize(entity this, Vehicle info, float nodrop); bool vehicle_impulse(entity this, int imp); bool vehicles_crushable(entity e); +float vehicle_altitude(entity this, float amax); #endif #endif diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index d65d061fb..2750621f2 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -629,7 +629,7 @@ void bumblebee_land(entity this) { float hgt; - hgt = raptor_altitude(this, 512); + hgt = vehicle_altitude(this, 512); this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime); this.angles_x *= 0.95; this.angles_z *= 0.95; diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qh b/qcsrc/common/vehicles/vehicle/bumblebee.qh index 7a9fc2ccb..b04303892 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qh +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qh @@ -6,8 +6,4 @@ void CSQC_BUMBLE_GUN_HUD(); #endif -#ifdef SVQC -float raptor_altitude(entity this, float amax); -#endif - #endif diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 28716fc26..fe381d3c6 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -77,23 +77,16 @@ vector autocvar_g_vehicle_raptor_bouncepain = '1 4 1000'; .entity bomb1; .entity bomb2; -float raptor_altitude(entity this, float amax) -{ - tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * amax), MOVE_WORLDONLY, this); - return vlen(this.origin - trace_endpos); -} - void raptor_land(entity this) { float hgt; - hgt = raptor_altitude(this, 512); + hgt = vehicle_altitude(this, 512); this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime); this.angles_x *= 0.95; this.angles_z *= 0.95; - if(hgt < 128) - if(hgt > 0) + if(hgt < 128 && hgt > 0) this.frame = (hgt / 128) * 25; this.bomb1.gun1.avelocity_y = 90 + ((this.frame / 25) * 2000); @@ -113,19 +106,19 @@ void raptor_land(entity this) void raptor_exit(entity this, int eject) { - vector spot; this.tur_head.exteriormodeltoclient = NULL; if(!IS_DEAD(this)) { setthink(this, raptor_land); - this.nextthink = time; + this.nextthink = time; } if(!this.owner) return; makevectors(this.angles); + vector spot; if(eject) { spot = this.origin + v_forward * 100 + '0 0 64'; @@ -172,7 +165,6 @@ bool raptor_frame(entity this) vehicles_frame(vehic, this); - float ftmp = 0; /* ftmp = vlen(vehic.velocity); if(ftmp > autocvar_g_vehicle_raptor_speed_forward) @@ -226,7 +218,7 @@ bool raptor_frame(entity this) if(df_y > 180) df_y -= 360; if(df_y < -180) df_y += 360; - ftmp = shortangle_f(this.v_angle_y - vang_y, vang_y); + float ftmp = shortangle_f(this.v_angle_y - vang_y, vang_y); if(ftmp > 180) ftmp -= 360; if(ftmp < -180) ftmp += 360; vehic.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + vehic.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);