Ejemplo n.º 1
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            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)
            {
                Logger.Write(
                    session.Translation.GetTranslation(TranslationString.FarmPokestopsOutsideRadius, distanceFromStart),
                    LogLevel.Warning);

                var eggWalker = new EggWalker(1000, session);

                await session.Navigation.Move(new GeoCoordinate(
                                                  session.Settings.DefaultLatitude,
                                                  session.Settings.DefaultLongitude,
                                                  LocationUtils.getElevation(session.Settings.DefaultLatitude,
                                                                             session.Settings.DefaultLongitude)),
                                              null,
                                              session,
                                              cancellationToken);

                // we have moved this distance, so apply it immediately to the egg walker.
                await eggWalker.ApplyDistance(distanceFromStart, cancellationToken);
            }

            // initialize the variables in UseNearbyPokestopsTask here, as this is a fresh start.
            UseNearbyPokestopsTask.Initialize();
            await UseNearbyPokestopsTask.Execute(session, cancellationToken);
        }
        private static async Task WalkingToPokeStop(ISession session, CancellationToken cancellationToken, FortData pokeStop, FortDetailsResponse fortInfo)
        {
            var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                   session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);

            // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
            // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
            if (!session.LogicSettings.UseGpxPathing)
            {
                // Will modify Lat,Lng and Name to fake position
                //Need refactor it to speparate from pokestop logic -> samuraitruong will do it.
                SetMoveToTargetTask.CheckSetMoveToTargetStatus(ref fortInfo, ref pokeStop);

                var eggWalker = new EggWalker(1000, session);

                cancellationToken.ThrowIfCancellationRequested();

                if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
                {
                    session.EventDispatcher.Send(new FortTargetEvent {
                        Name = fortInfo.Name, Distance = distance, Route = "NecroBot"
                    });
                }
                else
                {
                    BaseWalkStrategy.FortInfo = fortInfo;
                }
                var pokeStopDestination = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
                                                            LocationUtils.getElevation(session, pokeStop.Latitude, pokeStop.Longitude));

                if (pokeStop.Type == FortType.Gym)
                {
                    session.EventDispatcher.Send(new GymWalkToTargetEvent()
                    {
                        Name      = fortInfo.Name,
                        Distance  = distance,
                        Latitude  = fortInfo.Latitude,
                        Longitude = fortInfo.Longitude
                    });
                }

                await session.Navigation.Move(pokeStopDestination,
                                              async() =>
                {
                    await OnWalkingToPokeStopOrGym(session, pokeStop, cancellationToken);
                },
                                              session,
                                              cancellationToken);

                // we have moved this distance, so apply it immediately to the egg walker.
                await eggWalker.ApplyDistance(distance, cancellationToken);
            }
        }
Ejemplo n.º 3
0
 public Session(ISettings settings, ILogicSettings logicSettings)
 {
     Settings           = settings;
     LogicSettings      = logicSettings;
     ApiFailureStrategy = new ApiFailureStrategy(this);
     EventDispatcher    = new EventDispatcher();
     Translation        = Common.Translation.Load(logicSettings);
     Reset(settings, LogicSettings);
     Runtime     = new RuntimeSettings();
     State       = BotState.Idle;
     Stats       = new Statistics();
     EggWalker   = new EggWalker(this);
     ActionQueue = new ObservableCollection <ManualAction>();
 }
Ejemplo n.º 4
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var distanceFromStart = LocationUtils.CalculateDistanceInMeters(
                session.Settings.DefaultLatitude, session.Settings.DefaultLongitude,
                session.Client.CurrentLatitude, session.Client.CurrentLongitude);

            var response = await session.Client.Player.UpdatePlayerLocation(session.Client.CurrentLatitude, session.Client.CurrentLongitude, session.Client.CurrentAltitude, 0);

            // Edge case for when the client somehow ends up outside the defined radius
            if (session.LogicSettings.MaxTravelDistanceInMeters != 0 && checkForMoveBackToDefault &&
                distanceFromStart > session.LogicSettings.MaxTravelDistanceInMeters)
            {
                checkForMoveBackToDefault = false;
                Logger.Write(
                    session.Translation.GetTranslation(TranslationString.FarmPokestopsOutsideRadius, distanceFromStart),
                    LogLevel.Warning);

                var eggWalker = new EggWalker(1000, session);

                var defaultLocation = new MapLocation(session.Settings.DefaultLatitude,
                                                      session.Settings.DefaultLongitude,
                                                      LocationUtils.getElevation(session.ElevationService, session.Settings.DefaultLatitude, session.Settings.DefaultLongitude)
                                                      );

                await session.Navigation.Move(defaultLocation,
                                              async() =>
                {
                    await MSniperServiceTask.Execute(session, cancellationToken);
                },
                                              session,
                                              cancellationToken);

                // we have moved this distance, so apply it immediately to the egg walker.
                await eggWalker.ApplyDistance(distanceFromStart, cancellationToken);
            }
            checkForMoveBackToDefault = false;

            await CatchNearbyPokemonsTask.Execute(session, cancellationToken);

            // initialize the variables in UseNearbyPokestopsTask here, as this is a fresh start.
            UseNearbyPokestopsTask.Initialize();
            await UseNearbyPokestopsTask.Execute(session, cancellationToken);
        }
Ejemplo n.º 5
0
        private static async Task FortPokestop(ISession session, CancellationToken cancellationToken, FortData pokeStop)
        {
            var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

            // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
            // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
            if (!session.LogicSettings.UseGpxPathing)
            {
                var eggWalker = new EggWalker(1000, session);

                var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                       session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                cancellationToken.ThrowIfCancellationRequested();

                if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
                {
                    session.EventDispatcher.Send(new FortTargetEvent {
                        Name = fortInfo.Name, Distance = distance, Route = "NecroBot"
                    });
                }
                else
                {
                    BaseWalkStrategy.FortInfo = fortInfo;
                }

                await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
                                                                LocationUtils.getElevation(pokeStop.Latitude, pokeStop.Longitude)),
                                              async() =>
                {
                    // Catch normal map Pokemon
                    await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                    //Catch Incense Pokemon
                    await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                    return(true);
                },
                                              session,
                                              cancellationToken);

                // we have moved this distance, so apply it immediately to the egg walker.
                await eggWalker.ApplyDistance(distance, cancellationToken);
            }

            //Catch Lure Pokemon
            if (pokeStop.LureInfo != null)
            {
                await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
            }

            FortSearchResponse fortSearch;
            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

            do
            {
                cancellationToken.ThrowIfCancellationRequested();

                if (SearchThresholdExceeds(session))
                {
                    break;
                }

                fortSearch =
                    await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                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;

                        session.EventDispatcher.Send(new FortFailedEvent
                        {
                            Name   = fortInfo.Name,
                            Try    = fortTry,
                            Max    = retryNumber - zeroCheck,
                            Looted = false
                        });

                        if (!session.LogicSettings.FastSoftBanBypass)
                        {
                            DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0);
                        }
                    }
                }
                else
                {
                    if (fortTry != 0)
                    {
                        session.EventDispatcher.Send(new FortFailedEvent
                        {
                            Name   = fortInfo.Name,
                            Try    = fortTry + 1,
                            Max    = retryNumber - zeroCheck,
                            Looted = true
                        });
                    }

                    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
                    });

                    if (fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull)
                    {
                        storeRI = 1;
                    }

                    session.Stats.PokeStopTimestamps.Add(DateTime.Now.Ticks);
                    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.RandomlyPauseAtStops)
            {
                if (++RandomStop >= RandomNumber)
                {
                    RandomNumber = rc.Next(4, 11);
                    RandomStop   = 0;
                    int RandomWaitTime = rc.Next(30, 120);
                    Thread.Sleep(RandomWaitTime);
                }
            }
        }
