function WrightAI::GetBestRouteEngine(tile_1, tile_2) { local engine_list = AIEngineList(AIVehicle.VT_AIR); engine_list.Valuate(AIEngine.CanRefitCargo, this.cargoId); engine_list.KeepValue(1); local small_aircraft = AIAirport.GetAirportType(tile_1) == AIAirport.AT_SMALL || AIAirport.GetAirportType(tile_2) == AIAirport.AT_SMALL || AIAirport.GetAirportType(tile_1) == AIAirport.AT_COMMUTER ||AIAirport.GetAirportType(tile_2) == AIAirport.AT_COMMUTER; if (small_aircraft) { engine_list.Valuate(AIEngine.GetPlaneType); engine_list.RemoveValue(AIAirport.PT_BIG_PLANE); } local helicopter = AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIPORT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIPORT || AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIDEPOT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIDEPOT || AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELISTATION || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELISTATION; if (helicopter) { engine_list.Valuate(AIEngine.GetPlaneType); engine_list.KeepValue(AIAirport.PT_HELICOPTER); } engine_list.Valuate(AIEngine.GetMaxSpeed); engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING); local dist = AIMap.DistanceSquare(tile_1, tile_2); engine_list.Valuate(AIEngine.GetMaximumOrderDistance); local temp_list = AIList(); temp_list.AddList(engine_list); temp_list.KeepValue(0); for (local i = temp_list.Begin(); temp_list.HasNext(); i = temp_list.Next) { temp_list.SetValue(i, 0xFFFFFFFF); } engine_list.RemoveValue(0); engine_list.AddList(temp_list); engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING); AILog.Warning(AIEngine.GetName(engine_list.Begin()) + " maximum distance is " + engine_list.GetValue(engine_list.Begin())); if (engine_list.Count() == 0) { return null; } else { return engine_list.Begin(); } }