]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/vehicles/vehicles.qc
Merge remote branch 'origin/master' into terencehill/infinite_ammo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / vehicles.qc
index 644411fc6f78fd57a9dea42a3b223aef067b416a..d9d77b5f5211957f539c4ee41b1057beec0980a4 100644 (file)
@@ -1,5 +1,8 @@
 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();
@@ -10,8 +13,8 @@ void vehicles_clearrturn();
 void vehicles_setreturn();
 
 
-/** AuxiliaryXhair* 
-    Send addictional points of interest to be drawn, to vehicle owner
+/** AuxiliaryXhair*
+    Send additional points of interest to be drawn, to vehicle owner
 **/
 float MAX_AXH = 4;
 .entity AuxiliaryXhair[MAX_AXH];
@@ -80,6 +83,12 @@ void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
 */
 // End AuxiliaryXhair
 
+/**
+    Notifies the client that he enterd a vehicle, and sends 
+    realavent data.
+    
+    only sends vehicle_id atm (wich is a HUD_* constant, ex. HUD_SPIDERBOT)
+**/
 void CSQCVehicleSetup(entity own, float vehicle_id)
 {
        msg_entity = own;
@@ -90,21 +99,22 @@ void CSQCVehicleSetup(entity own, float vehicle_id)
 }
 
 /** vehicles_locktarget
-    
+
     Generic target locking.
-    
+
     Figure out if what target is "locked" (if any), for missile tracking as such.
-    
+
     after calling, "if(self.lock_target != world && self.lock_strength == 1)" mean
     you have a locked in target.
-    
+
     Exspects a crosshair_trace() or equivalent to be
     dont before calling.
-    
+
 **/
 .entity lock_target;
 .float  lock_strength;
 .float  lock_time;
+.float  lock_soundtime;
 void vehicles_locktarget(float incr, float decr, float _lock_time)
 {
     if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
@@ -115,11 +125,20 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
     }
 
     if(self.lock_time > time)
+    {
+        if(self.lock_target)
+        if(self.lock_soundtime < time)
+        {
+            self.lock_soundtime = time + 0.5;
+            play2(self.owner, "vehicles/locked.wav");
+        }
+        
         return;
+    }
 
     if(trace_ent != world)
     {
-        if(teams_matter && trace_ent.team == self.team)
+        if(teamplay && trace_ent.team == self.team)
             trace_ent = world;
 
         if(trace_ent.deadflag != DEAD_NO)
@@ -131,7 +150,22 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
 
     if(self.lock_target == world && trace_ent != world)
         self.lock_target = trace_ent;
-
+    
+    if(self.lock_target && trace_ent == self.lock_target) 
+    {            
+        if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
+        {
+            play2(self.owner, "vehicles/lock.wav");
+            self.lock_soundtime = time + 0.8;
+        }        
+        else if (self.lock_strength != 1 && self.lock_soundtime < time)
+        {            
+            play2(self.owner, "vehicles/locking.wav");
+            self.lock_soundtime = time + 0.3;
+        }
+        
+    }    
+        
     // Have a locking target
     // Trace hit current target
     if(trace_ent == self.lock_target && trace_ent != world)
@@ -153,7 +187,7 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
 }
 
 #define VEHICLE_UPDATE_PLAYER(fld,vhname) \
-self.owner.vehicle_##fld = self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld
+self.owner.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
 
 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
 traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
@@ -176,7 +210,7 @@ vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float
     return v_forward  * force_fromtag_power;
 }
 
