Ejemplo n.º 1
0
        private bool ExecuteCatchandFarm()
        {
            if (BotSettings.RelocateDefaultLocation)
            {
                return(false);
            }
            if ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds > lastsearchtimestamp + 10000)
            {
                lastsearchtimestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;

                var mapObjectsResponse = objClient.Map.GetMapObjects().Result.Item1;
                //narrow map data to pokestops within walking distance
                var pokeStops = GetNearbyPokeStops(false, mapObjectsResponse);
                var pokestopsWithinRangeStanding = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(objClient.CurrentLatitude, objClient.CurrentLongitude, i.Latitude, i.Longitude) < 40);

                var withinRangeStandingList = pokestopsWithinRangeStanding as IList <FortData> ?? pokestopsWithinRangeStanding.ToList();
                if (withinRangeStandingList.Any())
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Green, $"{withinRangeStandingList.Count} Pokestops within range of user");

                    foreach (var pokestop in withinRangeStandingList)
                    {
                        if (!GlobalVars.Gyms.Spin)
                        {
                            if (pokestop.Type != FortType.Checkpoint)
                            {
                                continue;
                            }
                        }

                        if (pokestop.Type == FortType.Gym)
                        {
                            Logger.Info("Spinning Gym");
                        }

                        var fortInfo = objClient.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);
                        var farmed   = CheckAndFarmNearbyPokeStop(pokestop, objClient, fortInfo);

                        if (farmed)
                        {
                            pokestop.CooldownCompleteTimestampMs = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 300500;
                        }

                        Setout.SetCheckTimeToRun();
                        RandomHelper.RandomSleep(500, 600); // Time between pokestops
                    }
                }
                CatchingLogic.Execute(mapObjectsResponse);

                GymsLogic.Execute();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void FarmPokestopOnBreak(FortData[] pokeStops, Client client)
        {
            //check for overlapping pokestops where we are taking a break
            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Reached break location. Using Lures Enabled");

            var pokestopsWithinRangeStanding = pokeStops
                                               .Where(i => LocationUtils
                                                      .CalculateDistanceInMeters(
                                                          objClient.CurrentLatitude,
                                                          objClient.CurrentLongitude,
                                                          i.Latitude,
                                                          i.Longitude) < 40);

            var pokestopCount = pokestopsWithinRangeStanding.Count();

            Logger.ColoredConsoleWrite(ConsoleColor.Green, $"{pokestopCount} Pokestops within range of where you are standing.");

            //Begin farming loop while on break
            do
            {
                foreach (var pokestop in pokestopsWithinRangeStanding)
                {
                    if (BotSettings.RelocateDefaultLocation)
                    {
                        break;
                    }

                    CatchingLogic.Execute();

                    var fortInfo = objClient.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (BotSettings.UseLureGUIClick || (BotSettings.UseLureAtBreak && !pokestop.ActiveFortModifier.Any() && !addedlure))
                    {
                        if (objClient.Inventory.GetItemAmountByType(ItemId.ItemTroyDisk) > 0)
                        {
                            BotSettings.UseLureGUIClick = false;

                            Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Adding lure and setting resume walking to 30 minutes");

                            objClient.Fort.AddFortModifier(fortInfo.FortId, ItemId.ItemTroyDisk);

                            Setout.resumetimestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 30000;
                            addedlure = true;
                        }
                    }

                    var farmed = CheckAndFarmNearbyPokeStop(pokestop, objClient, fortInfo);
                    if (farmed)
                    {
                        pokestop.CooldownCompleteTimestampMs = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 300500;
                    }

                    Setout.SetCheckTimeToRun();

                    RandomHelper.RandomSleep(30000, 40000);

                    // wait for a bit before repeating farm cycle to avoid spamming
                }

                if (!BotSettings.RelocateDefaultLocation)
                {
                    continue;
                }

                Setout.resumetimestamp      = -10000;
                BotSettings.pauseAtPokeStop = false;

                Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Exit Command detected - Ending break");
            } while (BotSettings.pauseAtPokeStop);
        }
