Loading

Paste #pyzhscwft

  1.     function sendLowProfitVehiclesToDepot() {
  2.         local roadVehicleList = AIVehicleList();
  3.         roadVehicleList.Valuate(AIVehicle.GetVehicleType);
  4.         roadVehicleList.KeepValue(AIVehicle.VT_ROAD);
  5.  
  6.         if(LuDiAIAfterFix.MAX_TOWN_VEHICLES - 50 > roadVehicleList.Count()) {
  7.             return;
  8.         }
  9.  
  10.         if((AIDate.GetCurrentDate() - m_lastVehicleRemoved) > 60) {
  11.             local vehicleList = AIVehicleList_Depot(m_depotTile);
  12.             vehicleList.Valuate(AIVehicle.GetAge);
  13.             vehicleList.KeepAboveValue(2 * 365);
  14.  
  15.  
  16.             for (local vehicle = vehicleList.Begin(); vehicleList.HasNext(); vehicle = vehicleList.Next()) {
  17.                 AIController.Sleep(1);
  18.                 local cargoId = Utils.getCargoId(m_cargoClass);
  19.                 local cargoWaiting = AIStation.GetCargoWaiting(AIStation.GetStationID(m_stationTo), cargoId) +
  20.                     AIStation.GetCargoWaiting(AIStation.GetStationID(m_stationFrom), cargoId);
  21.  
  22.                 if ((cargoWaiting < 150) ||
  23.                     (AIVehicle.GetProfitLastYear(vehicle) < (highestProfitLastYear() / 6))) {
  24.  
  25.                     if(sendVehicleToDepot(vehicle)) {
  26.                         m_sentToDepotList.AddItem(vehicle, 0);
  27.                     }
  28.                 }
  29.             }
  30.         }
  31.     }

Comments