private void editBookmarkToolStripMenuItem_Click(object sender, EventArgs e) { int[] selectedRows = dataGridViewExplore.SelectedCells.OfType <DataGridViewCell>().Where(c => c.RowIndex != dataGridViewExplore.NewRowIndex).Select(c => c.RowIndex).OrderBy(v => v).Distinct().ToArray(); if (selectedRows.Length == 0) { return; } var obj = dataGridViewExplore[0, selectedRows[0]].Value; if (obj == null) { return; } SystemClass sc = SystemClass.GetSystem((string)obj); if (sc == null) { EDDiscovery.Forms.MessageBoxTheme.Show("Unknown system, system is without co-ordinates", "Edit bookmark", MessageBoxButtons.OK); } else { RoutingUtils.showBookmarkForm(_discoveryForm, sc, null, false); } }
private void ExportRoute_Click(object sender, RoutedEventArgs e) { ImportExportRouteText.Clear(); var points = _mapPoints.Select(x => x.Location).ToList(); string encodedRoute = null; var firstOrDefault = points.FirstOrDefault(); if (firstOrDefault == null) { return; } try { encodedRoute = RoutingUtils.EncodeToPolyline(points); } catch (Exception) { //do nothing } if (encodedRoute == null) { return; } ImportExportRouteText.Text = encodedRoute; ImportExportRoute.Visibility = Visibility.Visible; ImportExportHeading.Text = TranslationEngine.GetDynamicTranslationString("%EXPORT_ROUTE%", "Export Route"); ImportExportRouteSubmit.Visibility = Visibility.Collapsed; ImportExportInstructions.Text = TranslationEngine.GetDynamicTranslationString("%EXPORT_INSTRUCTION%", "Copy the below route to create a backup or share with others."); }
private void ImportRouteSubmit_Click(object sender, RoutedEventArgs e) { ImportExportRoute.Visibility = Visibility.Collapsed; var encRoute = ImportExportRouteText.Text; if (encRoute == null) { return; } List <GoogleLocation> decodedPoints; try { decodedPoints = RoutingUtils.DecodePolyline(encRoute).ToList(); } catch (Exception) { return; } ClearRouteBuilder(); var i = 0; foreach (var point in decodedPoints) { var pointlatlon = new PointLatLng(point.lat, point.lng); CreateImportedMarker(pointlatlon, i == 0); i++; } if (i > 0) { try { if (_routeBuilder != null && _routeBuilder.Status == TaskStatus.Running) { return; } _cts = new CancellationTokenSource(); _routeBuilder = Task.Run(() => BuildTheRouteTask(Token), Token); } catch (Exception) { //ignore } } ImportExportRouteText.Clear(); var startMarker = decodedPoints.FirstOrDefault(); if (startMarker != null) { RouteCreatorMap.Position = new PointLatLng(startMarker.lat, startMarker.lng); } RouteCreatorMap.ZoomAndCenterMarkers(null); }
private void setTargetToolStripMenuItem_Click(object sender, EventArgs e) { int[] selectedRows = dataGridViewExplore.SelectedCells.OfType <DataGridViewCell>().Where(c => c.RowIndex != dataGridViewExplore.NewRowIndex).Select(c => c.RowIndex).OrderBy(v => v).Distinct().ToArray(); if (selectedRows.Length == 0) { return; } var obj = dataGridViewExplore[0, selectedRows[0]].Value; if (obj == null) { return; } RoutingUtils.setTargetSystem(_discoveryForm, (string)obj); }
private List <ADObjectId> GetServersToConnectPreferringLocalToSite(HashSet <ADObjectId> serversInDag, int numEntries) { List <ADObjectId> list = new List <ADObjectId>(numEntries); List <ADObjectId> list2 = new List <ADObjectId>(serversInDag.Count); List <ADObjectId> list3 = new List <ADObjectId>(serversInDag.Count); foreach (ADObjectId adobjectId in serversInDag) { ADObjectId adobjectId2 = null; if (this.serverToSiteMap.TryGetValue(adobjectId, out adobjectId2) && adobjectId2.Equals(this.localSiteId)) { list2.Add(adobjectId); } else { list3.Add(adobjectId); } } if (list2.Count > 0) { RoutingUtils.ShuffleList <ADObjectId>(list2); foreach (ADObjectId item in list2) { list.Add(item); if (list.Count == numEntries) { break; } } } if (list.Count < numEntries) { RoutingUtils.ShuffleList <ADObjectId>(list3); foreach (ADObjectId item2 in list3) { list.Add(item2); if (list.Count == numEntries) { break; } } } return(list); }
private void updateScreen() { if (currentSystem == null) { return; } if (_currentRoute == null) { DisplayText("Please set a route, by right clicking", ""); return; } if (_currentRoute.Systems.Count == 0) { DisplayText(_currentRoute.Name, "Route contains no waypoints"); return; } string topline = ""; string bottomLine = ""; string firstSystemName = _currentRoute.Systems[0]; SystemClassDB firstSystem = SystemClassDB.GetSystem(firstSystemName); SystemClassDB finalSystem = SystemClassDB.GetSystem(_currentRoute.Systems[_currentRoute.Systems.Count - 1]); if (finalSystem != null) { string mesg = "remain"; double distX = SystemClassDB.Distance(currentSystem.System, finalSystem); //Small hack to pull the jump range from TripPanel1 var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0); if (jumpRange > 0) { int jumps = (int)Math.Ceiling(distX / jumpRange); if (jumps > 0) { mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps"); } } topline = String.Format("{0} {1} WPs {2:N2}ly {3}", _currentRoute.Name, _currentRoute.Systems.Count, distX, mesg); } else { topline = String.Format("{0} {1} WPs remain", _currentRoute.Name, _currentRoute.Systems.Count); } SystemClassDB nearestSystem = null; double minDist = double.MaxValue; int nearestidx = -1; for (int i = 0; i < _currentRoute.Systems.Count; i++) { String sys = _currentRoute.Systems[i]; SystemClassDB sc = SystemClassDB.GetSystem(sys); if (sc == null) { continue; } double dist = SystemClassDB.Distance(currentSystem.System, sc); if (dist <= minDist) { if (nearestSystem == null || !nearestSystem.name.Equals(sc.name)) { minDist = dist; nearestidx = i; nearestSystem = sc; } } } string name = null; if (nearestSystem != null && firstSystem != null) { double first2Neasest = SystemClassDB.Distance(firstSystem, nearestSystem); double first2Me = SystemClassDB.Distance(firstSystem, currentSystem.System); string nextName = null; int wp = nearestidx + 1; if (nearestidx < _currentRoute.Systems.Count - 1) { nextName = _currentRoute.Systems[nearestidx + 1]; } if (first2Me >= first2Neasest && !String.IsNullOrWhiteSpace(nextName)) { name = nextName; wp++; } else { name = nearestSystem.name; } SystemClassDB nextSystem = SystemClassDB.GetSystem(name); if (nextSystem == null) { bottomLine = String.Format("WP{0}: {1} {2}", wp, nextName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } else { double distance = SystemClassDB.Distance(currentSystem.System, nextSystem); bottomLine = String.Format("{0:N2}ly to WP{1}: {2} {3}", distance, wp, name, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } } else { bottomLine = String.Format("WP{0}: {1} {2}", 1, firstSystemName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); name = firstSystemName; } if (name != null && name.CompareTo(lastsystem) != 0) { if (autoCopyWPToolStripMenuItem.Checked) { Clipboard.SetText(name); } if (autoSetTargetToolStripMenuItem.Checked) { string targetName; double x, y, z; TargetClass.GetTargetPosition(out targetName, out x, out y, out z); if (name.CompareTo(targetName) != 0) { RoutingUtils.setTargetSystem(discoveryform, name, false); } } } lastsystem = name; DisplayText(topline, bottomLine); }
public static async Task Execute(ISession session, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var pokestopList = await GetPokeStops(session); var eggWalker = new EggWalker(1000, session); if (pokestopList.Count <= 0) { session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound) }); if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; } if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); } await Task.Delay(60000, cancellationToken); await session.Navigation.Move(new GeoCoordinate(session.Client.CurrentLatitude + session.Client.rnd.NextInRange(-0.0001, 0.0001), session.Client.CurrentLongitude + session.Client.rnd.NextInRange(-0.0001, 0.0001)), session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, async() => { // Catch normal map Pokemon await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(session, cancellationToken); return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken); return(true); }, cancellationToken, session); pokestopList = await GetPokeStops(session); } session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokestopList.Select(x => x.BaseFortData) }); var bestRoute = new List <GeoCoordinate>(); session.Runtime.PokestopsToCheckGym = 13 + session.Client.rnd.Next(15); while (pokestopList.Any()) { cancellationToken.ThrowIfCancellationRequested(); if (session.Runtime.PokestopsToCheckGym <= 0) { session.Runtime.PokestopsToCheckGym = 0; var gymsNear = (await GetGyms(session)).OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)) .ToList(); if (gymsNear.Count > 0) { session.Runtime.PokestopsToCheckGym = 13 + session.Client.rnd.Next(15); var nearestGym = gymsNear.FirstOrDefault(); if (nearestGym != null) { var gymInfo = await session.Client.Fort.GetGymDetails(nearestGym.Id, nearestGym.Latitude, nearestGym.Longitude); var gymDistance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, nearestGym.Latitude, nearestGym.Longitude); session.EventDispatcher.Send(new GymPokeEvent { Name = gymInfo.Name, Distance = gymDistance, Description = gymInfo.Description, GymState = gymInfo.GymState }); } } } if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; } if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); } var newPokestopList = (await GetPokeStops(session)).OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)).Where(x => pokestopList.All(i => i.Id != x.Id) && LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, x.Latitude, x.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters).ToList(); session.EventDispatcher.Send(new PokeStopListEvent { Forts = newPokestopList.Select(x => x.BaseFortData) }); pokestopList.AddRange(newPokestopList); var pokeStop = pokestopList.OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)).FirstOrDefault(x => !session.MapCache.CheckPokestopUsed(x)); if (pokeStop == null) { await Task.Delay(60000, cancellationToken); continue; } if (session.LogicSettings.RoutingService == RoutingService.GoogleDirections || session.LogicSettings.RoutingService == RoutingService.MapzenValhalla) { //#if DEBUG // bestRoute = RoutingUtils.GetBestRoute(pokeStop, pokestopList.Where(x => !session.MapCache.CheckPokestopUsed(x)), 10); //#else bestRoute = RoutingUtils.GetBestRoute(pokeStop, pokestopList.Where(x => !session.MapCache.CheckPokestopUsed(x)), 20); //#endif session.EventDispatcher.Send(new PokestopsOptimalPathEvent() { Coords = bestRoute.Select(x => Tuple.Create(x.Latitude, x.Longitude)).ToList() }); } var tooFarPokestops = pokestopList.Where(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude) > session.LogicSettings.MaxTravelDistanceInMeters).ToList(); foreach (var tooFar in tooFarPokestops) { pokestopList.Remove(tooFar); } var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude); var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); session.EventDispatcher.Send(new FortTargetEvent { Name = fortInfo.Name, Distance = distance }); if (session.LogicSettings.Teleport) { await session.Client.Player.UpdatePlayerLocation(fortInfo.Latitude, fortInfo.Longitude, session.Client.Settings.DefaultAltitude); } else { await MoveToPokestop(session, cancellationToken, pokeStop, bestRoute, eggWalker); } bestRoute.Clear(); if (!session.LogicSettings.LootPokestops) { session.MapCache.UsedPokestop(pokeStop, session); continue; } if (!session.ForceMoveJustDone) { var timesZeroXPawarded = 0; var fortTry = 0; //Current check const int retryNumber = 50; //How many times it needs to check to clear softban const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban //var shownSoftBanMessage = false; do { cancellationToken.ThrowIfCancellationRequested(); if (session.MapCache.CheckPokestopUsed(pokeStop)) { break; //already used somehow } var fortSearch = await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) { timesZeroXPawarded = 0; } if (fortSearch.ExperienceAwarded == 0) { if (TimesZeroXPawarded == 0) { await MoveToPokestop(session, cancellationToken, pokeStop, null, eggWalker); } timesZeroXPawarded++; if ((int)fortSearch.CooldownCompleteTimestampMs != 0) { break; // Check if successfully looted, if so program can continue as this was "false alarm". } if (timesZeroXPawarded <= zeroCheck) { continue; } session.MapCache.UsedPokestop(pokeStop, session); //f**k that pokestop - skip it break; } else { session.EventDispatcher.Send(new FortUsedEvent { Id = pokeStop.Id, Name = fortInfo.Name, Exp = fortSearch.ExperienceAwarded, Gems = fortSearch.GemsAwarded, Items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded), Latitude = pokeStop.Latitude, Longitude = pokeStop.Longitude, InventoryFull = fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull }); session.EventDispatcher.Send(new InventoryNewItemsEvent() { Items = fortSearch.ItemsAwarded.ToItemList() }); session.MapCache.UsedPokestop(pokeStop, session); session.Runtime.StopsHit++; pokeStop.CooldownCompleteTimestampMS = DateTime.UtcNow.AddMinutes(5).ToUnixTime(); if (session.LogicSettings.CatchWildPokemon) { await CatchWildPokemonsTask.Execute(session, cancellationToken); } break; //Continue with program as loot was succesfull. } } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. if (session.LogicSettings.Teleport) { await Task.Delay(session.LogicSettings.DelayPokestop, cancellationToken); } else { await Task.Delay(1000, cancellationToken); } //Catch Lure Pokemon if (pokeStop.LureInfo != null && session.LogicSettings.CatchWildPokemon) { await CatchLurePokemonsTask.Execute(session, pokeStop.BaseFortData, cancellationToken); } if (session.LogicSettings.Teleport && session.LogicSettings.CatchWildPokemon) { await CatchNearbyPokemonsTask.Execute(session, cancellationToken); } await eggWalker.ApplyDistance(distance, cancellationToken); } session.Runtime.PokestopsToCheckGym--; if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer) { await SnipePokemonTask.Execute(session, cancellationToken); } } }
public static async Task NoTeleport(ISession session, CancellationToken cancellationToken, Random random) { cancellationToken.ThrowIfCancellationRequested(); var distanceFromStart = LocationUtils.CalculateDistanceInMeters( session.Settings.DefaultLatitude, session.Settings.DefaultLongitude, session.Client.CurrentLatitude, session.Client.CurrentLongitude); // Edge case for when the client somehow ends up outside the defined radius if (session.LogicSettings.MaxTravelDistanceInMeters != 0 && distanceFromStart > session.LogicSettings.MaxTravelDistanceInMeters) { session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsOutsideRadius, distanceFromStart) }); await Task.Delay(1000, cancellationToken); await session.Navigation.Move( new GeoCoordinate(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude), session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, null, null, cancellationToken, session); } var pokestopList = await GetPokeStops(session); //var stopsHit = 0; //Replaced with RuntimeSettings.stopsHit; //var displayStatsHit = 0; session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokestopList.Select(x => x.BaseFortData).ToList() }); if (session.LogicSettings.UseEggIncubators && !session.EggWalker.Inited) { await session.EggWalker.InitEggWalker(cancellationToken); } if (pokestopList.Count <= 0) { if (!pokestopList.Any()) { await CheckChallengeDoneTask.Execute(session, cancellationToken); await CheckChallengeTask.Execute(session, cancellationToken); } session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound) }); } if (session.ForceMoveToResume != null && session.ForceMoveTo == null) { session.EventDispatcher.Send(new NoticeEvent { Message = session.Translation.GetTranslation(TranslationString.UnDoneForceMove, session.ForceMoveToResume.Latitude, session.ForceMoveToResume.Longitude) }); session.ForceMoveTo = session.ForceMoveToResume; } var bestRoute = new List <GeoCoordinate>(); while (pokestopList.Any()) { session.Runtime.BreakOutOfPathing = false; cancellationToken.ThrowIfCancellationRequested(); if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); } if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; pokestopList = await GetPokeStops(session); session.Client.Player.SetInitial(session.Client.CurrentLatitude, session.Client.CurrentLongitude, session.Client.CurrentAltitude); session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokestopList.Select(x => x.BaseFortData).ToList() }); } if (session.LogicSettings.UseCustomRoute && session.LogicSettings.CustomRoute != null && session.LogicSettings.CustomRoute.RoutePoints.Count > 2) { session.EventDispatcher.Send(new NoticeEvent { Message = session.Translation.GetTranslation(TranslationString.CustomRouteEnabled) }); break; } await ActionQueueTask.Execute(session, cancellationToken); //resort pokestopList = pokestopList.OrderBy( i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList(); if (session.LogicSettings.UsePokeStopLuckyNumber) { if (pokestopList.Count >= session.LogicSettings.PokestopSkipLuckyNumberMinUse) { int rng = random.Next(session.LogicSettings.PokestopSkipLuckyMin, session.LogicSettings.PokestopSkipLuckyMax); #if DEBUG Logger.Write("Skip Pokestop RNG: " + rng + " against " + session.LogicSettings.PokestopSkipLuckyNumber, LogLevel.Debug); #endif if (rng == session.LogicSettings.PokestopSkipLuckyNumber) { #if DEBUG Logger.Write("Skipping Pokestop due to the rng god's will.", LogLevel.Debug); #endif if (pokestopList.Count > 0) { pokestopList.RemoveAt(0); } } } } if (pokestopList.Count == 0) { break; } var pokeStop = pokestopList[0]; pokestopList.RemoveAt(0); //prolly no longer needed since MobBot Routing is dead. //Lunatiq //if (session.LogicSettings.RoutingService == RoutingService.GoogleDirections || session.LogicSettings.RoutingService == RoutingService.MapzenValhalla) //{ bestRoute = RoutingUtils.GetBestRoute(pokeStop, pokestopList.Where(x => !session.MapCache.CheckPokestopUsed(x)), 20); session.EventDispatcher.Send(new PokestopsOptimalPathEvent { Coords = bestRoute.Select(x => Tuple.Create(x.Latitude, x.Longitude)).ToList() }); //} session.Runtime.TargetStopID = pokeStop.Id; var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude); var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); session.EventDispatcher.Send(new FortTargetEvent { Id = fortInfo.FortId, Name = fortInfo.Name, Distance = distance, Latitude = fortInfo.Latitude, Longitude = fortInfo.Longitude, Description = fortInfo.Description, url = fortInfo.ImageUrls?.Count > 0 ? fortInfo.ImageUrls[0] : "" }); await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, async() => { if (session.LogicSettings.CatchWildPokemon) { // Catch normal map Pokemon await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon remove this for time constraints //await CatchIncensePokemonsTask.Execute(session, cancellationToken); } return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken); return(true); }, cancellationToken, session, waypointsToVisit : bestRoute); if (!session.ForceMoveJustDone) { var timesZeroXPawarded = 0; var fortTry = 0; //Current check const int retryNumber = 50; //How many times it needs to check to clear softban const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban if (session.Runtime.BreakOutOfPathing) { continue; } do { cancellationToken.ThrowIfCancellationRequested(); if (pokeStop.CooldownCompleteTimestampMS < DateTime.UtcNow.ToUnixTime()) { break; //already looted somehow } var fortSearch = await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); if (fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull) { await RecycleItemsTask.Execute(session, cancellationToken); } if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) { timesZeroXPawarded = 0; } if (fortSearch.ExperienceAwarded == 0) { timesZeroXPawarded++; if (timesZeroXPawarded > zeroCheck) { if ((int)fortSearch.CooldownCompleteTimestampMs != 0) { break; // Check if successfully looted, if so program can continue as this was "false alarm". } fortTry += 1; if (session.LogicSettings.Teleport) { session.EventDispatcher.Send(new FortFailedEvent { Name = fortInfo.Name, Try = fortTry, Max = retryNumber - zeroCheck }); await Task.Delay(session.LogicSettings.DelaySoftbanRetry, cancellationToken); } else { await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 400); } } } else { session.EventDispatcher.Send(new FortUsedEvent { Id = pokeStop.Id, Name = fortInfo.Name, Exp = fortSearch.ExperienceAwarded, Gems = fortSearch.GemsAwarded, Items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded), Latitude = pokeStop.Latitude, Longitude = pokeStop.Longitude, InventoryFull = fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull, Description = fortInfo.Description, url = fortInfo.ImageUrls?[0] }); session.Runtime.StopsHit++; session.EventDispatcher.Send(new InventoryNewItemsEvent { Items = fortSearch.ItemsAwarded.ToItemList() }); if (fortSearch.PokemonDataEgg != null) { session.EventDispatcher.Send(new EggFoundEvent { Distance = fortSearch.PokemonDataEgg.EggKmWalkedTarget, PokeStopName = fortInfo.Name }); } if (session.Runtime.PokeBallsToCollect > 0) { session.Runtime.PokeBallsToCollect -= fortSearch.ItemsAwarded.ToItemList() .Where(x => x.Item1 == ItemId.ItemPokeBall || x.Item1 == ItemId.ItemGreatBall || x.Item1 == ItemId.ItemUltraBall || x.Item1 == ItemId.ItemMasterBall).Sum(x => x.Item2); } session.MapCache.UsedPokestop(pokeStop, session); break; //Continue with program as loot was succesfull. } } while (fortTry < 1); //retryNumber - zeroCheck && fortSearch.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime()); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. await Task.Delay(session.LogicSettings.DelayPokestop, cancellationToken); //Catch Lure Pokemon if (session.LogicSettings.CatchWildPokemon) { if (pokeStop.LureInfo != null) { await CatchLurePokemonsTask.Execute(session, pokeStop.BaseFortData, cancellationToken); } if (session.LogicSettings.Teleport) { await CatchNearbyPokemonsTask.Execute(session, cancellationToken); } } } if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer) { await SnipePokemonTask.Execute(session, cancellationToken); } } }
public IEnumerable <List <double> > DecodeToList() { return(RoutingUtils.DecodePolylineToList(points)); }
public IEnumerable <GoogleLocation> Decode() { return(RoutingUtils.DecodePolyline(points)); }
void displayLastFSDOrScoop(HistoryEntry he) { pictureBox.ClearImageList(); lastHE = he; if (he != null) { Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; Color backcolour = IsTransparent ? Color.Black : this.BackColor; ExtendedControls.PictureBoxHotspot.ImageElement edsm = pictureBox.AddTextFixedSizeC(new Point(5, 5), new Size(80, 20), "EDSM", displayfont, backcolour, textcolour, 0.5F, true, he, "View system on EDSM"); edsm.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("EDSM", edsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), edsm.pos, true); ExtendedControls.PictureBoxHotspot.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(5, 35), new Size(80, 20), "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point"); start.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("Start", edsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), start.pos, true); backcolour = IsTransparent ? Color.Transparent : this.BackColor; string name; Point3D tpos; bool targetpresent = TargetClass.GetTargetPosition(out name, out tpos); String topline = " Route Not Set"; if (targetpresent) { double dist = SystemClassDB.Distance(he.System, tpos.X, tpos.Y, tpos.Z); string mesg = "Left"; if (jumpRange > 0) { int jumps = (int)Math.Ceiling(dist / jumpRange); if (jumps > 0) { mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps"); } } topline = String.Format("{0} | {1:N2}ly {2}", name, dist, mesg); } topline = String.Format("{0} [{2}] | {1}", he.System.name, topline, discoveryform.history.GetVisitsCount(he.System.name)); pictureBox.AddTextAutoSize(new Point(100, 5), new Size(1000, 40), topline, displayfont, textcolour, backcolour, 1.0F); string botline = ""; botline += String.Format("{0:n}{1} @ {2} | {3} | ", he.TravelledDistance, ((he.TravelledMissingjump > 0) ? "ly (*)" : "ly"), he.Travelledjumps, he.TravelledSeconds); ExtendedControls.PictureBoxHotspot.ImageElement botlineleft = pictureBox.AddTextAutoSize(new Point(100, 35), new Size(1000, 40), botline, displayfont, textcolour, backcolour, 1.0F); double fuel = 0.0; HistoryEntry fuelhe; switch (he.journalEntry.EventTypeID) { case EliteDangerous.JournalTypeEnum.FuelScoop: fuel = (he.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; break; case EliteDangerous.JournalTypeEnum.FSDJump: fuel = (he.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; break; case EliteDangerous.JournalTypeEnum.RefuelAll: fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump || x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop); if (fuelhe.journalEntry.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump) { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; } else { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; } fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelAll).Amount; break; case EliteDangerous.JournalTypeEnum.RefuelPartial: fuelhe = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.FSDJump || x.journalEntry.EventTypeID == JournalTypeEnum.FuelScoop); if (fuelhe.journalEntry.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump) { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFSDJump).FuelLevel; } else { fuel = (fuelhe.journalEntry as EliteDangerous.JournalEvents.JournalFuelScoop).Total; } fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelPartial).Amount; break; //fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelAll).Amount; //case EliteDangerous.JournalTypeEnum.RefuelPartial: ////fuel += (he.journalEntry as EliteDangerous.JournalEvents.JournalRefuelPartial).Amount; default: break; } fuel = Math.Floor(fuel * 100.0) / 100.0; if (tankSize == -1 || tankWarning == -1) { botline = "Please set ships details"; } else { if (fuel > tankSize) { fuel = tankSize; } botline = String.Format("{0}t / {1}t", fuel.ToString("N1"), tankSize.ToString("N1")); if ((fuel / tankSize) < (tankWarning / 100.0)) { textcolour = discoveryform.theme.TextBlockHighlightColor; botline += String.Format(" < {0}%", tankWarning.ToString("N1")); } } if (currentCargo >= 0 && linearConstant > 0 && unladenMass > 0 && optimalMass > 0 && powerConstant > 0 && maxFuelPerJump > 0) { double maxJumps = 0; double maxJumpDistance = RoutingUtils.maxJumpDistance(fuel, currentCargo, linearConstant, unladenMass, optimalMass, powerConstant, maxFuelPerJump, out maxJumps); double JumpRange = Math.Pow(maxFuelPerJump / (linearConstant * 0.001), 1 / powerConstant) * optimalMass / (currentCargo + unladenMass + fuel); HistoryEntry lastJet = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.JetConeBoost); if (lastJet != null && lastJet.EventTimeLocal > lastHE.EventTimeLocal) { JumpRange *= (lastJet.journalEntry as EliteDangerous.JournalEvents.JournalJetConeBoost).BoostValue; botline += String.Format(" [{0:N2}ly @ BOOST]", Math.Floor(JumpRange * 100) / 100); } else { botline += String.Format(" [{0:N2}ly @ {1:N2}ly / {2:N0}]", Math.Floor(JumpRange * 100) / 100, Math.Floor(maxJumpDistance * 100) / 100, Math.Floor(maxJumps * 100) / 100); } } pictureBox.AddTextAutoSize(new Point(botlineleft.pos.Right, 35), new Size(1000, 40), botline, displayfont, textcolour, backcolour, 1.0F); pictureBox.Render(); } }
public static async Task Execute(ISession session, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var pokestopList = await GetPokeStops(session); if (session.LogicSettings.UseEggIncubators && !session.EggWalker.Inited) { await session.EggWalker.InitEggWalker(cancellationToken); } if (pokestopList.Count <= 0) { if (!pokestopList.Any()) { await CheckChallengeDoneTask.Execute(session, cancellationToken); await CheckChallengeTask.Execute(session, cancellationToken); } session.EventDispatcher.Send(new WarnEvent { Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound) }); if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; } if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); } await Task.Delay(60000, cancellationToken); await session.Navigation.Move(new GeoCoordinate(session.Client.CurrentLatitude + session.Client.Rnd.NextInRange(-0.0001, 0.0001), session.Client.CurrentLongitude + session.Client.Rnd.NextInRange(-0.0001, 0.0001)), session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, async() => { // Catch normal map Pokemon await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(session, cancellationToken); return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken); return(true); }, cancellationToken, session); pokestopList = await GetPokeStops(session); } session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokestopList.Select(x => x.BaseFortData) }); if (session.ForceMoveToResume != null && session.ForceMoveTo == null) { session.EventDispatcher.Send(new NoticeEvent { Message = session.Translation.GetTranslation(TranslationString.UnDoneForceMove, session.ForceMoveToResume.Latitude, session.ForceMoveToResume.Longitude) }); session.ForceMoveTo = session.ForceMoveToResume; } var bestRoute = new List <GeoCoordinate>(); session.Runtime.PokestopsToCheckGym = 13 + session.Client.Rnd.Next(15); while (pokestopList.Any()) { if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; } if (session.LogicSettings.UseCustomRoute && session.LogicSettings.CustomRoute != null && session.LogicSettings.CustomRoute.RoutePoints.Count > 2) { session.EventDispatcher.Send(new NoticeEvent { Message = session.Translation.GetTranslation(TranslationString.CustomRouteEnabled) }); break; } if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); } var newPokestopList = (await GetPokeStops(session)).OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)).Where(x => pokestopList.All(i => i.Id != x.Id) && LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, x.Latitude, x.Longitude) < session.LogicSettings.MaxTravelDistanceInMeters).ToList(); session.EventDispatcher.Send(new PokeStopListEvent { Forts = newPokestopList.Select(x => x.BaseFortData) }); pokestopList.AddRange(newPokestopList); var pokeStop = pokestopList.OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude)).FirstOrDefault(x => !session.MapCache.CheckPokestopUsed(x)); if (pokeStop == null) { await Task.Delay(60000, cancellationToken); continue; } //No Longer Usable, MobBot is dead - Lunatiq //if (session.LogicSettings.RoutingService == RoutingService.GoogleDirections || session.LogicSettings.RoutingService == RoutingService.MapzenValhalla ) //{ bestRoute = RoutingUtils.GetBestRoute(pokeStop, pokestopList.Where(x => !session.MapCache.CheckPokestopUsed(x)), 20); session.EventDispatcher.Send(new PokestopsOptimalPathEvent { Coords = bestRoute.Select(x => Tuple.Create(x.Latitude, x.Longitude)).ToList() }); //} var tooFarPokestops = pokestopList.Where(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, i.Latitude, i.Longitude) > session.LogicSettings.MaxTravelDistanceInMeters).ToList(); foreach (var tooFar in tooFarPokestops) { pokestopList.Remove(tooFar); } //var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, // session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude); var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); //session.EventDispatcher.Send(new FortTargetEvent {Name = fortInfo.Name, Distance = distance}); if (session.LogicSettings.Teleport) { await session.Client.Player.UpdatePlayerLocation(fortInfo.Latitude, fortInfo.Longitude, session.Client.Settings.DefaultAltitude); } else { await MoveToPokestop(session, cancellationToken, pokeStop, bestRoute); } bestRoute.Clear(); await ActionQueueTask.Execute(session, cancellationToken); if (!session.LogicSettings.LootPokestops) { session.MapCache.UsedPokestop(pokeStop, session); continue; } #region old fort logic //if (!session.ForceMoveJustDone) //{ // var timesZeroXPawarded = 0; // var fortTry = 0; //Current check // const int retryNumber = 50; //How many times it needs to check to clear softban // const int zeroCheck = 5; //How many times it checks fort before it thinks it's softban // //var shownSoftBanMessage = false; // do // { // cancellationToken.ThrowIfCancellationRequested(); // if (session.MapCache.CheckPokestopUsed(pokeStop)) break; //already used somehow // var fortSearch = // await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude); // if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0) timesZeroXPawarded = 0; // if (fortSearch.ExperienceAwarded == 0) // { // if (TimesZeroXPawarded == 0) // await MoveToPokestop(session, cancellationToken, pokeStop, null); // timesZeroXPawarded++; // if ((int) fortSearch.CooldownCompleteTimestampMs != 0) // { // break; // // Check if successfully looted, if so program can continue as this was "false alarm". // } // if (timesZeroXPawarded <= zeroCheck) continue; // session.MapCache.UsedPokestop(pokeStop, session); //f**k that pokestop - skip it // break; // } // else // { // session.EventDispatcher.Send(new FortUsedEvent // { // Id = pokeStop.Id, // Name = fortInfo.Name, // Exp = fortSearch.ExperienceAwarded, // Gems = fortSearch.GemsAwarded, // Items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded), // Latitude = pokeStop.Latitude, // Longitude = pokeStop.Longitude, // InventoryFull = fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull, // Description = fortInfo.Description, // url = fortInfo.ImageUrls.FirstOrDefault() // }); // if (fortSearch.PokemonDataEgg != null) // { // session.EventDispatcher.Send(new EggFoundEvent // { // Distance = fortSearch.PokemonDataEgg.EggKmWalkedTarget, // PokeStopName = fortInfo.Name // }); // } // session.EventDispatcher.Send(new InventoryNewItemsEvent // { // Items = fortSearch.ItemsAwarded.ToItemList() // }); // if (session.Runtime.PokeBallsToCollect > 0) // { // session.Runtime.PokeBallsToCollect -= fortSearch.ItemsAwarded.ToItemList() // .Where(x => x.Item1 == ItemId.ItemPokeBall || // x.Item1 == ItemId.ItemGreatBall || x.Item1 == ItemId.ItemUltraBall || // x.Item1 == ItemId.ItemMasterBall).Sum(x => x.Item2); // } // session.MapCache.UsedPokestop(pokeStop, session); // session.Runtime.StopsHit++; // pokeStop.CooldownCompleteTimestampMS = DateTime.UtcNow.AddMinutes(5).ToUnixTime(); // if (session.LogicSettings.CatchWildPokemon) // { // await CatchWildPokemonsTask.Execute(session, cancellationToken); // } // break; //Continue with program as loot was succesfull. // } // } while (fortTry < retryNumber - zeroCheck); // //Stop trying if softban is cleaned earlier or if 40 times fort looting failed. // if (session.LogicSettings.Teleport) // await Task.Delay(session.LogicSettings.DelayPokestop, cancellationToken); // else // await Task.Delay(1000, cancellationToken); // //Catch Lure Pokemon // if (pokeStop.LureInfo != null && session.LogicSettings.CatchWildPokemon) // { // await CatchLurePokemonsTask.Execute(session, pokeStop.BaseFortData, cancellationToken); // } // if (session.LogicSettings.Teleport && session.LogicSettings.CatchWildPokemon) // await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //} #endregion session.Runtime.PokestopsToCheckGym--; if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer) { await SnipePokemonTask.Execute(session, cancellationToken); } } }