function GenerateEnemyVehicles()
{
   deleteVariables("$enemyVehicles*");
   
   // get info about player gang first
   
   %tonnage = GetVehicleTonnage();
         
   // the total tonnage allowed for the enemy gang will have a swing by percentage
   
   %rand = getRandom(1, 5);
   
   switch$ ($Difficulty)
   {
      case "easy":
         %rand = getRandom(3, 6);
      case "normal":
         %rand = getRandom(1, 5);      
      case "hard":      
         %rand = getRandom(1, 4);
   }

   switch$ (%rand)
   {
      case 1:
         %enemytonnage = %tonnage*".30";   
         %enemytonnage = %tonnage-%enemytonnage;
      case 2:
         %enemytonnage = %tonnage*".40";   
         %enemytonnage = %tonnage-%enemytonnage;      
      case 3:
         %enemytonnage = %tonnage*".50";   
         %enemytonnage = %tonnage-%enemytonnage;
      case 4:
         %enemytonnage = %tonnage*".60";   
         %enemytonnage = %tonnage-%enemytonnage;
      case 5:
         %enemytonnage = %tonnage*".70";   
         %enemytonnage = %tonnage-%enemytonnage;
      case 6:
         %enemytonnage = %tonnage*".80";   
         %enemytonnage = %tonnage-%enemytonnage;
   }
   
   %enemytonnage = mfloor(%enemytonnage);   
   
   // for every silo remaining this tonnage will increase by 1 ton
   
   switch$ ($Difficulty)
   {
      case "easy":
         %num = 10-$remainingsilos;            
      case "normal":
         %num = 15- $remainingsilos;      
      case "hard":      
         %num = 20 - $remainingsilos;      
   }
   
   // we need to stop this number from getting too large, we just need a little increase
   
   %num = %num / 2;
      
   %enemytonnage = %enemytonnage+%num;
      
   if(%enemytonnage < 1)
      %enemytonnage = 1;
         
   echo("ENEMY TONNAGE " @ %enemytonnage);
   
   // choose the number of vehicles
   
   while(%enemytonnage >= 1)
   {
      %rand = getRandom(1, 24);                        

      switch$ (%rand)
      {
         case 1:
            %tonnage = GetSingleVehicleTonnage("dunebuggy");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("dunebuggy");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("dunebuggy");
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "dunebuggy";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("dunebuggy");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhphp] = 0;                              
               $enemyvehicles[%slot, stockramhphp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               
               %enemytonnage = %enemytonnage-%tonnage;
            }

         case 2:
            %tonnage = GetSingleVehicleTonnage("bike");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("bike");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("bike");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "bike";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("bike");
               $enemyvehicles[%slot, tires] = 2;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 3:
            %tonnage = GetSingleVehicleTonnage("jeep");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("jeep");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("jeep");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "jeep";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("jeep");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 4:
            %tonnage = GetSingleVehicleTonnage("compact");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("compact");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("compact");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "compact";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("compact");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
         case 5:
            %tonnage = GetSingleVehicleTonnage("minivan");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("minivan");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("minivan");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "minivan";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("minivan");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 6:
            %tonnage = GetSingleVehicleTonnage("towtruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("towtruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("towtruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "towtruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("towtruck");
               $enemyvehicles[%slot, tires] = 6;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 7:
            %tonnage = GetSingleVehicleTonnage("van");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("van");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("van");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "van";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("van");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 8:
            %tonnage = GetSingleVehicleTonnage("limo");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("limo");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("limo");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "limo";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("limo");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 9:
            %tonnage = GetSingleVehicleTonnage("sedan");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("sedan");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("sedan");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, curentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "sedan";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("sedan");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 10:
            %tonnage = GetSingleVehicleTonnage("sportscar");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("sportscar");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("sportscar");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "sportscar";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("sportscar");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 11:
            %tonnage = GetSingleVehicleTonnage("pickuptruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("pickuptruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("pickuptruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, curentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "pickuptruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("pickuptruck");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 12:
            %tonnage = GetSingleVehicleTonnage("musclecar");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("musclecar");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("musclecar");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "musclecar";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("musclecar");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 13:
            %tonnage = GetSingleVehicleTonnage("stationwagon");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("stationwagon");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("statonwagon");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "stationwagon";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("stationwagon");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 14:
            %tonnage = GetSingleVehicleTonnage("humvee");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("humvee");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("humvee");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "humvee";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("humvee");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 15:
            %tonnage = GetSingleVehicleTonnage("suv");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("suv");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("suv");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "suv";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("suv");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 16:
            %tonnage = GetSingleVehicleTonnage("flatbedtruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("flatbedtruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("flatbedtruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "flatbedtruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("flatbedtruck");
               $enemyvehicles[%slot, tires] = 14;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 17:
         
            %tonnage = GetSingleVehicleTonnage("trailertruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("trailertruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("trailertruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "trailertruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("trailertruck");
               $enemyvehicles[%slot, tires] = 18;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 18:
            %tonnage = GetSingleVehicleTonnage("fireengine");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("fireengine");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("fireengine");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "fireengine";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("fireengine");
               $enemyvehicles[%slot, tires] = 6;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 19:
            %tonnage = GetSingleVehicleTonnage("garbagetruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("garbagetruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("garbagetruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "garbagetruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("garbagetruck");
               $enemyvehicles[%slot, tires] = 6;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 20:
            %tonnage = GetSingleVehicleTonnage("bus");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("bus");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("bus");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "bus";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("bus");
               $enemyvehicles[%slot, tires] = 10;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 21:
            %tonnage = GetSingleVehicleTonnage("boxtruck");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("boxtruck");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("boxtruck");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "boxtruck";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("boxtruck");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 22:
            %tonnage = GetSingleVehicleTonnage("cargovan");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("cargovan");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("cargovan");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "cargovan";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("cargovan");
               $enemyvehicles[%slot, tires] = 6;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 23:
            %tonnage = GetSingleVehicleTonnage("ambulance");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("ambulance");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("ambulance");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "ambulance";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("ambulance");
               $enemyvehicles[%slot, tires] = 4;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
            
         case 24:
            %tonnage = GetSingleVehicleTonnage("construction");

            if(%tonnage <= %enemytonnage)
            {
               %slot++;
               $enemyvehicles[%slot, currentvehiclehp] = GetStockVehicleHitPoints("construction");
               $enemyvehicles[%slot, stockvehiclehp] = GetStockVehicleHitPoints("construction");
               $enemyvehicles[%slot, stockarmor] = 0;
               $enemyvehicles[%slot, currentarmor] = 0;
               $enemyvehicles[%slot, acceleration] = 0;
               $enemyvehicles[%slot, brakes] = 0;
               $enemyvehicles[%slot, steering] = 0;
               $enemyvehicles[%slot, stocktirearmor] = 0;
               $enemyvehicles[%slot, currenttirearmor] = 0;
               $enemyvehicles[%slot, currentgastankarmor] = 0;
               $enemyvehicles[%slot, stockgastankarmor] = 0;
               $enemyvehicles[%slot, tireupgrade] = 0;
               $enemyvehicles[%slot, currentwindowarmor] = 0;
               $enemyvehicles[%slot, stockwindowarmor] = 0;
               $enemyvehicles[%slot, badtires] = 0;
               $enemyvehicles[%slot, vehicle] = "construction";
               $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed("construction");
               $enemyvehicles[%slot, tires] = 0;
               $enemyvehicles[%slot, currentramhp] = 0;               
               $enemyvehicles[%slot, stockramhp] = 0;                              
               $Enemyvehicles[%slot, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
               $enemyvehicles[%slot, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               $enemyvehicles[%slot, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%slot, vehicle]);                              
               %enemytonnage = %enemytonnage-%tonnage;
            }
      }
   }
   
   $enemyvehicles[numvehicles] = %slot;
}

// if this is a silo capture make it a special gang

function GenerateNukeGang()
{
   echo("GENERATED NUKE GANG");
   
   %count = getRandom(6, 10);
   
   for(%i=1;%i<=%count;%i++)
   {   
      $enemyvehicles[%i, currentvehiclehp] = GetStockVehicleHitPoints("humvee");
      $enemyvehicles[%i, stockvehiclehp] = GetStockVehicleHitPoints("humvee");
      $enemyvehicles[%i, stockarmor] = 0;
      $enemyvehicles[%i, currentarmor] = 0;
      $enemyvehicles[%i, acceleration] = 0;
      $enemyvehicles[%i, brakes] = 0;
      $enemyvehicles[%i, steering] = 0;
      $enemyvehicles[%i, stocktirearmor] = 0;
      $enemyvehicles[%i, currenttirearmor] = 0;
      $enemyvehicles[%i, currentgastankarmor] = 0;
      $enemyvehicles[%i, stockgastankarmor] = 0;
      $enemyvehicles[%i, tireupgade] = 0;
      $enemyvehicles[%i, currentwindowarmor] = 0;
      $enemyvehicles[%i, stockwindowarmor] = 0;
      $enemyvehicles[%i, badtires] = 0;
      $enemyvehicles[%i, vehicle] = "humvee";
      $enemyvehicles[%i, topspeed] = GetVehicleTopSpeed("humvee");
      $enemyvehicles[%i, tires] = 4;
      $enemyvehicles[%i, currentramhp] = 0;               
      $enemyvehicles[%i, stockramhp] = 0;                              
      $Enemyvehicles[%i, supplycapacity] = GetVehicleSupplyCapacity($Enemyvehicles[%i, vehicle]);
      $enemyvehicles[%i, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%i, vehicle]);                              
      $enemyvehicles[%i, stockenginehp] = GetStockEngineHitPoints($Enemyvehicles[%i, vehicle]);                              
   }

   $enemyvehicles[numvehicles] = %count;
}

// add improvements based on the number of points the player gang has //////////////////////////////////

function GenerateEnemyPoints()
{      
   GetGangUpgradePoints();   
   
   %rand = getRandom(1, 3);
   
   echo("PLAYER POINTS IS " @ $points);
   
   switch$ (%rand)
   {
      case 1:
         %points = $points*".05";
      case 2:
         %points = $points*".10";
      case 3:
         %points = $points*".15";
   }
   
   echo("ENEMY POINTS BEFORE SILOS IS " @ %points);
      
   switch$ ($remainingsilos)
   {
      case 1:
         %num = 100;            
      case 2:
         %num = 95;      
      case 3:      
         %num = 90;      
      case 4:
         %num = 85;      
      case 5:
         %num = 80;      
      case 6:
         %num = 75;      
      case 7:
         %num = 70;      
      case 8:
         %num = 65;      
      case 9:
         %num = 60;      
      case 10:
         %num = 55;      
      case 11:
         %num = 50;      
      case 12:
         %num = 45;      
      case 13:
         %num = 40;      
      case 14:
         %num = 35;      
      case 15:
         %num = 30;      
      case 16:
         %num = 25;      
      case 17:
         %num = 20;      
      case 18:
         %num = 15;      
      case 19:
         %num = 10;      
      case 20:
         %num = 5;      
   }
   
   echo("ENEMY POINTS AFTER SILOS IS " @ %num);
      
   %points = %points+%num;

   %points = mCeil(%points);
   
   if(%points >= $points)
   {
      %points = $points / 3;
      %points = mCeil(%points);
   }
   
   echo("ENEMY UPGRADE POINTS " @ %points);
   
   while(%points > 0)
   {
      %rand = getRandom(1, 12);
      
      %slot = getRandom(1,$Enemyvehicles[numvehicles]); 
      
      %mount = "";
      
      // if it's a smaller class vehile just change rand to 10 so a special weapon doesn't get mounted on it

            
      switch$ (%rand)
      {
         case 1:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "armor");
            %armor = GetUpgradeArmorPoints($enemyvehicles[%slot, vehicle]);
            %max = %armor*5;

            if(%cost <= %points && $enemyvehicles[%slot, stockarmor] < %max && $Enemyvehicles[%slot, vehicle] !$= "bike" && $Enemyvehicles[%slot, vehicle] !$= "dunebuggy")
            {
               $enemyvehicles[%slot, stockarmor] = $enemyvehicles[%slot, stockarmor]+%armor;
               $enemyvehicles[%slot, currentarmor] = $enemyvehicles[%slot, currentarmor]+%armor;
               %points = %points-%cost;
            }
         case 2:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "tireupgrade");

            if(%cost <= %points && $enemyvehicles[%slot, tireupgrade] < 3)
            {
               $Enemyvehicles[%slot, tireupgrade]++;
               %points = %points-%cost;
            }
         case 3:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "brakes");

            if(%cost <= %points && $enemyvehicles[%slot, brakes] < 5)
            {
               $enemyvehicles[%slot, brakes]++;              
               %points = %points-%cost;
            }
         case 4:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "acceleration");

            if(%cost <= %points && $enemyvehicles[%slot, acceleration] < 5)
            {
               $enemyvehicles[%slot, acceleration]++;              
               %points = %points-%cost;
            }
         case 5:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "steering");

            if(%cost <= %points && $enemyvehicles[%slot, steering] < 5)
            {
               $enemyvehicles[%slot, steering]++;              
               %points = %points-%cost;
            }
         case 6:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "tirearmor");
            %armor = GetUpgradeTireArmorPoints($Enemyvehicles[%slot, vehicle]);
            %max = %armor*5;

            if(%cost <= %points && $enemyvehicles[%slot, stocktirearmor] < %max && $Enemyvehicles[%slot, vehicle] !$= "bike" && $Enemyvehicles[%slot, vehicle] !$= "dunebuggy")
            {
               $Enemyvehicles[%slot, stocktirearmor] = $Enemyvehicles[%slot, stocktirearmor]+%armor;
               $Enemyvehicles[%slot, currenttirearmor] = $Enemyvehicles[%slot, currenttirearmor]+%armor;
               %points = %points-%cost;
            }
         case 7:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "gastankarmor");
            %armor = GetUpgradeGasTankArmorPoints($Enemyvehicles[%slot, vehicle]);
            %max = %armor*5;

            if(%cost <= %points && $enemyvehicles[%slot, stockgastankarmor] < %max)
            {
               $Enemyvehicles[%slot, stockgastankarmor] = $Enemyvehicles[%slot, stockgastankarmor]+%armor;
               $Enemyvehicles[%slot, currentgastankarmor] = $Enemyvehicles[%slot, currentgastankarmor]+%armor; 
               %points = %points-%cost;
            }
         case 8:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "ram");
            %ram = GetUpgradeRamPoints($Enemyvehicles[%slot, vehicle]);
            %max = %points*5;

            if(%cost <= %points && $enemyvehicles[%slot, stockramhp] < %max && $Enemyvehicles[%slot, vehicle] !$= "compact" && $Enemyvehicles[%slot, vehicle] !$= "bike" && $Enemyvehicles[%slot, vehicle] !$= "jeep" && $Enemyvehicles[%slot, vehicle] !$= "dunebuggy")
            {
               $Enemyvehicles[%slot, stockramhp] = $Enemyvehicles[%slot, stockramhp]+%ram;
               $Enemyvehicles[%slot, currentramhp] = $Enemyvehicles[%slot, currentramhp]+%ram;
               %points = %points-%cost;
            }

            if($Enemyvehicles[%slot, stockramhp] > 0)
               AttachRam($Enemyvehicles[%slot, battleid]);
         case 9:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "windowarmor");
            %armor = GetUpgradewindowArmorPoints($Enemyvehicles[%slot, vehicle]);
            %max = %armor*5;
         
            if(%cost <= %points && $enemyvehicles[%slot, stockwindowarmor] < %max && $Enemyvehicles[%slot, vehicle] !$= "bike" && $Enemyvehicles[%slot, vehicle] !$= "dunebuggy")
            {
               $Enemyvehicles[%slot, stockwindowarmor] = $Enemyvehicles[%slot, stockwindowarmor]+%armor;
               $Enemyvehicles[%slot, currentwindowarmor] = $Enemyvehicles[%slot, currentwindowarmor]+%armor;
               %points = %points-%cost;
            }
         case 10:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "capacity");
            %capacity = GetSupplyCapacityUpgrade($Enemyvehicles[%slot, vehicle]);
            %max = %capacity*5;
            %max = %max+GetVehicleSupplyCapacity($Enemyvehicles[%slot, vehicle]);
         
            if(%cost <= %points && $Enemyvehicles[%slot, supplycapacity] < %max)
            {
               $Enemyvehicles[%slot, SupplyCapacity] = $Enemyvehicles[%slot, SupplyCapacity]+GetSupplyCapacityUpgrade($Enemyvehicles[%slot, vehicle]);
               %points = %points-%cost;
            }
         case 11:
            %cost = GetPointCost($enemyvehicles[%slot, vehicle], "topspeed");
         
            if(%cost <= %points)
            {
               $enemyvehicles[%slot, topspeed] = $enemyvehicles[%slot, topspeed]+10;
               $enemyvehicles[%slot, topspeedlevel]++;
               %points = %points-%cost;
            }
         
         // mounted weapon
         
         case 12:
            // if this is the first time then pick a weapon if they can afford it
            
            if($enemyvehicles[%slot, mountedweapon] $= "" && $Enemyvehicles[%slot, vehicle] !$= "bike" && $Enemyvehicles[%slot, vehicle] !$= "jeep" && $Enemyvehicles[%slot, vehicle] !$= "dunebuggy")
            {
               %weapon = 1;
            
               if($CapturedCities >= 10)
                  %weapon = getRandom(1, 2);

               if($CapturedCities >= 20)
                  %weapon = getRandom(1, 3);

               if($CapturedCities >= 35)
                  %weapon = getRandom(1, 4);

               switch$ (%weapon)
               {
                  case 1:
                     %cost = GetPointCost($enemyvehicles[%slot, vehicle], "crossbow");

                     if(%cost <= %points)
                     {
                        $enemyvehicles[%slot, mountedweapon] = "crossbow";
                        %hitpoints = GetUpgradeSpecialWeaponHitPoints("crossbow");
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                        %points = %points-%cost;
                        %mount = true;
                     }

                  case 2:
                     %cost = GetPointCost($enemyvehicles[%slot, vehicle], "flamethrower");

                     if(%cost <= %points)
                     {
                        $enemyvehicles[%slot, mountedweapon] = "flamethrower";
                        %hitpoints = GetUpgradeSpecialWeaponHitPoints("flamethrower");
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                        %points = %points-%cost;
                        %mount = true;
                     }
                  
                  case 3:
                     %cost = GetPointCost($enemyvehicles[%slot, vehicle], "machinegun");

                     if(%cost <= %points)
                     {
                        $enemyvehicles[%slot, mountedweapon] = "machinegun";
                        %hitpoints = GetUpgradeSpecialWeaponHitPoints("machinegun");
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                        %points = %points-%cost;
                        %mount = true;
                     }
                  
                  case 4:
                     %cost = GetPointCost($enemyvehicles[%slot, vehicle], "rpg");

                     if(%cost <= %points)
                     {
                        $enemyvehicles[%slot, mountedweapon] = "rpg";                  
                        %hitpoints = GetUpgradeSpecialWeaponHitPoints("rpg");
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                        %points = %points-%cost;
                        %mount = true;
                     }
               }
            }
            
            // if it already else a mounted weapon, the %mount flag is to make sure it doesn't
            // upgrade right after it gets a mounted weapon
            
            if($enemyvehicles[%slot, mountedweapon] !$= "" && %mount $= "")
            {
               switch$ ($enemyvehicles[%slot, mountedweapon])
               {
                  case "machinegun":
                     %cost = GetPointCost($enemyvehicles[%slot, mountedweapon]);
                     %hitpoints = GetUpgradeSpecialWeaponHitPoints("machinegun");
                     %max = %hitpoints*5;
                     
                     if(%cost <= %points && $Enemyvehicles[%slot, stockmountedweaponhp] < %max)
                     {
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                     }
                  
                  case "flamethrower":
                     %cost = GetPointCost($enemyvehicles[%slot, mountedweapon]);
                     %hitpoints = GetUpgradeSpecialWeaponHitPoints("flamethrower");
                     %max = %hitpoints*5;
                     
                     if(%cost <= %points && $Enemyvehicles[%slot, stockmountedweaponhp] < %max)
                     {
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                     }
                  
                  case "rpg":
                     %cost = GetPointCost($enemyvehicles[%slot, mountedweapon]);
                     %hitpoints = GetUpgradeSpecialWeaponHitPoints("rpg");
                     %max = %hitpoints*5;
                     
                     if(%cost <= %points && $Enemyvehicles[%slot, stockmountedweaponhp] < %max)
                     {
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                     }
                  
                  case "crossbow":                  
                     %cost = GetPointCost($enemyvehicles[%slot, mountedweapon]);
                     %hitpoints = GetUpgradeSpecialWeaponHitPoints("crossbow");
                     %max = %hitpoints*5;
                     
                     if(%cost <= %points && $Enemyvehicles[%slot, stockmountedweaponhp] < %max)
                     {
                        $Enemyvehicles[%slot, stockmountedweaponhp] = $Enemyvehicles[%slot, stockmountedweaponhp]+%hitpoints;
                        $Enemyvehicles[%slot, currentmountedweaponhp] = $Enemyvehicles[%slot, currentmountedweaponhp]+%hitpoints;
                     }                  
               }
            }            
      }

      // I don't think the points will always be brought down to zero so let it loop 200 times before a break
      // 200 times should be more then enough for all upgrade points to be displaced
       
      if(%j == 200)
         break;   
      
      %j++;
   }
}