Ejemplo n.º 6
0
 private static async Task MoveToPokestop(ISession session, CancellationToken cancellationToken, FortCacheItem pokeStop, List <GeoCoordinate> waypoints, EggWalker eggWalker)
 {
     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
             await CatchIncensePokemonsTask.Execute(session, cancellationToken);
         }
         return(true);
     },
                                   async() =>
     {
         await UseNearbyPokestopsTask.Execute(session, cancellationToken);
         return(true);
     }, cancellationToken, session, waypointsToVisit : waypoints, eggWalker : eggWalker);
 }
Ejemplo n.º 7
0
        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);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="destination">Desired location to move</param>
        /// <param name="walkingSpeedMin">Minimal walking speed during the move</param>
        /// <param name="walkingSpeedMax">Maximal walking speed during the move</param>
        /// <param name="functionExecutedWhileWalking">Functions #1 to be exec while walking, like task or smth</param>
        /// <param name="functionExecutedWhileWalking2">Functions #1 to be exec while walking, like task or smth</param>
        /// <param name="cancellationToken">regular session cancelation token</param>
        /// <param name="session">ISession param of the bot, to detect which bot started it</param>
        /// <param name="direct">Directly move to the point, skip routing services</param>
        /// <param name="waypointsToVisit">Waypoints to visit during the move, required to redure Google Directions API usage</param>
        /// <param name="eggWalker"></param>
        /// <returns></returns>
        internal async Task <PlayerUpdateResponse> Move(GeoCoordinate destination, double walkingSpeedMin, double walkingSpeedMax, Func <Task <bool> > functionExecutedWhileWalking, Func <Task <bool> > functionExecutedWhileWalking2,
                                                        CancellationToken cancellationToken, ISession session, bool direct = false, List <GeoCoordinate> waypointsToVisit = null, EggWalker eggWalker = null)
        {
            var currentLocation = new GeoCoordinate(_client.CurrentLatitude, _client.CurrentLongitude, _client.CurrentAltitude);
            var result          = new PlayerUpdateResponse();

            if (session.LogicSettings.UseHumanPathing)
            {
                var waypoints = new List <GeoCoordinate>();

                if (!direct)
                {
                    RoutingResponse routingResponse = null;
                    try
                    {
                        switch (session.LogicSettings.RoutingService)
                        {
                        case RoutingService.MobBot:
                            routingResponse = Routing.GetRoute(currentLocation, destination, session);
                            break;

                        case RoutingService.OpenLs:
                            routingResponse = OsmRouting.GetRoute(currentLocation, destination, session);
                            break;

                        case RoutingService.GoogleDirections:
                            routingResponse = GoogleRouting.GetRoute(currentLocation, destination, session,
                                                                     waypointsToVisit);
                            break;

                        case RoutingService.MapzenValhalla:
                            routingResponse = MapzenRouting.GetRoute(currentLocation, destination, session,
                                                                     waypointsToVisit);
                            break;
                        }
                    }
                    catch (NullReferenceException ex)
                    {
                        session.EventDispatcher.Send(new DebugEvent
                        {
                            Message = ex.ToString()
                        });
                        routingResponse = new RoutingResponse();
                    }

                    if (routingResponse?.Coordinates != null)
                    {
                        foreach (var item in routingResponse.Coordinates)
                        {
                            if (item == null)
                            {
                                continue;
                            }
                            //0 = lat, 1 = long (MAYBE NOT THO?)
                            switch (session.LogicSettings.RoutingService)
                            {
                            case RoutingService.MobBot:
                                waypoints.Add(new GeoCoordinate(item[1], item[0]));
                                break;

                            case RoutingService.OpenLs:
                                waypoints.Add(new GeoCoordinate(item.ToArray()[1], item.ToArray()[0], item.ToArray()[2]));
                                break;

                            case RoutingService.GoogleDirections:
                                waypoints.Add(new GeoCoordinate(item[0], item[1]));
                                break;

                            case RoutingService.MapzenValhalla:
                                waypoints.Add(new GeoCoordinate(item[0], item[1]));
                                break;
                            }
                        }
                        if ((session.LogicSettings.RoutingService == RoutingService.GoogleDirections || session.LogicSettings.RoutingService == RoutingService.MobBot || session.LogicSettings.RoutingService == RoutingService.MapzenValhalla) && session.LogicSettings.UseMapzenApiElevation)
                        {
                            waypoints = await session.MapzenApi.FillAltitude(waypoints);
                        }
                    }
                }

                if (waypoints.Count == 0)
                {
                    waypoints.Add(destination);
                }
                else if (waypoints.Count > 1)
                {
                    var nextPath = waypoints.Select(item => Tuple.Create(item.Latitude, item.Longitude)).ToList();
                    session.EventDispatcher.Send(new NextRouteEvent
                    {
                        Coords = nextPath
                    });
                    destination = waypoints.Last();
                }

                var  navi               = new Navigation(_client, UpdatePositionEvent);
                var  waypointsArr       = waypoints.ToArray();
                long nextMaintenceStamp = 0;
                //MILD REWRITE TO USE HUMANPATHWALKING;
                foreach (var t in waypointsArr)
                {
                    if (session.ForceMoveTo != null)
                    {
                        return(await ForceMoveTask.Execute(session, cancellationToken));
                    }
                    // skip waypoints under 5 meters
                    var sourceLocation   = new GeoCoordinate(_client.CurrentLatitude, _client.CurrentLongitude);
                    var distanceToTarget = LocationUtils.CalculateDistanceInMeters(sourceLocation, t);
                    if (distanceToTarget <= 5)
                    {
                        continue;
                    }

                    var nextSpeed = RandomExtensions.NextInRange(session.Client.rnd, walkingSpeedMin, walkingSpeedMax) * session.Settings.MoveSpeedFactor;
                    session.State = BotState.Walk;
                    result        = await navi.HumanPathWalking(session, t, nextSpeed, functionExecutedWhileWalking, functionExecutedWhileWalking2, cancellationToken);

                    if (session.Runtime.BreakOutOfPathing)
                    {
                        return(result);
                    }
                    UpdatePositionEvent?.Invoke(t.Latitude, t.Longitude, t.Altitude);

                    if (nextMaintenceStamp < DateTime.UtcNow.ToUnixTime())
                    {
                        await MaintenanceTask.Execute(session, cancellationToken);

                        nextMaintenceStamp = DateTime.UtcNow.AddMinutes(3).ToUnixTime();
                    }
                    if (eggWalker != null)
                    {
                        await eggWalker.ApplyDistance(distanceToTarget, cancellationToken);
                    }
                }
                session.State = BotState.Idle;
                var curcoord = new GeoCoordinate(session.Client.CurrentLatitude, session.Client.CurrentLongitude);
                if (LocationUtils.CalculateDistanceInMeters(curcoord, destination) > 40)
                {
                    var nextSpeed = RandomExtensions.NextInRange(session.Client.rnd, walkingSpeedMin, walkingSpeedMax) * session.Settings.MoveSpeedFactor;

                    result = await navi.HumanPathWalking(session, destination, nextSpeed, functionExecutedWhileWalking, functionExecutedWhileWalking2, cancellationToken);
                }
                await MaintenanceTask.Execute(session, cancellationToken);
            }
            else
            {
                if (destination.Latitude.Equals(session.Runtime.lastPokeStopCoordinate.Latitude) && destination.Longitude.Equals(session.Runtime.lastPokeStopCoordinate.Longitude))
                {
                    session.Runtime.BreakOutOfPathing = true;
                }

                if (session.Runtime.BreakOutOfPathing)
                {
                    await MaintenanceTask.Execute(session, cancellationToken);

                    return(result);
                }
                var navi     = new Navigation(_client, UpdatePositionEvent);
                var curcoord = new GeoCoordinate(session.Client.CurrentLatitude, session.Client.CurrentLongitude);
                if (LocationUtils.CalculateDistanceInMeters(curcoord, destination) > 40)
                {
                    var nextSpeed = RandomExtensions.NextInRange(session.Client.rnd, walkingSpeedMin, walkingSpeedMax) * session.Settings.MoveSpeedFactor;

                    result = await navi.HumanPathWalking(session, destination, nextSpeed, functionExecutedWhileWalking, functionExecutedWhileWalking2, cancellationToken);
                }
            }
            session.State = BotState.Idle;
            await MaintenanceTask.Execute(session, cancellationToken);

            return(result);
        }
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var pokestopList = await GetPokeStops(session);

            var stopsHit  = 0;
            var eggWalker = new EggWalker(1000, session);

            if (pokestopList.Count <= 0)
            {
                session.EventDispatcher.Send(new WarnEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                });
            }

            session.EventDispatcher.Send(new PokeStopListEvent {
                Forts = pokestopList
            });


            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();

                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
                });
                pokestopList.AddRange(newPokestopList);

                var pokeStop = pokestopList.OrderBy(i => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                 session.Client.CurrentLongitude, i.Latitude, i.Longitude)).First(x => x.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());
                pokeStop.CooldownCompleteTimestampMs = DateTime.UtcNow.ToUnixTime() + 300 * 1000;

                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);
                }

                await CatchWildPokemonsTask.Execute(session, cancellationToken);

                FortSearchResponse fortSearch;
                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
                do
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    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);
                        }
                        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;

                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name = fortInfo.Name,
                                Try  = fortTry,
                                Max  = retryNumber - zeroCheck
                            });
                            if (session.LogicSettings.Teleport)
                            {
                                await Task.Delay(session.LogicSettings.DelaySoftbanRetry);
                            }
                            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
                        });

                        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);
                }
                else
                {
                    await Task.Delay(1000, cancellationToken);
                }


                //Catch Lure Pokemon


                if (pokeStop.LureInfo != null)
                {
                    await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
                }
                if (session.LogicSettings.Teleport)
                {
                    await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                }

                await eggWalker.ApplyDistance(distance, cancellationToken);

                if (stopsHit++ == 5 + session.Client.rnd.Next(5)) //TODO: OR item/pokemon bag is full
                {
                    stopsHit = 0;
                    if (fortSearch.ItemsAwarded.Count > 0)
                    {
                        await session.Inventory.RefreshCachedInventory();
                    }
                    await RecycleItemsTask.Execute(session, cancellationToken);

                    if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                        session.LogicSettings.EvolveAllPokemonAboveIv)
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                    {
                        await LevelUpPokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.RenamePokemon)
                    {
                        await RenamePokemonTask.Execute(session, cancellationToken);
                    }
                }

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }
            }
        }
