Loading

Paste #po9qykj5r

  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.    
  24.     local dist = AIMap.DistanceSquare(tile_1, tile_2);
  25.     engine_list.Valuate(WrightAI.GetMaximumOrderDistance);
  26.     engine_list.KeepAboveValue(dist - 1);
  27.     engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING);
  28.     AILog.Warning(AIEngine.GetName(engine_list.Begin()) + " maximum distance is " + engine_list.GetValue(engine_list.Begin()));
  29.  
  30.     if (engine_list.Count() == 0) {
  31.         return null;
  32.     } else {
  33.         return engine_list.Begin();
  34.     }
  35. }
  36.  
  37. function::WrightAI::GetMaximumOrderDistance(engine) {
  38.     local dist = AIEngine.GetMaximumOrderDistance(engine);
  39.     return dist == 0 ? 0xFFFFFFFF : dist;
  40. }

Version history

Revision # Author Created at
pjfxbqdcs Anonymous 26 Aug 2018, 18:32:56 UTC Diff

Comments