diff --git a/configs/config.json.example b/configs/config.json.example index b0a8547030..758882899a 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -404,7 +404,8 @@ "catch_lured_pokemon": true, "catch_incensed_pokemon": true, "min_ultraball_to_keep": 5, - "berry_threshold": 0.35, + "berry_threshold": 0.35, + "use_pinap_on_vip": false, "vip_berry_threshold": 0.9, "treat_unseen_as_vip": true, "daily_catch_limit": 800, diff --git a/docs/configuration_files.md b/docs/configuration_files.md index eb4700621a..3a0f433f30 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -603,6 +603,7 @@ The default settings are 'safe' settings intended to simulate human and app beha "catch_lured_pokemon": true, "min_ultraball_to_keep": 5, "berry_threshold": 0.35, +"use_pinap_on_vip": false, "vip_berry_threshold": 0.9, "catch_throw_parameters": { "excellent_rate": 0.1, @@ -631,6 +632,7 @@ Setting | Description ---- | ---- `min_ultraball_to_keep` | Allows the bot to use ultraballs on non-VIP pokemon as long as number of ultraballs is above this setting `berry_threshold` | The ideal catch rate threshold before using a razz berry on normal pokemon (higher threshold means using razz berries more frequently, for example if we raise `berry_threshold` to 0.5, any pokemon that has an initial catch rate between 0 to 0.5 will initiate a berry throw) +`use_pinap_on_vip` | Use pinap berry instead of razz berry on on VIP pokemon. The bot will use razz berry if pinap berry has run out `vip_berry_threshold` | The ideal catch rate threshold before using a razz berry on VIP pokemon `flee_count` | The maximum number of times catching animation will play before the pokemon breaks free `flee_duration` | The length of time for each animation diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index f4ddcc0f31..be98b9a478 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -517,7 +517,7 @@ def _register_events(self): self.event_manager.register_event('skip_evolve') self.event_manager.register_event('threw_berry_failed', parameters=('status_code',)) self.event_manager.register_event('vip_pokemon') - self.event_manager.register_event('gained_candy', parameters=('quantity', 'type')) + self.event_manager.register_event('gained_candy', parameters=('gained_candy', 'quantity', 'type')) self.event_manager.register_event('catch_limit') self.event_manager.register_event('spin_limit') self.event_manager.register_event('show_best_pokemon', parameters=('pokemons')) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index b5ce8a5a43..21ba2def55 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -32,6 +32,7 @@ ITEM_GREATBALL = 2 ITEM_ULTRABALL = 3 ITEM_RAZZBERRY = 701 +ITEM_PINAPBERRY = 705 DEFAULT_UNSEEN_AS_VIP = True @@ -78,6 +79,7 @@ def initialize(self): self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) self.daily_catch_limit = self.config.get('daily_catch_limit', 800) + self.use_pinap_on_vip = self.config.get('use_pinap_on_vip', False) self.vanish_settings = self.config.get('vanish_settings', {}) self.consecutive_vanish_limit = self.vanish_settings.get('consecutive_vanish_limit', 10) @@ -389,19 +391,19 @@ def _use_berry(self, berry_id, berry_count, encounter_id, catch_rate_by_ball, cu } ) - response_dict = self.bot.api.use_item_capture( - item_id=berry_id, + response_dict = self.bot.api.use_item_encounter( + item=berry_id, encounter_id=encounter_id, - spawn_point_id=self.spawn_point_guid + spawn_point_guid=self.spawn_point_guid ) responses = response_dict['responses'] - if response_dict and response_dict['status_code'] == 1: + if response_dict['status_code'] == 1: # update catch rates using multiplier - if 'item_capture_mult' in responses['USE_ITEM_CAPTURE']: + if 'capture_probability' in responses['USE_ITEM_ENCOUNTER']: for rate in catch_rate_by_ball: - new_catch_rate_by_ball.append(rate * responses['USE_ITEM_CAPTURE']['item_capture_mult']) + new_catch_rate_by_ball.append(float(responses['USE_ITEM_ENCOUNTER']['capture_probability']['capture_probability'][current_ball-1])) self.emit_event( 'threw_berry', formatted="Threw a {berry_name}! Catch rate with {ball_name} is now: {new_catch_rate}", @@ -439,7 +441,6 @@ def _use_berry(self, berry_id, berry_count, encounter_id, catch_rate_by_ball, cu level='info', formatted="softban_log table not found, skipping log" ) - # unknown status code else: new_catch_rate_by_ball = catch_rate_by_ball @@ -459,7 +460,14 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): :type pokemon: Pokemon """ - berry_count = self.inventory.get(ITEM_RAZZBERRY).count + + if self.use_pinap_on_vip and is_vip: + berry_id = ITEM_PINAPBERRY + else: + berry_id = ITEM_RAZZBERRY + + berry_count = self.inventory.get(berry_id).count + ball_count = {} for ball_id in [ITEM_POKEBALL, ITEM_GREATBALL, ITEM_ULTRABALL]: ball_count[ball_id] = self.inventory.get(ball_id).count @@ -468,8 +476,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): min_ultraball_to_keep = ball_count[ITEM_ULTRABALL] if self.min_ultraball_to_keep is not None and self.min_ultraball_to_keep >= 0: min_ultraball_to_keep = self.min_ultraball_to_keep - - berry_id = ITEM_RAZZBERRY + maximum_ball = ITEM_GREATBALL if ball_count[ITEM_ULTRABALL] < min_ultraball_to_keep else ITEM_ULTRABALL ideal_catch_rate_before_throw = self.vip_berry_threshold if is_vip else self.berry_threshold @@ -491,17 +498,34 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): while next_ball < maximum_ball: next_ball += 1 num_next_balls += ball_count[next_ball] + + # If pinap berry is not enough, use razz berry + if berry_count == 0 and self.use_pinap_on_vip: + if berry_id == ITEM_PINAPBERRY: + berry_id = ITEM_RAZZBERRY + berry_count = self.inventory.get(berry_id).count + else: + berry_id = ITEM_PINAPBERRY + berry_count = self.inventory.get(berry_id).count # check if we've got berries to spare berries_to_spare = berry_count > 0 if is_vip else berry_count > num_next_balls + 30 - - # use a berry if we are under our ideal rate and have berries to spare + changed_ball = False + + # use pinap if config set to true + if self.use_pinap_on_vip and is_vip and berries_to_spare and not used_berry: + self._use_berry(berry_id, berry_count, encounter_id, catch_rate_by_ball, current_ball) + self.inventory.get(berry_id).remove(1) + berry_count -= 1 + used_berry = True + + # use a berry if we are under our ideal rate and have berries to spare if catch_rate_by_ball[current_ball] < ideal_catch_rate_before_throw and berries_to_spare and not used_berry: new_catch_rate_by_ball = self._use_berry(berry_id, berry_count, encounter_id, catch_rate_by_ball, current_ball) if new_catch_rate_by_ball != catch_rate_by_ball: catch_rate_by_ball = new_catch_rate_by_ball - self.inventory.get(ITEM_RAZZBERRY).remove(1) + self.inventory.get(berry_id).remove(1) berry_count -= 1 used_berry = True @@ -519,7 +543,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): new_catch_rate_by_ball = self._use_berry(berry_id, berry_count, encounter_id, catch_rate_by_ball, current_ball) if new_catch_rate_by_ball != catch_rate_by_ball: catch_rate_by_ball = new_catch_rate_by_ball - self.inventory.get(ITEM_RAZZBERRY).remove(1) + self.inventory.get(berry_id).remove(1) berry_count -= 1 used_berry = True @@ -703,10 +727,11 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): self.emit_event( 'gained_candy', - formatted='You now have {quantity} {type} candy!', + formatted='Candy gained: {gained_candy}. You now have {quantity} {type} candy!', data = { + 'gained_candy': str(candy_gain), 'quantity': candy.quantity, - 'type': candy.type, + 'type': candy.type }, )