Ejemplo n.º 10
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            var tracks    = GetGpxTracks(session);
            var eggWalker = new EggWalker(1000, session);

            if (_resumeTrack + _resumeTrackSeg + _resumeTrackPt == 0)
            {
                _resumeTrack    = session.LogicSettings.ResumeTrack;
                _resumeTrackSeg = session.LogicSettings.ResumeTrackSeg;
                _resumeTrackPt  = session.LogicSettings.ResumeTrackPt;

                // initialize the variables in UseNearbyPokestopsTask here, as this is a fresh start.
                UseNearbyPokestopsTask.Initialize();
            }

            for (var curTrk = _resumeTrack; curTrk < tracks.Count; curTrk++)
            {
                _resumeTrack = curTrk;
                cancellationToken.ThrowIfCancellationRequested();

                var track         = tracks.ElementAt(curTrk);
                var trackSegments = track.Segments;

                for (var curTrkSeg = _resumeTrackSeg; curTrkSeg < trackSegments.Count; curTrkSeg++)
                {
                    _resumeTrackSeg = curTrkSeg;
                    cancellationToken.ThrowIfCancellationRequested();

                    var trackPoints = trackSegments.ElementAt(curTrkSeg).TrackPoints;

                    for (var curTrkPt = _resumeTrackPt; curTrkPt < trackPoints.Count; curTrkPt++)
                    {
                        _resumeTrackPt = curTrkPt;
                        cancellationToken.ThrowIfCancellationRequested();

                        var nextPoint = trackPoints.ElementAt(curTrkPt);
                        var distance  = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                session.Client.CurrentLongitude,
                                                                                Convert.ToDouble(nextPoint.Lat, CultureInfo.InvariantCulture),
                                                                                Convert.ToDouble(nextPoint.Lon, CultureInfo.InvariantCulture));

                        if (distance > 5000)
                        {
                            session.EventDispatcher.Send(new ErrorEvent
                            {
                                Message =
                                    session.Translation.GetTranslation(TranslationString.DesiredDestTooFar,
                                                                       nextPoint.Lat, nextPoint.Lon, session.Client.CurrentLatitude,
                                                                       session.Client.CurrentLongitude)
                            });
                            break;
                        }

                        var geo = new GeoCoordinate(Convert.ToDouble(trackPoints.ElementAt(curTrkPt).Lat, CultureInfo.InvariantCulture),
                                                    Convert.ToDouble(trackPoints.ElementAt(curTrkPt).Lon, CultureInfo.InvariantCulture));

                        await session.Navigation.Move(geo,
                                                      async() =>
                        {
                            await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                            //Catch Incense Pokemon
                            await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                            await UseNearbyPokestopsTask.Execute(session, cancellationToken);
                            return(true);
                        },
                                                      session,
                                                      cancellationToken);

                        await eggWalker.ApplyDistance(distance, cancellationToken);
                    } //end trkpts
                    _resumeTrackPt = 0;
                }     //end trksegs
                _resumeTrackSeg = 0;
            }         //end tracks
            _resumeTrack = 0;
        }
Ejemplo n.º 11
0
        public static async Task <PlayerUpdateResponse> Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var eggWalker = new EggWalker(1000, session);


            var moveToCoords = session.ForceMoveTo;
            var distance     = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                       session.Client.CurrentLongitude, moveToCoords.Latitude, moveToCoords.Longitude);

            session.EventDispatcher.Send(new WarnEvent
            {
                Message = $"ForceMove to {session.ForceMoveTo.Latitude} - {session.ForceMoveTo.Longitude} Started! Distance: {distance.ToString("N1")}m"
            });
            session.ForceMoveTo = null;
            PlayerUpdateResponse result;

            if (session.LogicSettings.Teleport)
            {
                result = await session.Client.Player.UpdatePlayerLocation(moveToCoords.Latitude, moveToCoords.Longitude,
                                                                          session.Client.Settings.DefaultAltitude);
            }
            else
            {
                result = await session.Navigation.Move(new GeoCoordinate(moveToCoords.Latitude, moveToCoords.Longitude),
                                                       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, true);
                    return(true);
                }, cancellationToken, session, eggWalker : eggWalker);
            }

            session.EventDispatcher.Send(new WarnEvent
            {
                Message = "ForceMove Done!"
            });
            session.ForceMoveJustDone = true;
            session.ForceMoveTo       = null;
            session.EventDispatcher.Send(new ForceMoveDoneEvent());

            if (session.LogicSettings.Teleport)
            {
                await Task.Delay(session.LogicSettings.DelayPokestop, cancellationToken);
            }
            else
            {
                await Task.Delay(1000, cancellationToken);
            }

            await eggWalker.ApplyDistance(distance, cancellationToken);


            if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
            {
                await SnipePokemonTask.Execute(session, cancellationToken);
            }
            return(result);
        }
