Esempio n. 1
0
    def _old_walk_to(self, speed, lat, lng, alt):
        dist = distance(
            i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng)
        steps = (dist + 0.0) / (speed + 0.0)  # may be rational number
        intSteps = int(steps)
        residuum = steps - intSteps
        log.info('[#] Walking from ' + str((i2f(self.api._position_lat), i2f(
            self.api._position_lng))) + " to " + str(str((lat, lng))) +
                   " for approx. " + str(format_time(ceil(steps))))
        if steps != 0:
            dLat = (lat - i2f(self.api._position_lat)) / steps
            dLng = (lng - i2f(self.api._position_lng)) / steps

            for i in range(intSteps):
                cLat = i2f(self.api._position_lat) + \
                    dLat + random_lat_long_delta()
                cLng = i2f(self.api._position_lng) + \
                    dLng + random_lat_long_delta()
                self.api.set_position(cLat, cLng, alt)
                self.ai.heartbeat()
                sleep(1)  # sleep one second plus a random delta
                self._work_at_position(
                    i2f(self.api._position_lat), i2f(self.api._position_lng),
                    alt, False)

            self.api.set_position(lat, lng, alt)
            self.ai.heartbeat()
            log.info("[#] Finished walking")
Esempio n. 2
0
    def _walk_to(self, speed, lat, lng, alt):
        dist = distance(i2f(self.api._position_lat),
                        i2f(self.api._position_lng), lat, lng)
        steps = (dist + 0.0) / (speed + 0.0)  # may be rational number
        intSteps = int(steps)
        residuum = steps - intSteps

        log.info('Бежим из ' + str((i2f(self.api._position_lat),
                                    i2f(self.api._position_lng))) + " в " +
                 str(str((lat, lng))) + " на " + str(round(dist, 2)) +
                 " по прямой. " + str(format_time(ceil(steps))))

        if steps != 0:
            dLat = (lat - i2f(self.api._position_lat)) / steps
            dLng = (lng - i2f(self.api._position_lng)) / steps

            for i in range(intSteps):
                cLat = i2f(
                    self.api._position_lat) + dLat + random_lat_long_delta()
                cLng = i2f(
                    self.api._position_lng) + dLng + random_lat_long_delta()
                self.api.set_position(cLat, cLng, alt)
                self.ai.heartbeat()

                sleep(1)
            self.api.set_position(lat, lng, alt)
            self.ai.heartbeat()
Esempio n. 3
0
    def _walk_to(self, speed, lat, lng, alt):
        dist = distance(i2f(self.api._position_lat),
                        i2f(self.api._position_lng), lat, lng)
        steps = (dist + 0.0) / (speed + 0.0)  # may be rational number
        intSteps = int(steps)
        residuum = steps - intSteps

        log.info('Бежим из ' + str((i2f(self.api._position_lat),
                                    i2f(self.api._position_lng))) + " в " +
                 str(str((lat, lng))) + " по прямой. " +
                 str(format_time(ceil(steps))))

        if steps != 0:
            dLat = (lat - i2f(self.api._position_lat)) / steps
            dLng = (lng - i2f(self.api._position_lng)) / steps

            for i in range(intSteps):
                cLat = i2f(
                    self.api._position_lat) + dLat + random_lat_long_delta()
                cLng = i2f(
                    self.api._position_lng) + dLng + random_lat_long_delta()
                self.api.set_position(cLat, cLng, alt)
                self.ai.heartbeat()

                self._work_at_position(i2f(self.api._position_lat),
                                       i2f(self.api._position_lng),
                                       alt,
                                       seen_pokemon=True,
                                       seen_pokestop=False,
                                       seen_gym=False)
                sleep(2 * self.scanner.mode.is_human)
            self.api.set_position(lat, lng, alt)
            self.ai.heartbeat()
Esempio n. 4
0
    def _walk_to(self, speed, lat, lng, alt):
        dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng)
        steps = (dist + 0.0) / (speed + 0.0)  # may be rational number
        intSteps = int(steps)
        residuum = steps - intSteps

        log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) +
                   " на " + str(round(dist, 2)) + " по прямой. " + str(format_time(ceil(steps))))

        if steps != 0:
            dLat = (lat - i2f(self.api._position_lat)) / steps
            dLng = (lng - i2f(self.api._position_lng)) / steps

            for i in range(intSteps):
                cLat = i2f(self.api._position_lat) + dLat + random_lat_long_delta()
                cLng = i2f(self.api._position_lng) + dLng + random_lat_long_delta()
                self.api.set_position(cLat, cLng, alt)
                self.ai.heartbeat()

                sleep(1)
            self.api.set_position(lat, lng, alt)
            self.ai.heartbeat()