function GenerateEnemyPersonnel()
{
   %playermen = GetTotalCombatPeople();
   
   %percentage = "." @ getRandom(10, 25);

   switch$ ($Difficulty)
   {
      case "easy":
         %num = 10-$remainingsilos;            
      case "normal":
         %num = 15- $remainingsilos;      
      case "hard":      
         %num = 20 - $remainingsilos;      
   }
   
   %value = %playermen*%percentage;
   %value = mCeil(%value);
   
   %men = %playermen-%value;
   
   %men = %men+%num;

   // get the total vehicle capacity, if there is more men then capacity then round it off
      
   for(%i=1;%i<=$enemyvehicles[numvehicles];%i++)
   {
      %capacity = GetVehiclePeopleCapacity($enemyvehicles[%i, vehicle])+%capacity;
   }
   
   if(%men > %capacity)
      %men = %capacity;
   
   // randomly assign the rest of the men
   
   $TotalEnemyMen = %men;  // used for the generate guns and ammo function
   
   while(%men > 0)
   {
      %vehiclenum = getRandom(1, $enemyvehicles[numvehicles]);
      
      if($Enemyvehicles[%vehiclenum, vehicle] !$= "")
      {
         %id = $Enemyvehicles[%vehiclenum, battleid];
         
         if(getWordCount(%id.crew) < GetVehiclePeopleCapacity($Enemyvehicles[%vehiclenum, vehicle]))
         {
            %class = getRandom(1, 6);
            
            switch$ (%class)
            {
               case 1:
                  %class = "refuges";
               case 2:
                  %class = "brigands";
               case 3:
                  %class = "militia";
               case 4:
                  %class = "police";
               case 5:
                  %class = "soldiers";
               case 6:
                  %class = "mercenaries";
            }
            
            if(%id.crew $= "")
               %id.crew = %class;
            else
               %id.crew = %id.crew SPC %class;
            
            %men--;
         }
      }
   }   
}