Ejemplo n.º 12
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var pokestopList = await GetPokeStops(session);

            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();
                await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

                pokestopList =
                    pokestopList.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();

                // randomize next pokestop between first and second by distance
                var pokestopListNum = 0;
                if (pokestopList.Count > 1)
                {
                    pokestopListNum = rc.Next(0, 2);
                }

                var pokeStop = pokestopList[pokestopListNum];
                pokestopList.RemoveAt(pokestopListNum);

                var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
                // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
                if (!session.LogicSettings.UseGpxPathing)
                {
                    var eggWalker = new EggWalker(1000, session);

                    var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                           session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                    cancellationToken.ThrowIfCancellationRequested();

                    if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
                    {
                        session.EventDispatcher.Send(new FortTargetEvent {
                            Name = fortInfo.Name, Distance = distance, Route = "NecroBot"
                        });
                    }
                    else
                    {
                        BaseWalkStrategy.FortInfo = fortInfo;
                    }

                    await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
                                                                    LocationUtils.getElevation(pokeStop.Latitude, pokeStop.Longitude)),
                                                  async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                        return(true);
                    },
                                                  session,
                                                  cancellationToken);

                    // we have moved this distance, so apply it immediately to the egg walker.
                    await eggWalker.ApplyDistance(distance, cancellationToken);
                }

                //Catch Lure Pokemon
                if (pokeStop.LureInfo != null)
                {
                    await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
                }

                FortSearchResponse fortSearch;
                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
                do
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    if (SearchThresholdExceeds(session))
                    {
                        break;
                    }

                    fortSearch =
                        await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                    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;

                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name   = fortInfo.Name,
                                Try    = fortTry,
                                Max    = retryNumber - zeroCheck,
                                Looted = false
                            });

                            if (!session.LogicSettings.FastSoftBanBypass)
                            {
                                DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0);
                            }
                        }
                    }
                    else
                    {
                        if (fortTry != 0)
                        {
                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name   = fortInfo.Name,
                                Try    = fortTry + 1,
                                Max    = retryNumber - zeroCheck,
                                Looted = true
                            });
                        }

                        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
                        });

                        if (fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull)
                        {
                            storeRI = 1;
                        }

                        session.Stats.PokeStopTimestamps.Add(DateTime.Now.Ticks);
                        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.RandomlyPauseAtStops)
                {
                    if (++RandomStop >= RandomNumber)
                    {
                        RandomNumber = rc.Next(4, 11);
                        RandomStop   = 0;
                        int RandomWaitTime = rc.Next(30, 120);
                        Thread.Sleep(RandomWaitTime);
                    }
                }

                if (++stopsHit >= storeRI)     //TODO: OR item/pokemon bag is full //check stopsHit against storeRI random without dividing.
                {
                    storeRI  = rc.Next(6, 12); //set new storeRI for new random value
                    stopsHit = 0;

                    await RecycleItemsTask.Execute(session, cancellationToken);

                    if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                        session.LogicSettings.EvolveAllPokemonAboveIv ||
                        session.LogicSettings.UseLuckyEggsWhileEvolving ||
                        session.LogicSettings.KeepPokemonsThatCanEvolve)
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.UseLuckyEggConstantly)
                    {
                        await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.UseIncenseConstantly)
                    {
                        await UseIncenseConstantlyTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.TransferWeakPokemon)
                    {
                        await TransferWeakPokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.RenamePokemon)
                    {
                        await RenamePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.AutoFavoritePokemon)
                    {
                        await FavoritePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                    {
                        await LevelUpPokemonTask.Execute(session, cancellationToken);
                    }

                    await GetPokeDexCount.Execute(session, cancellationToken);
                }

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }
            }
        }
Ejemplo n.º 13
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var pokestopsTuple = await GetPokeStops(session);

            pokestopList = pokestopsTuple.Item2;

            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();
                await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

                pokestopList =
                    pokestopList.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();

                // randomize next pokestop between first and second by distance
                var pokestopListNum = 0;
                if (pokestopList.Count > 1)
                {
                    pokestopListNum = rc.Next(0, 2);
                }

                var pokeStop = pokestopList[pokestopListNum];
                pokestopList.RemoveAt(pokestopListNum);

                // this logic should only be called when we reach a pokestop either via GPX path or normal walking
                // as when walk-sniping, we want to get to the snipe ASAP rather than stop for lured pokemon upon
                // calling FarmPokestop; in that situation we are also always within 40m of the pokestop, so no
                // need to walk to it
                var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
                // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
                if (!session.LogicSettings.UseGpxPathing)
                {
                    var eggWalker = new EggWalker(1000, session);

                    var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                           session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                    cancellationToken.ThrowIfCancellationRequested();

                    if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
                    {
                        session.EventDispatcher.Send(new FortTargetEvent {
                            Name = fortInfo.Name, Distance = distance, Route = "NecroBot"
                        });
                    }
                    else
                    {
                        BaseWalkStrategy.FortInfo = fortInfo;
                    }

                    await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
                                                                    LocationUtils.getElevation(session, pokeStop.Latitude, pokeStop.Longitude)),
                                                  async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                        // Minor fix google route ignore pokestop
                        await LookPokestops(session, pokeStop, cancellationToken);
                        return(true);
                    },
                                                  session,
                                                  cancellationToken);

                    // we have moved this distance, so apply it immediately to the egg walker.
                    await eggWalker.ApplyDistance(distance, cancellationToken);
                }

                await FortAction(session, pokeStop, fortInfo, cancellationToken);

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    //refactore to move this code inside the task later.
                    await HumanWalkSnipeTask.Execute(session, cancellationToken,
                                                     async (double lat, double lng) =>
                    {
                        //idea of this function is to spin pokestop on way. maybe risky.
                        var reachablePokestops = pokestopList.Where(i =>
                                                                    LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                            session.Client.CurrentLongitude, i.Latitude, i.Longitude) < 40 &&
                                                                    i.CooldownCompleteTimestampMs == 0
                                                                    ).ToList();
                        reachablePokestops = reachablePokestops.OrderBy(i =>
                                                                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();

                        foreach (var ps in reachablePokestops)
                        {
                            if (!session.LogicSettings.UseGpxPathing)
                            {
                                pokestopList.Remove(ps);
                            }
                            var fi = await session.Client.Fort.GetFort(ps.Id, ps.Latitude, ps.Longitude);
                            await FarmPokestop(session, ps, fi, cancellationToken, true);
                            await Task.Delay(2000);
                        }
                    },
                                                     async() =>
                    {
                        // if using GPX we have to move back to the original pokestop, to resume the path.
                        // we do not try to use pokest;ops on the way back, as we will have used them getting
                        // here.
                        if (session.LogicSettings.UseGpxPathing)
                        {
                            var eggWalker = new EggWalker(1000, session);

                            var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                   session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                            var geo = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude);

                            await session.Navigation.Move(geo,
                                                          async() =>
                            {
                                await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                                //Catch Incense Pokemon
                                await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                                return(true);
                            },
                                                          session,
                                                          cancellationToken);

                            await eggWalker.ApplyDistance(distance, cancellationToken);
                            return;
                        }

                        var nearestStop = pokestopList.OrderBy(i =>
                                                               LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                       session.Client.CurrentLongitude, i.Latitude, i.Longitude)).FirstOrDefault();

                        var walkedDistance = LocationUtils.CalculateDistanceInMeters(nearestStop.Latitude, nearestStop.Longitude, session.Client.CurrentLatitude, session.Client.CurrentLongitude);
                        if (walkedDistance > session.LogicSettings.HumanWalkingSnipeWalkbackDistanceLimit)
                        {
                            await Task.Delay(3000);
                            var nearbyPokeStops = await UpdateFortsData(session);
                            var notexists       = nearbyPokeStops.Where(p => !pokestopList.Any(x => x.Id == p.Id)).ToList();
                            pokestopList.AddRange(notexists);
                            session.EventDispatcher.Send(new PokeStopListEvent {
                                Forts = pokestopList
                            });
                            session.EventDispatcher.Send(new HumanWalkSnipeEvent()
                            {
                                Type            = HumanWalkSnipeEventTypes.PokestopUpdated,
                                Pokestops       = notexists,
                                NearestDistance = walkedDistance
                            });
                        }
                    });
                }
            }
        }
