Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
876 stars 198 forks source link

Why are all Pokemon detected are exactly 200 km away? #123

Open WhataShane opened 7 years ago

WhataShane commented 7 years ago

I'm running the example program and can't figure out why every Pokemon it picks up is exactly 200m away. Is this a glitch?

filharvey commented 7 years ago

Did you change the location. Defaults to times square

fr0th commented 7 years ago

You mean 200m?

WhataShane commented 7 years ago

Yes, no matter the location, Pokemon are always 200m (whoops) away. For reference:

'use strict';

var PokemonGO = require('./poke.io.js');

// using var so you can login with multiple users
var a = new PokemonGO.Pokeio();

//Set environment variables or replace placeholder text
var location = {
    type: 'name',
    name: 'Santa Monica Pier'
};

var username = 'my username';
var password = 'my password'
var provider = 'ptc';

a.init(username, password, location, provider, function(err) {
    if (err) throw err;

    console.log('1[i] Current location: ' + a.playerInfo.locationName);
    console.log('1[i] lat/long/alt: : ' + a.playerInfo.latitude + ' ' + a.playerInfo.longitude + ' ' + a.playerInfo.altitude);

    a.GetProfile(function(err, profile) {
        if (err) throw err;

        console.log('1[i] Username: ' + profile.username);
        console.log('1[i] Poke Storage: ' + profile.poke_storage);
        console.log('1[i] Item Storage: ' + profile.item_storage);

        var poke = 0;
        if (profile.currency[0].amount) {
            poke = profile.currency[0].amount;
        }

        console.log('1[i] Pokecoin: ' + poke);
        console.log('1[i] Stardust: ' + profile.currency[1].amount);

        setInterval(function(){
            a.Heartbeat(function(err,hb) {
                if(err) {
                    console.log(err);
                }

                for (var i = hb.cells.length - 1; i >= 0; i--) {
                    if(hb.cells[i].NearbyPokemon[0]) {
                        //console.log(a.pokemonlist[0])
                        var pokemon = a.pokemonlist[parseInt(hb.cells[i].NearbyPokemon[0].PokedexNumber)-1];
                        console.log('1[+] There is a ' + pokemon.name + ' at ' + hb.cells[i].NearbyPokemon[0].DistanceMeters.toString() + ' meters');
                    }
                }

            });
        }, 5000);

    });
});

And the output:

[i] Logging with user: ----
[i] Session token: ----
[i] Received PTC access token!
[i] Received API Endpoint: https://pgorelease.nianticlabs.com/plfe/112/rpc
1[i] Current location: Santa Monica Pier
1[i] lat/long/alt: : 34.0092419 -118.4976037 0
[i] Logged in!
1[i] Username: ----
1[i] Poke Storage: 250
1[i] Item Storage: 350
1[i] Pokecoin: 0
1[i] Stardust: 100
1[+] There is a Magikarp at 200 meters
1[+] There is a Electabuzz at 200 meters
1[+] There is a Omanyte at 200 meters
1[+] There is a Magikarp at 200 meters
1[+] There is a Electabuzz at 200 meters
1[+] There is a Omanyte at 200 meters
1[+] There is a Magikarp at 200 meters
^C
d-pollard commented 7 years ago

Plus, these are not the pokemon that you can immediately catch.

filharvey commented 7 years ago

Yep all Pokemon in a radius show up at 200m. This is like 3 stars in the game. You still need to get closer for them to turn up

WillXu15 commented 7 years ago

hb.cells.WildPokemon will give you pokemon close by and get their gps coords.

dougiefresh49 commented 7 years ago

@WhataShane like @filharvey stated, 200m is equivalent to the 3 stars (or footprints) in the game. There is some bug in the game currently that all the pokemon on the radar show up as 3 footprints away, which might have something to do with it.

here is an article about the glitch

WhataShane commented 7 years ago

Understood, thanks everyone. I'll try using hb.cells.WildPokemon in its place and report back.

WhataShane commented 7 years ago

In lieu of a new Pokemon species, I'm now encountering a new problem instead.
My script, made to print the Pokemon available in the surrounding area (using WildPokemon), seems to only work when I set my location to popular places like the Santa Monica Pier or Times Square. Otherwise, when it's set to locations like the street I live on, it prints absolutely nothing, bar the heartbeat notification. Is this a kink in the api? Or is my search radius simply not large enough to detect the surrounding Pokemon?

Assuming the latter: I was under the impression that WildPokemon would reveal all Pokemon in a larger radius than NearbyPokemon, but I suppose this is not the case. I take it the only way to map out the locations of all the local Pokemon is to write an algorithm that has my character move in circles that gradually grow in size. Has something like this already been developed?

I'm not sure it makes much of a difference in this use case, but I switched over to @d-pollard's fork of the api. (thanks for ES6!)

Edit: Just stumbled upon the nearby Pokemon function found in this https://github.com/Daplie/node-pokemap/blob/master/index.js ... They don't seem to have a script implemented that moves their character around. Why are they able to register these Pokemon?