-// Experimental hovermode wich uses attraction/repulstion from surface unsted of gravity/repulsion
+// Experimental hovermode wich uses attraction/repulstion from surface insted of gravity/repulsion
 // Can possibly be use to move abt any surface (inclusing walls/celings)
 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
 {
@@ -201,6 +235,10 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
 // Generic vehile projectile system
 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
+    // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
+    if(inflictor.owner == self.owner)
+        return; 
+    
     self.health -= damage;
     self.velocity += force;
     if(self.health < 1)
@@ -235,7 +273,7 @@ void vehicles_projectile_explode()
 entity vehicles_projectile(string _mzlfx, string _mzlsound,
                            vector _org, vector _vel,
                            float _dmg, float _radi, float _force,  float _size,
-                           float _deahtype, float _projtype, float _health, 
+                           float _deahtype, float _projtype, float _health,
                            float _cull, float _clianim)
 {
     entity proj;
@@ -272,7 +310,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
         proj.flags           = FL_PROJECTILE | FL_NOTARGET;
 
     if(_mzlsound)
-        sound (self, CHAN_WEAPON, _mzlsound, VOL_BASE, ATTN_NORM);
+        sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTN_NORM);
 
     if(_mzlfx)
         pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
@@ -287,7 +325,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 // End generic vehile projectile system
 
 /** vehicles_spawn
-    Exetuted for all vehiles on (re)spawn.
+    Exetuted for all vehicles on (re)spawn.
     Sets defaults for newly spawned units.
 **/
 void vehicles_spawn()
@@ -296,7 +334,7 @@ void vehicles_spawn()
 
     // De-own & reset
     self.vehicle_hudmodel.viewmodelforclient = self;
-    
+
     self.owner              = world;
     self.touch              = vehicles_touch;
     self.event_damage       = vehicles_damage;
@@ -308,6 +346,7 @@ void vehicles_spawn()
     self.bot_attack         = TRUE;
     self.flags              = FL_NOTARGET;
     self.avelocity          = '0 0 0';
+    self.velocity           = '0 0 0';
 
     // Reset locking
     self.lock_strength      = 0;
@@ -344,7 +383,6 @@ void vehicles_touch()
         // Colided with world?
         if(other == world)
         {
-            // Apply velocity based self damage here
         }
         else
         {
@@ -386,7 +424,7 @@ void vehicles_enter()
     if(self.phase > time)
         return;
 
-    if(teams_matter)
+    if(teamplay)
     if(self.team)
     if(self.team != other.team)
         return;
@@ -399,12 +437,12 @@ void vehicles_enter()
 
     self.owner          = other;
     self.switchweapon   = other.switchweapon;
-    
+
     // .viewmodelforclient works better.
     //self.vehicle_hudmodel.drawonlytoclient = self.owner;
 
-    self.vehicle_hudmodel.viewmodelforclient = self.owner;        
-    
+    self.vehicle_hudmodel.viewmodelforclient = self.owner;
+
     self.event_damage         = vehicles_damage;
     self.nextthink            = 0;
     self.owner.angles         = self.angles;
@@ -427,7 +465,7 @@ void vehicles_enter()
     self.owner.vehicle_reload1  = self.vehicle_reload1;
     self.owner.vehicle_reload2  = self.vehicle_reload2;
 
-    // Cnnt do this, hides attached objects too.
+    // Cant do this, hides attached objects too.
     //self.exteriormodeltoclient = self.owner;
     //self.tur_head.exteriormodeltoclient = self.owner;
 
@@ -450,7 +488,6 @@ void vehicles_enter()
     }
     else
     {
-        WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
         WriteAngle(MSG_ONE,  self.angles_x * -1); // tilt
         WriteAngle(MSG_ONE,  self.angles_y);      // yaw
         WriteAngle(MSG_ONE,  0);                  // roll
@@ -459,12 +496,88 @@ void vehicles_enter()
     vehicles_clearrturn();
 
     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');
+        }
+    }
+    
     self.vehicle_enter();
 }
 
