agar.io-clone icon indicating copy to clipboard operation
agar.io-clone copied to clipboard

Help

Open Faris90 opened this issue 7 years ago • 4 comments

where is the eject mass loss code I am asking because I am making a self feed server where you can fire unlimited food

Faris90 avatar Jun 30 '17 15:06 Faris90

I think it is in server/server.js from lines 417 to line 445:

    socket.on('1', function() {
        // Fire food.
        for(var i=0; i<currentPlayer.cells.length; i++)
        {
            if(((currentPlayer.cells[i].mass >= c.defaultPlayerMass + c.fireFood) && c.fireFood > 0) || (currentPlayer.cells[i].mass >= 20 && c.fireFood === 0)){
                var masa = 1;
                if(c.fireFood > 0)
                    masa = c.fireFood;
                else
                    masa = currentPlayer.cells[i].mass*0.1;
                currentPlayer.cells[i].mass -= masa;
                currentPlayer.massTotal -=masa;
                massFood.push({
                    id: currentPlayer.id,
                    num: i,
                    masa: masa,
                    hue: currentPlayer.hue,
                    target: {
                        x: currentPlayer.x - currentPlayer.cells[i].x + currentPlayer.target.x,
                        y: currentPlayer.y - currentPlayer.cells[i].y + currentPlayer.target.y
                    },
                    x: currentPlayer.cells[i].x,
                    y: currentPlayer.cells[i].y,
                    radius: util.massToRadius(masa),
                    speed: 25
                });
            }
        }
    });

vikramdurai avatar Jul 01 '17 06:07 vikramdurai

Which line from 417 to 445

Faris90 avatar Jul 01 '17 12:07 Faris90

This person made it 100% clear how this works

ghost avatar Aug 02 '17 23:08 ghost

@Faris90 Your question was "where is the eject mass loss code". That whole thing IS the "eject mass loss code". If you can read English, surely you can read the English of the source code? Do you know what a FOR command is? What an IF or ELSE command does? Do you even know how to program? Or are we going to have to help you learn that too? The code above (yes, the whole code) loops through every cell, checking to see if it has enough mass, and removes mass from each one before adding an ejected mass. Do you know what a "-=" operator does? You might want to look into that if you want to accomplish what you're looking to do.

Ayelis avatar Nov 13 '17 07:11 Ayelis