//Poison Mummy v1.0 by Renounce4: Edited by Clubber
//Change these variables to configure the mummy
var PoisonMummy_Strength = 13 //how much damage is dealt on contact (4 = 1 heart)
var PoisonMummy_Speed = .25 //how fast the mummy moves (1 is player speed)
var PoisonMummy_Health = 255 //how much health the mummy has (4 = 1 heart)
var PoisonMummy_Chance = 3 //percent of the time the mummy will spray poison
var PoisonMummy_Poison = 2 //how much damage the poison deals
var PoisonMummy_Range = 2 //!HALF THE WIDTH! of the cube of poison made by the mummy
var PoisonMummy_Length = 40 //amount of time in ticks that the poison will stay after being sprayed (20 ticks = 1 second)

//Do not change the values below
var plength = PoisonMummy_Length
for(var m = 0;m < spawnedEntities.length;m++) {
	var ent = spawnedEntities[m]
	ent.setTexture("/mob/Mummy.png")
	ent.setAttackStrength(PoisonMummy_Strength)
	ent.setMoveSpeed(PoisonMummy_Speed)
	ent.setMaxHealth(PoisonMummy_Health)
	ent.setHealth(PoisonMummy_Health)
}

PoisonSpray = function(poicx,poicy,poicz,PoisonMummy_Range,ent,PoisonMummy_Poison) {
	ppos = player.getPosition()
	for(var poix = poicx - PoisonMummy_Range;poix <= poicx + PoisonMummy_Range;poix++) {
		for(var poiy = poicy - PoisonMummy_Range;poiy <= poicy + PoisonMummy_Range;poiy++) {
			for(var poiz = poicz - PoisonMummy_Range;poiz <= poicz + PoisonMummy_Range;poiz++) {
				nrand = Math.random()
				effect.spawnParticle("reddust",poix+(nrand-.25),poiy+(nrand-.3),poiz+(nrand-.15),-1,.1,0)
				if(ppos.x >= poicx - PoisonMummy_Range && ppos.x <= poicx + PoisonMummy_Range && ppos.y >= poicy - PoisonMummy_Range && ppos.y <= poicy + PoisonMummy_Range && ppos.z >= poicz - PoisonMummy_Range && ppos.z <= poicz + PoisonMummy_Range) {
					player.attackEntityFrom(ent,PoisonMummy_Poison)
				}
			}
		}
	}
}

pchange = function() {
	plength = PoisonMummy_Length
}

var k = [];

for (var i = 0; i < spawnedEntities.length; i++) {
    k[i] = 0;
}

function drop(ent) {
    var heartChance = (player.getMaxHealth() / player.getHealth()) / 10;
    if (player.getHealth() == player.getMaxHealth()) {
        heartChance = 0;
    }
    if (Math.random() <= heartChance || player.getHealth() < 6) {
        ent.dropItem(Item(459));
        return;
    }
	 return;
}