Ejemplo n.º 14
0
        public static async Task NoTeleport(ISession session, CancellationToken cancellationToken)
        {
            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.HumanLikeWalking(
                    new GeoCoordinate(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude),
                    session.LogicSettings.WalkingSpeedInKilometerPerHour, null, cancellationToken);
            }

            var pokestopList = await GetPokeStops(session);

            var stopsHit        = 0;
            var displayStatsHit = 0;
            var eggWalker       = new EggWalker(1000, session);

            if (pokestopList.Count <= 0)
            {
                session.EventDispatcher.Send(new WarnEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                });
            }

            session.EventDispatcher.Send(new PokeStopListEvent {
                Forts = pokestopList
            });

            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();

                //resort
                pokestopList =
                    pokestopList.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();
                var pokeStop = pokestopList[0];
                pokestopList.RemoveAt(0);

                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[0]
                });
                if (session.LogicSettings.Teleport)
                {
                    await session.Client.Player.UpdatePlayerLocation(fortInfo.Latitude, fortInfo.Longitude,
                                                                     session.Client.Settings.DefaultAltitude);
                }

                else
                {
                    await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude),
                                                              session.LogicSettings.WalkingSpeedInKilometerPerHour,
                                                              async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                        return(true);
                    }, cancellationToken);
                }

                FortSearchResponse fortSearch;
                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
                do
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    fortSearch =
                        await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                    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;

                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name = fortInfo.Name,
                                Try  = fortTry,
                                Max  = retryNumber - zeroCheck
                            });
                            if (session.LogicSettings.Teleport)
                            {
                                await Task.Delay(session.LogicSettings.DelaySoftbanRetry);
                            }
                            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]
                        });

                        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);
                }
                else
                {
                    await Task.Delay(1000, cancellationToken);
                }


                //Catch Lure Pokemon


                if (pokeStop.LureInfo != null)
                {
                    await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
                }
                if (session.LogicSettings.Teleport)
                {
                    await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                }

                await eggWalker.ApplyDistance(distance, cancellationToken);

                if (++stopsHit % 5 == 0) //TODO: OR item/pokemon bag is full
                {
                    stopsHit = 0;
                    // need updated stardust information for upgrading, so refresh your profile now
                    await DownloadProfile(session);

                    if (fortSearch.ItemsAwarded.Count > 0)
                    {
                        await session.Inventory.RefreshCachedInventory();
                    }
                    await RecycleItemsTask.Execute(session, cancellationToken);

                    if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                        session.LogicSettings.EvolveAllPokemonAboveIv)
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                    {
                        await LevelUpPokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }
                    if (session.LogicSettings.RenamePokemon)
                    {
                        await RenamePokemonTask.Execute(session, cancellationToken);
                    }
                    if (++displayStatsHit >= 4)
                    {
                        await DisplayPokemonStatsTask.Execute(session);

                        displayStatsHit = 0;
                    }
                }

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }
            }
        }
