var sk = 0; var sk = [0]; var pos; var created = 1;
var spawned = -1; var explode = 0; var peaceful = false;
var random_max = 30; 
var random_1 = 0; var random_2 = 26;  var itemID_1 = 261; var itemMin_1 = 1; var itemMax_1 = 1; var itemDmg_1 = 0;
var random_3 = 4; var random_4 = 24;  var itemID_2 = 262; var itemMin_2 = 0; var itemMax_2 = 8; var itemDmg_2 = 0;
var random_5 = 4; var random_6 = 20;  var itemID_3 = 2003; var itemMin_3 = 0; var itemMax_3 = 7; var itemDmg_3 = 0;
var random_7 = 0; var random_8 = 14;  var itemID_4 = 352; var itemMin_4 = 1; var itemMax_4 = 2; var itemDmg_4 = 0;
var random_9 = 0; var random_10 = 0;  var itemID_5 = 0; var itemMin_5 = 0; var itemMax_5 = 0; var itemDmg_5 = 0;

var shealth = 22; var moveSpeed = 0.8;
var texture = "mob/desert_skeleton.png"; var damageSound = "";
var power = 1.5; var itemHeldID = 0;

for (var i = 0; spawnedEntities != null &&  i < spawnedEntities.length; i++) {var ent = spawnedEntities[i];
if (peaceful != true) {ent.setAttackStrength(power);} ent.setTexture(texture);
ent.setMaxHealth(shealth); ent.setMoveSpeed(moveSpeed); 
ent.setHealth(ent.getMaxHealth()); ent.pathToEntity(player);
var healthcare = ent.getHealth();
if (itemHeldID != 0) {ent.setHeldItem(Item(itemHeldID));}}

function everyTick() {var epos = ent.getPosition(); var pos = player.getPosition(); var rot = player.getRotation();
var distance = Math.floor(Math.sqrt(Math.pow(epos.x-pos.x,2)+Math.pow(epos.y-pos.y,2)+Math.pow(epos.z-pos.z,2)));
var rand = Math.random()*5; if (distance < 5 && rand > 4.8 && ent.onGround == true) 
{switch (Math.floor(rand*10)/10)
{case 4.8: ent.addVelocity(Math.cos((rot.yaw+80)/57.32)/4,0.4,Math.sin((rot.yaw+80)/57.32)/4); break;
case 4.9: ent.addVelocity(Math.cos((rot.yaw+260)/57.32)/2,0.6,Math.sin((rot.yaw+260)/57.32)/2); break;}}

if (healthcare != 0 && healthcare != ent.getHealth()) {healthcare = ent.getHealth();
switch (Math.round(rand))
{case 0: case 1: case 2: ent.addVelocity(Math.cos((rot.yaw+300)/57.32)/2,0.1,Math.sin((rot.yaw+300)/57.32)/2); break;
case 3: case 4: case 5: ent.addVelocity(Math.cos((rot.yaw+220)/57.32)/2,0.1,Math.sin((rot.yaw+220)/57.32)/2); break;}
if (damageSound != "") {sound.playSoundUI(damageSound);}}}