Skip to content
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

question about nickname #35

Closed
agarioBotDev opened this issue Dec 1, 2015 · 9 comments
Closed

question about nickname #35

agarioBotDev opened this issue Dec 1, 2015 · 9 comments

Comments

@agarioBotDev
Copy link

hey Dude !

your script is very usefull for me, but i really tried hard to get the nickname from the other balls around
, adding sth to the appear in agario-client.js....is there a way to get the nickname of a ball, or is it anywhere stored in the packet? (i don't mean the nickname of your bots) i want them to go into sb, when appear

thanks,
David

@agarioBotDev
Copy link
Author

or how is it possible to get the x and y coordinate of my cell in the browser ?
can't find something usefull...

@pulviscriptor
Copy link
Owner

I'm not sure i correctly understood your question. Don't know that is adding sth to the appear and i want them to go into sb but i will try.

nickname from the other balls around

If you want really "around" balls, lets count this like "balls on screen".
Balls objects have ball.visible property, which shows is ball visible on screen, and ball.name which have nickname of player, if he set his nickname.
So here is code for examples/basic.js that will show all nicknames around you after 5 seconds.

setTimeout(function(){ //timer for 5 seconds
    console.log('SEARCHING FOR BALLS AROUND ME!');
    for(var ball_id in client.balls) {
        if(!client.balls.hasOwnProperty(ball_id)) continue; //prototype can get in the way

        var ball = client.balls[ball_id];
        if(!ball.visible) continue; //this ball is not on the screen
        if(!ball.name)    continue; //this ball don't have a nickname
        if(ball.mine)     continue; //this is our ball

        console.log('I see ball with nickname near me! ID ' + ball_id + ' and nickname ' + ball.name);
    }
}, 5000);

example
You can find full list of properties in readme

how is it possible to get the x and y coordinate of my cell in the browser

Can't help with that. I code my own lib without using original code from browser. I don't know where and what stored there.

@agarioBotDev
Copy link
Author

@pulviscriptor that's exactly what i want, but don't know why it doesn't work for me (picture above)...and how can i add this to multiple ?
error

@pulviscriptor
Copy link
Owner

Also here is code for ballAppear event

client.on('ballAppear', function(ball_id) {
    var ball = client.balls[ball_id];
    if(ball.name) console.log('NEW BALL WITH NICKNAME APPEARED! ID ' + ball_id + ', nickname ' + ball.name);
});

agarioBotDev, i pasted code to end of the file basic.js. Maybe you pasting it in wrong place. Show me your basic.js where you pasted code.

how can i add this to multiple

Its up to you, i don't know where you want it.

@agarioBotDev
Copy link
Author

error
ok the timer works now, the ballAppear event not, don't know why...
i added this to the multiple.js:

bot.client.on('ballAppear', function (ball_id) {
            var ball = client.balls[ball_id];
            if (ball.name == "somone") console.log('NEW BALL WITH NICKNAME APPEARED! ID ' + ball_id + ', nickname ' + ball.name);
        });

what i'm doing wrong ?

PS: thanks for your great help 👍

@pulviscriptor
Copy link
Owner

Try to replace
var ball = client.balls[ball_id];
with
var ball = bot.client.balls[ball_id];

@agarioBotDev
Copy link
Author

thanks, works

@agarioBotDev
Copy link
Author

one last question...
do you have an idea why this doesn't work ?

bot.client.on('ballAppear', function (ball_id) {
            var ball = bot.client.balls[ball_id];
            if (ball.name == "[Dm] Master")
            {
                console.log('Master appeared !');
                bot.interval_id = setInterval(function () { bot.recalculateTarget() }, 1000000000); // to give the bot enough time to move to me --> next line
                bot.client.moveTo(ball.x, ball.y);                                                  // here the bot have to move to me, but it doens't work, he still search for this little pieces...?
            }

        });

PS: it displays the message, so the event work fine

@pulviscriptor
Copy link
Owner

I don't know what is wrong there, but i see what you trying to do.
You can choose easier way to do this.
You can just modify recalculateTarget() and add just one line to it

            var ball = bot.client.balls[ball_id];
            if(ball.virus) continue;
            if(!ball.visible) continue;
            if(ball.mine) continue;
            if(ball.name == 'yourname') return bot.client.moveTo(ball.x, ball.y); //add this line here
            if(ball.size/my_ball.size > 0.5) continue;

Didn't tested, but should work.
This is not most correct way to do it, but it will work for you i think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants