for (var i = 0; gran [i] != undefined; i++) 
{if (gran [i] [4] != false)
{if (gran [i] [1] > gran [i] [2]) {gran [i] [2] = Math.min(5+gran [i] [2],gran [i] [1]);} 
if (gran [i] [1] < gran [i] [2]) {gran [i] [2] = 0;}
if (gran [i] [1] == gran [i] [2] && gran [i] [2] != 0) {grenadeThrow();}}
if (gran [i] [0] != false)
{if (gran [i] [3].isAlive() == true) {if (time.time >= gran [i] [5]) {gran [i] [6] = gran [i] [3].getPosition();
function lol() {var projectile = effect.spawnParticle("largesmoke", 0, 0, 0, 0, 0, 0);
	projectile.setPosition(gran [i] [6].x - 0.5 + Math.random()*1, 
	gran [i] [6].y+Math.random()*1, gran [i] [6].z - 0.5 + Math.random()*1);
	projectile.setVelocity(0.5-Math.random()*1, Math.random()*0.5, 0.5-Math.random()*1);
	projectile.collidesWithClipBlocks = false;} for (var j = 0; j < 40; j++) {lol();}
damageHim = gran [i] [3].getEntitiesWithinRange(8);
for (var ii = 0; ii < damageHim.length; ii++) {damageFound = damageHim[ii]; damagePos = damageFound.getPosition();
damageFound.attackEntityFrom(gran [i] [3], Math.max(16-Math.sqrt(Math.pow(gran [i] [6].x-damagePos.x,2)+
Math.pow(gran [i] [6].y-damagePos.y,2)+Math.pow(gran [i] [6].z-damagePos.z,2))*2,0));}
effect.explode(gran [i] [3], gran [i] [6].x, gran [i] [6].y, gran [i] [6].z, 0.1, true);
gran [i] [3].setDead(); gran [i] [0] = false; gran [i] [4] = false;}}}}