From: Mario Date: Sat, 2 Jan 2016 07:46:56 +0000 (+1000) Subject: Vehicles: always show smoke when low on health, even when empty X-Git-Tag: xonotic-v0.8.2~1323 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8c3e3073006aab575bdb1f6d12c1afe38a8ec31e;p=xonotic%2Fxonotic-data.pk3dir.git Vehicles: always show smoke when low on health, even when empty --- diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 6b2f32881..53ed9bf4c 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -622,28 +622,33 @@ void shieldhit_think() } } -void vehicles_painframe() -{SELFPARAM(); - if(self.owner.vehicle_health <= 50) - if(self.pain_frame < time) +void vehicles_painframe(entity this) +{ + int myhealth = ((this.owner) ? this.owner.vehicle_health : ((this.vehicle_health / this.max_health) * 100)); + + if(myhealth <= 50) + if(this.pain_frame < time) { - float _ftmp; - _ftmp = self.owner.vehicle_health / 50; - self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp); - pointparticles(EFFECT_SMOKE_SMALL, (self.origin + (randomvec() * 80)), '0 0 0', 1); + float _ftmp = myhealth / 50; + this.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp); + pointparticles(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1); - if(self.vehicle_flags & VHF_DMGSHAKE) - self.velocity += randomvec() * 30; + if(this.vehicle_flags & VHF_DMGSHAKE) + this.velocity += randomvec() * 30; - if(self.vehicle_flags & VHF_DMGROLL) - if(self.vehicle_flags & VHF_DMGHEADROLL) - self.tur_head.angles += randomvec(); + if(this.vehicle_flags & VHF_DMGROLL) + if(this.vehicle_flags & VHF_DMGHEADROLL) + this.tur_head.angles += randomvec(); else - self.angles += randomvec(); - + this.angles += randomvec(); } } +void vehicles_frame(entity this, entity actor) +{ + vehicles_painframe(this); +} + void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) {SELFPARAM(); self.dmg_time = time; @@ -1130,6 +1135,8 @@ void vehicles_think() Vehicle info = get_vehicleinfo(self.vehicleid); info.vr_think(info); + vehicles_painframe(self); + CSQCMODEL_AUTOUPDATE(self); } diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 0c80818f9..b567221c4 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -101,6 +101,9 @@ float bumblebee_gunner_frame() entity gunner = self; setself(vehic); + // this isn't technically a vehicle (yet), let's not do frame functions on it (yet) + //vehicles_frame(gun, player); + vehic.solid = SOLID_NOT; //setorigin(gunner, vehic.origin); gunner.velocity = vehic.velocity; @@ -426,6 +429,8 @@ float bumblebee_pilot_frame() vehic = self.vehicle; setself(vehic); + vehicles_frame(vehic, pilot); + if(IS_DEAD(vehic)) { setself(pilot); diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 5da6cae37..3c0eba969 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -177,7 +177,7 @@ float racer_frame() racer = self.vehicle; setself(racer); - vehicles_painframe(); + vehicles_frame(racer, player); if(pointcontents(racer.origin) != CONTENT_WATER) racer.air_finished = time + autocvar_g_vehicle_racer_water_time; diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index a63fe4a1f..2c88c424d 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -173,7 +173,8 @@ float raptor_frame() raptor = self.vehicle; setself(raptor); - vehicles_painframe(); + vehicles_frame(raptor, player); + /* ftmp = vlen(self.velocity); if(ftmp > autocvar_g_vehicle_raptor_speed_forward) diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 0e8355f5a..d7d5e1d62 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -82,9 +82,10 @@ float spiderbot_frame() player = self; spider = self.vehicle; - setself(spider); - vehicles_painframe(); + vehicles_frame(spider, player); + + setself(spider); player.BUTTON_ZOOM = 0; player.BUTTON_CROUCH = 0;