]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/vehicles/vehicles.qc
Ignore sky & softtargets for vehicle impact damage. Extand vehile impactdamage to...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / vehicles.qc
index 908ccc624253cb118cff557a8cde5481b5eeb869..c56715e9bc1966d0860d164c133a00f8e97c54dc 100644 (file)
@@ -376,51 +376,47 @@ float vehicles_crushable(entity e)
     return FALSE;
 }
 
-void vehilces_worldimpact(float _minspeed, float _speedfac, float _maxpain)
-{
+void vehilces_impact(float _minspeed, float _speedfac, float _maxpain)
+{    
+    if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
+        return;
+    
     if(self.play_time < time)
     {                    
-        float wc, take;
-        wc = vlen(self.velocity - self.oldvelocity);
+        float wc = vlen(self.velocity - self.oldvelocity);
+        //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
+        //dprint("vel: ", vtos(self.velocity), "\n");
         if(_minspeed < wc)
         {
-            take = min(_speedfac * wc, _maxpain);
+            float take = take = min(_speedfac * wc, _maxpain);
             Damage (self, world, world, take, DEATH_FALL, self.origin, '0 0 0');
             self.play_time = time + 0.25;
             
-            dprint("oldvel: ", vtos(self.oldvelocity), "\n");
-            dprint("vel: ", vtos(self.velocity), "\n");
-            dprint("wc: ", ftos(wc), "\n");
-            dprint("take: ", ftos(take), "\n");
-            
+            //dprint("wc: ", ftos(wc), "\n");
+            //dprint("take: ", ftos(take), "\n");
         }
     }
 }
 
-.void() vehicle_worldimpact;
+.void() vehicle_impact;
 void vehicles_touch()
 {
     // Vehicle currently in use
     if(self.owner)
     {
-        // Colided with world?
-        if(other == world)
-        {
-            if(self.vehicle_worldimpact)
-                self.vehicle_worldimpact();
-        }
-        else
+        if(other != world)
+        if(vehicles_crushable(other))
         {
-            if(other.vehicle_flags & VHF_ISVEHICLE)
-            {
-                //other.velocity += self.velocity * (self.mass / other.mass);
-            }
-            else if(vehicles_crushable(other))
-            {
-                if(vlen(self.velocity) != 0)
-                    Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VHCRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
-            }
+            if(vlen(self.velocity) != 0)
+                Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VHCRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
+            
+            return; // Dont do selfdamage when hitting "soft targets".
         }
+        
+        if(self.play_time < time)
+        if(self.vehicle_impact)
+            self.vehicle_impact();
+        
         return;
     }