// determine how many guns and much ammo they have

function GenerateEnemyGuns()
{
   %rand1 = getRandom(1, 2);
   
   if(%rand1 == 1)
   {
      %rand = getRandom(5, 15);
      %percent = "." @ %rand;
      %value = $TotalEnemyMen*%percent;
      %value = mCeil(%value);
      %guns = $TotalEnemyMen-%value;
   }
   else
   {
      %rand = getRandom(10, 35);
      %percent = "." @ %rand;
      %value = $TotalEnemyMen*%percent;
      %value = mCeil(%value);
      %guns = $TotalEnemyMen+%value;
   }
      
   // generate the ammo
   
   %rand = getRandom(1, 5);
   
   switch$ (%rand)
   {
      case 1:
         %multiplier = 10;      
      case 2:
         %multiplier = 15;            
      case 3:
         %multiplier = 20;      
      case 4:
         %multiplier = 25;      
      case 5:
         %multiplier = 30;      
   }
   
   %ammo = %guns*%multiplier;
   
   echo("ENEMY STARTING AMMO " @ %ammo SPC %multiplier);
   
   $enemyGuns = %guns;  // will use it later for after battle loot
   
   echo("STARTING ENEMY GUNS " @ %guns);
      
   if(%guns > $TotalEnemyMen)
      %guns = $TotalEnemyMen;
   
   while(%guns > 0)
   {
      %slot = getRandom(1, $enemyvehicles[numvehicles]);                        
      %id = $enemyvehicles[%slot, battleid];
      
      if(%id.guns < getWordCount(%id.crew))
      {
         %id.guns++;
         %guns--;
         %id.ammo = %id.ammo+%multiplier;
      }
   }
}

