Beispiel #1
0
        private async Task ExecuteFarmingPokestopsAndPokemons(Client client)
        {
            var distanceFromStart = LocationUtils.CalculateDistanceInMeters(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude, _client.CurrentLat, _client.CurrentLng);

            if (_clientSettings.MaxWalkingRadiusInMeters != 0 && distanceFromStart > _clientSettings.MaxWalkingRadiusInMeters)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Youre outside of the defined Max Walking Radius. Walking back!");
                var update = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);

                var start = await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);
            }

            Resources.OutPutWalking = true;
            var mapObjects = await _client.GetMapObjects();

            //var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());

            var pokeStops =
                _navigation.pathByNearestNeighbour(
                    mapObjects.MapCells.SelectMany(i => i.Forts)
                    .Where(
                        i =>
                        i.Type == FortType.Checkpoint &&
                        i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime())
                    .OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude)).ToArray(), _clientSettings.WalkingSpeedInKilometerPerHour);


            if (_clientSettings.MaxWalkingRadiusInMeters != 0)
            {
                pokeStops = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, i.Latitude, i.Longitude) <= _clientSettings.MaxWalkingRadiusInMeters).ToArray();
                if (pokeStops.Count() == 0)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops in a range of " + _clientSettings.MaxWalkingRadiusInMeters + "m!");
                    await ExecuteCatchAllNearbyPokemons();
                }
            }


            if (pokeStops.Count() == 0)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "We cant find any PokeStops, which are unused! Probably Server unstable, or you visted them all. Retrying..");
                await ExecuteCatchAllNearbyPokemons();
            }
            else
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "We found " + pokeStops.Count() + " PokeStops near.");
            }

            foreach (var pokeStop in pokeStops)
            {
                await UseIncense();

                await ExecuteCatchAllNearbyPokemons();

                if (count >= 3)
                {
                    count = 0;
                    await StatsLog(client);

                    if (_clientSettings.EvolvePokemonsIfEnoughCandy)
                    {
                        await EvolveAllPokemonWithEnoughCandy();
                    }

                    if (_clientSettings.AutoIncubate)
                    {
                        await StartIncubation();
                    }

                    await TransferDuplicatePokemon(_clientSettings.keepPokemonsThatCanEvolve);
                    await RecycleItems();

                    ////
                    if (_clientSettings.UseLuckyEggIfNotRunning)
                    {
                        await _inventory.UseLuckyEgg(_client);
                    }
                }
                //if (_clientSettings.pokevision)
                //{
                //    foreach (spottedPoke p in await _pokevision.GetNearPokemons(_client.CurrentLat, _client.CurrentLng))
                //    {
                //        var dist = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, p._lat, p._lng);
                //        Logger.ColoredConsoleWrite(ConsoleColor.Magenta, $"PokeVision: A {StringUtils.getPokemonNameByLanguage(_clientSettings, p._pokeId)} in {dist:0.##}m distance. Trying to catch.");
                //        var upd = await _navigation.HumanLikeWalking(new GeoCoordinate(p._lat, p._lng), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);
                //    }
                //}

                _infoObservable.PushNewGeoLocations(new GeoCoordinate(_client.CurrentLat, _client.CurrentLng));

                var distance = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, pokeStop.Latitude, pokeStop.Longitude);
                var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                if (fortInfo == null)
                {
                    continue;
                }
                Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Next Pokestop: {fortInfo.Name} in {distance:0.##}m distance.");
                var update = await _navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);

                ////var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                count++;

                if (fortSearch.ExperienceAwarded > 0)
                {
                    failed_softban = 0;
                    _botStats.AddExperience(fortSearch.ExperienceAwarded);
                    var egg = "";
                    if (fortSearch.PokemonDataEgg != null)
                    {
                        egg = ", Egg " + fortSearch.PokemonDataEgg.EggKmWalkedTarget;
                    }
                    else
                    {
                        egg = "";
                    }
                    var gems = "";
                    if (fortSearch.GemsAwarded > 0)
                    {
                        gems = ", Gems:" + fortSearch.GemsAwarded;
                    }
                    else
                    {
                        gems = "";
                    }

                    var items = "";
                    if (StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded) != "")
                    {
                        items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded);
                    }
                    else
                    {
                        items = "Nothing (Inventory Full?)";
                    }

                    Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Farmed XP: {fortSearch.ExperienceAwarded}{gems}{egg}, Items: {items}", LogLevel.Info);
                    int eggs = 0;
                    if (fortSearch.PokemonDataEgg != null)
                    {
                        eggs = fortSearch.PokemonDataEgg.EggKmWalkedTarget;
                    }
                    try
                    {
                        TelegramUtil.getInstance().sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Pokestop, fortInfo.Name, fortSearch.ExperienceAwarded, eggs, fortSearch.GemsAwarded, items);
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    failed_softban++;
                    if (failed_softban >= 6)
                    {
                        Logger.Error("Detected Softban. Trying to use our Special 1337 Unban Methode.");
                        for (int i = 0; i < 60; i++)
                        {
                            var unban = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                            if (unban.ExperienceAwarded > 0)
                            {
                                break;
                            }
                        }
                        failed_softban = 0;
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, "Probably unbanned you.");
                    }
                }

                await RandomHelper.RandomDelay(50, 200);
            }
            if (_clientSettings.WalkBackToDefaultLocation)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Walking back to Default Location.");
                await _navigation.HumanLikeWalking(new GeoCoordinate(_clientSettings.DefaultLatitude, _clientSettings.DefaultLongitude), _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);
            }
        }
