]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Vehicles: always show smoke when low on health, even when empty
authorMario <mario@smbclan.net>
Sat, 2 Jan 2016 07:46:56 +0000 (17:46 +1000)
committerMario <mario@smbclan.net>
Sat, 2 Jan 2016 07:46:56 +0000 (17:46 +1000)
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc

index 6b2f3288145b791a0f8c7ef17f41c3040276d226..53ed9bf4cc682f0111088d99d02ec18b07042b3e 100644 (file)
@@ -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);
 }
 
index 0c80818f9a1e19f13187f44cc6cf7cc8f4fb18bd..b567221c46b37f87bb6eaa4a045aa5233a576cf6 100644 (file)
@@ -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);
index 5da6cae37a19bec43e2e39ee0c7b267e34de2fb7..3c0eba96953cdfeebc1811a3959e746ea51dcf0a 100644 (file)
@@ -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;
index a63fe4a1fabc0a4f2b435f0463814a9b357b6cdf..2c88c424d17a8ea9c6cff9616806acfea3296ed3 100644 (file)
@@ -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)
index 0e8355f5a2cb3fa37cc076bcf19ab2092118bc23..d7d5e1d6220d166252ab4fc07db815b7c4b2a54d 100644 (file)
@@ -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;