function GenerateQuickEnemyVehicles()
{
   
   // generate vehicle stats
   
   for(%i=1;%i<=10;%i++)
   {
      if($EnemyQuickVehicles[%i] !$= "")
      {
         %slot++;
         $enemyvehicles[%slot, currentarmor] = 0;
         $enemyvehicles[%slot, stockarmor] = 0;
         $enemyvehicles[%slot, acceleration] = 0;
         $enemyvehicles[%slot, brakes] = 0;
         $enemyvehicles[%slot, steering] = 0;
         $enemyvehicles[%slot, currenttirearmor] = 0;
         $enemyvehicles[%slot, stocktirearmor] = 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] = $EnemyQuickVehicles[%i];
         $enemyvehicles[%slot, topspeed] = GetVehicleTopSpeed($EnemyQuickVehicles[%i]);
         $enemyvehicles[%slot, tires] = GetTires($EnemyQuickVehicles[%i]);
         $enemyvehicles[%slot, currentramhp] = 0;                              
         $enemyvehicles[%slot, stockramhp] = 0;                              
      }
   }
   
   // generate personel
   
   echo("Generate Enemy Soldiers");
   
   %SeedSoldiers = enemy_soldiers.text;
   
   while(%SeedSoldiers > 0)
   {
      %i = getRandom(1, %slot);

      if($Enemyvehicles[%i, vehicle] !$= "")
      {
         %id = $Enemyvehicles[%i, battleid];
           
         if(getWordCount(%id.crew) < GetVehiclePeopleCapacity($Enemyvehicles[%i, 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;
               
            %SeedSoldiers--;
         }
      }
   }   
   
   // generate guns
   
   echo("Generate Enemy Guns");
      
   %SeedGuns = enemy_guns.text;
     
   while(%SeedGuns > 0)
   {
      if($Enemyvehicles[%i, vehicle] !$= "")
      {
         %id = $Enemyvehicles[%i, battleid];
         
         %id.guns++;
         %SeedGuns--;
      }
   }
   
   // generate ammo   
   
   echo("Generate Enemy Ammo");
   
   for(%i=1;%i<=10;%i++)
   {
      if($Enemyvehicles[%i, vehicle] !$= "")
      {
         %id = $Enemyvehicles[%i, battleid];
         
         %count = getWordCount(%id.crew);
         
         %id.ammo = %count*enemy_ammo.text;      
      }
   }
   
   // apply upgrades
   
   for(%i=1;%i<=10;%i++)
   {
      if($enemyvehicles[%i, vehicle] !$= "")
      {
         %control = "eqbupgrade" @ %i;
         %armorgroup = %control.armorgroup;
         %systemsgroup = %control.systemsgroup;
         %ram = %control.ram;
         %mountedweapon = %control.mountedweapon;
         
         if($Enemyvehicles[%i, vehicle] !$= "bike" && $Enemyvehicles[%i, vehicle] !$= "dunebuggy")
            $Enemyvehicles[%i, currentarmor] = GetUpgradeArmorPoints($Enemyvehicles[%i, vehicle])*%armorgroup;

         if($Enemyvehicles[%i, vehicle] !$= "bike" && $Enemyvehicles[%i, vehicle] !$= "dunebuggy")
            $Enemyvehicles[%i, currenttirearmor] = GetUpgradeTireArmorPoints($Enemyvehicles[%i, vehicle])*%armorgroup;              

         if($Enemyvehicles[%i, vehicle] !$= "compact" && $Enemyvehicles[%i, vehicle] !$= "bike" && $Enemyvehicles[%i, vehicle] !$= "dunebuggy" && $Enemyvehicles[%i, vehicle] !$= "jeep" )
         {
            if(%ram > 0)
            {
               $Enemyvehicles[%i, currentramhp] = GetUpgradeRamPoints($Enemyvehicles[%i, vehicle])*%ram;
               AttachRam(%id);
            }
         }

         if($Enemyvehicles[%i, vehicle] !$= "bike" && $Enemyvehicles[%i, vehicle] !$= "dunebuggy")
            $Enemyvehicles[%i, currentwindowarmor] = GetUpgradeWindowArmorPoints($Enemyvehicles[%i, vehicle])*%armorgroup;

         $Enemyvehicles[%i, tireupgrade] = %systemsgroup;              

         if($Enemyvehicles[%i, tireupgrade] > 3)
            $Enemyvehicles[%i, tireupgrade] = 3;

         $Enemyvehicles[%i, brakes] = %systemsgroup;              
         $Enemyvehicles[%i, acceleration] = %systemsgroup;              
         $Enemyvehicles[%i, steering] = %systemsgroup;              
         $Enemyvehicles[%i, currentgastankarmor] = GetUpgradeGasTankArmorPoints($Enemyvehicles[%i, vehicle])*%armorgroup;              
         $Enemyvehicles[%i, topspeed] = $Enemyvehicles[%i, topspeed]+%systemsgroup*10;
         $Enemyvehicles[%i, currentvehiclehp] = GetStockVehicleHitPoints($Enemyvehicles[%i, vehicle]);         
         $Enemyvehicles[%i, stockvehiclehp] = GetStockVehicleHitPoints($Enemyvehicles[%i, vehicle]);         
         $Enemyvehicles[%i, currentenginehp] = GetStockEngineHitPoints($Enemyvehicles[%i, vehicle]);
         
         if(%mountedweapon > 0)
         {
            %rand = getRandom(1, 4);
            
            switch$ (%rand)
            {
               case 1:
                     $Enemyvehicles[%i, mountedweapon] = "machinegun";
               case 2:
                     $Enemyvehicles[%i, mountedweapon] = "crossbow";
               case 3:
                     $Enemyvehicles[%i, mountedweapon] = "flamethrower";
               case 4:
                     $Enemyvehicles[%i, mountedweapon] = "rpg";                  
            }
            
            $Enemyvehicles[%i, currentmountedweaponhp] = GetUpgradeSpecialWeaponHitPoints($Enemyvehicles[%i, mountedweapon]);
         }
      }
   }   
}

function SpawnQuickEnemyVehicles()
{
   // get center of map
      
   $StartX = getWord($Battlegrid.getPosition(), 0);
   $StartY = getWord($Battlegrid.GetPosition(), 1);
      
   for(%i=1;%i<=10;%i++)
   {
      if($EnemyQuickVehicles[%i] !$= "")
         CreateEnemyVehicle($EnemyQuickVehicles[%i], %i);
   }
}
