Loading

Paste #pjfxbqdcs

  1. function WrightAI::GetBestRouteEngine(tile_1, tile_2) {
  2.     local engine_list = AIEngineList(AIVehicle.VT_AIR);
  3.     engine_list.Valuate(AIEngine.CanRefitCargo, this.cargoId);
  4.     engine_list.KeepValue(1);
  5.    
  6.     local small_aircraft = AIAirport.GetAirportType(tile_1) == AIAirport.AT_SMALL || AIAirport.GetAirportType(tile_2) == AIAirport.AT_SMALL ||
  7.                            AIAirport.GetAirportType(tile_1) == AIAirport.AT_COMMUTER ||AIAirport.GetAirportType(tile_2) == AIAirport.AT_COMMUTER;
  8.     if (small_aircraft) {
  9.         engine_list.Valuate(AIEngine.GetPlaneType);
  10.         engine_list.RemoveValue(AIAirport.PT_BIG_PLANE);
  11.     }
  12.    
  13.     local helicopter = AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIPORT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIPORT ||
  14.                        AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIDEPOT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIDEPOT ||
  15.                        AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELISTATION || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELISTATION;
  16.     if (helicopter) {
  17.         engine_list.Valuate(AIEngine.GetPlaneType);
  18.         engine_list.KeepValue(AIAirport.PT_HELICOPTER);
  19.     }
  20.  
  21.     engine_list.Valuate(AIEngine.GetMaxSpeed);
  22.     engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING);
  23.     local dist = AIMap.DistanceSquare(tile_1, tile_2);
  24.     engine_list.Valuate(AIEngine.GetMaximumOrderDistance);
  25.  
  26.     local temp_list = AIList();
  27.     temp_list.AddList(engine_list);
  28.     temp_list.KeepValue(0);
  29.     for (local i = temp_list.Begin(); temp_list.HasNext(); i = temp_list.Next) {
  30.         temp_list.SetValue(i, 0xFFFFFFFF);
  31.     }
  32.     engine_list.RemoveValue(0);
  33.     engine_list.AddList(temp_list);
  34.     engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING);
  35.     AILog.Warning(AIEngine.GetName(engine_list.Begin()) + " maximum distance is " + engine_list.GetValue(engine_list.Begin()));
  36.  
  37.     if (engine_list.Count() == 0) {
  38.         return null;
  39.     } else {
  40.         return engine_list.Begin();
  41.     }
  42. }

Comments