Merge branch 'master' into Mario/vehicles
authorMario <mario.mario@y7mail.com>
Mon, 18 Nov 2013 18:03:32 +0000 (05:03 +1100)
committerMario <mario.mario@y7mail.com>
Mon, 18 Nov 2013 18:03:32 +0000 (05:03 +1100)
12 files changed:
1  2 
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/tturrets.qc
qcsrc/common/constants.qh
qcsrc/common/notifications.qh
qcsrc/common/vehicles/unit/bumblebee.qc
qcsrc/common/vehicles/unit/spiderbot.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_impulse.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/gamemode_assault.qc

Simple merge
index 2516a369e4ea8d53a42c983b0e552ded75601d61,8c9d59dd91f9a77e421d746a0b8193a8c449fb0f..b33339bedd5bf062cd435019df2c4a336b51631b
@@@ -1562,12 -1564,23 +1562,12 @@@ void CSQC_UpdateView(float w, float h
  
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
-     
      if(hud && !intermission)
 -    {
 -        if(hud == HUD_SPIDERBOT)
 -            CSQC_SPIDER_HUD();
 -        else if(hud == HUD_WAKIZASHI)
 -            CSQC_WAKIZASHI_HUD();
 -        else if(hud == HUD_RAPTOR)
 -            CSQC_RAPTOR_HUD();
 -        else if(hud == HUD_BUMBLEBEE)
 -            CSQC_BUMBLE_HUD();
 -        else if(hud == HUD_BUMBLEBEE_GUN)
 -            CSQC_BUMBLE_GUN_HUD();
 -    }
 +              VEH_ACTION(hud, VR_HUD);
-       
        cl_notice_run();
-       
        // let's reset the view back to normal for the end
        setproperty(VF_MIN, '0 0 0');
        setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
Simple merge
index a8ebd03c1f42d28b64d950dfa28fe04fd3ccf876,2088348b17527dd50317c5a464a4afa6896415a0..cf703feaf59da0504ca1f5bb56cdf1ebbfc8aeac
@@@ -256,17 -256,25 +256,17 @@@ void turret_draw2d(
              return; // Dont draw wp's for turrets out of view
          o_z = 0;
          if(hud != HUD_NORMAL)
 -        {
 -            switch(hud)
 -            {
 -                case HUD_SPIDERBOT:
 -                case HUD_WAKIZASHI:
 -                case HUD_RAPTOR:
 -                case HUD_BUMBLEBEE:
 -                    if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
 -                        txt = "gfx/vehicles/vth-mover.tga";
 -                    else
 -                        txt = "gfx/vehicles/vth-stationary.tga";
 -
 -                    vector pz = drawgetimagesize(txt) * 0.25;
 -                    drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.75, DRAWFLAG_NORMAL);
 -                    break;
 -            }
 +        {        
 +                      if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
 +                              txt = "gfx/vehicles/vth-mover.tga";
 +                      else
 +                              txt = "gfx/vehicles/vth-stationary.tga";
-                         
++
 +                      vector pz = drawgetimagesize(txt) * 0.25;
 +                      drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.75, DRAWFLAG_NORMAL);
          }
        }
-     
        if(dist > self.maxdistance)
          return;
  
Simple merge
Simple merge
index e22a4da704e87089e73d3e16075d00aeaee4cafa,0000000000000000000000000000000000000000..747f3fa42ec04ad7f52cb62a2f6e0954191bd54f
mode 100644,000000..100644
--- /dev/null
@@@ -1,1224 -1,0 +1,1224 @@@
-       
 +#ifdef REGISTER_VEHICLE
 +REGISTER_VEHICLE(
 +/* VEH_##id   */ BUMBLEBEE,
 +/* function   */ v_bumblebee,
 +/* spawnflags */ VHF_DMGSHAKE,
 +/* mins,maxs  */ '-130 -130 -130', '130 130 130',
 +/* model        */ "models/vehicles/bumblebee_body.dpm",
 +/* head_model */ "",
 +/* hud_model  */ "models/vehicles/spiderbot_cockpit.dpm",
 +/* tags                 */ "", "", "tag_viewport",
 +/* netname      */ "bumblebee",
 +/* fullname   */ _("Bumblebee")
 +);
 +#else
 +
 +const float BRG_SETUP = 2;
 +const float BRG_START = 4;
 +const float BRG_END = 8;
 +
 +#ifdef SVQC
 +float autocvar_g_vehicle_bumblebee_speed_forward;
 +float autocvar_g_vehicle_bumblebee_speed_strafe;
 +float autocvar_g_vehicle_bumblebee_speed_up;
 +float autocvar_g_vehicle_bumblebee_speed_down;
 +float autocvar_g_vehicle_bumblebee_turnspeed;
 +float autocvar_g_vehicle_bumblebee_pitchspeed;
 +float autocvar_g_vehicle_bumblebee_pitchlimit;
 +float autocvar_g_vehicle_bumblebee_friction;
 +
 +float autocvar_g_vehicle_bumblebee_energy;
 +float autocvar_g_vehicle_bumblebee_energy_regen;
 +float autocvar_g_vehicle_bumblebee_energy_regen_pause;
 +
 +float autocvar_g_vehicle_bumblebee_health;
 +float autocvar_g_vehicle_bumblebee_health_regen;
 +float autocvar_g_vehicle_bumblebee_health_regen_pause;
 +
 +float autocvar_g_vehicle_bumblebee_shield;
 +float autocvar_g_vehicle_bumblebee_shield_regen;
 +float autocvar_g_vehicle_bumblebee_shield_regen_pause;
 +
 +float autocvar_g_vehicle_bumblebee_cannon_cost;
 +float autocvar_g_vehicle_bumblebee_cannon_damage;
 +float autocvar_g_vehicle_bumblebee_cannon_radius;
 +float autocvar_g_vehicle_bumblebee_cannon_refire;
 +float autocvar_g_vehicle_bumblebee_cannon_speed;
 +float autocvar_g_vehicle_bumblebee_cannon_spread;
 +float autocvar_g_vehicle_bumblebee_cannon_force;
 +
 +float autocvar_g_vehicle_bumblebee_cannon_ammo;
 +float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
 +float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
 +
 +var float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
 +
 +float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
 +float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
 +float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
 +float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
 +float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
 +
 +
 +float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
 +float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
 +float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
 +float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
 +
 +float autocvar_g_vehicle_bumblebee_raygun_range;
 +float autocvar_g_vehicle_bumblebee_raygun_dps;
 +float autocvar_g_vehicle_bumblebee_raygun_aps;
 +float autocvar_g_vehicle_bumblebee_raygun_fps;
 +
 +float autocvar_g_vehicle_bumblebee_raygun;
 +float autocvar_g_vehicle_bumblebee_healgun_hps;
 +float autocvar_g_vehicle_bumblebee_healgun_hmax;
 +float autocvar_g_vehicle_bumblebee_healgun_aps;
 +float autocvar_g_vehicle_bumblebee_healgun_amax;
 +float autocvar_g_vehicle_bumblebee_healgun_sps;
 +float autocvar_g_vehicle_bumblebee_healgun_locktime;
 +
 +float autocvar_g_vehicle_bumblebee_respawntime;
 +
 +float autocvar_g_vehicle_bumblebee_blowup_radius;
 +float autocvar_g_vehicle_bumblebee_blowup_coredamage;
 +float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
 +float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
 +var vector autocvar_g_vehicle_bumblebee_bouncepain;
 +
 +var float autocvar_g_vehicle_bumblebee = 0;
 +
 +
 +float bumble_raygun_send(entity to, float sf);
 +
 +void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
 +{
 +      vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
 +      vehicles_projectile("bigplasma_muzzleflash", "weapons/flacexp3.wav",
 +                                              v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
 +                                              autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
 +                                              DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, TRUE, TRUE, _owner);
 +}
 +
 +float bumblebee_gunner_frame()
 +{
 +      entity vehic    = self.vehicle.owner;
 +      entity gun      = self.vehicle;
 +      entity gunner   = self;
 +      self = vehic;
-       
++
 +      vehic.solid = SOLID_NOT;
 +      //setorigin(gunner, vehic.origin);
 +      gunner.velocity = vehic.velocity;
-               setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);                
++
 +      float _in, _out;
 +      vehic.angles_x *= -1;
 +      makevectors(vehic.angles);
 +      vehic.angles_x *= -1;
 +      if((gun == vehic.gun1))
 +      {
 +              _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
 +              _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
 +              setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
 +      }
 +      else
 +      {
 +              _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
 +              _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
-       
++              setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
 +      }
