]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/vehicles/vehicles.qc
Merge remote-tracking branch 'origin/master' into samual/mutator_ctf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / vehicles.qc
index c4e2875380486575ed766684f7def98d1053ff28..963f1875c1913d5ee9bceeecee2b76be7acfeeac 100644 (file)
@@ -2,7 +2,6 @@ float autocvar_g_vehicles_crush_dmg;
 float autocvar_g_vehicles_crush_force;
 float autocvar_g_vehicles_delayspawn;
 float autocvar_g_vehicles_delayspawn_jitter;
-float autocvar_g_vehicles_allow_flagcarry;
 
 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
 void vehicles_return();
@@ -339,6 +338,7 @@ void vehicles_spawn()
     self.touch              = vehicles_touch;
     self.event_damage       = vehicles_damage;
     self.iscreature         = TRUE;
+    self.teleportable       = FALSE; // no teleporting for vehicles, too buggy
     self.damagedbycontents     = TRUE;
     self.movetype           = MOVETYPE_WALK;
     self.solid              = SOLID_SLIDEBOX;
@@ -356,7 +356,7 @@ void vehicles_spawn()
 
     // Return to spawn
     self.angles             = self.pos2;
-    setorigin(self, self.pos1 + '0 0 128');
+    setorigin(self, self.pos1 + '0 0 0');
     // Show it
     pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
 
@@ -376,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;
     }
 
@@ -500,19 +520,10 @@ void vehicles_enter()
 
     CSQCVehicleSetup(self.owner, self.hud);
     
-    if(other.flagcarried)
-    {
-        if(!autocvar_g_vehicles_allow_flagcarry)
-            DropFlag(other.flagcarried, world, world);
-        else
-        {            
-            other.flagcarried.scale = 1;
-            setattachment(other.flagcarried, self, ""); 
-            setorigin(other, '0 0 96');
-        }
-    }
+    MUTATOR_CALLHOOK(VehicleEnter);
     
     self.vehicle_enter();
+    antilag_clear(other);
 }
 
 /** vehicles_findgoodexit
@@ -608,6 +619,8 @@ void vehicles_exit(float eject)
         self.owner.hud            = HUD_NORMAL;
         self.owner.switchweapon   = self.switchweapon;
         //self.owner.BUTTON_USE     = 0;
+        
+        CSQCVehicleSetup(self.owner, HUD_NORMAL);
     }
 
     if(self.deadflag == DEAD_NO)
@@ -623,13 +636,8 @@ void vehicles_exit(float eject)
         self.team = 0;
     else
         self.team = self.tur_head.team;
-    
-    if(self.owner.flagcarried)
-    {
-        self.owner.flagcarried.scale = 0.6;
-        setattachment(self.owner.flagcarried, self.owner, ""); 
-        setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
-    }
+   
+    MUTATOR_CALLHOOK(VehicleExit);
     
     sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
     self.vehicle_exit(eject);
@@ -668,9 +676,7 @@ void shieldhit_think()
 }
 
 void vehicles_painframe()
-{
-//.float       pain_finished;                  //Added by Supajoe
-    
+{    
     if(self.owner.vehicle_health <= 50)
     if(self.pain_frame < time)
     {  
@@ -975,6 +981,7 @@ float vehicle_initialize(string  net_name,
     self.takedamage         = DAMAGE_AIM;
     self.bot_attack         = TRUE;
     self.iscreature         = TRUE;
+    self.teleportable       = FALSE; // no teleporting for vehicles, too buggy
     self.damagedbycontents     = TRUE;
     self.hud                = vhud;