-void vehicles_exit(float eject)
+/** vehicles_findgoodexit
+    Locates a valid location for the player to exit the vehicle.
+    Will first try prefer_spot, then up 100 random spots arround the vehicle
+    wich are in direct line of sight and empty enougth to hold a players bbox
+**/
+vector vehicles_findgoodexit(vector prefer_spot)
 {
+    //vector exitspot;
+    float mysize;
+    
+    tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
+    if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+        return prefer_spot;
+    
+    mysize = vlen(self.maxs - self.mins);
+    float i;
+    vector v, v2;
+    v2 = 0.5 * (self.absmin + self.absmax);
+    for(i = 0; i < 100; ++i)
+    {        
+        v = randomvec();
+        v_z = 0;
+        v = v2 + normalize(v) * mysize;
+        tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
+        if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+            return v;
+    }
+    
+    /*
+    exitspot = (self.origin + '0 0 48') + v_forward * mysize;
+    tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
+    if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+        return exitspot;
+    
+    exitspot = (self.origin + '0 0 48') - v_forward * mysize;
+    tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
+    if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+        return exitspot;
+
+    exitspot = (self.origin + '0 0 48') + v_right * mysize;
+    tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
+    if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+        return exitspot;
+    
+    exitspot = (self.origin + '0 0 48') - v_right * mysize;
+    tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
+    if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
+        return exitspot;
+    */
+    
+    return self.origin;
+}
+
+/** vehicles_exit
+    Standarrd vehicle release fucntion.
+    custom code goes in self.vehicle_exit
+**/
+void vehicles_exit(float eject)
+{      
+    entity oldself;
+    if(self.flags & FL_CLIENT)
+    {
+        oldself = self;
+        self = self.vehicle;
+    }
+    
        self.flags |= FL_NOTARGET;
 
     if (self.owner)
@@ -473,8 +586,8 @@ void vehicles_exit(float eject)
         WriteByte (MSG_ONE, SVC_SETVIEWPORT);
         WriteEntity( MSG_ONE, self.owner);
 
-        WriteByte (MSG_ONE, SVC_SETVIEWANGLES); // 10 = SVC_SETVIEWANGLES
-        WriteAngle(MSG_ONE, 0);                 // tilt
+        WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
+        WriteAngle(MSG_ONE, 0);                 // pich
         WriteAngle(MSG_ONE, self.angles_y);     // yaw
         WriteAngle(MSG_ONE, 0);                 // roll
 
@@ -491,7 +604,7 @@ void vehicles_exit(float eject)
         self.owner.event_damage   = PlayerDamage;
         self.owner.hud            = HUD_NORMAL;
         self.owner.switchweapon   = self.switchweapon;
-        self.owner.BUTTON_USE     = 0;
+        //self.owner.BUTTON_USE     = 0;
     }
 
     if(self.deadflag == DEAD_NO)
@@ -503,11 +616,25 @@ void vehicles_exit(float eject)
 
     self.phase = time + 1;
 
-    if(!teams_matter)
+    if(!teamplay)
         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);
+    }
+    
+    sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
     self.vehicle_exit(eject);
     self.owner = world;
+    vehicles_reset_colors();
+    
+    if(oldself)
+        self = oldself;
 }
 
 
@@ -519,7 +646,7 @@ void vehicles_regen(.float timer, .float regen_field, float field_max, float rpa
         self.regen_field = min(self.regen_field + regen * delta_time, field_max);
 
         if(self.owner)
-            self.owner.regen_field = self.regen_field / field_max;
+            self.owner.regen_field = (self.regen_field / field_max) * 100;
     }
 }
 
@@ -537,6 +664,30 @@ void shieldhit_think()
     }
 }
 
+void vehicles_painframe()
+{
+//.float       pain_finished;                  //Added by Supajoe
+    
+    if(self.owner.vehicle_health <= 50)
+    if(self.pain_frame < time)
+    {  
+        float _ftmp;  
+        _ftmp = self.owner.vehicle_health / 50;
+        self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
+        pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
+        
+        if(self.vehicle_flags & VHF_DMGSHAKE)
+            self.velocity += randomvec() * 30;
+        
+        if(self.vehicle_flags & VHF_DMGROLL)
+            if(self.vehicle_flags & VHF_DMGHEADROLL)
+                self.tur_head.angles += randomvec();
+            else
+                self.angles += randomvec();
+        
+    }    
+}
+
 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
     self.dmg_time = time;
@@ -555,7 +706,6 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, float deat
             self.vehicle_shieldent.think       = shieldhit_think;
         }
 
-
         self.vehicle_shieldent.colormod    = '1 1 1';
         self.vehicle_shieldent.alpha       = 0.45;
         self.vehicle_shieldent.angles      = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
@@ -565,15 +715,27 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, float deat
 
         if(self.vehicle_shield < 0)
         {
+            self.vehicle_health            -= fabs(self.vehicle_shield);
             self.vehicle_shieldent.colormod = '2 0 0';
             self.vehicle_shield             = 0;
             self.vehicle_shieldent.alpha    = 0.75;
-            self.vehicle_health            -= fabs(self.vehicle_shield);
+            
+               if(sound_allowed(MSG_BROADCAST, attacker))
+                spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);   // FIXME: PLACEHOLDER
         }
+        else
+               if(sound_allowed(MSG_BROADCAST, attacker))
+                spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM);  // FIXME: PLACEHOLDER
+
     }
     else
+    {
         self.vehicle_health -= damage;
 
+        if(sound_allowed(MSG_BROADCAST, attacker))
+            spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);  // FIXME: PLACEHOLDER
+    }
+
     self.velocity += force; // * (vlen(force) / self.mass);
 
     if(self.vehicle_health <= 0)