Ejemplo n.º 15
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            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)
            {
                Logger.Write(
                    session.Translation.GetTranslation(TranslationString.FarmPokestopsOutsideRadius, distanceFromStart),
                    LogLevel.Warning);

                await session.Navigation.Move(
                    new GeoCoordinate(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude, LocationUtils.getElevation(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude)),
                    session.LogicSettings.WalkingSpeedInKilometerPerHour, null, cancellationToken, session.LogicSettings.DisableHumanWalking);
            }

            var pokestopList = await GetPokeStops(session);

            var stopsHit = 0;
            var rc       = new Random(); //initialize pokestop random cleanup counter first time

            storeRI = rc.Next(8, 15);
            var eggWalker = new EggWalker(1000, session);

            if (pokestopList.Count <= 0)
            {
                session.EventDispatcher.Send(new WarnEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                });
            }

            session.EventDispatcher.Send(new PokeStopListEvent {
                Forts = pokestopList
            });

            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();

                //resort
                var pokestopListWithDetails = pokestopList
                                              .Select(p =>
                {
                    Boolean useNav   = session.LogicSettings.UseOsmNavigation && LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, p.Latitude, p.Longitude) > session.LogicSettings.OsmMinDistanceInMeter;
                    String uri       = useNav ? string.Format(_CultureEnglish, "http://www.yournavigation.org/api/1.0/gosmore.php?flat={0:0.000000}&flon={1:0.000000}&tlat={2:0.000000}&tlon={3:0.000000}&v=foot", session.Client.CurrentLatitude, session.Client.CurrentLongitude, p.Latitude, p.Longitude) : null;
                    XDocument doc    = useNav ? XDocument.Load(uri) : null;
                    XNamespace kmlns = useNav ? XNamespace.Get("http://earth.google.com/kml/2.0") : null;
                    var points       = !useNav ? null :
                                       doc.Element(kmlns + "kml")
                                       .Element(kmlns + "Document")
                                       .Element(kmlns + "Folder")
                                       .Element(kmlns + "Placemark")
                                       .Element(kmlns + "LineString")
                                       .Element(kmlns + "coordinates")
                                       .Value
                                       .Trim()
                                       .Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                                       .Select(pp =>
                    {
                        String[] parts = pp.Split(',');
                        return(new
                        {
                            Latitude = double.Parse(parts[1], _CultureEnglish),
                            Longitude = double.Parse(parts[0], _CultureEnglish),
                        });
                    })
                                       .ToArray();
                    Double dist = useNav ?
                                  new Func <double>(() =>
                    {
                        Double d = 0d;
                        for (int i = 1; i < points.Length; i++)
                        {
                            d += LocationUtils.CalculateDistanceInMeters
                                 (
                                points[i - 1].Latitude,
                                points[i - 1].Longitude,
                                points[i].Latitude,
                                points[i].Longitude
                                 );
                        }
                        return(d);
                    })() :
                                  LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, p.Latitude, p.Longitude);
                    return(new
                    {
                        PokeStop = p,
                        UseOSM = useNav,
                        Distance = dist,
                        NavigationDocumentUri = uri,
                        NavigationDocument = doc,
                        NavigationDocumentNamespace = kmlns,
                        Points = points
                    });
                })
                                              .OrderBy(p => p.Distance)
                                              .ToList();
                // randomize next pokestop between first and second by distance
                var pokestopListNum = 0;
                if (pokestopList.Count > 1)
                {
                    pokestopListNum = rc.Next(0, 2);
                }

                var pokeStop = pokestopListWithDetails[pokestopListNum];
                pokestopList.Remove(pokeStop.PokeStop);

                var distance = pokeStop.Distance;
                var fortInfo = await session.Client.Fort.GetFort(pokeStop.PokeStop.Id, pokeStop.PokeStop.Latitude, pokeStop.PokeStop.Longitude);

                session.EventDispatcher.Send(new FortTargetEvent {
                    Name = fortInfo.Name, Distance = distance
                });

                if (pokeStop.UseOSM)
                {
                    var points = pokeStop.Points;
                    if (points.Any())
                    {
                        foreach (var step in points)
                        {
                            await MoveToLocationAsync(session, cancellationToken, step.Latitude, step.Longitude);
                        }
                    }
                }
                //Why no else? Just to be sure =)
                await MoveToLocationAsync(session, cancellationToken, pokeStop.PokeStop.Latitude, pokeStop.PokeStop.Longitude);

                //Catch Lure Pokemon
                if (pokeStop.PokeStop.LureInfo != null)
                {
                    await CatchLurePokemonsTask.Execute(session, pokeStop.PokeStop, cancellationToken);
                }

                FortSearchResponse fortSearch;
                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
                do
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    fortSearch =
                        await session.Client.Fort.SearchFort(pokeStop.PokeStop.Id, pokeStop.PokeStop.Latitude, pokeStop.PokeStop.Longitude);

                    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;

                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name   = fortInfo.Name,
                                Try    = fortTry,
                                Max    = retryNumber - zeroCheck,
                                Looted = false
                            });

                            if (!session.LogicSettings.FastSoftBanBypass)
                            {
                                DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0);
                            }
                        }
                    }
                    else
                    {
                        if (fortTry != 0)
                        {
                            session.EventDispatcher.Send(new FortFailedEvent
                            {
                                Name   = fortInfo.Name,
                                Try    = fortTry + 1,
                                Max    = retryNumber - zeroCheck,
                                Looted = true
                            });
                        }

                        session.EventDispatcher.Send(new FortUsedEvent
                        {
                            Id            = pokeStop.PokeStop.Id,
                            Name          = fortInfo.Name,
                            Exp           = fortSearch.ExperienceAwarded,
                            Gems          = fortSearch.GemsAwarded,
                            Items         = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded),
                            Latitude      = pokeStop.PokeStop.Latitude,
                            Longitude     = pokeStop.PokeStop.Longitude,
                            InventoryFull = fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull
                        });

                        if (fortSearch.Result == FortSearchResponse.Types.Result.InventoryFull)
                        {
                            storeRI = 1;
                        }

                        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.

                await eggWalker.ApplyDistance(distance, cancellationToken);

                if (++stopsHit >= storeRI)     //TODO: OR item/pokemon bag is full //check stopsHit against storeRI random without dividing.
                {
                    storeRI  = rc.Next(6, 12); //set new storeRI for new random value
                    stopsHit = 0;

                    await RecycleItemsTask.Execute(session, cancellationToken);

                    if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                        session.LogicSettings.EvolveAllPokemonAboveIv ||
                        session.LogicSettings.UseLuckyEggsWhileEvolving ||
                        session.LogicSettings.KeepPokemonsThatCanEvolve)
                    {
                        await EvolvePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.UseLuckyEggConstantly)
                    {
                        await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.UseIncenseConstantly)
                    {
                        await UseIncenseConstantlyTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.TransferDuplicatePokemon)
                    {
                        await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.TransferWeakPokemon)
                    {
                        await TransferWeakPokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.RenamePokemon)
                    {
                        await RenamePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.AutoFavoritePokemon)
                    {
                        await FavoritePokemonTask.Execute(session, cancellationToken);
                    }

                    if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                    {
                        await LevelUpPokemonTask.Execute(session, cancellationToken);
                    }

                    await GetPokeDexCount.Execute(session, cancellationToken);
                }

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }
            }
        }
Ejemplo n.º 16
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var pokestopsTuple = await GetPokeStops(session);

            var allPokestops = pokestopsTuple.Item1;
            var pokestopList = pokestopsTuple.Item2;

            while (pokestopList.Any())
            {
                cancellationToken.ThrowIfCancellationRequested();
                await SnipeMSniperTask.CheckMSniperLocation(session, cancellationToken);

                pokestopList =
                    pokestopList.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();

                // randomize next pokestop between first and second by distance
                var pokestopListNum = 0;
                if (pokestopList.Count > 1)
                {
                    pokestopListNum = rc.Next(0, 2);
                }

                var pokeStop = pokestopList[pokestopListNum];
                pokestopList.RemoveAt(pokestopListNum);

                // this logic should only be called when we reach a pokestop either via GPX path or normal walking
                // as when walk-sniping, we want to get to the snipe ASAP rather than stop for lured pokemon upon
                // calling FarmPokestop; in that situation we are also always within 40m of the pokestop, so no
                // need to walk to it
                var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                // we only move to the PokeStop, and send the associated FortTargetEvent, when not using GPX
                // also, GPX pathing uses its own EggWalker and calls the CatchPokemon tasks internally.
                if (!session.LogicSettings.UseGpxPathing)
                {
                    var eggWalker = new EggWalker(1000, session);

                    var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                           session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                    cancellationToken.ThrowIfCancellationRequested();

                    if (!session.LogicSettings.UseGoogleWalk && !session.LogicSettings.UseYoursWalk)
                    {
                        session.EventDispatcher.Send(new FortTargetEvent {
                            Name = fortInfo.Name, Distance = distance, Route = "NecroBot"
                        });
                    }
                    else
                    {
                        BaseWalkStrategy.FortInfo = fortInfo;
                    }

                    await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude,
                                                                    LocationUtils.getElevation(session, pokeStop.Latitude, pokeStop.Longitude)),
                                                  async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                        return(true);
                    },
                                                  session,
                                                  cancellationToken);

                    // we have moved this distance, so apply it immediately to the egg walker.
                    await eggWalker.ApplyDistance(distance, cancellationToken);
                }

                //Catch Lure Pokemon
                if (pokeStop.LureInfo != null)
                {
                    // added for cooldowns
                    await Task.Delay(Math.Min(session.LogicSettings.DelayBetweenPlayerActions, 3000));

                    await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
                }

                await FarmPokestop(session, pokeStop, fortInfo, cancellationToken);

                if (++stopsHit >= storeRI)     //TODO: OR item/pokemon bag is full //check stopsHit against storeRI random without dividing.
                {
                    storeRI  = rc.Next(6, 12); //set new storeRI for new random value
                    stopsHit = 0;

                    if (session.LogicSettings.UseNearActionRandom)
                    {
                        await HumanRandomActionTask.Execute(session, cancellationToken);
                    }
                    else
                    {
                        await RecycleItemsTask.Execute(session, cancellationToken);

                        if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                            session.LogicSettings.EvolveAllPokemonAboveIv ||
                            session.LogicSettings.UseLuckyEggsWhileEvolving ||
                            session.LogicSettings.KeepPokemonsThatCanEvolve)
                        {
                            await EvolvePokemonTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.UseLuckyEggConstantly)
                        {
                            await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.UseIncenseConstantly)
                        {
                            await UseIncenseConstantlyTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.TransferDuplicatePokemon)
                        {
                            await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.TransferWeakPokemon)
                        {
                            await TransferWeakPokemonTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.RenamePokemon)
                        {
                            await RenamePokemonTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.AutoFavoritePokemon)
                        {
                            await FavoritePokemonTask.Execute(session, cancellationToken);
                        }
                        if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                        {
                            await LevelUpPokemonTask.Execute(session, cancellationToken);
                        }

                        await GetPokeDexCount.Execute(session, cancellationToken);
                    }
                }

                if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                {
                    await SnipePokemonTask.Execute(session, cancellationToken);
                }

                if (session.LogicSettings.EnableHumanWalkingSnipe)
                {
                    //refactore to move this code inside the task later.
                    await HumanWalkSnipeTask.Execute(session, cancellationToken,
                                                     async (double lat, double lng) =>
                    {
                        //idea of this function is to spin pokestop on way. maybe risky.
                        var reachablePokestops = allPokestops.Where(i =>
                                                                    LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                            session.Client.CurrentLongitude, i.Latitude, i.Longitude) < 40).ToList();
                        reachablePokestops = reachablePokestops.OrderBy(i =>
                                                                        LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                                session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();
                        foreach (var ps in reachablePokestops)
                        {
                            if (!session.LogicSettings.UseGpxPathing || pokestopList.Contains(ps))
                            {
                                pokestopList.Remove(ps);
                            }

                            var fi = await session.Client.Fort.GetFort(ps.Id, ps.Latitude, ps.Longitude);
                            await FarmPokestop(session, ps, fi, cancellationToken);
                        }
                    },
                                                     async() =>
                    {
                        // if using GPX we have to move back to the original pokestop, to resume the path.
                        // we do not try to use pokestops on the way back, as we will have used them getting
                        // here.
                        if (session.LogicSettings.UseGpxPathing)
                        {
                            var eggWalker = new EggWalker(1000, session);

                            var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                   session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
                            var geo = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude);

                            await session.Navigation.Move(geo,
                                                          async() =>
                            {
                                await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                                //Catch Incense Pokemon
                                await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                                return(true);
                            },
                                                          session,
                                                          cancellationToken);

                            await eggWalker.ApplyDistance(distance, cancellationToken);
                            return;
                        }

                        var nearestStop = pokestopList.OrderBy(i =>
                                                               LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                                       session.Client.CurrentLongitude, i.Latitude, i.Longitude)).FirstOrDefault();

                        var walkedDistance = LocationUtils.CalculateDistanceInMeters(nearestStop.Latitude, nearestStop.Longitude, session.Client.CurrentLatitude, session.Client.CurrentLongitude);
                        if (walkedDistance > session.LogicSettings.HumanWalkingSnipeWalkbackDistanceLimit)
                        {
                            await Task.Delay(3000);
                            var nearbyPokeStops = await UpdateFortsData(session);
                            var notexists       = nearbyPokeStops.Where(p => !pokestopList.Any(x => x.Id == p.Id)).ToList();
                            pokestopList.AddRange(notexists);
                            session.EventDispatcher.Send(new PokeStopListEvent {
                                Forts = pokestopList
                            });
                            session.EventDispatcher.Send(new HumanWalkSnipeEvent()
                            {
                                Type            = HumanWalkSnipeEventTypes.PokestopUpdated,
                                Pokestops       = notexists,
                                NearestDistance = walkedDistance
                            });
                        }
                    });
                }
            }
        }