function MountEnemyTriggers(%vehicle)
{   
   // middle sensor
   
   %obj = GetMiddleSensor("EnemyMiddleSensor");

   sg.addToScene(%obj);

//   %obj.SetDebugOn(5);
   
   %obj.vehicle = %vehicle;
   %obj.mount(%vehicle, "0 0", 0, true, true, true, true);   
   %vehicle.middlesensor = %obj;
      
   // right forward sensor

   %obj = GetRightForwardSensor("EnemyRightForwardSensor");
   
   sg.addToScene(%obj);

//   %obj.SetDebugOn(5);
   
   %obj.vehicle = %vehicle;
   %obj.mount(%vehicle, "0 0", 0, true, true, true, true);   
   %vehicle.rightforwardsensor = %obj;
   
   // left sensor

   %obj = GetLeftForwardSensor("EnemyLeftForwardSensor");

   sg.addToScene(%obj);

//   %obj.SetDebugOn(5);
   
   %obj.vehicle = %vehicle;
   %obj.mount(%vehicle, "0 0", 0, true, true, true, true);   
   %vehicle.leftforwardsensor = %obj;
      
   // mount bumpers
   
   %obj = GetFrontBumper("EnemyFrontBumper", %vehicle);
//   %obj.SetDebugOn(5);

   sg.addToScene(%obj);
   
   %obj.vehicle = %vehicle;
   %obj.mount(%vehicle, "0 -.9", 0, true, true, true, true);   
   %vehicle.bumper = %obj;

   // firing sensors
   
   MountEnemyFiringPoints(%vehicle);   
}