@@ -589,16 +751,6 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, float deat
     }
 }
 
-void vehicles_return()
-{
-    pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
-
-    self.enemy.think     = vehicles_spawn;
-    self.enemy.nextthink = time;
-
-    remove(self);
-}
-
 void vehicles_clearrturn()
 {
     entity ret;
@@ -610,33 +762,107 @@ void vehicles_clearrturn()
         {
             ret.classname   = "";
             ret.think       = SUB_Remove;
-            ret.nextthink   = time + 0.1;
+            ret.nextthink   = time + 0.1;            
+            
+            if(ret.waypointsprite_attached)
+                WaypointSprite_Kill(ret.waypointsprite_attached);
+            
             return;
         }
-
         ret = ret.chain;
     }
 }
 
+void vehicles_return()
+{
+    pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
+
+    self.enemy.think     = vehicles_spawn;
+    self.enemy.nextthink = time;
+
+    if(self.waypointsprite_attached)
+        WaypointSprite_Kill(self.waypointsprite_attached);
+            
+    remove(self);
+}
+
+void vehicles_showwp_goaway()
+{
+    if(self.waypointsprite_attached)
+        WaypointSprite_Kill(self.waypointsprite_attached);
+            
+    remove(self);
+    
+}
+
+void vehicles_showwp()
+{
+    entity oldself;
+    vector rgb;
+    
+    if(self.cnt)
+    {        
+        self.think      = vehicles_return;
+        self.nextthink  = self.cnt;
+    }    
+    else
+    {
+        self.think      = vehicles_return;
+        self.nextthink  = time +1;
+        
+        oldself = self;
+        self = spawn();
+        setmodel(self, "null");
+        self.team = oldself.enemy.team;
+        self.enemy = oldself.enemy;
+        setorigin(self, oldself.enemy.pos1);
+        
+        self.nextthink = time + 5;
+        self.think = vehicles_showwp_goaway;
+    }
+    
+    if(teamplay && self.team)
+           rgb = TeamColor(self.team);
+    else
+           rgb = '1 1 1';
+    WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
+    if(self.waypointsprite_attached)
+    {        
+        WaypointSprite_UpdateRule(self.waypointsprite_attached, self.enemy.team, SPRITERULE_DEFAULT);        
+        if(oldself == world)
+            WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);        
+        WaypointSprite_Ping(self.waypointsprite_attached);
+    }    
+    
+    if(oldself != world)
+        self = oldself;
+}
+
 void vehicles_setreturn()
 {
     entity ret;
-
+    
     vehicles_clearrturn();
 
     ret = spawn();
     ret.classname   = "vehicle_return";
-    ret.enemy       = self;
-    ret.think       = vehicles_return;
-    ret.nextthink   = time + self.vehicle_respawntime;
-}
-
-float vehicles_customizeentityforclient()
-{
-    if(self.deadflag  == DEAD_DEAD)
-        return FALSE;
+    ret.enemy       = self;    
+    ret.team        = self.team;
+    ret.think       = vehicles_showwp;
+    
+    if(self.deadflag != DEAD_NO)
+    {
+        ret.cnt         = time + self.vehicle_respawntime;
+        ret.nextthink   = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 5);        
+    }        
     else
-        return TRUE;
+    {
+        ret.nextthink   = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 1);        
+    }
+    
+    setmodel(ret, "null");
+    setorigin(ret, self.pos1 + '0 0 96');
+       
 }
 
 void vehicles_configcheck(string  configname, float check_cvar)
@@ -656,14 +882,14 @@ void vehicles_reset_colors()
 
     if(autocvar_g_fullbrightplayers)
         _effects |= EF_FULLBRIGHT;
-        
+
     if(self.team)
         _colormap = 1024 + (self.team - 1) * 17;
     else
         _colormap = 1024;
 
-    _glowmod    = '0 0 0';
-    _colormod   = '0 0 0';
+    _glowmod  = '0 0 0';
+    _colormod = '0 0 0';
 
     // Find all ents attacked to main model and setup effects, colormod etc.
     e = findchainentity(tag_entity, self);
@@ -671,23 +897,23 @@ void vehicles_reset_colors()
     {
         if(e != self.vehicle_shieldent)
         {
-            e.effects   = _effects  | EF_LOWPRECISION;
+            e.effects   = _effects; //  | EF_LOWPRECISION;
             e.colormod  = _colormod;
             e.colormap  = _colormap;
             e.alpha     = 1;
         }
         e = e.chain;
     }