Ejemplo n.º 3
0
        private void FncPokeStop(Client client, FortData[] pokeStopsIn, bool metros30)
        {
            var distanceFromStart = LocationUtils
                                    .CalculateDistanceInMeters(
                BotSettings.DefaultLatitude,
                BotSettings.DefaultLongitude,
                objClient.CurrentLatitude,
                objClient.CurrentLongitude);

            lureEncounters.Clear();

            // TODO: do it optionable
            // Reordering array randomly to do it a little more difficult to detect.
            // Random rnd=new Random();
            //FortData[] pokeStops = pokeStopsIn.OrderBy(x => rnd.Next()).ToArray();
            var pokeStops = pokeStopsIn;

            //walk between pokestops in default collection
            var queue = new Queue <FortData>();

            foreach (var pokeStop in pokeStops)
            {
                queue.Enqueue(pokeStop);
            }

            for (var i = pokeStops.Length - 2; i > 0; i--)
            {
                queue.Enqueue(pokeStops[i]);
            }

            while (queue.Count > 0)
            {
                var pokeStop = queue.Dequeue();
                queue.Enqueue(pokeStop);
                #region Mystery Check by Cicklow

                // in Archimedean spiral only capture PokeStops if distance is < to 30 meters!
                if (metros30)
                {
                    var distance1 = LocationUtils
                                    .CalculateDistanceInMeters(
                        objClient.CurrentLatitude,
                        objClient.CurrentLongitude,
                        pokeStop.Latitude,
                        pokeStop.Longitude);

                    if (distance1 > 31 && FailedSoftban < 2)
                    {
                        //Logger.ColoredConsoleWrite(ConsoleColor.Green, "Pokestop mas: " + distance.ToString());
                        continue; //solo agarrar los pokestop que esten a menos de 30 metros
                    }
                }

                #endregion

                //make sure user defined limits have not been reached
                Setout.SetCheckTimeToRun();

                #region Walk defined Route

                if (GlobalVars.NextDestinationOverride.Count > 0)
                {
                    try
                    {
                        do
                        {
                            WalkUserRoute(pokeStops);

                            #region Check for Exit Command

                            if (BotSettings.RelocateDefaultLocation)
                            {
                                break;
                            }

                            #endregion

                            if (!BotSettings.RepeatUserRoute)
                            {
                                continue;
                            }

                            foreach (var geocoord in GlobalVars.RouteToRepeat)
                            {
                                GlobalVars.NextDestinationOverride.AddLast(geocoord);
                            }
                        } while (BotSettings.RepeatUserRoute);
                    }
                    catch (Exception e)
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                        Logger.AddLog(string.Format("Error in Walk Defined Route: " + e));
                    }
                }

                #endregion

                #region Check for Exit Command


                if (BotSettings.RelocateDefaultLocation)
                {
                    break;
                }

                #endregion

                //get destination pokestop information
                var distance = LocationUtils
                               .CalculateDistanceInMeters(
                    objClient.CurrentLatitude,
                    objClient.CurrentLongitude,
                    pokeStop.Latitude,
                    pokeStop.Longitude);

                var fortInfo = objClient.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                //log error if pokestop not found
                if (fortInfo == null)
                {
                    Task.Factory.StartNew(() => infoObservable.PushPokeStopInfoUpdate(pokeStop, "!!Can't Get PokeStop Information!!"));
                    continue;
                }

                Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Next Pokestop: {fortInfo.Name} in {distance:0.##}m distance.");

                #region Break At Lure Logic

                //check if user wants to break at lured pokestop
                if (BotSettings.BreakAtLure && fortInfo.Modifiers.Any())
                {
                    Setout.pausetimestamp  = -10000;
                    Setout.resumetimestamp = fortInfo.Modifiers.First().ExpirationTimestampMs;
                    var timeRemaining = Setout.resumetimestamp - (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;

                    Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Active Lure at next Pokestop - Pausing walk for " + Math.Round(timeRemaining / 60 / 1000, 2) + " Minutes");

                    BotSettings.pauseAtPokeStop = true;
                }

                #endregion

                try
                {
                    WalkWithRouting(pokeStop.Latitude, pokeStop.Longitude);
                }
                catch (Exception e)
                {
                    Logger.ExceptionInfo(string.Format("Error in Walk Default Route: " + e));
                }

                // Pause and farm nearby pokestops
                if (BotSettings.pauseAtPokeStop)
                {
                    FarmPokestopOnBreak(pokeStops, client);
                }
            }
        }