function CreateEnemyVehicle(%name, %slot)
{
   %list = GetVehiclePolyList(%name);
   
   %starterpos = getRandom(1, 10000) SPC getRandom(1, 10000);  // this is needed so vehicles aren't created on top of each other
   
   %vehicle =    new t2dStaticSprite() {
                     canSaveDynamicFields = "1";
                     Position = %starterpos;
                     enemy = "1";
                     layer = "3";
                     class = "enemyclass";
                     CollisionPolyList = %list;
                     scenegraph = "sg";
                  };

   if($ObjectList $= "")
      $ObjectList = %vehicle;
   else
      $ObjectList = $ObjectList SPC %vehicle;      


   %vehicle.SetCollisionActive(true, true);
   %vehicle.vehiclename = %name;
   %vehicle.SetImageMap(%name);
   %vehicle.SetForwardMovementOnly(true);      
   
   // this will hopefully keep them evenly divided
      
   %rand++;
      
   if(%rand == 3)
      %rand = 1;
      
   %value = getRandom(90, 140);      
   %var = %var+75;
   
   // mount bar
      
   %obj = CreateRedBar();
   if(%name $= "flatbedtruck" || %name $= "trailertruck")
      %obj.mount(%vehicle, "0 6", 0, true, true, true, true);   
   else
      %obj.mount(%vehicle, "0 1.5", 0, true, true, true, true);   

   %vehicle.marker = %obj;
            
   // give it some id
   
   %vehicle.slot = %slot;

   if($quickbattle $= "")
      %vehicle.topspeed = $enemyvehicles[%slot, topspeed];
   else
      %vehicle.topspeed = GetVehicleTopSpeed(%name);
         
   $enemyvehicles[%slot, battleid] = %vehicle;
   
   %vehicle.SetSize(GetSize(%name));
   
   MountEnemyTriggers(%vehicle);
   
   return %vehicle;
}