-       
++
 +      crosshair_trace(gunner);
 +      vector _ct = trace_endpos;
 +      vector ad;
 +
 +      if(autocvar_g_vehicle_bumblebee_cannon_lock)
 +      {
 +              if(gun.lock_time < time)
 +                      gun.enemy = world;
 +
 +              if(trace_ent)
 +                      if(trace_ent.movetype)
 +                              if(trace_ent.takedamage)
 +                                      if(!trace_ent.deadflag)
 +                                      {
 +                                              if(teamplay)
 +                                              {
 +                                                      if(trace_ent.team != gunner.team)
 +                                                      {
 +                                                              gun.enemy = trace_ent;
 +                                                              gun.lock_time = time + 5;
 +                                                      }
 +                                              }
 +                                              else
 +                                              {
 +                                                      gun.enemy = trace_ent;
 +                                                      gun.lock_time = time + 5;
 +                                              }
 +                                      }
 +      }
 +
 +      if(gun.enemy)
 +      {
 +              float i, distance, impact_time;
 +
 +              vector vf = real_origin(gun.enemy);
 +              vector _vel = gun.enemy.velocity;
 +              if(gun.enemy.movetype == MOVETYPE_WALK)
 +                      _vel_z *= 0.1;
 +
 +
 +              ad = vf;
 +              for(i = 0; i < 4; ++i)
 +              {
 +                      distance = vlen(ad - gunner.origin);
 +                      impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
 +                      ad = vf + _vel * impact_time;
 +              }
 +              trace_endpos = ad;
 +
 +
 +              UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
 +              vehicle_aimturret(vehic, trace_endpos, gun, "fire",
 +                                                autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
 +                                                _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
 +
 +      }
 +      else
 +              vehicle_aimturret(vehic, _ct, gun, "fire",
 +                                                autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
 +                                                _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
 +
 +      if(gunner.BUTTON_ATCK)
 +              if(time > gun.attack_finished_single)
 +                      if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
 +                      {
 +                              gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
 +                              bumblebee_fire_cannon(gun, "fire", gunner);
 +                              gun.delay = time;
 +                              gun.attack_finished_single = time + autocvar_g_vehicle_bumblebee_cannon_refire;
 +                      }
 +
 +      VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
 +
 +      if(vehic.vehicle_flags & VHF_HASSHIELD)
 +              VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
 +
 +      ad = gettaginfo(gun, gettagindex(gun, "fire"));
 +      traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
 +
 +      UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
 +
 +      if(vehic.owner)
 +              UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
 +
 +      vehic.solid = SOLID_BBOX;
 +      gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
 +      gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 +
 +      self = gunner;
 +      return 1;
 +}
 +
 +void bumblebee_gunner_exit(float _exitflag)
 +{
 +      if(IS_REAL_CLIENT(self))
 +      {
 +              msg_entity = self;
 +              WriteByte(MSG_ONE, SVC_SETVIEWPORT);
 +              WriteEntity(MSG_ONE, self);
 +
 +              WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
 +              WriteAngle(MSG_ONE, 0);
 +              WriteAngle(MSG_ONE, self.vehicle.angles_y);
 +              WriteAngle(MSG_ONE, 0);
 +      }
-               self.vehicle.owner.gunner1 = world;             
++
 +      CSQCVehicleSetup(self, HUD_NORMAL);
 +      setsize(self, PL_MIN, PL_MAX);
 +
 +      self.takedamage     = DAMAGE_AIM;
 +      self.solid          = SOLID_SLIDEBOX;
 +      self.movetype       = MOVETYPE_WALK;
 +      self.effects        &= ~EF_NODRAW;
 +      self.alpha          = 1;
 +      self.PlayerPhysplug = func_null;
 +      self.view_ofs       = PL_VIEW_OFS;
 +      self.event_damage   = PlayerDamage;
 +      self.hud            = HUD_NORMAL;
 +      self.switchweapon   = self.vehicle.switchweapon;
 +
 +    vh_player = self;
 +    vh_vehicle = self.vehicle;
 +    MUTATOR_CALLHOOK(VehicleExit);
 +    self = vh_player;
 +    self.vehicle = vh_vehicle;
 +
 +      self.vehicle.vehicle_hudmodel.viewmodelforclient = self.vehicle;
 +
 +      fixedmakevectors(self.vehicle.owner.angles);
 +
 +      if(self == self.vehicle.owner.gunner1)
 +      {
-               self.vehicle.owner.gunner2 = world;     
++              self.vehicle.owner.gunner1 = world;
 +      }
 +      else if(self == self.vehicle.owner.gunner2)
 +      {
-       }       
++              self.vehicle.owner.gunner2 = world;
 +              v_right *= -1;
-               
++      }
 +      else
 +              dprint("^1self != gunner1 or gunner2, this is a BIG PROBLEM, tell tZork this happend.\n");
-       
++
 +      vector spot = self.vehicle.owner.origin + + v_up * 128 + v_right * 300;
 +      spot = vehicles_findgoodexit(spot);
 +      //setorigin(self , spot);
 +
 +      self.velocity = 0.75 * self.vehicle.owner.velocity + normalize(spot - self.vehicle.owner.origin) * 200;
 +      self.velocity_z += 10;
 +
 +      self.vehicle.phase = time + 5;
 +      self.vehicle        = world;
 +}
 +
 +float bumblebee_gunner_enter()
 +{
 +      RemoveGrapplingHook(other);
 +      entity _gun, _gunner;
 +      if(!self.gunner1)
 +      {
 +              _gun = self.gun1;
 +              _gunner = self.gunner1;
 +              self.gunner1 = other;
 +      }
 +      else if(!self.gunner2)
 +      {
 +              _gun = self.gun2;
 +              _gunner = self.gunner2;
 +              self.gunner2 = other;
 +      }
 +      else
 +      {
 +              dprint("^1ERROR:^7Tried to enter a fully occupied vehicle!\n");
 +              return FALSE;
 +      }
 +
 +      _gunner            = other;
 +      _gunner.vehicle    = _gun;
 +      _gun.switchweapon  = other.switchweapon;
 +      _gun.vehicle_exit  = bumblebee_gunner_exit;
 +
 +      other.angles            = self.angles;
 +      other.takedamage        = DAMAGE_NO;
 +      other.solid             = SOLID_NOT;
 +      other.movetype          = MOVETYPE_NOCLIP;
 +      other.alpha             = -1;
 +      other.event_damage      = func_null;
 +      other.view_ofs          = '0 0 0';
 +      other.hud               = _gun.hud;
 +      other.PlayerPhysplug    = _gun.PlayerPhysplug;
 +      other.vehicle_ammo1     = self.vehicle_ammo1;
 +      other.vehicle_ammo2     = self.vehicle_ammo2;
 +      other.vehicle_reload1   = self.vehicle_reload1;
 +      other.vehicle_reload2   = self.vehicle_reload2;
 +      other.vehicle_energy    = self.vehicle_energy;
 +      other.PlayerPhysplug    = bumblebee_gunner_frame;
 +      other.flags             &= ~FL_ONGROUND;
 +
 +      msg_entity = other;
 +      WriteByte(MSG_ONE, SVC_SETVIEWPORT);
 +      WriteEntity(MSG_ONE, _gun.vehicle_viewport);
 +      WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
 +      WriteAngle(MSG_ONE, _gun.angles_x + self.angles_x);    // tilt
 +      WriteAngle(MSG_ONE, _gun.angles_y + self.angles_y);    // yaw
 +      WriteAngle(MSG_ONE, 0);                             // roll
 +      _gun.vehicle_hudmodel.viewmodelforclient = other;
 +
 +      CSQCVehicleSetup(other, other.hud);
-       if not(IS_PLAYER(other))
++
 +    vh_player = other;
 +    vh_vehicle = _gun;
 +    MUTATOR_CALLHOOK(VehicleEnter);
 +    other = vh_player;
 +    _gun = vh_vehicle;
 +
 +      return TRUE;
 +}
 +
 +float vehicles_valid_pilot()
 +{
-       if not(IS_REAL_CLIENT(other))
++      if (!IS_PLAYER(other))
 +              return FALSE;
 +
 +      if(other.deadflag != DEAD_NO)
 +              return FALSE;
 +
 +      if(other.vehicle != world)
 +              return FALSE;
 +
-       if(pilot.movement_x > 0 && vang_x < autocvar_g_vehicle_bumblebee_pitchlimit) 
++      if (!IS_REAL_CLIENT(other))
 +              if(!autocvar_g_vehicles_allow_bots)
 +                      return FALSE;
 +
 +      if(teamplay && other.team != self.team)
 +              return FALSE;
 +
 +      return TRUE;
 +}
 +
 +void bumblebee_touch()
 +{
 +      if(self.gunner1 != world && self.gunner2 != world)
 +      {
 +              vehicles_touch();
 +              return;
 +      }
 +
 +      if(vehicles_valid_pilot())
 +      {
 +              if(self.gun1.phase <= time)
 +                      if(bumblebee_gunner_enter())
 +                              return;
 +
 +              if(self.gun2.phase <= time)
 +                      if(bumblebee_gunner_enter())
 +                              return;
 +      }
 +
 +      vehicles_touch();
 +}
 +
 +void bumblebee_regen()
 +{
 +      if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
 +              self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
 +                                                                         self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
 +
 +      if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
 +              self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
 +                                                                         self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
 +
 +      if(self.vehicle_flags  & VHF_SHIELDREGEN)
 +              vehicles_regen(self.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, TRUE);
 +
 +      if(self.vehicle_flags  & VHF_HEALTHREGEN)
 +              vehicles_regen(self.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, FALSE);
 +
 +      if(self.vehicle_flags  & VHF_ENERGYREGEN)
 +              vehicles_regen(self.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, FALSE);
 +
 +}
 +
 +float bumblebee_pilot_frame()
 +{
 +      entity pilot, vehic;
 +      vector newvel;
 +
 +      pilot = self;
 +      vehic = self.vehicle;
 +      self   = vehic;
 +
 +
 +      if(vehic.deadflag != DEAD_NO)
 +      {
 +              self = pilot;
 +              pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
 +              return 1;
 +      }
 +
 +      bumblebee_regen();
 +
 +      crosshair_trace(pilot);
 +
 +      vector vang;
 +      float ftmp;
 +
 +      vang = vehic.angles;
 +      newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
 +      vang_x *= -1;
 +      newvel_x *= -1;
 +      if(newvel_x > 180)  newvel_x -= 360;
 +      if(newvel_x < -180) newvel_x += 360;
 +      if(newvel_y > 180)  newvel_y -= 360;
 +      if(newvel_y < -180) newvel_y += 360;
 +
 +      ftmp = shortangle_f(pilot.v_angle_y - vang_y, vang_y);
 +      if(ftmp > 180)  ftmp -= 360;
 +      if(ftmp < -180) ftmp += 360;
 +      vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity_y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
 +
 +      // Pitch
 +      ftmp = 0;
-       else if(pilot.movement_x < 0 && vang_x > -autocvar_g_vehicle_bumblebee_pitchlimit) 
++      if(pilot.movement_x > 0 && vang_x < autocvar_g_vehicle_bumblebee_pitchlimit)
 +              ftmp = 4;
-       
++      else if(pilot.movement_x < 0 && vang_x > -autocvar_g_vehicle_bumblebee_pitchlimit)
 +              ftmp = -8;
 +
 +      newvel_x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel_x , autocvar_g_vehicle_bumblebee_pitchlimit);
 +      ftmp = vang_x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel_x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
 +      vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity_x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
 +
 +      vehic.angles_x = anglemods(vehic.angles_x);
 +      vehic.angles_y = anglemods(vehic.angles_y);
 +      vehic.angles_z = anglemods(vehic.angles_z);
 +
 +      makevectors('0 1 0' * vehic.angles_y);
 +      newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
 +
 +      if(pilot.movement_x != 0)
 +      {
 +              if(pilot.movement_x > 0)
 +                      newvel += v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
 +              else if(pilot.movement_x < 0)
 +                      newvel -= v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
 +      }
 +
 +      if(pilot.movement_y != 0)
 +      {
 +              if(pilot.movement_y < 0)
 +                      newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
 +              else if(pilot.movement_y > 0)
 +                      newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
 +              ftmp = newvel * v_right;
 +              ftmp *= frametime * 0.1;
 +              vehic.angles_z = bound(-15, vehic.angles_z + ftmp, 15);
 +      }
 +      else
 +      {
 +              vehic.angles_z *= 0.95;
 +              if(vehic.angles_z >= -1 && vehic.angles_z <= -1)
 +                      vehic.angles_z = 0;
 +      }
 +
 +      if(pilot.BUTTON_CROUCH)
 +              newvel -=   v_up * autocvar_g_vehicle_bumblebee_speed_down;
 +      else if(pilot.BUTTON_JUMP)
 +              newvel +=  v_up * autocvar_g_vehicle_bumblebee_speed_up;
 +
 +      vehic.velocity  += newvel * frametime;
 +      pilot.velocity = pilot.movement  = vehic.velocity;