Esempio n. 5
0
    def _walk_to(self, speed, lat, lng, alt):
        dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng)
        steps = (dist + 0.0) / (speed + 0.0)  # may be rational number
        intSteps = int(steps)
        residuum = steps - intSteps

        log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) +
                   " по прямой. " + str(format_time(ceil(steps))))

        if steps != 0:
            dLat = (lat - i2f(self.api._position_lat)) / steps
            dLng = (lng - i2f(self.api._position_lng)) / steps

            for i in range(intSteps):
                cLat = i2f(self.api._position_lat) + dLat + random_lat_long_delta()
                cLng = i2f(self.api._position_lng) + dLng + random_lat_long_delta()
                self.api.set_position(cLat, cLng, alt)
                self.ai.heartbeat()

                self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, seen_pokemon=True, seen_pokestop=False, seen_gym=False)
                sleep(2*self.scanner.mode.is_human)
            self.api.set_position(lat, lng, alt)
            self.ai.heartbeat()
Esempio n. 6
0
    def work(self):
        lat = self.pokestop['latitude']
        lng = self.pokestop['longitude']

        self.api.fort_details(fort_id=self.pokestop['id'], latitude=lat, longitude=lng)
        response_dict = self.api.call()
        print response_dict
        if 'responses' in response_dict \
                and'FORT_DETAILS' in response_dict['responses'] \
                and 'name' in response_dict['responses']['FORT_DETAILS']:
            fort_details = response_dict['responses']['FORT_DETAILS']
            fort_name = fort_details['name'].encode('utf8', 'replace')

            parse_fort_details(self.pokestop['id'], 1, fort_details, self.session)
        else:
            fort_name = 'Unknown'
        log.info('[#] Now at Pokestop: ' + fort_name + ' - Spinning...')
        sleep(1)
        self.api.fort_search(fort_id=self.pokestop['id'],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
                'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                log.info("[+] Loot: ")
                experience_awarded = spin_details.get('experience_awarded', False)
                if experience_awarded:
                    log.info("[+] " + str(experience_awarded) + " xp")

                items_awarded = spin_details.get('items_awarded', False)

                if items_awarded:
                    tmp_count_items = {}
                    for item in items_awarded:
                        item_id = item['item_id']
                        if not item_id in tmp_count_items:
                            tmp_count_items[item_id] = item['item_count']
                        else:
                            tmp_count_items[item_id] += item['item_count']

                    for item_id, item_count in tmp_count_items.iteritems():
                        log.info("[+] Loot: {0} count {1}".format(item_id, item_count))
                else:
                    log.info("[#] Nothing found.")

                pokestop_cooldown = spin_details.get('cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    log.info('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) - seconds_since_epoch)))

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                    log.warning(
                        'Stopped at Pokestop and did not find experience, items '
                        'or information about the stop cooldown. You are '
                        'probably softbanned. Try to play on your phone, '
                        'if pokemons always ran away and you find nothing in '
                        'PokeStops you are indeed softbanned. Please try again '
                        'in a few hours.')
            elif spin_details['result'] == 2:
                log.info("[#] Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    log.info('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))
            elif spin_details['result'] == 4:
                log.info("[#] Inventory is full, switching to catch mode...")
                #self.config.mode = 'poke'

            if 'chain_hack_sequence_number' in response_dict['responses'][
                    'FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH'][
                    'chain_hack_sequence_number']
            else:
                log.info('[#] may search too often, lets have a rest')
                return 11
        sleep(8)
        return 0
Esempio n. 7
0
    def _walk_to(self, walk_speed, dest_lat, dest_lng, alt):
        init_lat = self.api._position_lat
        init_lng = self.api._position_lng
        walk_distance = distance(init_lat, init_lng, dest_lat, dest_lng)
        walk_distance_total = max(1, walk_distance)
        walk_steps = (walk_distance + 0.0) / (walk_speed + 0.0)

        if walk_distance < walk_speed or int(walk_steps) <= 1:
            delta_lat = 0
            delta_lng = 0
            magnitude = 0
        else:
            delta_lat = (dest_lat - init_lat) / int(walk_steps)
            delta_lng = (dest_lng - init_lng) / int(walk_steps)
            magnitude = self._pythagorean(delta_lat, delta_lng)

        log.info("Бежим из [{}, {}] в [{}, {}] на расстояние {}, со скоростью {}, ориентировочно за {}".format(init_lat, init_lng, dest_lat, dest_lng, round(walk_distance, 2), walk_speed, format_time(ceil(walk_steps))))

        if (delta_lat == 0 and delta_lng == 0) or walk_distance < walk_speed:
            self.api.set_position(dest_lat, dest_lng, 0)
            return True


        while True:
            total_delta_step = walk_distance/int(walk_steps)
            total_delta_lat = (dest_lat - self.api._position_lat)
            total_delta_lng = (dest_lng - self.api._position_lng)
            magnitude = self._pythagorean(total_delta_lat, total_delta_lng)

            if distance(self.api._position_lat, self.api._position_lng, dest_lat, dest_lng) <= total_delta_step:
                self.api.set_position(dest_lat, dest_lng, alt)
                self.ai.heartbeat()
                break

            unit_lat = total_delta_lat / magnitude
            unit_lng = total_delta_lng / magnitude

            scaled_delta_lat = unit_lat * magnitude
            scaled_delta_lng = unit_lng * magnitude

            c_lat = init_lat + scaled_delta_lat + random_lat_long_delta()
            c_lng = init_lng + scaled_delta_lng + random_lat_long_delta()

            self.api.set_position(c_lat, c_lng, 0)
            self.ai.heartbeat()

            sleep(1)
Esempio n. 8
0
    def work(self):
        lat = self.pokestop['latitude']
        lng = self.pokestop['longitude']

        self.api.fort_details(fort_id=self.pokestop['id'],
                              latitude=lat,
                              longitude=lng)
        response_dict = self.api.call()
        print response_dict
        if 'responses' in response_dict \
                and'FORT_DETAILS' in response_dict['responses'] \
                and 'name' in response_dict['responses']['FORT_DETAILS']:
            fort_details = response_dict['responses']['FORT_DETAILS']
            fort_name = fort_details['name'].encode('utf8', 'replace')

            parse_fort_details(self.pokestop['id'], 1, fort_details,
                               self.session)
        else:
            fort_name = 'Unknown'
        log.info('[#] Now at Pokestop: ' + fort_name + ' - Spinning...')
        sleep(1)
        self.api.fort_search(fort_id=self.pokestop['id'],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
                'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                log.info("[+] Loot: ")
                experience_awarded = spin_details.get('experience_awarded',
                                                      False)
                if experience_awarded:
                    log.info("[+] " + str(experience_awarded) + " xp")

                items_awarded = spin_details.get('items_awarded', False)

                if items_awarded:
                    tmp_count_items = {}
                    for item in items_awarded:
                        item_id = item['item_id']
                        if not item_id in tmp_count_items:
                            tmp_count_items[item_id] = item['item_count']
                        else:
                            tmp_count_items[item_id] += item['item_count']

                    for item_id, item_count in tmp_count_items.iteritems():
                        log.info("[+] Loot: {0} count {1}".format(
                            item_id, item_count))
                else:
                    log.info("[#] Nothing found.")

                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    log.info('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                    log.warning(
                        'Stopped at Pokestop and did not find experience, items '
                        'or information about the stop cooldown. You are '
                        'probably softbanned. Try to play on your phone, '
                        'if pokemons always ran away and you find nothing in '
                        'PokeStops you are indeed softbanned. Please try again '
                        'in a few hours.')
            elif spin_details['result'] == 2:
                log.info("[#] Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    log.info('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))
            elif spin_details['result'] == 4:
                log.info("[#] Inventory is full, switching to catch mode...")
                #self.config.mode = 'poke'

            if 'chain_hack_sequence_number' in response_dict['responses'][
                    'FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH'][
                    'chain_hack_sequence_number']
            else:
                log.info('[#] may search too often, lets have a rest')
                return 11
        sleep(8)
        return 0