Beispiel #2
0
        private bool CheckAndFarmNearbyPokeStop(FortData pokeStop, Client client, FortDetailsResponse fortInfo)
        {
            if (Setout.count >= 9)
            {
                Setout.Execute();
            }

            if (pokeStop.CooldownCompleteTimestampMs < (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds && BotSettings.FarmPokestops)
            {
                var fortSearch = objClient.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                Logger.Debug("================[VERBOSE LOGGING - Pokestop Search]================");
                Logger.Debug($"Result: {fortSearch.Result}");
                Logger.Debug($"ChainHackSequenceNumber: {fortSearch.ChainHackSequenceNumber}");
                Logger.Debug($"Cooldown Complete (MS): {fortSearch.CooldownCompleteTimestampMs}");
                Logger.Debug($"EXP Award: {fortSearch.ExperienceAwarded}");
                Logger.Debug($"Gems Award: {fortSearch.GemsAwarded}");
                Logger.Debug($"Item Award: {fortSearch.ItemsAwarded}");
                Logger.Debug($"Egg Data: {fortSearch.PokemonDataEgg}");
                Logger.Debug("==================================================================");

                switch (fortSearch.Result.ToString())
                {
                case "NoResultSet":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: We did not recieve a result from the pokestop.");
                    break;

                case "Success":
                    // It already showed our pokestop Information
                    break;

                case "OutOfRange":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: The pokestop is out of range!");
                    break;

                case "InCooldownPeriod":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: The current Pokestop is in the cooldown period.");
                    break;

                case "InventoryFull":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: Your Inventory is full. You did not recieve any items.");
                    break;

                case "ExceededDailyLimit":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: You are above your daily limit of pokestops! You should stop farming pokestops.");
                    break;
                }

                Setout.count++;
                var strDate      = DateTime.Now.ToString("HH:mm:ss");
                var pokeStopInfo = $"{fortInfo.Name}{Environment.NewLine}Visited:{strDate}{Environment.NewLine}";

                if (fortSearch.ExperienceAwarded > 0)
                {
                    var egg = "/";

                    if (fortSearch.PokemonDataEgg != null)
                    {
                        egg = fortSearch.PokemonDataEgg.EggKmWalkedTarget + "km";
                    }

                    var items = "";

                    if (fortSearch.ItemsAwarded != null)
                    {
                        items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded);
                    }

                    var logrestock = false;

                    if (fortSearch.ItemsAwarded != null)
                    {
                        foreach (var item in fortSearch.ItemsAwarded)
                        {
                            if (item.ItemId == ItemId.ItemPokeBall || item.ItemId == ItemId.ItemGreatBall || item.ItemId == ItemId.ItemUltraBall)
                            {
                                logrestock = true;
                            }
                        }

                        if (logrestock && pokeballoutofstock)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Detected Pokeball Restock - Enabling Catch Pokemon");

                            CatchingLogic.AllowCatchPokemon = true;
                            pokeballoutofstock = false;
                        }

                        FailedSoftban = 0;
                        BotStats.AddExperience(fortSearch.ExperienceAwarded);
                        Setout.RefreshConsoleTitle(client);
                        Setout.pokeStopFarmedCount++;
                        Setout.SaveSession();

                        Logger.Info($"Farmed XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Egg: {egg}, Items: {items}");

                        var strItems = items.Replace(",", Environment.NewLine);
                        pokeStopInfo += $"{fortSearch.ExperienceAwarded} XP{Environment.NewLine}{fortSearch.GemsAwarded}{Environment.NewLine}{egg}{Environment.NewLine}{strItems}";

                        Logger.Debug("LureInfo: " + pokeStop.LureInfo);
                        if (pokeStop.LureInfo != null)
                        {
                            var pokedata = new MapPokemon();
                            pokedata.EncounterId           = pokeStop.LureInfo.EncounterId;
                            pokedata.PokemonId             = pokeStop.LureInfo.ActivePokemonId;
                            pokedata.Latitude              = pokeStop.Latitude;
                            pokedata.Longitude             = pokeStop.Longitude;
                            pokedata.ExpirationTimestampMs = pokeStop.LureInfo.LureExpiresTimestampMs;
                            pokedata.SpawnPointId          = pokeStop.LureInfo.FortId;

                            infoObservable.PushNewPokemonLocation(pokedata);
                            Logger.Debug("Lured Pokemon: " + pokedata);

                            if (!BotSettings.catchPokemonSkipList.Contains(pokedata.PokemonId) && GlobalVars.CatchPokemon)
                            {
                                if (!lureEncounters.Contains(pokedata.EncounterId.ToString()))
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Catching Lured Pokemon");
                                    CatchingLogic.CatchLuredPokemon(pokedata.EncounterId, pokedata.SpawnPointId, pokedata.PokemonId, pokedata.Longitude, pokedata.Latitude);

                                    lureEncounters.Add(pokedata.EncounterId.ToString());
                                }
                                else
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Skipped Lure Pokemon: " + pokedata.PokemonId + " because we have already caught him, or catching pokemon is disabled");
                                }
                            }
                        }

                        double eggs = 0;

                        if (fortSearch.PokemonDataEgg != null)
                        {
                            eggs = fortSearch.PokemonDataEgg.EggKmWalkedTarget;
                        }

                        Telegram?.sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Pokestop, fortInfo.Name, fortSearch.ExperienceAwarded, eggs, fortSearch.GemsAwarded, StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded));
                    }
                }

                Task.Factory.StartNew(() => infoObservable.PushPokeStopInfoUpdate(pokeStop, pokeStopInfo));

                return(true);
            }

            if (!BotSettings.FarmPokestops)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Farm Pokestop option unchecked, skipping and only looking for pokemon");

                return(false);
            }

            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Pokestop not ready to farm again, skipping and only looking for pokemon");

            return(false);
        }