-       {               
++
 +
 +      if(autocvar_g_vehicle_bumblebee_healgun_locktime)
-                       {            
++      {
 +              if(vehic.tur_head.lock_time < time || vehic.tur_head.enemy.deadflag)
 +                      vehic.tur_head.enemy = world;
 +
 +              if(trace_ent)
 +              if(trace_ent.movetype)
 +              if(trace_ent.takedamage)
 +              if(!trace_ent.deadflag)
 +              {
 +                      if(teamplay)
 +                      {
 +                              if(trace_ent.team == pilot.team)
 +                              {
 +                                      vehic.tur_head.enemy = trace_ent;
 +                                      vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
 +                              }
 +                      }
 +                      else
-                       
++                      {
 +                              vehic.tur_head.enemy = trace_ent;
 +                              vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
 +                      }
 +              }
-                       trace_endpos = real_origin(vehic.tur_head.enemy);                       
-                       UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);               
++
 +              if(vehic.tur_head.enemy)
 +              {
-       
++                      trace_endpos = real_origin(vehic.tur_head.enemy);
++                      UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
 +              }
 +      }
-               
++
 +      vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
 +                                        autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1,  autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
 +                                        autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1,  autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides,  autocvar_g_vehicle_bumblebee_raygun_turnspeed);
 +
 +      if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
 +      {
 +              vehic.gun3.enemy.realowner = pilot;
 +              vehic.gun3.enemy.effects &= ~EF_NODRAW;
-               
++
 +              vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
 +              vehic.gun3.enemy.SendFlags |= BRG_START;
-               
++
 +              traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
-               
++
 +              if(trace_ent)
 +              {
 +                      if(autocvar_g_vehicle_bumblebee_raygun)
 +                      {
 +                              Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
 +                              vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
 +                      }
 +                      else
 +                      {
 +                              if(trace_ent.deadflag == DEAD_NO)
 +                                      if((teamplay && trace_ent.team == pilot.team) || !teamplay)
 +                                      {
 +
 +                                              if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
 +                                              {
 +                                                      if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.tur_health)
 +                                                              trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.tur_health);
 +
 +                                                      if(autocvar_g_vehicle_bumblebee_healgun_hps)
 +                                                              trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.tur_health);
 +                                              }
 +                                              else if(IS_CLIENT(trace_ent))
 +                                              {
 +                                                      if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
 +                                                              trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
 +
 +                                                      if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
 +                                                              trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
 +
 +                                                      trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
 +                                              }
 +                                              else if(trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
 +                                              {
 +                                                      if(trace_ent.health  <= trace_ent.tur_health && autocvar_g_vehicle_bumblebee_healgun_hps)
 +                                                              trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.tur_health);
 +                                                      //else ..hmmm what? ammo?
 +
 +                                                      trace_ent.SendFlags |= TNSF_STATUS;
 +                                              }
 +                                      }
 +                      }
 +              }
-               
++
 +              vehic.gun3.enemy.hook_end = trace_endpos;
 +              setorigin(vehic.gun3.enemy, trace_endpos);
 +              vehic.gun3.enemy.SendFlags |= BRG_END;
-       
++
 +              vehic.wait = time + 1;
 +      }
 +      else
 +              vehic.gun3.enemy.effects |= EF_NODRAW;
 +      /*{
 +              if(vehic.gun3.enemy)
 +                      remove(vehic.gun3.enemy);
 +
 +              vehic.gun3.enemy = world;
 +      }
 +      */
-               
++
 +      VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
 +      VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
 +
 +      pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 +      pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 +
 +      if(vehic.vehicle_flags & VHF_HASSHIELD)
 +              VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
-       
++
 +      vehic.angles_x *= -1;
 +      makevectors(vehic.angles);
 +      vehic.angles_x *= -1;
 +      setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
 +
 +      pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
 +      self = pilot;
 +
 +      return 1;
 +}
 +
 +void bumblebee_exit(float eject)
 +{
 +      self.touch = vehicles_touch;
 +      self.think = vehicles_think;
 +      self.nextthink = time;
-       
++
 +      if(!self.owner)
 +              return;
-       if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)              
++
 +      fixedmakevectors(self.angles);
 +      vector spot;
-       
++      if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
 +              spot = self.origin + v_up * 128 + v_forward * 200;
 +      else
 +              spot = self.origin + v_up * 128 - v_forward * 200;
-       
++
 +      spot = vehicles_findgoodexit(spot);
-       
++
 +      // Hide beam
 +      if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
 +              self.gun3.enemy.effects |= EF_NODRAW;
 +    }
 +
 +      self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
 +      self.owner.velocity_z += 10;
 +      setorigin(self.owner, spot);
