Getting the following error when trying to catch a Pokémon, when you're full on Pokémon (sorry, line numbers are probably a bit off due to my modifications)
Shouldn't happen with default settings, but hey... you know me.
[23:29:10] Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at PokemonGo.RocketAPI.Logic.Logic.<ExecuteCatchAllNearbyPokemons>d__7.MoveNext() in A:\PathToAwesomeNess\PokemonGo.RocketAPI.Logic\Logic.cs:line 108
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificat ion(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PokemonGo.RocketAPI.Logic.Logic.<ExecuteFarmingPokestopsAndPokemons>d__6.MoveNex t() in A:\PathToAwesomeNess\PokemonGo.RocketAPI.Logic\Logic.cs:line 88
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificat ion(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PokemonGo.RocketAPI.Logic.Logic.<<Execute>b__4_0>d.MoveNext() in A:\PathToAwesomeNess\PokemonGo.RocketAPI.Logic\Logic.cs:line 44
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificat ion(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PokemonGo.RocketAPI.Logic.Logic.<RepeatAction>d__5.MoveNext() in A:\PathToAwesomeNess\PokemonGo.RocketAPI.Logic\Logic.cs:line 70
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificat ion(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PokemonGo.RocketAPI.Logic.Logic.<Execute>d__4.MoveNext() in A:\PathToAwesomeNess\PokemonGo.RocketAPI.Logic\Logic.cs:line 44
You have to edit the block of code in Logic.cs to change it from cp to PokemonId
Code:private async Task<MiscEnums.Item> GetBestBall(WildPokemon pokemon) { var pokemonCp = pokemon?.PokemonData?.Cp; var pokeBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_POKE_BALL); var greatBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_GREAT_BALL); var ultraBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_ULTRA_BALL); var masterBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_MASTER_BALL); if (masterBallsCount > 0 && pokemonCp >= 1000) return MiscEnums.Item.ITEM_MASTER_BALL; else if (ultraBallsCount > 0 && pokemonCp >= 1000) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (greatBallsCount > 0 && pokemonCp >= 1000) return MiscEnums.Item.ITEM_GREAT_BALL; if (ultraBallsCount > 0 && pokemonCp >= 600) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (greatBallsCount > 0 && pokemonCp >= 600) return MiscEnums.Item.ITEM_GREAT_BALL; if (greatBallsCount > 0 && pokemonCp >= 350) return MiscEnums.Item.ITEM_GREAT_BALL; if (pokeBallsCount > 0) return MiscEnums.Item.ITEM_POKE_BALL; if (greatBallsCount > 0) return MiscEnums.Item.ITEM_GREAT_BALL; if (ultraBallsCount > 0) return MiscEnums.Item.ITEM_ULTRA_BALL; if (masterBallsCount > 0) return MiscEnums.Item.ITEM_MASTER_BALL; return MiscEnums.Item.ITEM_POKE_BALL; }
If you change what in red to this it should work but I have not test it.
Code:var pokemonId = pokemon?.?.Id; // not sure if this right way to get id // use Master ball if it CHARMENDER or PIKACHU if (PokemonId == 4 || PokemonId == 25 ) { if (masterBallsCount > 0 ) return MiscEnums.Item.ITEM_MASTER_BALL; else if (ultraBallsCount > 0) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (greatBallsCount > 0 ) return MiscEnums.Item.ITEM_GREAT_BALL; } // use ULTRA ball if Squirtle if (PokemonId == 7 ) { if (masterBallsCount > 0 ) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (greatBallsCount > 0 ) return MiscEnums.Item.ITEM_GREAT_BALL; }
Last edited by sh4z4m; 07-21-2016 at 04:47 PM.
I want to keep both of my Hypnos without transfering one of them. Any ideas how to do it??
any way to keep a certain cp lvl ? I have like 8 pokemon of the same and like for 9 diff pokemon with 2k + cp. im not trying to have them all transfered. is it just not supported in this version? if not I would appreciate it even more than what I am right now. i appreciate you so much for your work
i can't compile, why?
This version isn't giving me a google token to add in app.config, any ideas why ? It asks me to go to google.com/device every time.
Thought I'd give back and share my modifications, answering a few questions that I haven't seen answered yet. Enjoy & give thanks/thumbs up if you like! Thank you!
Line numbers might be a little bit off and the places/method I'm doing things (not using arrays/list) may not be optimal, but hey...
Adjust cycle time between farming and transferring + evolving
Logic.cs 44:
Transfer all but the two highest instead of only the highest CP PokémonCode:await RepeatAction(2, async () => await ExecuteFarmingPokestopsAndPokemons(_client)); // default RepeatAction count = 10 = measured it once at approx. 30 minutes // 2 = measured it once at approx 13 min.
Inventory.cs 77:
Do not evolve PokémonCode:return pokemonList .GroupBy(p => p.PokemonId) .Where(x => x.Count() > 2) .SelectMany(p => p.Where(x => x.Favorite == 0).OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax).Skip(2).ToList());
Logic.cs 41:
Only evolve specific PokémonCode://await EvolveAllPokemonWithEnoughCandy();
Inventory.cs 108:
// Require 2x Candy requirement in inventory and Pokémon not to be specified, in that case evolve it
// Using this to save up the specified common Pokémon for mass-evolve with Candy
Exclusions on Pokémon to transfer // Do not transfer Pokémon above certain CP levelCode:if (familyCandy.Candy - pokemonCandyNeededAlready > 2*settings.CandyToEvolve &&! ( pokemon.PokemonId == PokemonId.Rattata || pokemon.PokemonId == PokemonId.Pidgey || pokemon.PokemonId == PokemonId.Pidgeotto || pokemon.PokemonId == PokemonId.Caterpie || pokemon.PokemonId == PokemonId.Metapod || pokemon.PokemonId == PokemonId.Weedle || pokemon.PokemonId == PokemonId.Kakuna ) )
// You can use this to build up a stack of these Pokémon, while not auto-Evolving them, so you can use them along with a Lucky Egg
Logic.cs 145:
Drop items from inventory when you have more than a certain amountCode:if (duplicatePokemon.PokemonId != PokemonId.Rattata && duplicatePokemon.PokemonId != PokemonId.Weedle && duplicatePokemon.PokemonId != PokemonId.Pidgey && duplicatePokemon.PokemonId != PokemonId.Caterpie && duplicatePokemon.Cp < 1000) { var transfer = await _client.TransferPokemon(duplicatePokemon.Id); Logger.Write($"Transfer {duplicatePokemon.PokemonId} with {duplicatePokemon.Cp} CP", LogLevel.Info); await Task.Delay(500); }
Settings.cs 27:
Use Ultra/Great Balls on Pokémon capture when their count exceed what you would drop from inventoryCode:new KeyValuePair<ItemId, int>(ItemId.ItemPokeBall, 50), new KeyValuePair<ItemId, int>(ItemId.ItemGreatBall, 50), new KeyValuePair<ItemId, int>(ItemId.ItemUltraBall, 100), new KeyValuePair<ItemId, int>(ItemId.ItemRazzBerry, 50), new KeyValuePair<ItemId, int>(ItemId.ItemPotion, 0), new KeyValuePair<ItemId, int>(ItemId.ItemSuperPotion, 0), new KeyValuePair<ItemId, int>(ItemId.ItemHyperPotion, 50), new KeyValuePair<ItemId, int>(ItemId.ItemRevive, 30)
Logic.cs in private async Task<MiscEnums.Item> GetBestBall(int? pokemonCp ~179+:
Do not use Raspberry when we have 10 or lessCode:if (masterBallsCount > 0 && pokemonCp >= 1000) return MiscEnums.Item.ITEM_MASTER_BALL; else if (ultraBallsCount > 100 || (ultraBallsCount > 0 && pokemonCp >= 1000)) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (ultraBallsCount > 50 || (greatBallsCount > 0 && pokemonCp >= 1000)) return MiscEnums.Item.ITEM_GREAT_BALL;
Use Master/Ultra/Great Balls when certain type of Pokémon is encounteredCode:Logic.cs 204: if (berry == null || berry.Count <= 10)
// This should probably be extended to include when a Pokémon that hasn't been caught yet is being encountered
Logic.cs 104:
Logic.cs 173:Code:var pokeball = await GetBestBall(pokemonCP, encounterPokemonResponse?.WildPokemon?.PokemonData?.PokemonId);
Logic.cs 180:Code:private async Task<MiscEnums.Item> GetBestBall(int? pokemonCp, PokemonId? pokemonId)
var pokeBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_POKE_BALL);
var greatBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_GREAT_BALL);
var ultraBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_ULTRA_BALL);
var masterBallsCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_MASTER_BALL);
Upgrade Pokéball type if possible, when capture probability is < 20%Code:if ( pokemonId == PokemonId.Charmender || pokemonId == PokemonId.Bulbasaur || pokemonId == PokemonId.Squirtle ) { if (masterBallsCount > 0) return MiscEnums.Item.ITEM_MASTER_BALL; else if (ultraBallsCount > 0) return MiscEnums.Item.ITEM_ULTRA_BALL; else if (greatBallsCount > 0) return MiscEnums.Item.ITEM_GREAT_BALL; else return MiscEnums.Item.ITEM_POKE_BALL; // OTHERWISE JUST CRASH!! What kinda trainer has no balls? And no, obviously, lady trainers have balls. }
Logic.cs 111:
Code://Throw berry if we can await UseBerry(pokemon.EncounterId, pokemon.SpawnpointId); // Upgrade Pokeball if < 20% cap chance if (encounterPokemonResponse?.CaptureProbability.CaptureProbability_.First() < 0.20) { if (pokeball == MiscEnums.Item.ITEM_POKE_BALL) pokeball = MiscEnums.Item.ITEM_GREAT_BALL; else if (pokeball == MiscEnums.Item.ITEM_GREAT_BALL) pokeball = MiscEnums.Item.ITEM_ULTRA_BALL; else if (pokeball == MiscEnums.Item.ITEM_ULTRA_BALL) pokeball = MiscEnums.Item.ITEM_MASTER_BALL; }
Last edited by Inny; 07-21-2016 at 06:06 PM. Reason: Added code tags
Transformation and removal of duplicates does not work until you run the program again .That is working only at the beginning of the program.
How to make what would be updated during the work?
What is the difference between this ([UPDATED] Pokemon Bot in C# Community Version) one?