-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Now bot can use berries. Yeah! + Fix #660, #666 #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
428f5d4
a2ab1f4
3a93c0b
0436a04
188578f
0775b3c
f1a464b
9c39fa7
83fdda7
265a2d3
30c32d4
3dbc915
1857a2b
100bc20
febbd1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +0,0 @@ | ||
| [submodule "origin"] | ||
| path = web | ||
| url = https://github.com/OpenPoGo/OpenPoGoWeb.git | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,11 @@ def work(self): | |
| if 'ENCOUNTER' in response_dict['responses']: | ||
| if 'status' in response_dict['responses']['ENCOUNTER']: | ||
| if response_dict['responses']['ENCOUNTER']['status'] is 7: | ||
| logger.log('[x] Pokemon Bag is full!', 'red') | ||
| return PokemonCatchWorker.BAG_FULL | ||
| if self.config.initial_transfer: | ||
| logger.log('[x] Pokemon Bag is full!', 'red') | ||
| return PokemonCatchWorker.BAG_FULL | ||
| else: | ||
| raise RuntimeError('Pokemon Bag is full!') | ||
|
|
||
| if response_dict['responses']['ENCOUNTER']['status'] is 1: | ||
| cp = 0 | ||
|
|
@@ -81,8 +84,28 @@ def work(self): | |
| pokeball = 2 # then use great balls | ||
| elif balls_stock[3] > 0: # or if great balls are out of stock too, and player has ultra balls... | ||
| pokeball = 3 # then use ultra balls | ||
|
|
||
| ## Use berry to increase success chance. | ||
| berry_id = 701 # @ TODO: use better berries if possible | ||
| berries_count = self.bot.item_inventory_count(berry_id) | ||
| if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and berry is in stock | ||
| success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) | ||
| logger.log('[x] Catch Rate with normal Pokeball is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) | ||
| self.api.use_item_capture( | ||
| item_id=berry_id, | ||
| encounter_id = encounter_id, | ||
| spawn_point_guid = spawnpoint_id | ||
| ) | ||
| response_dict = self.api.call() | ||
| if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']: | ||
|
|
||
| for i in range(len(catch_rate)): | ||
| catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Been testing this for a while and at times, item_capture_mult doesn't exist in USE_ITEM_CAPTURE, so it throws an error and crashes the bot.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this PR long time too and it have been working without issues to me.
https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/proto/RpcSub.proto#L436 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should exist in |
||
|
|
||
| success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) | ||
| logger.log('[#] Catch Rate with normal Pokeball has increased to {}%'.format(success_percentage)) | ||
| else: | ||
| pokeball = 0 # player doesn't have any of pokeballs, great balls or ultra balls | ||
| logger.log('[x] Fail to use berry. Status Code: {}'.format(response_dict['status_code']),'red') | ||
|
|
||
| while(pokeball < 3): | ||
| if catch_rate[pokeball-1] < 0.35 and balls_stock[pokeball+1] > 0: | ||
|
|
@@ -92,8 +115,8 @@ def work(self): | |
| break | ||
|
|
||
| # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable) | ||
|
|
||
| if pokeball is 0: | ||
| if balls_stock[pokeball] is 0: | ||
| logger.log( | ||
| '[x] Out of pokeballs, switching to farming mode...', 'red') | ||
| # Begin searching for pokestops. | ||
|
|
@@ -126,23 +149,24 @@ def work(self): | |
| 'CATCH_POKEMON']['status'] | ||
| if status is 2: | ||
| logger.log( | ||
| '[-] Attempted to capture {}- failed.. trying again!'.format(pokemon_name), 'red') | ||
| '[-] Attempted to capture {} - failed.. trying again!'.format(pokemon_name), 'red') | ||
| sleep(2) | ||
| continue | ||
| if status is 3: | ||
| logger.log( | ||
| '[x] Oh no! {} vanished! :('.format(pokemon_name), 'red') | ||
| if status is 1: | ||
| logger.log( | ||
| '[x] Captured {}! [CP {}] [IV {}]'.format( | ||
| pokemon_name, | ||
| cp, | ||
| pokemon_potential | ||
| ), 'green' | ||
| ) | ||
|
|
||
|
|
||
| id_list2 = self.count_pokemon_inventory() | ||
|
|
||
|
|
||
| logger.log('[x] Captured {}! [CP {}] [{}/{}/{}]'.format( | ||
| pokemon_name, | ||
| cp, | ||
| pokemon['pokemon_data']['individual_stamina'], | ||
| pokemon['pokemon_data']['individual_attack'], | ||
| pokemon['pokemon_data']['individual_defense'] | ||
| ), 'blue') | ||
|
|
||
| if self.config.evolve_captured: | ||
| pokemon_to_transfer = list(Set(id_list2) - Set(id_list1)) | ||
| self.api.evolve_pokemon(pokemon_id=pokemon_to_transfer[0]) | ||
|
|
@@ -166,9 +190,7 @@ def work(self): | |
| pokemon_to_transfer[0]) | ||
| logger.log( | ||
| '[#] {} has been exchanged for candy!'.format(pokemon_name), 'green') | ||
| else: | ||
| logger.log( | ||
| '[x] Captured {}! [CP {}]'.format(pokemon_name, cp), 'green') | ||
|
|
||
| break | ||
| time.sleep(5) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should reference the constant from item_list.py