-       
++
 +      antilag_clear(self.owner);
 +    self.owner = world;
 +}
 +
 +void bumblebee_blowup()
 +{
 +      RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
 +                               autocvar_g_vehicle_bumblebee_blowup_edgedamage,
 +                               autocvar_g_vehicle_bumblebee_blowup_radius, self,
 +                               autocvar_g_vehicle_bumblebee_blowup_forceintensity,
 +                               DEATH_VH_BUMB_DEATH, world);
 +
 +      sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
 +      pointparticles(particleeffectnum("explosion_large"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
-       
++
 +      if(self.owner.deadflag == DEAD_DYING)
 +              self.owner.deadflag = DEAD_DEAD;
-       
++
 +      remove(self);
 +}
 +
 +void bumblebee_diethink()
 +{
 +      if(time >= self.wait)
 +              self.think = bumblebee_blowup;
 +
 +      if(random() < 0.1)
 +      {
 +              sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
 +              pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
 +      }
 +
 +      self.nextthink = time + 0.1;
 +}
 +
 +float bumble_raygun_send(entity to, float sf)
 +{
 +      WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
 +
 +      WriteByte(MSG_ENTITY, sf);
 +      if(sf & BRG_SETUP)
 +      {
 +              WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
 +              WriteByte(MSG_ENTITY, self.realowner.team);
 +              WriteByte(MSG_ENTITY, self.cnt);
 +      }
 +
 +      if(sf & BRG_START)
 +      {
 +              WriteCoord(MSG_ENTITY, self.hook_start_x);
 +              WriteCoord(MSG_ENTITY, self.hook_start_y);
 +              WriteCoord(MSG_ENTITY, self.hook_start_z);
 +      }
 +
 +      if(sf & BRG_END)
 +      {
 +              WriteCoord(MSG_ENTITY, self.hook_end_x);
 +              WriteCoord(MSG_ENTITY, self.hook_end_y);
 +              WriteCoord(MSG_ENTITY, self.hook_end_z);
 +      }
 +
 +      return TRUE;
 +}
 +
 +void spawnfunc_vehicle_bumblebee()
 +{
 +      if not(autocvar_g_vehicle_bumblebee) { remove(self); return; }
 +      if not(vehicle_initialize(VEH_BUMBLEBEE, FALSE)) { remove(self); return; }
 +}
 +
 +float v_bumblebee(float req)
 +{
 +      switch(req)
 +      {
 +              case VR_IMPACT:
 +              {
 +                      if(autocvar_g_vehicle_bumblebee_bouncepain)
 +                              vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
 +                              
 +                      return TRUE;
 +              }
 +              case VR_ENTER:
 +              {
 +                      self.touch = bumblebee_touch;
 +                      self.nextthink = 0;
 +                      self.movetype = MOVETYPE_BOUNCEMISSILE;
 +                      return TRUE;
 +              }
 +              case VR_THINK:
 +              {
 +                      self.movetype = MOVETYPE_TOSS;
 +                      
 +                      self.angles_z *= 0.8;
 +                      self.angles_x *= 0.8;
 +                      
 +                      self.nextthink = time + 0.05;
 +                      
 +                      if(!self.owner)
 +                      {
 +                              entity oldself = self;          
 +                              if(self.gunner1)
 +                              {
 +                                      self = self.gunner1;
 +                                      oldself.gun1.vehicle_exit(VHEF_EJECT);
 +                                      entity oldother = other;
 +                                      other = self;
 +                                      self = oldself;
 +                                      self.phase = 0;
 +                                      self.touch();
 +                                      other = oldother;
 +                                      return TRUE;
 +                              }
 +                              
 +                              if(self.gunner2)
 +                              {
 +                                      self = self.gunner2;
 +                                      oldself.gun2.vehicle_exit(VHEF_EJECT);
 +                                      entity oldother = other;
 +                                      other = self;
 +                                      self = oldself;
 +                                      self.phase = 0;
 +                                      self.touch();
 +                                      other = oldother;
 +                                      return TRUE;
 +                              }               
 +                      }
 +                      
 +                      return TRUE;
 +              }
 +              case VR_DEATH:
 +              {
 +                      entity oldself = self;
 +      
 +                      // Hide beam
 +                      if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
 +                              self.gun3.enemy.effects |= EF_NODRAW;
 +                      
 +                      if(self.gunner1)
 +                      {
 +                              self = self.gunner1;
 +                              oldself.gun1.vehicle_exit(VHEF_EJECT);
 +                              self = oldself;
 +                      }
 +
 +                      if(self.gunner2)
 +                      {
 +                              self = self.gunner2;
 +                              oldself.gun2.vehicle_exit(VHEF_EJECT);
 +                              self = oldself;
 +                      }
 +
 +                      self.vehicle_exit(VHEF_EJECT);
 +
 +                      fixedmakevectors(self.angles);
 +                      vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
 +                      vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
 +                      vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
 +
 +                      entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
 +
 +                      if(random() > 0.5)
 +                              _body.touch = bumblebee_blowup;
 +                      else
 +                              _body.touch = func_null;
 +                              
 +                      _body.think = bumblebee_diethink;
 +                      _body.nextthink = time;
 +                      _body.wait = time + 2 + (random() * 8);
 +                      _body.owner = self;
 +                      _body.enemy = self.enemy;
 +                      
 +                      pointparticles(particleeffectnum("explosion_medium"), findbetterlocation(self.origin, 16), '0 0 0', 1);
 +                      
 +                      self.health                     = 0;
 +                      self.event_damage       = func_null;
 +                      self.solid                      = SOLID_CORPSE;
 +                      self.takedamage         = DAMAGE_NO;
 +                      self.deadflag           = DEAD_DYING;
 +                      self.movetype           = MOVETYPE_NONE;
 +                      self.effects            = EF_NODRAW;
 +                      self.colormod           = '0 0 0';
 +                      self.avelocity          = '0 0 0';
 +                      self.velocity           = '0 0 0';
 +                      self.touch                      = func_null;
 +                      self.nextthink          = 0;
 +
 +                      setorigin(self, self.pos1);
 +                      return TRUE;
 +              }
 +              case VR_SPAWN:
 +              {
 +                      if not(self.gun1)
 +                      {
 +                              // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
 +                              self.vehicle_shieldent = spawn();
 +                              self.vehicle_shieldent.effects = EF_LOWPRECISION;
 +                              setmodel(self.vehicle_shieldent, "models/vhshield.md3");
 +                              setattachment(self.vehicle_shieldent, self, "");
 +                              setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
 +                              self.vehicle_shieldent.scale       = 512 / vlen(self.maxs - self.mins);
 +                              self.vehicle_shieldent.think       = shieldhit_think;
 +                              self.vehicle_shieldent.alpha = -1;
 +                              self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
 +
 +                              self.gun1 = spawn();
 +                              self.gun2 = spawn();
 +                              self.gun3 = spawn();
 +
 +                              self.vehicle_flags |= VHF_MULTISLOT;
 +
 +                              self.gun1.owner = self;
 +                              self.gun2.owner = self;
 +                              self.gun3.owner = self;
 +
 +                              setmodel(self.gun1, "models/vehicles/bumblebee_plasma_right.dpm");
 +                              setmodel(self.gun2, "models/vehicles/bumblebee_plasma_left.dpm");
 +                              setmodel(self.gun3, "models/vehicles/bumblebee_ray.dpm");
 +
 +                              setattachment(self.gun1, self, "cannon_right");
 +                              setattachment(self.gun2, self, "cannon_left");
 +
 +                              // Angled bones are no fun, messes up gun-aim; so work arround it.
 +                              self.gun3.pos1 = self.angles;
 +                              self.angles = '0 0 0';
 +                              vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
 +                              ofs -= self.origin;
 +                              setattachment(self.gun3, self, "");
 +                              setorigin(self.gun3, ofs);
 +                              self.angles = self.gun3.pos1;
 +
 +                              vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit);
 +                              vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit);
 +
 +                              setorigin(self.vehicle_hudmodel, '50 0 -5');    // Move cockpit forward - down.
 +                              setorigin(self.vehicle_viewport, '5 0 2');    // Move camera forward up
 +
 +                              //fixme-model-bones
 +                              setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
 +                              setorigin(self.gun1.vehicle_viewport, '-85 0 50');
 +                              //fixme-model-bones
 +                              setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
 +                              setorigin(self.gun2.vehicle_viewport, '-85 0 50');
 +
 +                              self.scale = 1.5;
 +                              
 +                              // Raygun beam
 +                              if(self.gun3.enemy == world)
 +                              {                       
 +                                      self.gun3.enemy = spawn();
 +                                      Net_LinkEntity(self.gun3.enemy, TRUE, 0, bumble_raygun_send);
 +                                      self.gun3.enemy.SendFlags = BRG_SETUP;                  
 +                                      self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;                      
 +                                      self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
 +                              }
 +                      }
 +
 +                      self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
 +                      self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
 +                      self.solid = SOLID_BBOX;
 +                      self.movetype = MOVETYPE_TOSS;
 +                      self.damageforcescale = 0.025;
 +                      
 +                      self.PlayerPhysplug = bumblebee_pilot_frame;
 +                      
 +                      setorigin(self, self.origin + '0 0 25');
 +                      return TRUE;
 +              }
 +              case VR_SETUP:
 +              {
 +                      if(autocvar_g_vehicle_bumblebee_energy)
 +                      if(autocvar_g_vehicle_bumblebee_energy_regen)
 +                              self.vehicle_flags |= VHF_ENERGYREGEN;
 +
 +                      if(autocvar_g_vehicle_bumblebee_shield)
 +                              self.vehicle_flags |= VHF_HASSHIELD;
 +
 +                      if(autocvar_g_vehicle_bumblebee_shield_regen)
 +                              self.vehicle_flags |= VHF_SHIELDREGEN;
 +
 +                      if(autocvar_g_vehicle_bumblebee_health_regen)
 +                              self.vehicle_flags |= VHF_HEALTHREGEN;
 +                              
 +                      self.vehicle_exit = bumblebee_exit;
 +                      self.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
 +                      self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
 +                      self.max_health = self.vehicle_health;
 +                      self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
 +                              
 +                      return TRUE;
 +              }
 +              case VR_PRECACHE:
 +              {
 +                      precache_model("models/vehicles/bumblebee_body.dpm");
 +                      precache_model("models/vehicles/bumblebee_plasma_left.dpm");
 +                      precache_model("models/vehicles/bumblebee_plasma_right.dpm");
 +                      precache_model("models/vehicles/bumblebee_ray.dpm");
 +                      precache_model("models/vehicles/wakizashi_cockpit.dpm");
 +                      precache_model("models/vehicles/spiderbot_cockpit.dpm");
 +                      precache_model("models/vehicles/raptor_cockpit.dpm");
 +                      return TRUE;
 +              }
 +      }
 +
 +      return TRUE;
 +}
 +
 +#endif // SVQC
 +#ifdef CSQC
 +
 +void bumble_raygun_draw()
 +{
 +      float _len;
 +      vector _dir;
 +      vector _vtmp1, _vtmp2;
 +
 +      _len = vlen(self.origin - self.move_origin);
 +      _dir = normalize(self.move_origin - self.origin);
-               
++
 +      if(self.total_damages < time)
 +      {
 +              boxparticles(self.traileffect, self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
 +              boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
 +              self.total_damages = time + 0.1;
 +      }
 +
 +      float i, df, sz, al;
 +      for(i = -0.1; i < 0.2; i += 0.1)
 +      {
 +              df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
 +              sz = 5 + random() * 5;
 +              al = 0.25 + random() * 0.5;
 +              _vtmp1 = self.origin + _dir * _len * (0.25 + i);
 +              _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2));       //self.raygun_l1;
 +              Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
 +
 +              _vtmp2 = self.origin + _dir * _len * (0.5 + i);
 +              _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5));       //self.raygun_l2;
 +              Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
 +
 +              _vtmp1 = self.origin + _dir * _len * (0.75 + i);
 +              _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10);     //self.raygun_l3;
 +              Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
 +
 +              Draw_CylindricLine(_vtmp1, self.move_origin +  randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
 +      }
 +}
 +
 +void bumble_raygun_read(float bIsNew)
 +{
 +      float sf = ReadByte();
 +
 +      if(sf & BRG_SETUP)
 +      {
 +              self.cnt  = ReadByte();
 +              self.team = ReadByte();
 +              self.cnt  = ReadByte();
-               self.lip = particleeffectnum("healray_impact");         
++
 +              if(self.cnt)
 +                      self.colormod = '1 0 0';
 +              else
 +                      self.colormod = '0 1 0';
 +
 +              self.traileffect = particleeffectnum("healray_muzzleflash");
-       
-       
++              self.lip = particleeffectnum("healray_impact");
 +
 +              self.draw = bumble_raygun_draw;
 +      }
++
++
 +      if(sf & BRG_START)
 +      {
 +              self.origin_x = ReadCoord();
 +              self.origin_y = ReadCoord();
 +              self.origin_z = ReadCoord();
 +              setorigin(self, self.origin);
 +      }
 +
 +      if(sf & BRG_END)
 +      {
 +              self.move_origin_x = ReadCoord();
 +              self.move_origin_y = ReadCoord();
 +              self.move_origin_z = ReadCoord();
 +      }
 +}
 +
 +float v_bumblebee(float req)
 +{
 +      switch(req)
 +      {
 +              case VR_HUD:
 +              {
 +                      if(autocvar_r_letterbox)
 +                              return TRUE;
 +
 +                      vector picsize, hudloc = '0 0 0', pic2size, picloc;
 +
 +                      // Fetch health & ammo stats
 +                      HUD_GETVEHICLESTATS
 +
 +                      picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
 +                      hudloc_y = vid_conheight - picsize_y;
 +                      hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
 +
 +                      drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
 +
 +                      shield  *= 0.01;
 +                      vh_health  *= 0.01;
 +                      energy  *= 0.01;
 +                      reload1 *= 0.01;
 +
 +                      pic2size = draw_getimagesize(bumb_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
 +                      picloc = picsize * 0.5 - pic2size * 0.5;
 +
 +                      if(vh_health < 0.25)
 +                              drawpic(hudloc + picloc, bumb_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, bumb_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
 +
 +                      drawpic(hudloc + picloc, bumb_lgun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
 +                      drawpic(hudloc + picloc, bumb_lgun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
 +                      drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
 +
 +              // Health bar
 +                      picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // ..  and icon
 +                      picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
 +                      if(vh_health < 0.25)
 +                      {
 +                              if(alarm1time < time)
 +                              {
 +                                      alarm1time = time + 2;
 +                                      vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
 +                              }
 +
 +                              drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      }
 +                      else
 +                      {
 +                              drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                              if(alarm1time)
 +                              {
 +                                      vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
 +                                      alarm1time = 0;
 +                              }
 +                      }
 +
 +              // Shield bar
 +                      picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // ..  and icon
 +                      picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
 +                      picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
 +                      if(shield < 0.25)
 +                      {
 +                              if(alarm2time < time)
 +                              {
 +                                      alarm2time = time + 1;
 +                                      vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
 +                              }
 +                              drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      }
 +                      else
 +                      {
 +                              drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                              if(alarm2time)
 +                              {
 +                                      vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
 +                                      alarm2time = 0;
 +                              }
 +                      }
 +
 +                      ammo1 *= 0.01;
 +                      ammo2 *= 0.01;
 +
 +              // Gunner1 bar
 +                      picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +
 +              // Right gunner slot occupied?
 +                      if(!AuxiliaryXhair[1].draw2d)
 +                      {
 +                              shield = (picsize_x * 0.5) - (0.5 * stringwidth(_("No right gunner!"), FALSE, '1 0 0' * picsize_y + '0 1 0' * picsize_y));
 +                              drawfill(hudloc + picloc - '0.2 0.2 0', picsize + '0.4 0.4 0', '0.25 0.25 0.25', 0.75, DRAWFLAG_NORMAL);
 +                              drawstring(hudloc + picloc + '1 0 0' * shield, _("No right gunner!"), '1 0 0' * picsize_y + '0 1 0' * picsize_y, '1 0 0' + '0 1 1' * sin(time * 10), 1, DRAWFLAG_NORMAL);
 +                      }
 +
 +              // ..  and icon
 +                      picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
 +                      if(ammo1 < 0.2)
 +                              drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +
 +              // Gunner2 bar
 +                      picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo2, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // Left gunner slot occupied?
 +                      if(!AuxiliaryXhair[2].draw2d)
 +                      {
 +                              shield = (picsize_x * 0.5) - (0.5 * stringwidth(_("No left gunner!"), FALSE, '1 0 0' * picsize_y + '0 1 0' * picsize_y));
 +                              drawfill(hudloc + picloc - '0.2 0.2 0', picsize + '0.4 0.4 0', '0.25 0.25 0.25', 0.75, DRAWFLAG_NORMAL);
 +                              drawstring(hudloc + picloc + '1 0 0' * shield, _("No left gunner!"), '1 0 0' * picsize_y + '0 1 0' * picsize_y, '1 0 0' + '0 1 1' * sin(time * 10), 1, DRAWFLAG_NORMAL);
 +                      }
 +
 +              // ..  and icon
 +                      picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
 +                      if(ammo2 < 0.2)
 +                              drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +
 +                      if (scoreboard_showscores)
 +                              HUD_DrawScoreboard();
 +                      else
 +                      {
 +                              picsize = draw_getimagesize(waki_xhair);
 +                              picsize_x *= 0.5;
 +                              picsize_y *= 0.5;
 +                              drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), waki_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      }
 +                      return TRUE;
 +              }
 +              case VR_SETUP:
 +              {
 +                      // Raygun-locked
 +                      AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
 +                      AuxiliaryXhair[0].axh_scale   = 0.5;
 +
 +                      // Gunner1
 +                      AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-target.tga";
 +                      AuxiliaryXhair[1].axh_scale   = 0.75;
 +
 +                      // Gunner2
 +                      AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-target.tga";
 +                      AuxiliaryXhair[2].axh_scale   = 0.75;
 +                      return TRUE;
 +              }
 +              case VR_PRECACHE:
 +              {
 +                      precache_model("models/vehicles/bumblebee_body.dpm");
 +                      precache_model("models/vehicles/bumblebee_plasma_left.dpm");
 +                      precache_model("models/vehicles/bumblebee_plasma_right.dpm");
 +                      precache_model("models/vehicles/bumblebee_ray.dpm");
 +                      precache_model("models/vehicles/wakizashi_cockpit.dpm");
 +                      precache_model("models/vehicles/spiderbot_cockpit.dpm");
 +                      precache_model("models/vehicles/raptor_cockpit.dpm");
 +                      return TRUE;
 +              }
 +      }
 +
 +      return TRUE;
 +}
 +
 +#endif // CSQC
 +#endif // REGISTER_VEHICLE
index 86ca8aeb2325fdbf6d50d0588db8e0bd9432a17b,0000000000000000000000000000000000000000..5e01cd53e1f39c12bede30c21df501e55695dd01
mode 100644,000000..100644
--- /dev/null
@@@ -1,1085 -1,0 +1,1085 @@@
-                                                               5, autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0, 1, autocvar_g_vehicle_spiderbot_minigun_bulletconstant);
 +#ifdef REGISTER_VEHICLE
 +REGISTER_VEHICLE(
 +/* VEH_##id   */ SPIDERBOT,
 +/* function   */ v_spiderbot,
 +/* spawnflags */ VHF_DMGSHAKE,
 +/* mins,maxs  */ '-75 -75 10', '75 75 125',
 +/* model        */ "models/vehicles/spiderbot.dpm",
 +/* head_model */ "models/vehicles/spiderbot_top.dpm",
 +/* hud_model  */ "models/vehicles/spiderbot_cockpit.dpm",
 +/* tags                 */ "tag_head", "tag_hud", "",
 +/* netname      */ "spiderbot",
 +/* fullname   */ _("Spiderbot")
 +);
 +#else
 +
 +#ifdef SVQC
 +float autocvar_g_vehicle_spiderbot;
 +
 +float autocvar_g_vehicle_spiderbot_respawntime;
 +
 +float autocvar_g_vehicle_spiderbot_speed_stop;
 +float autocvar_g_vehicle_spiderbot_speed_strafe;
 +float autocvar_g_vehicle_spiderbot_speed_walk;
 +float autocvar_g_vehicle_spiderbot_turnspeed;
 +float autocvar_g_vehicle_spiderbot_turnspeed_strafe;
 +float autocvar_g_vehicle_spiderbot_movement_inertia;
 +
 +float autocvar_g_vehicle_spiderbot_springlength;
 +float autocvar_g_vehicle_spiderbot_springup;
 +float autocvar_g_vehicle_spiderbot_springblend;
 +float autocvar_g_vehicle_spiderbot_tiltlimit;
 +
 +float autocvar_g_vehicle_spiderbot_head_pitchlimit_down;
 +float autocvar_g_vehicle_spiderbot_head_pitchlimit_up;
 +float autocvar_g_vehicle_spiderbot_head_turnlimit;
 +float autocvar_g_vehicle_spiderbot_head_turnspeed;
 +
 +float autocvar_g_vehicle_spiderbot_health;
 +float autocvar_g_vehicle_spiderbot_health_regen;
 +float autocvar_g_vehicle_spiderbot_health_regen_pause;
 +
 +float autocvar_g_vehicle_spiderbot_shield;
 +float autocvar_g_vehicle_spiderbot_shield_regen;
 +float autocvar_g_vehicle_spiderbot_shield_regen_pause;
 +
 +float autocvar_g_vehicle_spiderbot_minigun_damage;
 +float autocvar_g_vehicle_spiderbot_minigun_refire;
 +float autocvar_g_vehicle_spiderbot_minigun_spread;
 +float autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
 +float autocvar_g_vehicle_spiderbot_minigun_ammo_max;
 +float autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
 +float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
 +float autocvar_g_vehicle_spiderbot_minigun_force;
 +float autocvar_g_vehicle_spiderbot_minigun_speed;
 +float autocvar_g_vehicle_spiderbot_minigun_bulletconstant;
 +
 +float autocvar_g_vehicle_spiderbot_rocket_damage;
 +float autocvar_g_vehicle_spiderbot_rocket_force;
 +float autocvar_g_vehicle_spiderbot_rocket_radius;
 +float autocvar_g_vehicle_spiderbot_rocket_speed;
 +float autocvar_g_vehicle_spiderbot_rocket_spread;
 +float autocvar_g_vehicle_spiderbot_rocket_refire;
 +float autocvar_g_vehicle_spiderbot_rocket_refire2;
 +float autocvar_g_vehicle_spiderbot_rocket_reload;
 +float autocvar_g_vehicle_spiderbot_rocket_health;
 +float autocvar_g_vehicle_spiderbot_rocket_noise;
 +float autocvar_g_vehicle_spiderbot_rocket_turnrate;
 +float autocvar_g_vehicle_spiderbot_rocket_lifetime;
 +
 +#define SBRM_FIRST 0
 +#define SBRM_VOLLY 0
 +#define SBRM_GUIDE 1
 +#define SBRM_ARTILLERY 2
 +#define SBRM_LAST 2
 +
 +vector autocvar_g_vehicle_spiderbot_bouncepain;
 +
 +void spiderbot_rocket_artillery()
 +{
 +      self.nextthink = time;
 +      UpdateCSQCProjectile(self);
 +}
 +
 +void spiderbot_rocket_unguided()
 +{
 +      vector newdir, olddir;
 +
 +      self.nextthink  = time;
 +
 +      olddir = normalize(self.velocity);
 +      newdir = normalize(self.pos1 - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
 +      self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
 +
 +      UpdateCSQCProjectile(self);
 +
 +      if (self.owner.deadflag != DEAD_NO || self.cnt < time || vlen(self.pos1 - self.origin) < 16)
 +              self.use();
 +}
 +
 +void spiderbot_rocket_guided()
 +{
 +      vector newdir, olddir;
 +
 +      self.nextthink  = time;
 +
 +      if not (self.realowner.vehicle)
 +              self.think = spiderbot_rocket_unguided;
 +
 +      crosshair_trace(self.realowner);
 +      olddir = normalize(self.velocity);
 +      newdir = normalize(trace_endpos - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
 +      self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
 +
 +      UpdateCSQCProjectile(self);
 +
 +      if (self.owner.deadflag != DEAD_NO || self.cnt < time)
 +              self.use();
 +}
 +
 +void spiderbot_guide_release()
 +{
 +      entity rkt;
 +      rkt = findchainentity(realowner, self.owner);
 +      if not (rkt)
 +              return;
 +
 +      crosshair_trace(self.owner);
 +      while(rkt)
 +      {
 +              if(rkt.think == spiderbot_rocket_guided)
 +              {
 +                      rkt.pos1 = trace_endpos;
 +                      rkt.think = spiderbot_rocket_unguided;
 +              }
 +              rkt = rkt.chain;
 +      }
 +}
 +
 +float spiberbot_calcartillery_flighttime;
 +vector spiberbot_calcartillery(vector org, vector tgt, float ht)
 +{
 +      float grav, sdist, zdist, vs, vz, jumpheight;
 +      vector sdir;
 +
 +      grav  = autocvar_sv_gravity;
 +      zdist = tgt_z - org_z;
 +      sdist = vlen(tgt - org - zdist * '0 0 1');
 +      sdir  = normalize(tgt - org - zdist * '0 0 1');
 +
 +      // how high do we need to go?
 +      jumpheight = fabs(ht);
 +      if(zdist > 0)
 +              jumpheight = jumpheight + zdist;
 +
 +      // push so high...
 +      vz = sqrt(2 * grav * jumpheight); // NOTE: sqrt(positive)!
 +
 +      // we start with downwards velocity only if it's a downjump and the jump apex should be outside the jump!
 +      if(ht < 0)
 +              if(zdist < 0)
 +                      vz = -vz;
 +
 +      vector solution;
 +      solution = solve_quadratic(0.5 * grav, -vz, zdist); // equation "z(ti) = zdist"
 +      // ALWAYS solvable because jumpheight >= zdist
 +      if(!solution_z)
 +              solution_y = solution_x; // just in case it is not solvable due to roundoff errors, assume two equal solutions at their center (this is mainly for the usual case with ht == 0)
 +      if(zdist == 0)
 +              solution_x = solution_y; // solution_x is 0 in this case, so don't use it, but rather use solution_y (which will be sqrt(0.5 * jumpheight / grav), actually)
 +
 +      if(zdist < 0)
 +      {
 +              // down-jump
 +              if(ht < 0)
 +              {
 +                      // almost straight line type
 +                      // jump apex is before the jump
 +                      // we must take the larger one
 +                      spiberbot_calcartillery_flighttime = solution_y;
 +              }
 +              else
 +              {
 +                      // regular jump
 +                      // jump apex is during the jump
 +                      // we must take the larger one too
 +                      spiberbot_calcartillery_flighttime = solution_y;
 +              }
 +      }
 +      else
 +      {
 +              // up-jump
 +              if(ht < 0)
 +              {
 +                      // almost straight line type
 +                      // jump apex is after the jump
 +                      // we must take the smaller one
 +                      spiberbot_calcartillery_flighttime = solution_x;
 +              }
 +              else
 +              {
 +                      // regular jump
 +                      // jump apex is during the jump
 +                      // we must take the larger one
 +                      spiberbot_calcartillery_flighttime = solution_y;
 +              }
 +      }
 +      vs = sdist / spiberbot_calcartillery_flighttime;
 +
 +      // finally calculate the velocity
 +      return sdir * vs + '0 0 1' * vz;
 +}
 +
 +void spiderbot_rocket_do()
 +{
 +      vector v;
 +      entity rocket = world;
 +
 +      if (self.wait != -10)
 +      {
 +              if (self.owner.BUTTON_ATCK2 && self.vehicle_weapon2mode == SBRM_GUIDE)
 +              {
 +                      if (self.wait == 1)
 +                      if (self.tur_head.frame == 9 || self.tur_head.frame == 1)
 +                      {
 +                              if(self.gun2.cnt < time && self.tur_head.frame == 9)
 +                                      self.tur_head.frame = 1;
 +
 +                              return;
 +                      }
 +                      self.wait = 1;
 +              }
 +              else
 +              {
 +                      if(self.wait)
 +                              spiderbot_guide_release();
 +
 +                      self.wait = 0;
 +              }
 +      }
 +
 +      if(self.gun2.cnt > time)
 +              return;
 +
 +      if (self.tur_head.frame >= 9)
 +      {
 +              self.tur_head.frame = 1;
 +              self.wait = 0;
 +      }
 +
 +      if (self.wait != -10)
 +              if not (self.owner.BUTTON_ATCK2)
 +                      return;
 +
 +
 +      v = gettaginfo(self.tur_head,gettagindex(self.tur_head,"tag_fire"));
 +
 +      switch(self.vehicle_weapon2mode)
 +      {
 +              case SBRM_VOLLY:
 +                      rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
 +                                                                 v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
 +                                                                 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
 +                                                                 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
 +                      crosshair_trace(self.owner);
 +                      float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
 +                      _dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
 +                      rocket.nextthink  = time + (_dist / autocvar_g_vehicle_spiderbot_rocket_speed);
 +                      rocket.think     = vehicles_projectile_explode;
 +
 +                      if(self.owner.BUTTON_ATCK2 && self.tur_head.frame == 1)
 +                              self.wait = -10;
 +                      break;
 +              case SBRM_GUIDE:
 +                      rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
 +                                                                 v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
 +                                                                 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
 +                                                                 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, FALSE, self.owner);
 +                      crosshair_trace(self.owner);
 +                      rocket.pos1        = trace_endpos;
 +                      rocket.nextthink  = time;
 +                      rocket.think      = spiderbot_rocket_guided;
 +
 +
 +              break;
 +              case SBRM_ARTILLERY:
 +                      rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
 +                                                                 v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
 +                                                                 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
 +                                                                 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
 +
 +                      crosshair_trace(self.owner);
 +
 +                      rocket.pos1        = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
 +                      rocket.pos1_z      = trace_endpos_z;
 +
 +                      traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
 +                      float h1 = 0.75 * vlen(v - trace_endpos);
 +
 +                      //v = trace_endpos;
 +                      traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
 +                      float h2 = 0.75 * vlen(rocket.pos1 - v);
 +
 +                      rocket.velocity  = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
 +                      rocket.movetype  = MOVETYPE_TOSS;
 +                      rocket.gravity   = 1;
 +                      //rocket.think   = spiderbot_rocket_artillery;
 +              break;
 +      }
 +      rocket.classname  = "spiderbot_rocket";
 +
 +      rocket.cnt = time + autocvar_g_vehicle_spiderbot_rocket_lifetime;
 +
 +      self.tur_head.frame += 1;
 +      if (self.tur_head.frame == 9)
 +              self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_reload;
 +      else
 +              self.attack_finished_single = ((self.vehicle_weapon2mode ==  SBRM_VOLLY) ? autocvar_g_vehicle_spiderbot_rocket_refire2 : autocvar_g_vehicle_spiderbot_rocket_refire);
 +
 +      self.gun2.cnt = time + self.attack_finished_single;
 +}
 +
 +float spiderbot_frame()
 +{
 +      vector ad, vf;
 +      entity player, spider;
 +      float ftmp;
 +
 +      if(intermission_running)
 +              return 1;
 +
 +      player = self;
 +      spider = self.vehicle;
 +      self   = spider;
 +
 +      vehicles_painframe();
 +
 +      player.BUTTON_ZOOM        = 0;
 +      player.BUTTON_CROUCH    = 0;
 +      player.switchweapon      = 0;
 +
 +
 +#if 1 // 0 to enable per-gun impact aux crosshairs
 +      // Avarage gun impact point's -> aux cross
 +      ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
 +      vf = v_forward;
 +      ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
 +      vf += v_forward;
 +      ad = ad * 0.5;
 +      v_forward = vf * 0.5;
 +      traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
 +      UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
 +#else
 +      ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
 +      traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
 +      UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
 +      vf = ad;
 +      ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
 +      traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
 +      UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
 +      ad = 0.5 * (ad + vf);
 +#endif
 +
 +      crosshair_trace(player);
 +      ad = vectoangles(normalize(trace_endpos - ad));
 +      ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
 +      ad = AnglesTransform_Normalize(ad, TRUE);
 +      //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
 +
 +      // Rotate head
 +      ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
 +      ad_y = bound(-ftmp, ad_y, ftmp);
 +      spider.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, spider.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
 +
 +      // Pitch head
 +      ad_x = bound(ftmp * -1, ad_x, ftmp);
 +      spider.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, spider.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
 +
 +
 +      //fixedmakevectors(spider.angles);
 +      makevectors(spider.angles + '-2 0 0' * spider.angles_x);
 +
 +      movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
 +
 +      if(spider.flags & FL_ONGROUND)
 +      {
 +              if(spider.frame == 4 && self.tur_head.wait != 0)
 +              {
 +                      sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
 +                      spider.frame = 5;
 +              }
 +
 +              if(player.BUTTON_JUMP && self.tur_head.wait < time)
 +              {
 +                      sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
 +                      //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
 +                      self.delay = 0;
 +
 +                      self.tur_head.wait = time + 2;
 +                      player.BUTTON_JUMP = 0;
 +                      spider.velocity   = v_forward * 700 + v_up * 600;
 +                      spider.frame = 4;
 +              }
 +              else
 +              {
 +                      if(vlen(player.movement) == 0)
 +                      {
 +                              if(self.sound_nexttime < time || self.delay != 3)
 +                              {
 +                                      self.delay = 3;
 +                                      self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
 +                                      //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
 +                                      sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
 +                              }
 +                              movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
 +                              spider.frame = 5;
 +                      }
 +                      else
 +                      {
 +                              // Turn Body
 +                              if(player.movement_x == 0 && player.movement_y != 0)
 +                                      ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
 +                              else
 +                                      ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
 +
 +                              ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
 +                              spider.angles_y = anglemods(spider.angles_y + ftmp);
 +                              spider.tur_head.angles_y -= ftmp;
 +
 +                              if(player.movement_x != 0)
 +                              {
 +                                      if(player.movement_x > 0)
 +                                      {
 +                                              player.movement_x = 1;
 +                                              spider.frame = 0;
 +                                      }
 +                                      else if(player.movement_x < 0)
 +                                      {
 +                                              player.movement_x = -1;
 +                                              spider.frame = 1;
 +                                      }
 +                                      player.movement_y = 0;
 +                                      movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
 +
 +                                      if(self.sound_nexttime < time || self.delay != 1)
 +                                      {
 +                                              self.delay = 1;
 +                                              self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
 +                                              sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
 +                                              //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
 +                                      }
 +                              }
 +                              else if(player.movement_y != 0)
 +                              {
 +                                      if(player.movement_y < 0)
 +                                      {
 +                                              player.movement_y = -1;
 +                                              spider.frame = 2;
 +                                      }
 +                                      else if(player.movement_y > 0)
 +                                      {
 +                                              player.movement_y = 1;
 +                                              spider.frame = 3;
 +                                      }
 +                                      movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
 +                                      if(self.sound_nexttime < time || self.delay != 2)
 +                                      {
 +                                              self.delay = 2;
 +                                              self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
 +                                              sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
 +                                              //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
 +                                      }
 +                              }
 +                      }
 +              }
 +      }
 +
 +      self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
 +      self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
 +
 +      if(player.BUTTON_ATCK)
 +      {
 +              spider.cnt = time;
 +              if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
 +              {
 +                      entity gun;
 +                      vector v;
 +                      spider.misc_bulletcounter += 1;
 +
 +                      self = player;
 +
 +                      mod(spider.misc_bulletcounter, 2) ? gun = spider.gun1 : gun = spider.gun2;
 +                      v = gettaginfo(gun, gettagindex(gun, "barrels"));
 +                      v_forward = normalize(v_forward);
 +                      v += v_forward * 50;
 +
 +//void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float force, float dtype, float tracereffects, float gravityfactor, float bulletconstant)
 +
 +                      fireBallisticBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_speed,
++                                                              5, autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0, autocvar_g_vehicle_spiderbot_minigun_bulletconstant);
 +
 +                      endFireBallisticBullet();
 +
 +//                    fireBullet (v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_damage,
 +//                            autocvar_g_vehicle_spiderbot_minigun_spread, DEATH_VH_SPID_MINIGUN, 0);
 +
 +                      sound (gun, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
 +                      //trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
 +                      pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
 +
 +                      self = spider;
 +
 +                      spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
 +                      spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
 +                      player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
 +                      spider.gun1.angles_z += 45;
 +                      spider.gun2.angles_z -= 45;
 +                      if(spider.gun1.angles_z >= 360)
 +                      {
 +                              spider.gun1.angles_z = 0;
 +                              spider.gun2.angles_z = 0;
 +                      }
 +              }
 +      }
 +      else
 +              vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
 +                                                                                 autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
 +                                                                                 autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, FALSE);
 +
 +
 +      spiderbot_rocket_do();
 +
 +      if(self.vehicle_flags  & VHF_SHIELDREGEN)
 +              vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, TRUE);
 +
 +      if(self.vehicle_flags  & VHF_HEALTHREGEN)
 +              vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, FALSE);
 +
 +      player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
 +      player.vehicle_ammo2 = spider.tur_head.frame;
 +
 +      if(spider.gun2.cnt <= time)
 +              player.vehicle_reload2 = 100;
 +      else
 +              player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
 +
 +      setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
 +      player.velocity = spider.velocity;
 +
 +      VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
 +
 +      if(self.vehicle_flags & VHF_HASSHIELD)
 +              VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
 +
 +      self = player;
 +      return 1;
 +}
 +
 +void spiderbot_exit(float eject)
 +{
 +      entity e;
 +      vector spot;
 +
 +      e = findchain(classname,"spiderbot_rocket");
 +      while(e)
 +      {
 +              if(e.owner == self.owner)
 +              {
 +                      e.realowner = self.owner;
 +                      e.owner = world;
 +              }
 +              e = e.chain;
 +      }
 +
 +      self.think = vehicles_think;
 +      self.nextthink = time;
 +      self.frame = 5;
 +      self.movetype = MOVETYPE_WALK;
 +
 +      if not(self.owner)
 +              return;
 +
 +      makevectors(self.angles);
 +      if(eject)
 +      {
 +              spot = self.origin + v_forward * 100 + '0 0 64';
 +              spot = vehicles_findgoodexit(spot);
 +              setorigin(self.owner , spot);
 +              self.owner.velocity = (v_up + v_forward * 0.25) * 750;
 +              self.owner.oldvelocity = self.owner.velocity;
 +      }
 +      else
 +      {
 +              if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
 +              {
 +                      self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
 +                      self.owner.velocity_z += 200;
 +                      spot = self.origin + v_forward * 128 + '0 0 64';
 +                      spot = vehicles_findgoodexit(spot);
 +              }
 +              else
 +              {
 +                      self.owner.velocity = self.velocity * 0.5;
 +                      self.owner.velocity_z += 10;
 +                      spot = self.origin + v_forward * 256 + '0 0 64';
 +                      spot = vehicles_findgoodexit(spot);
 +              }
 +              self.owner.oldvelocity = self.owner.velocity;
 +              setorigin(self.owner , spot);
 +      }
 +
 +      antilag_clear(self.owner);
 +      self.owner = world;
 +}
 +
 +void spiderbot_headfade()
 +{
 +      self.think = spiderbot_headfade;
 +      self.nextthink = self.fade_time;
 +      self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
 +
 +      if(self.cnt < time || self.alpha < 0.1)
 +      {
 +              if(self.alpha > 0.1)
 +              {
 +                      sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
 +                      pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
 +              }
 +              remove(self);
 +      }
 +}
 +
 +void spiderbot_blowup()
 +{
 +      if(self.cnt > time)
 +      {
 +              if(random() < 0.1)
 +              {
 +                      sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
 +                      pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
 +              }
 +              self.nextthink = time + 0.1;
 +              return;
 +      }
 +
 +      entity h, g1, g2, b;
 +      b = spawn();
 +      h = spawn();
 +      g1 = spawn();
 +      g2 = spawn();
 +
 +      setmodel(b, "models/vehicles/spiderbot.dpm");
 +      setmodel(h, "models/vehicles/spiderbot_top.dpm");
 +      setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
 +      setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
 +
 +      setorigin(b, self.origin);
 +      b.frame = 11;
 +      b.angles = self.angles;
 +      setsize(b, self.mins, self.maxs);
 +
 +      setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
 +      h.movetype = MOVETYPE_BOUNCE;
 +      h.solid = SOLID_BBOX;
 +      h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
 +      h.modelflags = MF_ROCKET;
 +      h.effects = EF_FLAME | EF_LOWPRECISION;
 +      h.avelocity = randomvec() * 360;
 +
 +      h.alpha = 1;
 +      h.cnt = time + (3.5 * random());
 +      h.fade_rate = 1 / min(self.respawntime, 10);
 +      h.fade_time = time;
 +      h.think = spiderbot_headfade;
 +      h.nextthink = time;
 +
 +      setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
 +      g1.movetype = MOVETYPE_TOSS;
 +      g1.solid = SOLID_CORPSE;
 +      g1.velocity = v_forward * 700 + (randomvec() * 32);
 +      g1.avelocity = randomvec() * 180;
 +
 +      setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
 +      g2.movetype = MOVETYPE_TOSS;
 +      g2.solid = SOLID_CORPSE;
 +      g2.velocity = v_forward * 700 + (randomvec() * 32);
 +      g2.avelocity = randomvec() * 180;
 +
 +      h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
 +
 +      SUB_SetFade(b,  time + 5, min(self.respawntime, 1));
 +      //SUB_SetFade(h,  time, min(self.respawntime, 10));
 +      SUB_SetFade(g1, time, min(self.respawntime, 10));
 +      SUB_SetFade(g2, time, min(self.respawntime, 10));
 +
 +      RadiusDamage (self, self.enemy, 250, 15, 250, world, 250, DEATH_VH_SPID_DEATH, world);
 +
 +      self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
 +      self.movetype = MOVETYPE_NONE;
 +      self.deadflag = DEAD_DEAD;
 +      self.solid = SOLID_NOT;
 +      self.tur_head.effects &= ~EF_FLAME;
 +      self.vehicle_hudmodel.viewmodelforclient = self;
 +}
 +
 +float spiderbot_impulse(float _imp)
 +{
 +      switch(_imp)
 +      {
 +              case 10:
 +              case 15:
 +              case 18:
 +                      self.vehicle.vehicle_weapon2mode += 1;
 +                      if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
 +                              self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
 +
 +                      //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
 +                      CSQCVehicleSetup(self, 0);
 +                      return TRUE;
 +              case 12:
 +              case 16:
 +              case 19:
 +                      self.vehicle.vehicle_weapon2mode -= 1;
 +                      if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
 +                              self.vehicle.vehicle_weapon2mode = SBRM_LAST;
 +
 +                      //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
 +                      CSQCVehicleSetup(self, 0);
 +                      return TRUE;
 +
 +              /*
 +              case 17: // toss gun, could be used to exit?
 +                      break;
 +              case 20: // Manual minigun reload?
 +                      break;
 +              */
 +      }
 +      return FALSE;
 +}
 +
 +void spawnfunc_vehicle_spiderbot()
 +{
 +      if not(autocvar_g_vehicle_spiderbot) { remove(self); return; }
 +      if not(vehicle_initialize(VEH_SPIDERBOT, FALSE)) { remove(self); return; }
 +}
 +
 +float v_spiderbot(float req)
 +{
 +      switch(req)
 +      {
 +              case VR_IMPACT:
 +              {
 +                      if(autocvar_g_vehicle_spiderbot_bouncepain)
 +                              vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
 +              
 +                      return TRUE;
 +              }
 +              case VR_ENTER:
 +              {
 +                      self.vehicle_weapon2mode = SBRM_GUIDE;
 +                      self.movetype = MOVETYPE_WALK;
 +                      CSQCVehicleSetup(self.owner, 0);
 +                      self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
 +                      self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
 +
 +                      if(self.owner.flagcarried)
 +                      {
 +                              setattachment(self.owner.flagcarried, self.tur_head, "");
 +                              setorigin(self.owner.flagcarried, '-20 0 120');
 +                      }
 +              
 +                      return TRUE;
 +              }
 +              case VR_THINK:
 +              {
 +                      if(self.flags & FL_ONGROUND)
 +                              movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
 +                      
 +                      return TRUE;
 +              }
 +              case VR_DEATH:
 +              {
 +                      self.health                             = 0;
 +                      self.event_damage               = func_null;
 +                      self.takedamage                 = DAMAGE_NO;
 +                      self.touch                              = func_null;
 +                      self.cnt                                = 3.4 + time + random() * 2;
 +                      self.think                              = spiderbot_blowup;
 +                      self.nextthink                  = time;
 +                      self.deadflag                   = DEAD_DYING;
 +                      self.frame                              = 5;
 +                      self.tur_head.effects  |= EF_FLAME;
 +                      self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
 +                      self.frame                              = 10;
 +                      self.movetype                   = MOVETYPE_TOSS;
 +
 +                      return TRUE;
 +              }
 +              case VR_SPAWN:
 +              {
 +                      if not(self.gun1)
 +                      {
 +                              self.vehicles_impulse = spiderbot_impulse;
 +                              self.gun1 = spawn();
 +                              self.gun2 = spawn();
 +                              setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
 +                              setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
 +                              setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
 +                              setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
 +                              self.gravity = 2;
 +                              self.mass = 5000;
 +                      }
 +
 +                      self.frame = 5;
 +                      self.tur_head.frame = 1;
 +                      self.movetype = MOVETYPE_WALK;
 +                      self.solid = SOLID_SLIDEBOX;
 +                      self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
 +                      self.tur_head.angles = '0 0 0';
 +                      self.vehicle_exit = spiderbot_exit;
 +
 +                      setorigin(self, self.pos1 + '0 0 128');
 +                      self.angles = self.pos2;
 +                      self.damageforcescale = 0.03;
 +                      self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
 +                      self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
 +                      
 +                      self.PlayerPhysplug = spiderbot_frame;
 +
 +                      return TRUE;
 +              }
 +              case VR_SETUP:
 +              {
 +                      if(autocvar_g_vehicle_spiderbot_shield)
 +                              self.vehicle_flags |= VHF_HASSHIELD;
 +
 +                      if(autocvar_g_vehicle_spiderbot_shield_regen)
 +                              self.vehicle_flags |= VHF_SHIELDREGEN;
 +
 +                      if(autocvar_g_vehicle_spiderbot_health_regen)
 +                              self.vehicle_flags |= VHF_HEALTHREGEN;
 +
 +                      self.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
 +                      self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
 +                      self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
 +                      self.max_health = self.vehicle_health;
 +
 +                      return TRUE;
 +              }
 +              case VR_PRECACHE:
 +              {
 +                      precache_model ("models/vhshield.md3");
 +                      precache_model ("models/vehicles/spiderbot.dpm");
 +                      precache_model ("models/vehicles/spiderbot_top.dpm");
 +                      precache_model ("models/vehicles/spiderbot_barrels.dpm");
 +                      precache_model ("models/vehicles/spiderbot_cockpit.dpm");
 +                      precache_model ( "models/uziflash.md3");
 +
 +                      precache_sound ("weapons/uzi_fire.wav" );
 +                      precache_sound ("weapons/rocket_impact.wav");
 +
 +                      precache_sound ("vehicles/spiderbot_die.wav");
 +                      precache_sound ("vehicles/spiderbot_idle.wav");
 +                      precache_sound ("vehicles/spiderbot_jump.wav");
 +                      precache_sound ("vehicles/spiderbot_strafe.wav");
 +                      precache_sound ("vehicles/spiderbot_walk.wav");
 +                      precache_sound ("vehicles/spiderbot_land.wav");
 +                      return TRUE;
 +              }
 +      }
 +
 +      return TRUE;
 +}
 +
 +#endif // SVQC
 +#ifdef CSQC
 +
 +#define spider_ico  "gfx/vehicles/sbot.tga"
 +#define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
 +#define spider_mgun "gfx/vehicles/sbot_mguns.tga"
 +string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
 +
 +#define SBRM_FIRST 1
 +#define SBRM_VOLLY 1
 +#define SBRM_GUIDE 2
 +#define SBRM_ARTILLERY 3
 +#define SBRM_LAST 3
 +
 +float v_spiderbot(float req)
 +{
 +      switch(req)
 +      {
 +              case VR_HUD:
 +              {
 +                      if(autocvar_r_letterbox)
 +                              return TRUE;
 +
 +                      vector picsize, hudloc = '0 0 0', pic2size, picloc;
 +                      float i;
 +
 +                      // Fetch health & ammo stats
 +                      HUD_GETVEHICLESTATS
 +
 +                      picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
 +                      hudloc_y = vid_conheight - picsize_y;
 +                      hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
 +
 +                      drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
 +
 +                      ammo1   *= 0.01;
 +                      shield  *= 0.01;
 +                      vh_health  *= 0.01;
 +                      reload2 *= 0.01;
 +
 +                      pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
 +                      picloc = picsize * 0.5 - pic2size * 0.5;
 +                      if(vh_health < 0.25)
 +                              drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
 +                      drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
 +                      drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
 +                      drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
 +
 +              // Health bar
 +                      picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // ..  and icon
 +                      picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
 +                      if(vh_health < 0.25)
 +                      {
 +                              if(alarm1time < time)
 +                              {
 +                                      alarm1time = time + 2;
 +                                      sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
 +                              }
 +                              drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      }
 +                      else
 +                      {
 +                              drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                              if(alarm1time)
 +                              {
 +                                      sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
 +                                      alarm1time = 0;
 +                              }
 +                      }
 +              // Shield bar
 +                      picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // ..  and icon
 +                      picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
 +                      picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
 +                      if(shield < 0.25)
 +                      {
 +                              if(alarm2time < time)
 +                              {
 +                                      alarm2time = time + 1;
 +                                      sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
 +                              }
 +                              drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      }
 +                      else
 +                      {
 +                              drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                              if(alarm2time)
 +                              {
 +                                      sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
 +                                      alarm2time = 0;
 +                              }
 +                      }
 +
 +              // Minigun bar
 +                      picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +              // ..  and icon
 +                      picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
 +                      if(ammo1 < 0.2)
 +                              drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +
 +              // Rocket ammo bar
 +                      picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
 +                      ammo1 = picsize_x / 8;
 +                      picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
 +                      drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
 +                      drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 +                      drawresetcliparea();
 +
 +              // ..  and icons
 +                      pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
 +                      picloc_x -= pic2size_x;
 +                      picloc_y += pic2size_y * 2.25;
 +                      if(ammo2 == 9)
 +                      {
 +                              for(i = 1; i < 9; ++i)
 +                              {
 +                                      picloc_x += ammo1;
 +                                      drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
 +                              }
 +                      }
 +                      else
 +                      {
 +                              for(i = 1; i < 9; ++i)
 +                              {
 +                                      picloc_x += ammo1;
 +                                      drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
 +                              }
 +                      }
 +                      pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
 +                      picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
 +                      if(ammo2 == 9)
 +                              drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
 +                      else
 +                              drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
 +
 +                      if (scoreboard_showscores)
 +                              HUD_DrawScoreboard();
 +                      else
 +                      {
 +                              switch(weapon2mode)
 +                              {
 +                                      case SBRM_VOLLY:
 +                                              spider_xhair = "gfx/vehicles/axh-bracket.tga";
 +                                              break;
 +                                      case SBRM_GUIDE:
 +                                              spider_xhair = "gfx/vehicles/axh-cross.tga";
 +                                              break;
 +                                      case SBRM_ARTILLERY:
 +                                              spider_xhair = "gfx/vehicles/axh-tag.tga";
 +                                              break;
 +                                      default:
 +                                              spider_xhair= "gfx/vehicles/axh-tag.tga";
 +                              }
 +
 +                              picsize = draw_getimagesize(spider_xhair);
 +                              picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
 +                              picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
 +
 +                              drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), spider_xhair, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
 +                      }
 +                      
 +                      return TRUE;
 +              }
 +              case VR_SETUP:
 +              {
 +                      // Minigun1
 +                      AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
 +                      AuxiliaryXhair[0].axh_scale   = 0.25;
 +                      // Minigun2
 +                      AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
 +                      AuxiliaryXhair[1].axh_scale   = 0.25;
 +                      // Rocket
 +                      AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
 +                      AuxiliaryXhair[2].axh_scale   = 0.5;
 +              
 +                      return TRUE;
 +              }
 +              case VR_PRECACHE:
 +              {
 +                      precache_model ("models/vhshield.md3");
 +                      precache_model ("models/vehicles/spiderbot.dpm");
 +                      precache_model ("models/vehicles/spiderbot_top.dpm");
 +                      precache_model ("models/vehicles/spiderbot_barrels.dpm");
 +                      precache_model ("models/vehicles/spiderbot_cockpit.dpm");
 +                      return TRUE;
 +              }
 +      }
 +
 +      return TRUE;
 +}
 +
 +#endif // CSQC
 +#endif // REGISTER_VEHICLE