-    
-    self.vehicle_hudmodel.effects  = self.effects  = _effects | EF_LOWPRECISION;
+
+    self.vehicle_hudmodel.effects  = self.effects  = _effects; // | EF_LOWPRECISION;
     self.vehicle_hudmodel.colormod = self.colormod = _colormod;
     self.vehicle_hudmodel.colormap = self.colormap = _colormap;
     self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
 
-    self.alpha          = 1;
-    self.avelocity      = '0 0 0';
-    self.velocity       = '0 0 0';
-    self.effects        = _effects;
+    self.alpha     = 1;
+    self.avelocity = '0 0 0';
+    self.velocity  = '0 0 0';
+    self.effects   = _effects;
 }
 
 float vehicle_initialize(string  net_name,
@@ -698,27 +924,28 @@ float vehicle_initialize(string  net_name,
                          string  hudtag,
                          string  viewtag,
                          float   vhud,
-                         vector min_s,
-                         vector max_s,
-                         float  nodrop,
+                         vector  min_s,
+                         vector  max_s,
+                         float   nodrop,
                          void()  spawnproc,
                          float   _respawntime,
                          float() physproc,
                          void()  enterproc,
                          void(float extflag) exitfunc,
                          void() dieproc,
-                         void() thinkproc )
+                         void() thinkproc,
+                         float  use_csqc)
 {
     addstat(STAT_HUD, AS_INT,  hud);
-       addstat(STAT_VEHICLESTAT_HEALTH,  AS_FLOAT, vehicle_health);
-       addstat(STAT_VEHICLESTAT_SHIELD,  AS_FLOAT, vehicle_shield);
-       addstat(STAT_VEHICLESTAT_ENERGY,  AS_FLOAT, vehicle_energy);
+       addstat(STAT_VEHICLESTAT_HEALTH,  AS_INT, vehicle_health);
+       addstat(STAT_VEHICLESTAT_SHIELD,  AS_INT, vehicle_shield);
+       addstat(STAT_VEHICLESTAT_ENERGY,  AS_INT, vehicle_energy);
 
        addstat(STAT_VEHICLESTAT_AMMO1,   AS_INT,   vehicle_ammo1);
-       addstat(STAT_VEHICLESTAT_RELOAD1, AS_FLOAT, vehicle_reload1);
+       addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
 
        addstat(STAT_VEHICLESTAT_AMMO2,   AS_INT,   vehicle_ammo2);
-       addstat(STAT_VEHICLESTAT_RELOAD2, AS_FLOAT, vehicle_reload2);
+       addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
 
     if(bodymodel == "")
         error("vehicles: missing bodymodel!");
@@ -731,11 +958,11 @@ float vehicle_initialize(string  net_name,
     else
         self.netname = net_name;
 
-    if(self.team && !teams_matter)
+    if(self.team && !teamplay)
         self.team = 0;
-
+        
     self.vehicle_flags |= VHF_ISVEHICLE;
-
+    
     setmodel(self, bodymodel);
 
     self.vehicle_viewport   = spawn();
@@ -747,15 +974,14 @@ float vehicle_initialize(string  net_name,
     self.iscreature         = TRUE;
     self.hud                = vhud;
 
-    //self.customizeentityforclient = vehicles_customizeentityforclient;
     self.vehicle_die         = dieproc;
     self.vehicle_exit        = exitfunc;
     self.vehicle_enter       = enterproc;
     self.PlayerPhysplug      = physproc;
     self.event_damage        = vehicles_damage;
     self.touch               = vehicles_touch;
-    self.think               = vehicles_spawn;
-    self.nextthink           = time;
+    self.think               = vehicles_spawn;    
+    self.nextthink           = time;        
     self.vehicle_respawntime = _respawntime;
     self.vehicle_spawn       = spawnproc;
 
@@ -790,15 +1016,14 @@ float vehicle_initialize(string  net_name,
         tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
         setorigin(self, trace_endpos);
     }
-    
-    //self.vehicle_hudmodel.effects = EF_NODEPTHTEST;
+
     self.pos1 = self.origin;
     self.pos2 = self.angles;
-
+    self.tur_head.team = self.team;
+    
     return TRUE;
 }
 
-
 void bugmenot()
 {
     self.vehicle_exit       = self.vehicle_exit;
@@ -807,121 +1032,3 @@ void bugmenot()
     self.vehicle_spawn      = self.vehicle_exit;
     self.AuxiliaryXhair     = self.AuxiliaryXhair;
 }
-
-#ifdef VEHICLES_CSQC
-// SendFlags
-float VSF_SETUP       = 2;          /// Send vehicle type etc
-float VSF_ORIGIN      = 4;          /// Send location
-float VSF_MOVEMENT    = 8;          /// Send movement update (and angle/avelocity)
-float VSF_STATS       = 16;         /// Send ammo, health etc
-float VSF_EXTRA       = 32;         /// Send additional data (turret rotations and such) handeld per vehicle type.
-float VSF_FULL_UPDATE = 16777215    /// Send everything
-
-
-#ifdef SVQC
-float send_vehile(entity to, float sf)
-{
-       WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
-
-       WriteByte(MSG_ENTITY, sf);
-       
-       if(sf & VSF_SETUP)
-       {
-        WriteByte(MSG_ENTITY,   self.hud);        //vehicle type = hud
-        WriteByte(MSG_ENTITY,   self.team);
-        WriteShort(MSG_ENTITY,  self.colormap);
-       }
-    
-    if(sf & VSF_ORIGIN)
-    {
-        WriteCoord(MSG_ENTITY, self.origin_x);
-        WriteCoord(MSG_ENTITY, self.origin_y);
-        WriteCoord(MSG_ENTITY, self.origin_z);        
-    }
-    
-    if(sf & VSF_MOVEMENT)
-    {    
-        WriteCoord(MSG_ENTITY, self.velocity_x);
-        WriteCoord(MSG_ENTITY, self.velocity_y);
-        WriteCoord(MSG_ENTITY, self.velocity_z);
-
-        WriteAngle(MSG_ENTITY, self.angles_x);
-        WriteAngle(MSG_ENTITY, self.angles_y);
-        WriteAngle(MSG_ENTITY, self.angles_z);
-
-        WriteCoord(MSG_ENTITY, self.avelocity_x);
-        WriteCoord(MSG_ENTITY, self.avelocity_y);
-        WriteCoord(MSG_ENTITY, self.avelocity_z);
-    }
-    
-    if(sf & VSF_STATS)
-    {
-        WriteShort(MSG_ENTITY, self.vehicle_health);
-        WriteShort(MSG_ENTITY, self.vehicle_shield);
-        WriteShort(MSG_ENTITY, self.vehicle_energy);
-        WriteShort(MSG_ENTITY, self.vehicle_ammo1);
-        WriteShort(MSG_ENTITY, self.vehicle_reload1);
-        WriteShort(MSG_ENTITY, self.vehicle_ammo2);
-        WriteShort(MSG_ENTITY, self.vehicle_reload2);
-    }
-    
-    if(sf & VSF_EXTRA)
-    {
-        self.vehile_send_exta(to);
-    }
-    
-    return TRUE;
-}
-
-void net_link_vehile()
-{    
-    self.SendFlags = 0xFFFFFF;
-    Net_LinkEntity(self, FALSE, 0, send_vehile);    
-}
-#endif // SVQC
-
-#ifdef CSQC
-void Net_ReadVehicle(float bIsNew)
-{
-    float sf;
-    
-    sf = ReadByte();
-    
-    if(sf & VSF_SETUP)
-    {
-        float vhtype;
-        vhtype = ReadByte();
-        
-    }
-    
-    if(bIsNew)
-    {
-        setmodel(self, "models/vehicles/wakizashi.dpm");
-        self.move_movetype = MOVETYPE_BOUNCE;        
-        self.entremove = VehicleRacerRemove;
-        setsize(self,  '-60 -60 -20', '60 60 20');        
-        self.draw = VehicleRacerDraw;
-        self.scale = 0.5;
-    }
-    
-    self.cnt = ReadByte();
-    
-    self.origin_x = ReadCoord();
-    self.origin_y = ReadCoord();
-    self.origin_z = ReadCoord();
-    
-    self.velocity_x = ReadCoord();
-    self.velocity_y = ReadCoord();
-    self.velocity_z = ReadCoord();
-
-    self.angles_x = ReadAngle();
-    self.angles_y = ReadAngle();
-    self.angles_z = ReadAngle();
-
-    self.move_origin    = self.origin;
-    self.move_velocity  = self.velocity;
-    self.move_angles    = self.angles;
-}
-#endif // CSQC
-
-#endif // VEHICLES_CSQC