Ejemplo n.º 17
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var distanceFromStart = LocationUtils.CalculateDistanceInMeters(
                session.Settings.DefaultLatitude, session.Settings.DefaultLongitude,
                session.Client.CurrentLatitude, session.Client.CurrentLongitude);

            if (session.Profile.PlayerData.Team == POGOProtos.Enums.TeamColor.Neutral && session.LogicSettings.TeamColor != POGOProtos.Enums.TeamColor.Neutral && !teamSettingRequested)
            {
                var response = await session.Client.Player.SetPlayerTeam(session.LogicSettings.TeamColor);

                teamSettingRequested = true;
            }

            await HealPokemons(session);

            // Edge case for when the client somehow ends up outside the defined radius
            if (session.LogicSettings.MaxTravelDistanceInMeters != 0 &&
                distanceFromStart > session.LogicSettings.MaxTravelDistanceInMeters)
            {
                Logger.Write(
                    session.Translation.GetTranslation(TranslationString.FarmPokestopsOutsideRadius, distanceFromStart),
                    LogLevel.Warning);

                await session.Navigation.Move(
                    new GeoCoordinate(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude),
                    session.LogicSettings.WalkingSpeedInKilometerPerHour, null, cancellationToken, session.LogicSettings.DisableHumanWalking);
            }

            var pokeGymsList = await GetPokeGyms(session);

            var eggWalker = new EggWalker(1000, session);

            if (pokeGymsList.Count <= 0)
            {
                session.EventDispatcher.Send(new WarnEvent
                {
                    Message = session.Translation.GetTranslation(TranslationString.FarmPokestopsNoUsableFound)
                });
            }

            session.EventDispatcher.Send(new PokeStopListEvent {
                Forts = pokeGymsList
            });

            //TODO : CATCH FREE GYMS
            foreach (var pokeGym in pokeGymsList.Where(gym => gym.Enabled && gym.OwnedByTeam == 0))
            {
                await CatchGym(session, pokeGym, cancellationToken);
            }

            List <FortData> PossibleFreeGyms = new List <FortData>();

            // TODO : FIGHT OTHER GYMS
            foreach (var pokeGym in pokeGymsList.Where(gym => gym.Enabled && gym.OwnedByTeam != 0).OrderBy(
                         i =>
                         LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                 session.Client.CurrentLongitude, i.Latitude, i.Longitude)))
            {
                var pokeGymInfo = await session.Client.Fort.GetGymDetails(pokeGym.Id, pokeGym.Latitude, pokeGym.Longitude);

                if (pokeGymInfo.Result != GetGymDetailsResponse.Types.Result.Success)
                {
                    continue;
                }
                var shouldAttack = ShouldAttackGym(session, pokeGymInfo);
                var isGymFree    = IsGymFree(session, pokeGymInfo);
                if (shouldAttack || isGymFree)
                {
                    if (isGymFree)
                    {
                        await CatchGym(session, pokeGym, cancellationToken);
                    }
                    else
                    {
                        var mayBeFree = await AttackGym(session, cancellationToken, pokeGym, pokeGymInfo, 10); // TODO: MAKE ATTACK TIMES CONFIGURABLE

                        if (mayBeFree)
                        {
                            await CatchGym(session, pokeGym, cancellationToken);
                        }
                    }
                }
                else
                {
                    session.EventDispatcher.Send(new WarnEvent()
                    {
                        Message = string.Format("GYM '{0}' SKIPPED", pokeGymInfo.Name)
                    });
                }
            }

            var count = pokeGymsList.Count;

            if (count > 0)
            {
                long delay = 5000;
                if (stopWatch.IsRunning)
                {
                    stopWatch.Stop();
                    delay = stopWatch.ElapsedMilliseconds;
                }
                if (delay >= 5000)
                {
                    var pg = pokeGymsList[(new Random()).Next(count)];
                    await session.Navigation.Move(new GeoCoordinate(pg.Latitude, pg.Longitude),
                                                  session.LogicSettings.WalkingSpeedInKilometerPerHour, null, cancellationToken, session.LogicSettings.DisableHumanWalking);

                    session.EventDispatcher.Send(new NoticeEvent()
                    {
                        Message = string.Format("TRAVELLING TO RANDOM GYM '{0}'", pg.Id)
                    });
                }
                stopWatch.Reset();
                stopWatch.Start();
            }
        }