Beispiel #3
0
        private async Task ExecuteFarmingPokestopsAndPokemons(bool path)
        {
            if (!path)
            {
                await ExecuteFarmingPokestopsAndPokemons();
            }
            else
            {
                var tracks    = GetGpxTracks();
                var curTrkPt  = 0;
                var curTrk    = 0;
                var maxTrk    = tracks.Count - 1;
                var curTrkSeg = 0;
                while (curTrk <= maxTrk)
                {
                    var track         = tracks.ElementAt(curTrk);
                    var trackSegments = track.Segments;
                    var maxTrkSeg     = trackSegments.Count - 1;
                    while (curTrkSeg <= maxTrkSeg)
                    {
                        var trackPoints = track.Segments.ElementAt(0).TrackPoints;
                        var maxTrkPt    = trackPoints.Count - 1;
                        while (curTrkPt <= maxTrkPt)
                        {
                            var nextPoint     = trackPoints.ElementAt(curTrkPt);
                            var distanceCheck = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat,
                                                                                        _client.CurrentLng, Convert.ToDouble(nextPoint.Lat), Convert.ToDouble(nextPoint.Lon));

                            if (distanceCheck > 5000)
                            {
                                Logger.Write(
                                    $"Your desired destination of {nextPoint.Lat}, {nextPoint.Lon} is too far from your current position of {_client.CurrentLat}, {_client.CurrentLng}",
                                    LogLevel.Error);
                                break;
                            }

                            Logger.Write(
                                $"Your desired destination is {nextPoint.Lat}, {nextPoint.Lon} your location is {_client.CurrentLat}, {_client.CurrentLng}",
                                LogLevel.Warning);

                            if (_clientSettings.UseLuckyEggs)
                            {
                                await UseLuckyEgg();
                            }
                            if (_clientSettings.UseIncense)
                            {
                                await UseIncense();
                            }

                            if (!_clientSettings.GPXIgnorePokemon)
                            {
                                await ExecuteCatchAllNearbyPokemons();
                            }

                            if (!_clientSettings.GPXIgnorePokestops)
                            {
                                var pokeStops = await _inventory.GetPokestops();

                                var pokestopList = pokeStops.ToList();

                                while (pokestopList.Any())
                                {
                                    pokestopList =
                                        pokestopList.OrderBy(
                                            i =>
                                            LocationUtils.CalculateDistanceInMeters(_client.CurrentLat,
                                                                                    _client.CurrentLng, i.Latitude, i.Longitude)).ToList();
                                    var pokeStop = pokestopList.First();
                                    pokestopList.Remove(pokeStop);

                                    var distance = LocationUtils.CalculateDistanceInMeters(_client.CurrentLat, _client.CurrentLng, pokeStop.Latitude, pokeStop.Longitude);
                                    var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                                    Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance", LogLevel.Pokestop);
                                    if (_client.Settings.DebugMode)
                                    {
                                        Logger.Write($"Latitude: {pokeStop.Latitude} - Longitude: {pokeStop.Longitude}", LogLevel.Debug);
                                    }

                                    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
                                    {
                                        var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                                        if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0)
                                        {
                                            timesZeroXPawarded = 0;
                                        }
                                        if (fortSearch.ExperienceAwarded == 0)
                                        {
                                            timesZeroXPawarded++;

                                            if (timesZeroXPawarded <= zeroCheck)
                                            {
                                                continue;
                                            }
                                            if ((int)fortSearch.CooldownCompleteTimestampMs != 0)
                                            {
                                                break; // Check if successfully looted, if so program can continue as this was "false alarm".
                                            }
                                            fortTry += 1;

                                            if (_client.Settings.DebugMode)
                                            {
                                                Logger.Write($"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber}", LogLevel.Warning);
                                            }

                                            await RandomHelper.RandomDelay(75, 100);
                                        }
                                        else
                                        {
                                            _stats.AddExperience(fortSearch.ExperienceAwarded);
                                            _stats.UpdateConsoleTitle(_client, _inventory);
                                            var eggReward = fortSearch.PokemonDataEgg != null ? "1" : "0";
                                            Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Eggs: {eggReward}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop);
                                            _recycleCounter++;
                                            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 (_recycleCounter >= 5)
                                    {
                                        await RecycleItems();
                                    }
                                }
                            }

                            if (!_clientSettings.GPXIgnorePokemon)
                            {
                                await
                                _navigation.HumanPathWalking(trackPoints.ElementAt(curTrkPt),
                                                             _clientSettings.WalkingSpeedInKilometerPerHour, ExecuteCatchAllNearbyPokemons);
                            }
                            else
                            {
                                await
                                _navigation.HumanPathWalking(trackPoints.ElementAt(curTrkPt),
                                                             _clientSettings.WalkingSpeedInKilometerPerHour, null);
                            }

                            if (curTrkPt >= maxTrkPt)
                            {
                                curTrkPt = 0;
                            }
                            else
                            {
                                curTrkPt++;
                            }
                        } //end trkpts
                        if (curTrkSeg >= maxTrkSeg)
                        {
                            curTrkSeg = 0;
                        }
                        else
                        {
                            curTrkSeg++;
                        }
                    } //end trksegs
                    if (curTrk >= maxTrkSeg)
                    {
                        curTrk = 0;
                    }
                    else
                    {
                        curTrk++;
                    }
                } //end tracks
            }
        }