async def move_to_with_gmo(self, next_pos, is_fast_speed=True, seconds_threshold=25, at_location=None): player_position = self.travel_time.prev_position seconds_between_locations = self.travel_time.time_to_location(next_pos) if seconds_between_locations > seconds_threshold: self.travel_time.set_fast_speed(is_fast_speed) seconds_between_locations = self.travel_time.time_to_location(next_pos) self.log.info("{} seconds to next location using fast speed".format(str(seconds_between_locations))) map_objects = None remaining_distance = equi_rect_distance_m(player_position, next_pos) while remaining_distance > 1: available = self.travel_time.meters_available_until_gmo() player_position = move_towards(player_position, next_pos, available) map_objects = await self.get_map_objects(player_position) num_pokemons = len(catchable_pokemon(map_objects)) self.log.info("Remaining distance is {}, {} meters available, {} pokemon at this pos".format( str(remaining_distance), str(available), str(num_pokemons))) if at_location: await at_location(player_position, map_objects) remaining_distance = equi_rect_distance_m(player_position, next_pos) self.travel_time.use_slow_speed() else: if seconds_between_locations > 0.1: self.log.info("{} seconds to next position {}".format(str(seconds_between_locations), str(next_pos))) map_objects = await self.get_map_objects(next_pos) return map_objects
def run_for_spawnpoints(runner, encounter_id, runner_spawnpoints): for idx, spawnpoint in enumerate(runner_spawnpoints): objects = runner.do_get_map_objects(spawnpoint.location()) if not is_seeing_blinds(objects): if not runner.name() in runner_blinds: runner_blinds[runner.name()] = 1 else: runner_blinds[runner.name()] += 1 else: runner_blinds[runner.name()] = 0 if runner_blinds[runner.name()] > 20: log.warning( "Runner {} has not seen any blinding pokemons for last 20 scans, probably blind" .format(runner.name())) for pkmn in catchable_pokemon( objects ): # todo: Consider other useful info the runner is picking up too log.info("{}={} and {}={}".format(type(encounter_id), encounter_id, type(pkmn["encounter_id"]), pkmn["encounter_id"])) if encounter_id == pkmn["encounter_id"]: log.info("Runner found after {} attempts (of {}): {}".format( idx, len(runner_spawnpoints), pkmn)) return pkmn
async def do_stuff(): account_manager = AsyncAccountManager.create_empty(args, loop) l5account = account_manager.add_account({"username": "******", "password": "******", "provider": "ptc"}) worker = wrap_account_no_replace(l5account, account_manager, 25) pos = (59.934393, 10.718153, 10) map_objects = await worker.do_get_map_objects(pos) pokestops = inrange_pokstops(map_objects, pos) gyms = inrange_gyms(map_objects, pos) cp = catchable_pokemon(map_objects) to_catch = cp[0] encounter_id = to_catch.encounter_id spawn_point_id = to_catch.spawn_point_id pokemon_id = to_catch.pokemon_id encounter_response = await worker.do_encounter_pokemon(encounter_id, spawn_point_id, pos) probability = EncounterPokemon(encounter_response, encounter_id).probability() if probability and len([x for x in probability.capture_probability if x > 0.38]) > 0: caught = await beh_catch_encountered_pokemon(worker, pos, encounter_id, spawn_point_id, probability, pokemon_id, False, fast=True) print(caught) gym = gyms[0] await worker.do_spin_pokestop(gym, pos)
def beh_spin_pokestop_raw(pogoservice, pokestop, player_position): pogoservice.do_pokestop_details(pokestop) spin_response = pogoservice.do_spin_pokestop(pokestop, player_position) result = spin_response['responses']['FORT_SEARCH'].result attempt = 0 if result == 4: beh_aggressive_bag_cleaning(pogoservice) spin_response = pogoservice.do_spin_pokestop(pokestop, player_position) result = spin_response['responses']['FORT_SEARCH'].result while result == 2 and attempt < 6: stop_pos = (pokestop.latitude,pokestop.longitude) dist = vincenty(stop_pos, player_position).m if dist > 40: log.error("Too far away from stop, {}m. this should not happen".format(str(dist))) return result # give up if attempt == 0: if player_position != stop_pos: player_position = move_towards(player_position, stop_pos, 1) if attempt == 2: objs = pogoservice.do_get_map_objects(player_position) log.info ("Extra gmo gave catchanble {}".format(str(len(catchable_pokemon(objs))))) time.sleep(1) # investigate if really needed attempt += 1 spin_response = pogoservice.do_spin_pokestop(pokestop, player_position) result = spin_response['responses']['FORT_SEARCH'].result log.info("{} attempt spinning gave result {}".format(str(attempt), str(result))) return result
async def beh_spin_pokestop_raw(pogoservice, pokestop, player_position, item_limits=None): await pogoservice.do_pokestop_details(pokestop) spin_response = await pogoservice.do_spin_pokestop(pokestop, player_position) result = spin_response['FORT_SEARCH'].result attempt = 0 if result == 6: print(str(pokestop)) if result == 4: await beh_aggressive_bag_cleaning(pogoservice, item_limits) spin_response = await pogoservice.do_spin_pokestop( pokestop, player_position) result = spin_response['FORT_SEARCH'].result while result == 2 and attempt < 6: stop_pos = (pokestop.latitude, pokestop.longitude) dist = equi_rect_distance_m(stop_pos, player_position) if dist > 40: pogoservice.log.error( "Too far away from stop, {}m. this should not happen".format( str(dist))) return result # give up if attempt == 0: if player_position != stop_pos: player_position = move_towards(player_position, stop_pos, 1) if attempt == 2: objs = await pogoservice.do_get_map_objects(player_position) pogoservice.log.info(u"Extra gmo gave catchanble {}".format( str(len(catchable_pokemon(objs))))) await asyncio.sleep(1) # investigate if really needed attempt += 1 spin_response = await pogoservice.do_spin_pokestop( pokestop, player_position) result = spin_response['FORT_SEARCH'].result pogoservice.log.info(u"{} attempt spinning gave result {}".format( str(attempt), str(result))) return result
async def process_points(locations, xp_boost_phase, cm, sm, wm, travel_time, worker, phase): first_loc = get_pos_to_use(locations[0]) worker.log.info(u"First lof {}".format(str(first_loc))) map_objects = await wm.move_to_with_gmo(first_loc) num_pokes = len(worker.account_info().pokemons) if num_pokes > 250: await discard_all_pokemon(worker) excluded_stops = exclusion_pokestops(xp_route_1 + xp_route_2) catch_condition = CatchConditions.grind_condition() if worker.account_info( )["level"] >= 9 else CatchConditions.pre_l9_condition() catch_condition.log_description(phase) do_extra_gmo_after_pokestops = False pos_index = 0 for route_element, next_route_element in pairwise(locations): if await sm.reached_limits(): return egg_active = await wm.use_egg(cm, xp_boost_phase) player_location = get_pos_to_use(route_element) next_pos = get_pos_to_use(next_route_element) await sm.spin_all_stops( map_objects, player_location, range_m=50, exclusion={} if xp_boost_phase else excluded_stops) if pos_index % 10 == 0: sm.log_inventory() if do_extra_gmo_after_pokestops: worker.log.info(u"Wating an extra cycle after fast moves") map_objects = await wm.get_map_objects(player_location) sm.log_status(egg_active, wm.has_egg, wm.egg_number, pos_index, phase) await cm.do_catch_moving(map_objects, player_location, next_pos, catch_condition, wm.is_any_egg()) await cm.do_bulk_transfers() time_to_location = travel_time.time_to_location(next_pos) out_of_eggs = wm.is_out_of_eggs_before_l30() if egg_active or out_of_eggs: candy_ = worker.account_info()["candy"] for evo in range(0, int( math.ceil(time_to_location / 1))): # todo was 15 but we dont care any more await cm.evolve_one(candy_, fast=True) slow_time_to_location = travel_time.slow_time_to_location(next_pos) use_fast = slow_time_to_location > 20 travel_time.set_fast_speed(use_fast) if use_fast: map_objects = await wm.move_to_with_gmo(next_pos, is_fast_speed=use_fast) do_extra_gmo_after_pokestops = len( catchable_pokemon(map_objects)) == 0 else: async def catch_moving(po, mo): cm.do_catch_moving(mo, po, next_pos, catch_condition, wm.is_any_egg()) map_objects = await wm.move_to_with_gmo(next_pos, is_fast_speed=use_fast, at_location=catch_moving) do_extra_gmo_after_pokestops = False await cm.do_bulk_transfers() if time_to_location > 20: cm.clear_state() pos_index += 1
((59.911297, 10.7577550), "783677808da1472b8ee1ac9ed02fc65d.11")) stop_4 = (((59.904540, 10.7665610), "787da22ba5e54bf094210927b6716b85.16"), ((59.909709, 10.7473550), "49b6c17d820d42a7ab43b7b8075da170.16")) stop_5 = (((59.904737, 10.7671730), "3d903c4baf0a46e3a74821168092cf11.16"), ((59.908853, 10.7559040), "04fb2625ff6345ba956d5bb12c557940.16")) stop_6_3km = (((59.907326, 10.7853680), "09abf40d1abf413990a4ff12f81734fb.16"), ((59.912380, 10.7312300), "10e4324fc7684c3594b976a4b114d312.16")) #travel_time = worker.getlayer(TravelTime) pos = (59.934393, 10.718153, 10) map_objects = worker.do_get_map_objects(pos) pokestops = inrange_pokstops(map_objects, pos) gyms = inrange_gyms(map_objects, pos) cp = catchable_pokemon(map_objects) gym = gyms[0] worker.do_spin_pokestop(gym, pos) pokemons = inventory_discardable_pokemon(worker) worker.do_transfer_pokemon(pokemons) to_use = stop_5 start = to_use[0] end = to_use[1] player_position = start[0] login = worker.login(player_position) l5obj = worker.do_get_map_objects(player_position) stop = inrange_pokstops(l5obj, player_position)[0] fort = {} fort.latitude = end[0][0]
def do_iterable_point_list(locations, xp_feeder, xp_boost_phase, catch_feed, cm, sm, wm, thread_num, travel_time, worker, phase, catch_condition, first_time=None, outer=True, pos_index=0): first_loc = get_pos_to_use(locations[0], None, thread_num) fallback_altitude = first_loc[2] log.info("First lof {}".format(str(first_loc))) map_objects = wm.move_to_with_gmo(first_loc) did_map_objects = True excluded_stops = exclusion_pokestops(xp_route_1 + xp_route_2) if first_time: first_time() catch_condition.log_description(phase) do_extra_gmo_after_pokestops = False for route_element, next_route_element in pairwise(locations): if cm.is_caught_already(route_element): continue if sm.reached_limits(): return # wm.use_incense() # disabled until I can find out how to identify if cm.can_start_evolving() and xp_feeder: beh_aggressive_bag_cleaning(worker) do_iterable_point_list(xp_feeder, None, True, NoOpFeed(), cm, sm, wm, None, travel_time, worker, phase, catch_condition, outer=False) egg_active = wm.use_egg(cm) player_location = get_pos_to_use(route_element, fallback_altitude, thread_num if outer else None) fallback_altitude = player_location[2] next_pos = get_pos_to_use(next_route_element, fallback_altitude, thread_num if outer else None) if is_encounter_to(route_element) or is_plain_coordinate( route_element) or xp_boost_phase or is_array_pokestops( route_element): sm.spin_all_stops( map_objects, player_location, range_m=50 if xp_boost_phase else 39.8, exclusion={} if xp_boost_phase else excluded_stops) else: pokestop = route_element[1] pokestop_id = pokestop[3] sm.spin_stops(map_objects, pokestop_id, player_location, pos_index, excluded_stops) if pos_index % 10 == 0: sm.log_inventory() if do_extra_gmo_after_pokestops: log.info("Wating an extra cycle after fast moves") map_objects = wm.get_map_objects(player_location) sm.log_status(egg_active, wm.has_egg, wm.egg_number, pos_index, phase) cm.do_catch_moving(map_objects, player_location, next_pos, pos_index, catch_condition) cm.do_bulk_transfers() time_to_location = travel_time.time_to_location(next_pos) out_of_eggs = wm.is_out_of_eggs_before_l30() if egg_active or out_of_eggs: candy_ = worker.account_info()["candy"] for evo in range(0, int(math.ceil(time_to_location / 15))): cm.evolve_one(candy_, fast=True) if outer: while True: encs = catch_feed.items[pos_index] enc_pos = None enc_id = None for encounter_id in encs: if encounter_id not in cm.processed_encounters: enc_id = encounter_id enc_pos = encs[enc_id][0] if not enc_id: break log.info("Dealing with nested location {}".format( str(enc_pos))) do_iterable_point_list([encs[enc_id][0], encs[enc_id][0]], xp_feeder, xp_boost_phase, NoOpFeed(), cm, sm, wm, None, travel_time, worker, phase, catch_condition, outer=False, pos_index=pos_index) # i dont like these heuristics one damn bit cm.processed_encounters.add( enc_id ) # this must be done in case there is nothing at the location for encounter_id in encs: # dump all other stuff reported from this location too, we'v been here. if encs[encounter_id][0] == enc_pos: cm.processed_encounters.add(encounter_id) slow_time_to_location = travel_time.slow_time_to_location(next_pos) use_fast = slow_time_to_location > 20 travel_time.set_fast_speed(use_fast) if use_fast: map_objects = wm.move_to_with_gmo(next_pos, is_fast_speed=use_fast) do_extra_gmo_after_pokestops = len( catchable_pokemon(map_objects)) == 0 else: map_objects = wm.move_to_with_gmo( next_pos, is_fast_speed=use_fast, at_location=lambda po, mo: cm.do_catch_moving(mo, po, next_pos, pos_index, catch_condition, broadcast=False)) do_extra_gmo_after_pokestops = False cm.do_bulk_transfers() if time_to_location > 20: cm.clear_state() pos_index += 1
#Q pos = (59.902942, 10.8763150) #pos = (59.900179, 10.860831) #pos= (59.926051, 10.703054) # frognerparken 4 stop #pos = (59.935523, 10.719660) # marienlyst pos=(59.908326, 10.722739) # akerbrygge ''' Call 5062448961839693824 59.90692377930243,10.722713849061687 ''' l5account = Account2("AahOuDaNos", "Freedom4@ll", "ptc", args, 7200, 1800, cycle(args.hash_key), None, {}, None) l5obj = l5account.do_get_map_objects(pos) print((l5account["level"])) print((str(catchable_pokemon(l5obj)))) pokemons = all_pokemon_pokedex_ids(l5obj) pokemon = regular_nonfav(l5obj) data_ = pokemon[3]["pokemon_data"] id_ = data_["id"] l5account.do_set_favourite(id_, True) for cellid in s2_cell_ids(l5obj): print(str(cellid)) l6account = Account2("ActOuDaGum", "Freedom4@ll", "ptc", args, 7200, 1800, cycle(args.hash_key), None, {}, None) l6obj = l6account.get_map_objects(pos) print((l5obj["level"])) scan_wilds = wild_pokemon(l6obj)