Ejemplo n.º 18
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            var route     = session.LogicSettings.CustomRoute;
            var eggWalker = new EggWalker(1000, session);

            if (route == null || route.RoutePoints.Count < 2)
            {
                session.EventDispatcher.Send(new WarnEvent
                {
                    Message = "No proper route loaded"
                });
                return;
            }

            var navi = new Navigation(session.Client);

            navi.UpdatePositionEvent += (lat, lng, alt) =>
            {
                session.EventDispatcher.Send(new UpdatePositionEvent {
                    Latitude = lat, Longitude = lng, Altitude = alt
                });
            };
            if (LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude,
                                                        route.RoutePoints[0].Latitude, route.RoutePoints[0].Longitude) > 10)
            {
                session.State = BotState.Walk;
                await session.Navigation.Move(route.RoutePoints[0],
                                              session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax,
                                              async() =>
                {
                    if (session.LogicSettings.CatchWildPokemon)
                    {
                        // 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, true);
                    return(true);
                }, cancellationToken, session);

                session.State = BotState.Idle;
            }

            var nextPath = route.RoutePoints.Select(item => Tuple.Create(item.Latitude, item.Longitude)).ToList();

            session.EventDispatcher.Send(new NextRouteEvent
            {
                Coords = nextPath
            });

            long nextMaintenceStamp = 0;

            while (!cancellationToken.IsCancellationRequested)
            {
                foreach (var wp in route.RoutePoints)
                {
                    session.State = BotState.Walk;

                    var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                           session.Client.CurrentLongitude, wp.Latitude, wp.Longitude);

                    await navi.HumanPathWalking(
                        session,
                        wp,
                        NextMoveSpeed(session),
                        async() =>
                    {
                        await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                        return(true);
                    },
                        async() =>
                    {
                        await UseNearbyPokestopsTask.Execute(session, cancellationToken, true);
                        return(true);
                    },
                        cancellationToken
                        );

                    session.State = BotState.Idle;
                    await eggWalker.ApplyDistance(distance, cancellationToken);

                    if (nextMaintenceStamp >= DateTime.UtcNow.ToUnixTime())
                    {
                        continue;
                    }
                    await MaintenanceTask.Execute(session, cancellationToken);

                    nextMaintenceStamp = DateTime.UtcNow.AddMinutes(3).ToUnixTime();
                }
            }
        }
Ejemplo n.º 19
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken)
        {
            var tracks    = GetGpxTracks(session);
            var eggWalker = new EggWalker(1000, session);

            for (var curTrk = 0; curTrk < tracks.Count; curTrk++)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var track         = tracks.ElementAt(curTrk);
                var trackSegments = track.Segments;

                if (curTrkSeg >= trackSegments.Count)
                {
                    curTrkSeg = 0;
                }
                for (; curTrkSeg < trackSegments.Count; curTrkSeg++)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    var trackPoints = track.Segments.ElementAt(curTrkSeg).TrackPoints;

                    if (curTrkPt >= trackPoints.Count)
                    {
                        curTrkPt = 0;
                    }
                    for (; curTrkPt < trackPoints.Count; curTrkPt++)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        var nextPoint = trackPoints.ElementAt(curTrkPt);
                        var distance  = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                                session.Client.CurrentLongitude,
                                                                                Convert.ToDouble(nextPoint.Lat, CultureInfo.InvariantCulture),
                                                                                Convert.ToDouble(nextPoint.Lon, CultureInfo.InvariantCulture));

                        if (distance > 5000)
                        {
                            session.EventDispatcher.Send(new ErrorEvent
                            {
                                Message =
                                    session.Translation.GetTranslation(TranslationString.DesiredDestTooFar,
                                                                       nextPoint.Lat, nextPoint.Lon, session.Client.CurrentLatitude,
                                                                       session.Client.CurrentLongitude)
                            });
                            break;
                        }

                        var pokestopList = await GetPokeStops(session);

                        while (pokestopList.Any())
                        // warning: this is never entered due to ps cooldowns from UseNearbyPokestopsTask
                        {
                            cancellationToken.ThrowIfCancellationRequested();

                            pokestopList =
                                pokestopList.OrderBy(
                                    i =>
                                    LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
                                                                            session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();
                            var pokeStop = pokestopList[0];
                            pokestopList.RemoveAt(0);

                            var fortInfo =
                                await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                            if (pokeStop.LureInfo != null)
                            {
                                await CatchLurePokemonsTask.Execute(session, pokeStop, cancellationToken);
                            }

                            var fortSearch =
                                await session.Client.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                            if (fortSearch.ExperienceAwarded > 0)
                            {
                                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
                                });
                            }
                            else
                            {
                                await RecycleItemsTask.Execute(session, cancellationToken);
                            }

                            if (fortSearch.ItemsAwarded.Count > 0)
                            {
                                await session.Inventory.RefreshCachedInventory();
                            }
                        }

                        if (DateTime.Now > _lastTasksCall)
                        {
                            _lastTasksCall =
                                DateTime.Now.AddMilliseconds(Math.Min(session.LogicSettings.DelayBetweenPlayerActions,
                                                                      3000));

                            await RecycleItemsTask.Execute(session, cancellationToken);

                            if (session.LogicSettings.EvolveAllPokemonWithEnoughCandy ||
                                session.LogicSettings.EvolveAllPokemonAboveIv ||
                                session.LogicSettings.UseLuckyEggsWhileEvolving ||
                                session.LogicSettings.KeepPokemonsThatCanEvolve)
                            {
                                await EvolvePokemonTask.Execute(session, cancellationToken);
                            }
                            await GetPokeDexCount.Execute(session, cancellationToken);

                            if (session.LogicSettings.AutomaticallyLevelUpPokemon)
                            {
                                await LevelUpPokemonTask.Execute(session, cancellationToken);
                            }
                            if (session.LogicSettings.UseLuckyEggConstantly)
                            {
                                await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
                            }
                            if (session.LogicSettings.UseIncenseConstantly)
                            {
                                await UseIncenseConstantlyTask.Execute(session, cancellationToken);
                            }
                            if (session.LogicSettings.TransferDuplicatePokemon)
                            {
                                await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
                            }
                            if (session.LogicSettings.TransferWeakPokemon)
                            {
                                await TransferWeakPokemonTask.Execute(session, cancellationToken);
                            }
                            if (session.LogicSettings.RenamePokemon)
                            {
                                await RenamePokemonTask.Execute(session, cancellationToken);
                            }

                            if (session.LogicSettings.AutoFavoritePokemon)
                            {
                                await FavoritePokemonTask.Execute(session, cancellationToken);
                            }

                            if (session.LogicSettings.SnipeAtPokestops || session.LogicSettings.UseSnipeLocationServer)
                            {
                                await SnipePokemonTask.Execute(session, cancellationToken);
                            }
                        }

                        var geo = new GeoCoordinate(Convert.ToDouble(trackPoints.ElementAt(curTrkPt).Lat, CultureInfo.InvariantCulture),
                                                    Convert.ToDouble(trackPoints.ElementAt(curTrkPt).Lon, CultureInfo.InvariantCulture));

                        await session.Navigation.Move(geo,
                                                      async() =>
                        {
                            await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
                            //Catch Incense Pokemon
                            await CatchIncensePokemonsTask.Execute(session, cancellationToken);
                            await UseNearbyPokestopsTask.Execute(session, cancellationToken);
                            return(true);
                        },
                                                      session,
                                                      cancellationToken);

                        await eggWalker.ApplyDistance(distance, cancellationToken);
                    } //end trkpts
                }     //end trksegs
            }         //end tracks
        }