index 08a0f027b0ba6c86ef865d89ab5c4ec498c8d8a0,65443f4782992f51f3528ebcbbc36300f98f8d47..0a95f7a365c908159daa85a7abc41b2e04f36b4e
@@@ -1610,14 -1610,10 +1610,14 @@@ void player_regen (void
  
                // if player rotted to death...  die!
                if(self.health < 1)
 +              {
 +                      if(self.vehicle)
 +                              vehicles_exit(VHEF_RELESE);
                        self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
 +              }
        }
  
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, regen_mod * frametime * (time > self.pauseregen_finished) * ((self.items & IT_FUEL_REGEN) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, rot_mod * frametime * (time > self.pauserotfuel_finished), limitf);
  }
  
@@@ -2137,10 -2133,9 +2137,10 @@@ void SpectatorThink(
        self.flags |= FL_CLIENT | FL_NOTARGET;
  }
  
 +void vehicles_enter (entity pl, entity veh);
  void PlayerUseKey()
  {
-       if not(IS_PLAYER(self))
+       if (!IS_PLAYER(self))
                return;
  
        if(self.vehicle)
          vehicles_exit(VHEF_NORMAL);
          return;
        }
-                               
 +      else if(autocvar_g_vehicles_enter)
 +      {
 +              if not(self.freezetag_frozen)
 +              if(self.deadflag == DEAD_NO)
 +              {
 +                      entity head, closest_target = world;
 +                      head = WarpZone_FindRadius(self.origin, autocvar_g_vehicles_enter_radius, TRUE);
-                               
++      
 +                      while(head) // find the closest acceptable target to enter
 +                      {
 +                              if(head.vehicle_flags & VHF_ISVEHICLE)
 +                              if(head.deadflag == DEAD_NO)
 +                              if not(head.owner)
 +                              {
 +                                      if(closest_target)
 +                                      {
 +                                              if(vlen(self.origin - head.origin) < vlen(self.origin - closest_target.origin))
 +                                              { closest_target = head; }
 +                                      }
 +                                      else { closest_target = head; }
 +                              }
-                               
++
 +                              head = head.chain;
 +                      }
-       
++
 +                      if(closest_target) { vehicles_enter(self, closest_target); return; }
 +              }
 +      }
        // a use key was pressed; call handlers
        MUTATOR_CALLHOOK(PlayerUseKey);
  }
index 2535444966e26b347541c7825410632fd6db362c,a4376bd418a101096d5fdf7d2e68c76070796578..28d794c6dfcbbeb52a9a628feff097b44ec0a742
@@@ -52,13 -52,13 +52,13 @@@ void ImpulseCommands (void
  
        if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
                return;
-     
      if(self.vehicle)
          if(self.vehicle.deadflag == DEAD_NO)
 -            if(self.vehicle.vehicles_impusle)
 -                if(self.vehicle.vehicles_impusle(imp))
 +            if(self.vehicle.vehicles_impulse)
 +                if(self.vehicle.vehicles_impulse(imp))
                      return;
-     
        if(CheatImpulse(imp))
        {
        }
Simple merge