var p = entity.getPosition();
var target = entity.getEntitiesWithinRange(2.5);
var h = entity.getHealth();

entity.pathToEntity(player);

if(entity.getHealth() <= 4)
{
	mTSB.texture = "/models/mob/SlugNoFlames2.png";
	entity.setMoveSpeed(0.6);
}
else
{
	for (var i=0; i<10; i++) // Création es particules
	{
		var tx = entity.position.x + ((Math.random() * 2) - 1.5);
		var ty = entity.position.y + ((Math.random() * 1.5)+0.5);
		var tz = entity.position.z + ((Math.random() * 2) - 1);

		effect.spawnParticle("flame", tx, ty, tz, 0.02, 0.02, 0.02);
	}	
	entity.setMoveSpeed(0.2);
}

var pPos = player.getPosition();
var angle = Math.atan2(p.z - pPos.z, p.x - pPos.x); // Se met face au joueur
angle = (angle / Math.PI) * 180;
angle += 90;
entity.setRotation(angle, entity.rotation.pitch);

for(var j = 0; j < target.length; j++) // Attaque le joueur
{
	var entj = target[j];
	if (entj.getClassType() == "Player" && h > 4)
	{
		player.setFireLevel(200)
		player.attackEntityFrom(player, 4);
		entity.setVelocity(0.1, 0.1, 0.1);
	}
	else if(entj.getClassType() == "Player" && h <= 4)
	{
		player.attackEntityFrom(player, 2);
	}
}

