agar.io-clone
agar.io-clone copied to clipboard
Help
where is the eject mass loss code I am asking because I am making a self feed server where you can fire unlimited food
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
});
}
}
});
Which line from 417 to 445
This person made it 100% clear how this works
@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.