Giter VIP home page Giter VIP logo

Comments (9)

agarioBotDev avatar agarioBotDev commented on May 22, 2024

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

from agario-client.

pulviscriptor avatar pulviscriptor commented on May 22, 2024

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.

from agario-client.

agarioBotDev avatar agarioBotDev commented on May 22, 2024

@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

from agario-client.

pulviscriptor avatar pulviscriptor commented on May 22, 2024

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.

from agario-client.

agarioBotDev avatar agarioBotDev commented on May 22, 2024

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 👍

from agario-client.

pulviscriptor avatar pulviscriptor commented on May 22, 2024

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

from agario-client.

agarioBotDev avatar agarioBotDev commented on May 22, 2024

thanks, works

from agario-client.

agarioBotDev avatar agarioBotDev commented on May 22, 2024

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

from agario-client.

pulviscriptor avatar pulviscriptor commented on May 22, 2024

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.

from agario-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.