function CheckRamLogicTB(%id)
{
   %rand = getRandom(1, 10);
   
   // it will decide on vehicle damage not ram damage
      
   %halfdamage = $Enemyvehicles[%id.slot, stockvehiclehp]/2;
   
   // it will only be eligible to ram a vehicle if it has less then half vehicle damage
         
   if(%rand == 1 && $Enemyvehicles[%id.slot, currentvehiclehp] < %halfdamage && %id.ramvehicle $= "")
   {
      echo(%id SPC "RAM ORDERS");
      
      %distance = 1000;
      
      // find the closest vehicle to board
      
      for(%i=1;%i<=10;%i++)
      {
         if($vehicles[%i, battleid] !$= "")
         {
            %dist = VectorDist($vehicles[%i, battleid].GetPosition(), %id.GetPosition());
            
            if(%dist < %distance)
               %target = $vehicles[%i, battleid];            
         }
      }
      
      %id.ramvehicle = true;      
      %id.target = %target;
   }

   %id.ramblock = true;      
   schedule(120000, 0, "RemoveEnemyRamBlock", %id);
}

function CheckBoardLogicTB(%id)
{   
   %rand = getRandom(1, 10);
   
   %crewcount = getWordCount(%id.crew);
   
   if(%rand == 1 && %crewcount > 6 && %id.boardvehicle $= "")
   {
      echo(%id SPC "BOARD VEHICLE");

      %distance = 1000;
      
      // find the closest vehicle to board
      
      for(%i=1;%i<=10;%i++)
      {
         if($vehicles[%i, battleid] !$= "")
         {
            %dist = VectorDist($vehicles[%i, battleid].GetPosition(), %id.GetPosition());
            
            if(%dist < %distance)
               %target = $vehicles[%i, battleid];            
         }
      }
      
      %id.boardvehicle = true;
      %id.target = %target;
   }
   
   %id.boardblock = true;
   schedule(60000, 0, "RemoveEnemyBoardBlock", %id);   
}

function RemoveEnemyRamBlockTB(%id)
{
   %id.ramblock = "";
}

function RemoveEnemyBoardBlockTB(%id)
{
   %id.boardblock = "";   
}