]> 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 051a9136ef7a21a3f2e919996f1302a86941b050..c56715e9bc1966d0860d164c133a00f8e97c54dc 100644 (file)
@@ -111,40 +111,6 @@ void CSQCVehicleSetup(entity own, float vehicle_id)
     dont before calling.
 
 **/
-void vh_crosshair_trace(entity player)
-{
-    float lag; 
-    entity pl;
-    
-    lag = ANTILAG_LATENCY(self);
-    if(lag < 0.001)
-        lag = 0;
-    if(clienttype(self) != CLIENTTYPE_REAL)
-        lag = 0;
-    if(autocvar_g_antilag == 0 || self.cvar_cl_noantilag)
-        lag = 0; // only do hitscan, but no antilag
-
-    if(lag)
-        FOR_EACH_PLAYER(pl)
-            if(pl != self)
-            {
-                antilag_takeback(pl, time - lag);
-                if(pl.vehicle)
-                    antilag_takeback(pl.vehicle, time - lag);
-
-            }
-
-    crosshair_trace(player);
-
-    if(lag)
-        FOR_EACH_PLAYER(pl)
-            if(pl != self)
-            {
-                antilag_restore(pl);
-                if(pl.vehicle)
-                    antilag_restore(pl.vehicle);
-            }
-}
 .entity lock_target;
 .float  lock_strength;
 .float  lock_time;
@@ -178,7 +144,7 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
         if(trace_ent.deadflag != DEAD_NO)
             trace_ent = world;
 
-        if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET || trace_ent.classname == "player")
+        if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
             trace_ent = world;
     }
 
@@ -410,27 +376,47 @@ float vehicles_crushable(entity e)
     return FALSE;
 }
 
+void vehilces_impact(float _minspeed, float _speedfac, float _maxpain)
+{    
+    if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
+        return;
+    
+    if(self.play_time < time)
+    {                    
+        float wc = vlen(self.velocity - self.oldvelocity);
+        //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
+        //dprint("vel: ", vtos(self.velocity), "\n");
+        if(_minspeed < wc)
+        {
+            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("wc: ", ftos(wc), "\n");
+            //dprint("take: ", ftos(take), "\n");
+        }
+    }
+}
+
+.void() vehicle_impact;
 void vehicles_touch()
 {
     // Vehicle currently in use
     if(self.owner)
     {
-        // Colided with world?
-        if(other == world)
-        {
-        }
-        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;
     }