pinv = player.getInventory(); var wing = 0; var timing = 0; var ent1; quantity = 0; btool = 0;
gran = [[false, 0, 0, 0, false, time.time+60]]; netA = [[false, 0, 0, 0, false, false, 0, 0, 0]];
rotCheck = player.getRotation(); posChk = pos = player.getPosition(); debugMode = false; 
arrowA = [[false, 0, 0, 0, false, 0, 0]]; timeWaited = 1; hitBlock = Vec3(0, 0, 0); slot = Item(1);
//[0] isShot, [1] shotTrigger, 
function sleep() {sleeping = 0;} function readItems() {}; keyIDCheck = [];
function chatFunc() {chatText = "";} function chatEnd() {chatText = "";}
blockHP = 0; blockName = ""; blockMaxHP = 0; script.runScript("prices.js");
blockx = 0; blocky = 0; blockz = 0; world.triggerBlock(92, 67, -176);
antiKill = [[Vec3(96,78,-126), Vec3(27,63,-57), 17, 0], [Vec3(205,56,-109), Vec3(285,43,-142), 17, 0]];
book = [[false, 1, 14, 1], [false, 6, 7, 6]]; areaUPcheck = 1;
// Array (Is shown [0], Min Pages [1], Max Pages [2], Current Page [3]) // book [Book #] [var]
script.runScript("restore Arrays.js"); shopChange = 0; getBlock2 = 0; getBlock = 0;
cheated = Math.floor(cheated); sTiming = 0;
script.runScript("customFonts.js"); shopOpen = ["", false];
font = new UICustomFont("/font/newFont.png", 8, UIDefaultCharWidths);
label = new UICustomLabel("", 0, 18, font, Color(1.0, 1.0, 1.0));
if (handfull == 0) {world.triggerBlock(284, 46, -121);}

function random(val) {
	return Math.random()*val;
}

function getPrice(amount, k, j, amplifier, val1, val2, val3) {
	valueRatio = val1 + Math.max(val2 - Math.sqrt(amount)/val3, 0);
	return prices [k] [j] [1]/prices [k] [j] [0] * valueRatio * amplifier;
}

function actionTime(val) {
	if (timing > val) {timing = 0; return true;} 
	else {return false;}
}

function wasKeyPressed(keyID) {
	for (i = 0; i < keyIDCheck.length; i++) if (keyID == keyIDCheck[i]) {return false;}
	return (keyboard.isKeyDown(keyID));
}

function isKeyActive(keyID, cooldown) {
	if (wasKeyPressed(keyID)) {timing = 0; return true;}
	return (keyboard.isKeyDown(keyID) && actionTime(cooldown));
}

function checkPointInBounds(vec, vecMin, vecMax) {
	trueVecMin = Vec3(Math.min(vecMin.x, vecMax.x), Math.min(vecMin.y, vecMax.y), Math.min(vecMin.z, vecMax.z));
	trueVecMax = Vec3(Math.max(vecMin.x, vecMax.x), Math.max(vecMin.y, vecMax.y), Math.max(vecMin.z, vecMax.z));
	return (vec.x >= trueVecMin.x && vec.y >= trueVecMin.y && vec.z >= trueVecMin.z 
		&& vec.x <= trueVecMax.x && vec.y <= trueVecMax.y && vec.z <= trueVecMax.z);
}

function checkPointInRange(vec, target, range) {
	return (vec.distance(target) < range);
}

function dash() {
	if (maxSpeed*1.4 > currentSpeed) {
		ii = Math.sqrt(Math.sqrt(Math.pow(1 - (burden/maxBurden)/2, 2)));
		player.setMoveSpeed(player.moveSpeed*2 + speed*2);
	} 
	if (random(10)*((burden/maxBurden)/2 + 1) >= 9) 
	energy -= energyGenerate*2;
}

function get_items() {
	for (i = 0; i < 3; i++) for (ii = 0; craftNeed [i] [ii] != undefined; ii++) {craftNeed [i] [ii] [4] = 0;}
	for (ii = 0; ii <= 35; ii++) {
		item_check = pinv.getItemInSlot(ii);
		for (i = 0; item_check != null && i < 4 && craftNeed [collumnShow] [i] [1] != 0; i++) {
			if (item_check.itemID == craftNeed [collumnShow] [i] [1] && 
			(item_check.damage == craftNeed [collumnShow] [i] [3] || craftNeed [collumnShow] [i] [3] == -1)) {
				craftNeed [collumnShow] [i] [4] += item_check.quantity; 
				if (craftNeed [collumnShow] [i] [2] <= craftNeed [collumnShow] [i] [4] && craftNeed [collumnShow] [i] [0] == false) 
				{craftNeed [collumnShow] [i] [0] = 1; craftList += 1;}
			}
		}
	}

	if (craftList >= i && craftLevel [collumnShow] <= craftingLevel) {
		pinv.addItem(Item(craftGet [0], craftGet [1], craftGet [2])); chat.print(craftSpeech); 
		if (schem_over) {crafting_xp += craftXP} else {cooking_xp += craftXP};
		if (specialDrop[collumnShow].itemID != 0) {pinv.addItem(specialDrop[collumnShow]);} 
		for (i = 0; craftNeed [collumnShow] [i] != undefined; i++) {
			if (craftNeed [collumnShow] [i] [3] != -1) {
				pinv.consumeItemAmount(craftNeed [collumnShow] [i] [1], craftNeed [collumnShow] [i] [3], craftNeed [collumnShow] [i] [2]);
			} else {
				for (ii = 0; ii < craftNeed [collumnShow] [i] [2]; ii++) {pinv.consumeItemAmount(craftNeed [collumnShow] [i] [1]);}
			}
		}
	} else {
		if (craftLevel [collumnShow] > craftingLevel) 
		{chat.print("My " + ((schem_over) ? "crafting" : "cooking") + " knowledge is too low to craft this");}
		else {chat.print("I don't have enough resources to craft this");}
	}
}

function readItems() {
	for (j = 0; j < 3; j++) {
		for (ii = 0; ii <= 35; ii++) {
			item_check = pinv.getItemInSlot(ii);
			if (item_check != null) {for (i = 0; craftNeed [j] [i] != undefined; i++) {
			if (item_check.itemID == craftNeed [j] [i] [1] && (item_check.damage == craftNeed [j] [i] [3] || craftNeed [j] [i] [3] == -1)) 
			{craftNeed [j] [i] [4] += item_check.quantity;}}}
		}
		for (i = 0; craftNeed [j] [i] != undefined; i++) for (ii = 0; ii <= 35; ii++) {
			craftCase [j] [i].text = craftNeed [j] [i] [4] + "/" + craftNeed [j] [i] [2];
			craftCase [j] [i].blue = 0; craftCase [j] [i].red = (craftNeed [j] [i] [4] < craftNeed [j] [i] [2]) ? 1 : 0; 
			craftCase [j] [i].green = (craftNeed [j] [i] [4] < craftNeed [j] [i] [2]) ? 0 : 1;
			if (craftNeed [j] [i] [2] == 0) {craftCase [j] [i].red = 1; craftCase [j] [i].green = 1; craftCase [j] [i].blue = 1;}
		}
		craftCase [j] [4].text = craftingLevel + "/" + craftLevel[j]; craftCase [j] [4].blue = 0;
		craftCase [j] [4].red = (craftingLevel < craftLevel[j]) ? 1 : 0; craftCase [j] [4].green = (craftingLevel < craftLevel[j]) ? 0 : 1;
	}
}

width = ui.getWidth(); height = ui.getHeight(); healing = 0;
energyLabelHP = 	UISprite("gui/energyHBar.png", 	width - 120, height - 30, 120, 40, 0, 0);
energyLabel = 		UISprite("gui/energyBar.png", 	width - 120, height - 30, 120, 40, 0, 0);
energyAmount = 		UILabel(maxEnergy, 10, height - 20);
eatingLabel = 		UISprite("gui/eatMeter.png", 	width/2 - 21, height/2 - 21, 43.5, 43.5, 0, 0);
netLabel = 			UISprite("gui/fishingSlot.png", width/2 - 12, height/2 - 92, 24, 24, 0, 0); 	netLabel.alpha = 0;
netItemLabel = 		UISprite("gui/items.png", 		width/2 - 8, height/2 - 88, 16, 16, 0, 0); 		netItemLabel.alpha = 0;
throwingLabel = 	UISprite("gui/throwMeter.png", 	width/2 - 70, 60, 130, 40, 0, 0); 				throwingLabel.alpha = 0;
throwingLabelHP = 	UISprite("gui/throwMeter2.png", width/2 - 70, 60, 130, 40, 0, 0); 				throwingLabelHP.alpha = 0;
throwingItem = 		UISprite("gui/items.png", 		width/2 - 67, 65, 16, 16, 16, 16); 				throwingItem.alpha = 0;
torchLabel = 		UISprite("gui/torchMeter.png", 	width/2 - 50, height/2 - 30, 16, 45.5, 0, 0); 	torchLabel.alpha = 0;
hungerLabelHP =		UISprite("gui/hungerHBar.png", 4, height - 30, 120, 40, 0, 0);
hungerLabel = 		UISprite("gui/hungerBar.png", 4, height - 30, 120, 40, 0, 0);
hungerAmount = 		UILabel(maxHunger, 10, height - 20);
breakLabelHP = 		UISprite("gui/break_me2.png", 	width/2 - 25, height/2 - 30, 50, 120, 0, 0); 	breakLabelHP.alpha = 0;
breakLabel = 		UISprite("gui/break_me.png", 	width/2 - 25, height/2 - 35, 50, 120, 0, 0); 	breakLabel.alpha = 0;
gardenLabel = 		UISprite("gui/flowerGrow.png", 	width/2 - 108, height/2 - 83, 256, 120, 0, 0);
waterAmount = 		UILabel(waterpower, width/2 - 102, height/2 - 74);
sunAmount = 		UILabel(sunpower, width/2 + 102, height/2 - 74);
coinLabel = 		UISprite("gui/coinbar.png", 	width - 105, 4, 256, 256, 0, 0);
coinAmount = 		UILabel(coins, width - 64, 8); coinAmount.centered = true;
clockLabel = 		UISprite("gui/NPC/clock.png", 	width - 32, 40, 256, 256, 0, 0);
clockAmount = 		UILabel(coins, width - 13, 51); clockAmount.centered = true;
clockAmount.red = 0; clockAmount.green = 0; clockAmount.blue = 0; clockAmount.shadow = false; 

armorV = [[298, 2, 0.15, 0, 1], [299, 5, 0.5, 0, 2], [300, 4, 0.3, 0, 3], [301, 2, 0.15, 0, 4],
[302, 3, 0.2, 0, 1], [303, 9, 0.6, 0, 2], [304, 7, 0.4, 0, 3], [305, 3, 0.2, 0, 4],
[306, 5, 0, 0.15, 1], [307, 16, 0, 0.5, 2], [308, 13, 0, 0.3, 3], [309, 4, 0, 0.15, 4],
[310, 12, 0.15, 0.15, 1], [311, 35, 0.5, 0.5, 2], [312, 28, 0.3, 0.3, 3], [313, 10, 0.15, 0.15, 4],
[314, 6, 0, 0.2, 1], [315, 18, 0, 0.6, 2], [316, 14, 0, 0.4, 3], [317, 5, 0, 0.2, 4]]
//ArmorV [ItemID [0], Defense [1], LightXP [2], HeavyXP [3], BodyPart [4] (1 - head, 2 - chest...)]
armorCase = UISprite("gui/armorCond.png", 5, height/2 + 30, 25.5, 47.5, 0, 0);
armorBody = []; for (i = 1; i < 13; i++)
{armorBody [i] = UISprite("gui/armorCond.png", 5, height/2 + 30, 25.5, 47.5, Math.floor(i/5)*25.5, i%5*47.5);}
sourceLabel = UISprite("gui/repairSource.png", width/2 - 130, height/2 - 40, 96, 96, 0, 0);
sourceLabel2 = UISprite("gui/repairSource.png", width/2 - 130, height/2 - 40, 96, 96, 96, 0);
sourceAmount = [UILabel(0, width/2 - 78, height/2 - 27), UILabel(0, width/2 - 78, height/2 - 8),
UILabel(0, width/2 - 78, height/2 + 11.5), UILabel(0, width/2 - 78, height/2 + 31),
UILabel(0, width/2 + 90, height/2 - 27), UILabel(0, width/2 + 90, height/2 - 8),
UILabel(0, width/2 + 90, height/2 + 11.5), UILabel(0, width/2 + 90, height/2 + 31)]
sourceLabel.alpha = 0; sourceLabel2.alpha = 0; 
for (i = 0; sourceAmount [i] != undefined ; i++) 
{sourceAmount [i].centered = true; sourceAmount [i].alpha = 0;}

levelAchiev = true;
levelAmount = UISprite("gui/skillPage.png", width/2 - 129, 9, 256, 256, 0, 0);
skillShow = [[0, 0, 0, "gui/fishingBolder.png", "gui/fishingBolder2.png", 1],
[0, 0, 0, "gui/swordBolder.png", "gui/swordBolder2.png", 1],
[0, 0, 0, "gui/bluntBolder.png", "gui/bluntBolder2.png", 1],
[0, 0, 0, "gui/harvestingBolder.png", "gui/harvestingBolder2.png", 1],
[0, 0, 0, "gui/gardeningBolder.png", "gui/gardeningBolder2.png", 1],
[0, 0, 0, "gui/cookingBolder.png", "gui/cookingBolder2.png", 1],
[0, 0, 0, "gui/smithingBolder.png", "gui/smithingBolder2.png", 1],
[0, 0, 0, "gui/miningBolder.png", "gui/miningBolder2.png", 1],
[0, 0, 0, "gui/woodcutBolder.png", "gui/woodcutBolder2.png", 1],
[0, 0, 0, "gui/craftingBolder.png", "gui/craftingBolder2.png", 1],
[0, 0, 0, "gui/lightBolder.png", "gui/lightBolder2.png", 1],
[0, 0, 0, "gui/heavyBolder.png", "gui/heavyBolder2.png", 1],
[0, 0, 0, "gui/diggingBolder.png", "gui/diggingBolder2.png", 1],
[0, 0, 0, "gui/unarmedBolder.png", "gui/unarmedBolder2.png", 1],
[0, 0, 0, "gui/rangeBolder.png", "gui/rangeBolder2.png", 1],
[UILabel(main_xp, width/2 + 50, 31), UISprite("gui/levelBar.png", width/2 - 44, 21, 83, 40, 0, 0),
UILabel(player.getHealth(), width/2 + 10, 28), UILabel(wholeA, width/2 - 76, 40),
UILabel(burden, width/2 + 90, 28), UILabel(burden, width/2 + 70, 28)]];

for (i = 0; i < mS; i++) {skillShow [i] [0] = UISprite(skillShow [i] [3], i*70, height/2 - 70, 256, 256, 0, 0);
skillShow [i] [1] = UISprite("gui/skillBar.png", i*70, height/2 - 70, 256, 256, 0, 0);
skillShow [i] [2] = UILabel(skillVar [i] [0], 52, height/2 - 57);}

bookCase = UISprite("gui/books/bookCase.png", width/2 - 129, height/2 - 100, 256, 256, 0, 0);
bookShow = UISprite("gui/books/bookPage"+book [0] [3]+".png", width/2 - 129, height/2 - 100, 256, 256, 0, 0);
bookPG0 = UILabel(book [0] [3] - 1, width/2 - 95, height/2 + 47);   //bookPG0.centered = true;
bookPG1 = UILabel(book [0] [3], width/2, height/2 + 35); 			//bookPG1.centered = true;
bookPG2 = UILabel(book [0] [3] + 1, width/2 + 95, height/2 + 50);   //bookPG2.centered = true;

mainPageShow = UISprite("customCrafting/craftPage.png", width/2 - 129, 9, 256, 256, 0, 0);
pageShow = UISprite("customCrafting/craftPage"+activeCraftPG+".png", width/2 - 129, 9, 256, 256, 0, 0);
craftFrame = UISprite("customCrafting/showCase.png", width/2 - 92, 32, 124, 160, 0, 0); 
craftPG = new Array (UILabel(0, 0, 0), UILabel(0, 0, 0), UILabel(0, 0, 0)); craftCase = new Array(0, 0, 0);
for (i = 0; i < 3; i++) {
	craftPG[i] = UILabel(craftPG - 1, width/2 - 95 + 95*i, height - 50); craftPG[i].centered = true;
	labelWidth = width/2 - 69 + 70*i;
	craftCase[i] = new Array (UILabel(0 + "/" + 0, labelWidth, height - 140),
	UILabel(0 + "/" + 0, labelWidth, height - 120), UILabel(0 + "/" + 0, labelWidth, height - 100),
	UILabel(0 + "/" + 0, labelWidth, height - 80), UILabel(0 + "/" + 0, labelWidth, height - 65));
}
craftItem = UILabel("", width/2 + 8, height/2 - 110); craftItem.centered = true;
craftItemPNG = UISprite("gui/items.png", width/2, height/2 - 116, 16, 16, 0, 0);
if (recipe_over || schem_over) {script.runScript((recipe_over) ? "customCooking.js" : "customCrafting.js");}
openCraftBook = UISprite("gui/items.png", width/2 - 8, height/2 - 8, 16, 16, 16*5, 16*13); openCraftBook.alpha = 0;
openCraft = UISprite("gui/gui.png", width/2, height/2, 16, 16, 0, 16*7); openCraft.alpha = 0;

hb2 = UISprite("gui/healthbar.png", width/2 - 96, height - 32, player.health/player.maxHealth*78, 124, 0, 0);
hb = UISprite("gui/healthbar_2.png", width/2 - 96, height - 32, 124, 124, 0, 0);
sb = UISprite("gui/fishing_skill.png", width/2 - 124, height/2 - 144 + skill_inc, 248, 124, 0, 0); sb.alpha = 0;
sb2 = UILabel("Skill", 0, 0); sb2.alpha = 0;

hb4 = UISprite("gui/healthbar_4.png", width/2 - 94, height/2 - 80, blockHP/blockMaxHP*80, 124, 0, 0);
hb5 = UISprite("gui/healthbar_4.png", width/2 - 94, height/2 - 80, blockHP/blockMaxHP*80, 124, 0, 0); hb5.green = hb5.red = 0.5; hb5.alpha = 0;
hb3 = UISprite("gui/healthbar_3.png", width/2 - 94, height/2 - 80, 174, 124, 0, 0);
blockLabel = UILabel(blockName, width/2 + 2, height/2 - 62); blockLabel.centered = true;

fp2 = UISprite("gui/Firepower.png", width/2 - 112, height/2 - 80, fireHP/fireMaxHP*180, 124, 0, 0);
fp = UISprite("gui/firepower_2.png", width/2 - 112, height/2 - 80, 200, 124, 0, 0);
firepowerLabel = UILabel(firepower, width/2 - 90, height/2 - 74); firepowerLabel.centered = true;
fireburnLabel = UILabel(fireburn, width/2, height/2 - 62); fireburnLabel.centered = true;
fireItem = UISprite("gui/firepower_2.png", width/2 - 71, height/2 - 79.5, 16, 16, 0, 0); fireItem.alpha = 0;

buildMainPage = UISprite("customCrafting/upgradeB.png", width/2 - 126, height/2 - 120, 256, 256, 0, 0);
buildCase = UISprite("customCrafting/upgradeC.png", width/2 - 92, height/2 - 92, 50, 124, 0, 0);
buildHouse = UISprite("gui/healthbar.png", width/2 - 126, height/2 - 120, 256, 256, 0, 0);
buildNeed = new Array (UILabel(0 + "/" + 0, width/2 + 10, height/2 - 59),
UILabel(0 + "/" + 0, width/2 + 10, height/2 - 33), UILabel(0 + "/" + 0, width/2 + 89, height/2 - 59),
UILabel(0 + "/" + 0, width/2 + 89, height/2 - 33));
buildHave = [0, 0, 0, 0]; for (i = 0; i < 4; i++) {buildNeed [i].centered = true;}

shopMain = UISprite("gui/NPC/shopMain.png", width/2 - 126, height/2 - 134, 256, 256, 0, 0);
shopCases = new Array (); for (i = 0; i < 16; i++) {shopCases [i] = new Array(0, 0); shopCases [i] [0] =
UISprite("gui/NPC/shopCaseDown.png", width/2 - 122 + i%4*63, height/2 - 90 + Math.floor(i/4)*38, 256, 256, 0, 0);
shopCases [i] [1] = UISprite("gui/items.png", shopCases [i] [0].x + 4.5, shopCases [i] [0].y + 5, 16, 16, 0, 0);
shopCases [i] [2] = UILabel(0 + "/" + 0, shopCases [i] [0].x + 39.5, shopCases [i] [0].y + 9);
shopCases [i] [3] = UILabel(0, shopCases [i] [0].x + 15, shopCases [i] [0].y + 14);
shopCases [i] [2].centered = true; shopCases [i] [3].centered = true;}
shopMoney = UILabel(0, width/2 + 100, height/2 + 72);
shopDisplay = UILabel("", width/2, height/2 + 72); shopDisplay.centered = true;
shopInCase = UISprite("gui/NPC/shopInCase.png", width/2 + 48, height/2 - 52, 256, 256, 0, 0);
shopInIcon = UISprite("gui/items.png", 0, 0, 16, 16, 0, 0);
shopInv = UILabel(0, width/2 + 60, height/2 - 26);
shopPage = [UILabel("<" + 0, width/2 - 84, height/2 + 88), UILabel(0 + ">", width/2 + 84, height/2 + 88),
UILabel(0 + "/" + 0, width/2, height/2 + 88)];
shopPage [0].centered = true; shopPage [1].centered = true; shopPage [2].centered = true;

lvlLabel = [UISprite("gui/lvlUP.png", width/2 - 8, height/2 - 8, 22.5, 22.5, 0*22.5, 0*22.5),
UISprite("gui/lvlUP.png", width/2 - 8, height/2 - 8, 22.5, 22.5, 2*22.5, 0*22.5),
UISprite("gui/lvlUP.png", width/2 - 8, height/2 - 8, 22.5, 22.5, 4*22.5, 0*22.5)]; 
lvlLabelActive = 0; lvlLabelRotate = 0;

helpShop = UISprite("gui/help_shop.png", width/2 - 120, height/2 - 50, 256, 256, 0, 0);
helpCraft = UISprite("gui/help_craft.png", width/2 - 80, height/2 - 50, 256, 256, 0, 0);
helpBuild = UISprite("gui/help_build.png", width/2 - 80, height/2 - 50, 256, 256, 0, 0);

//Achievements
achievCount = 18; achievShow = 0; achievShowID = 0; achievCompleted = 0;
achievLabel = []; achievBonusLabel = UILabel("BonusXP - 11%", width - 50, -22);
achievName = UILabel("", width/2, height - 80); achievName.centered = true;
achievClone = [UISprite("gui/achievCase.png", width/2 - 85, -65, 256, 256, 0, 0),
	UISprite("gui/achievements.png", width/2 - 80, -32, 32, 32, (i%8)*32, 32+Math.floor(i/8)*64),
	UISprite("gui/achievements.png", width/2 - 80, -32, 32, 32, 32, 0), 
	UILabel("", width/2 - 50, -22), UILabel("ACHIEVEMENT GAINED:", width/2 - 50, -22)];
achievClone [4].red = 1; achievClone [4].green = 1; achievClone [4].blue = 0;
for (i = 0; i < achievCount; i++) {
	achievLabel [i] = [UISprite("gui/achievements.png", width/2 - 129 + i*24, height/2 + 50, 32, 32, (i%8)*32, 32+Math.floor(i/8)*64),
	UISprite("gui/achievements.png", width/2 - 129 + i*24, height/2 + 50, 32, 32, 32, 0), 0, "", ""];
	if (achievSet [i] == 1) {achievLabel [i] [2] = 2;}
	achievLabel [i] [0].alpha = 0; achievLabel [i] [1].alpha = 0;
}
i = 0;
achievLabel [i] [4] = "NEWBIE SURVIVAL"; 		 achievLabel [i] [3] = "Survive one day/night cycle"; i++;
achievLabel [i] [4] = "FEEL THE RPG'NESS";  	 achievLabel [i] [3] = "Achieve next level"; i++;
achievLabel [i] [4] = "COPPER PURSE"; 			 achievLabel [i] [3] = "Get more than 30 coins"; i++;
achievLabel [i] [4] = "SURFACE CLEANER"; 		 achievLabel [i] [3] = "Destroy at least 100 blocks"; i++;
achievLabel [i] [4] = "PROJECT: SCRATCH"; 		 achievLabel [i] [3] = "First structure upgrade"; i++;
achievLabel [i] [4] = "JOURNEY BEGGINS"; 		 achievLabel [i] [3] = "Buy and use the first map"; i++;
achievLabel [i] [4] = "USEFUlL LENDING"; 		 achievLabel [i] [3] = "Invest 50 coins to shop"; i++;
achievLabel [i] [4] = "TALENT?"; 			     achievLabel [i] [3] = "Reach level 5 in any skill"; i++;
achievLabel [i] [4] = "NOT SOLID ENOUGH"; 		 achievLabel [i] [3] = "Destroy a stone block"; i++;
achievLabel [i] [4] = "CUT OFF HER CLOTHES";	 achievLabel [i] [3] = "Get a block of wool"; i++;
achievLabel [i] [4] = "THE REAL FOOD"; 			 achievLabel [i] [3] = "Get any kind of raw meat"; i++;
achievLabel [i] [4] = "CHICKENMANIA"; 			 achievLabel [i] [3] = "Collect at least 10 eggs"; i++;
achievLabel [i] [4] = "GETTING USED TO IT"; 	 achievLabel [i] [3] = "Survive seven days"; i++;
achievLabel [i] [4] = "WORTH OF A SINGLE COIN";  achievLabel [i] [3] = "Get at least 100 coins"; i++;
achievLabel [i] [4] = "ONLY FOR SELF DEFENSE";   achievLabel [i] [3] = "Get Sword/Blunt up to 5th level"; i++;
achievLabel [i] [4] = "HEAD FULL OF SKILLS";     achievLabel [i] [3] = "Reach 3rd level for 10 skills"; i++;
achievLabel [i] [4] = "STONE AGE?";   			 achievLabel [i] [3] = "Get any kind of stone tool"; i++;
achievLabel [i] [4] = "BRING IT ON";   			 achievLabel [i] [3] = "Get your first peace of armor"; i++;

cheatingSign = UISprite("gui/cheatingSign.png", width/2 - 27, -2, 256, 256, 0, 0);

sleepLabel = UISprite("gui/sleepBar.png", width - 120, height - 30, 120, 20, 0, 0);
dialogueBar = UISprite("gui/dialogueBar.png", 0, height - 44, 0, 44, 0, 0);
dialogueBar2 = UISprite("gui/dialogueBar.png", Math.min(220, width - 201), height - 44, 0, 44, 55, 0);
dialogueFace = UISprite("gui/NPC/unknown.png", 4, height - 40, 50, 50, 0, 0); dialogueFace.alpha = 0;
dialogueText = UILabel("", 46, height - 39); dialogueText.shadow = false;
dialogueText.red = 0; dialogueText.blue = 0; dialogueText.green = 0;
activeDialogueText = UILabel("", 46, height - 39); activeDialogueText.shadow = false;
activeDialogueText.red = 0.5; activeDialogueText.green = 0.4; activeDialogueText.blue = 0.0;
sleepEffect = UISprite("gui/sleepingEffect.png", 0, 0, width, height/4, 0, 0); sleepEffect.alpha = 0;
sleepEffect2 = UISprite("gui/sleepingEffect.png", 0, height-height/4, width, height/4, 0, 0); sleepEffect2.alpha = 0; 
sleepLabelB = UISprite("gui/sleepButton.png", width/2 - 17, height/2 - 15, 36, 30, 0, 0);
sleepAmount = UILabel(waitingTime, width/2 - 0, height/2 - 4); sleepAmount.centered = true;
/* FULLSCREEN */ script.runScript("l_labels.js");
// RETURN ORDINARY BLOCK //
function nonSpecialBlock() {
if (hitBlock != null) 
	{return (blockID == 174 || blockID == 64 || blockID == 54 || blockID == 61 || blockID == 58 || blockID == 69);}
}
// FOOD //
function foodConsume() {
if (nonSpecialBlock()) {eat = 0;}

if (eat == 1 && !(blockID == 206 && (blockMD == 7 || blockMD == 6) && cookable)) {//EAT
	if (pinv.getSlotContainingItem(itemID) != -1) {
		slot = pinv.getItemInSlot(pinv.getSlotContainingItem(itemID)); eatMeter += 1;
		if (eatMeter >= slot.maxDamage) {
			pinv.consumeItem(itemID); slot.damage = 0; eatMeter = 0;
			pHealth = Math.min(pHealth + player.getMaxHealth()*healper/100 + health, player.getMaxHealth()); 
			hunger = Math.max(hunger - dishunger, 0); sound.playSoundUI("sound.burp"); switch (rand) {
			case 0: case 1: case 2: chat.print(chance1); break; case 3: case 4: case 5:   chat.print(chance2); break;
			case 6: case 7: case 8: chat.print(chance3); break; case 9: case 10: case 11: chat.print(chance4); break;}
		} else {
			i = eatMeter/slot.maxDamage; eatingLabel.u = 43.5*Math.floor((i*15)/5); eatingLabel.v = 43.5*Math.floor((i*15)%5);
			if (sTiming > 3) {sTiming = 0; j = Math.ceil(Math.random()*3); sound.playSoundUI("sound.eat");}
		}
	}
} else if (blockID == 206 && (blockMD == 7 || blockMD == 6) && cookable) {//OVEN
	if (cookDropAmount == undefined) {cookDropAmount = 1;}
	for (i = 0; fireArray [i] != undefined && fireArray [i] [0] == true; i++) {fireVec = fireArray [i] [1];
		if (fireVec [0] == hitBlock.x && fireVec [1] == hitBlock.y && fireVec [2] == hitBlock.z && fireArray [i] [2] == 0) {
			blockx = fireVec [0]; blocky = fireVec [1]; blockz = fireVec [2];
			fireArray [i] [2] = fireArray [i] [3] = cooking*2; pinv.consumeItem(itemID); fireArray [i] [11] = cookXP;
			fireArray [i] [6] = cookingWD; fireArray [i] [7] = cookableID; fireArray [i] [8] = itemID; 
			fireArray [i] [10] = cookMax; fireArray [i] [11] = cookDropAmount;
			fireHP = fireArray [i] [2]; fireMaxHP = fireArray [i] [3]; fireburn = fireArray [i] [6];
		}
	}
}
}
// SMELTING //
function metalConsume() {time.sleep(0.05);
if (blockID == 206 && (blockMD == 3 || blockMD == 2) && smithable == true) 
for (i = 0; fireArray [i] != undefined && fireArray [i] [0] == true; i++)
if (hitBlock != null && fireArray [i] [1] [0] == hitBlock.x && fireArray [i] [1] [1] == hitBlock.y && fireArray [i] [1] [2] == hitBlock.z) {
	if (fireArray [i] [2] == 0) {
		blockx = fireArray [i] [1] [0]; blocky = fireArray [i] [1] [1]; blockz = fireArray [i] [1] [2];
		fireArray [i] [2] = fireArray [i] [3] = cooking*2; pinv.consumeItem(itemID); fireArray [i] [11] = smithXP;
		fireArray [i] [6] = cookingWD; fireArray [i] [7] = cookableID; fireArray [i] [8] = itemID; 
		fireArray [i] [10] = cookMax; fireArray [i] [11] = 1;
	} fireHP = fireArray [i] [2]; fireMaxHP = fireArray [i] [3]; fireburn = fireArray [i] [6];
}
}

function atackEngine() {
	if (pinv.getCurrentItem() != null) {if (pinv.getCurrentItem().itemID == itemID) {var ent = pinv.getCurrentItem();}}
	if (pinv.getOffhandItem() != null) {if (pinv.getOffhandItem().itemID == itemID) {var ent = pinv.getOffhandItem();}}
	if (hitBlock != null && blockID != 174 && blockID != 206 && rand > 1 && blockID != 64  && blockID != 58
		&& blockID != 61 && blockID != 54) {lastItemUsed.damage = Math.min(lastItemUsed.damage+1,maxDamage);}

	if (lastItemUsed.damage == maxDamage && firstHit == 1) {pinv.consumeItemAmount(itemID,maxDamage,1); chat.print(breakSpeech);}

	if (sTiming > 3 && hitEntity == null && hitBlock == null && world.getBlockID(Math.round(pos.x), Math.round(pos.y), Math.round(pos.z)) != 9) 
		{sound.playSoundUI("sound.sword_swing"); sTiming = 0;}
}

function swordEngine() {
	time.sleep(0.05); atackEngine();
	if (hitEntity != null) {
		lastItemUsed.damage =  Math.min(lastItemUsed.damage + (rand == 0) ? 2 : 1, maxDamage);
		hitEntity.attackEntityFrom(player, power);
		if (hitEntity.attackStrength != undefined)
			{sword_xp += Math.sqrt(hitEntity.attackStrength+hitEntity.getMoveSpeed()*hitEntity.getMaxHealth())/30*Math.sqrt(basicDMG + power);}
		else {sword_xp += (hitEntity.getMoveSpeed())*hitEntity.getMaxHealth()/40*Math.sqrt(basicDMG + power);}
	}
}

function bluntEngine() {
	atackEngine();
	if (hitEntity != null) {
		lastItemUsed.damage =  Math.min(lastItemUsed.damage + (rand == 0) ? 2 : 1, maxDamage);
		hitEntity.attackEntityFrom(player, power);
		if (hitEntity.attackStrength != undefined)
			{blunt_xp += Math.sqrt(hitEntity.attackStrength+hitEntity.getMoveSpeed()*hitEntity.getMaxHealth())/30*Math.sqrt(basicDMG + power);}
		else {blunt_xp += (hitEntity.getMoveSpeed())*hitEntity.getMaxHealth()/40*Math.sqrt(basicDMG + power);}
		if (Math.round()*100 < stunChance) {hitEntity.setStunned(stunPower);}
	}
}

function fireUP() {
	if (blockID == 206 && (blockMD == 7 || blockMD == 6 || blockMD == 3 || blockMD == 2)) {
		for (i = 0; fireArray [i] != undefined && fireArray [i] [0] == true; i++)
		if (fireArray [i] [1] [0] == hitBlock.x && fireArray [i] [1] [1] == hitBlock.y && fireArray [i] [1] [2] == hitBlock.z) {
			j = fireArray [i] [5] + fireP; fireArray [i] [4] = 0; for (ii = 0; ii < j; ii++) {fireArray [i] [4] += 1; j -= ii;} 
			fireArray [i] [5] += fireP; blockx = fireArray [i] [1] [0]; blocky = fireArray [i] [1] [1]; fireArray [i] [0] = true;
			blockz = fireArray [i] [1] [2]; fireP = 0; break;
		}
		if (fireArray [i] == undefined) {fireArray [i] = [false, [0, 0, 0], 0, 0, 0, 0, "0", 0, 0, 0, 0, 1];}
		if (fireArray [i] [0] == false) {
			fireArray [i] [1] = [hitBlock.x, hitBlock.y, hitBlock.z]; fireArray [i] [0] = true;
			blockx = fireArray [i] [1] [0]; blocky = fireArray [i] [1] [1]; blockz = fireArray [i] [1] [2]; fireArray [i] [9] = blockMD;
			j = fireArray [i] [5] + fireP; fireArray [i] [4] = 0; for (ii = 0; ii < j; ii++) {fireArray [i] [4] += 1; j -= ii;} 
			fireArray [i] [5] += fireP; fireArray [i] [0] = true; fireP = 0;
		}
		pinv.consumeItemAmount(lastItemUsed.itemID, lastItemUsed.damage, 1);
	}
}

function repairFun() {
	if (hitBlock != null && itemID != 468 && blockID == 206 && blockMD == 8 && lastItemUsed != null) {
		lastItemUsed.damage = Math.max(lastItemUsed.damage - repair*Math.sqrt(smithing_lvl/20*repair+1), 0);
		i = (Math.pow(repair/1.5, 2) + lastItemUsed.damage + Math.sqrt(lastItemUsed.maxDamage))/(lastItemUsed.maxDamage*(smithing_lvl/20 + 1))*30;
		if (intence_repair > 100) {
			pinv.consumeItemAmount(itemID,lastItemUsed.damage,1); repairConsume(lastItemUsed, false);
			chat.print("It seems I can't handle repairing after all"); 
		}
		j = lastItemUsed.itemID; k = 0; jj = (140 - intence_repair)*10;
		if (prices [j] [k] [7]/jj <= parseInt(sourceAmount [0].text) && prices [j] [k] [8]/jj <= parseInt(sourceAmount [1].text) &&
		prices [j] [k] [9]/jj <= parseInt(sourceAmount [2].text) && prices [j] [k] [10]/jj <= parseInt(sourceAmount [3].text) &&
		prices [j] [k] [11]/jj <= parseInt(sourceAmount [4].text) && prices [j] [k] [12]/jj <= parseInt(sourceAmount [5].text) &&
		prices [j] [k] [13]/jj <= parseInt(sourceAmount [6].text) && prices [j] [k] [14]/jj <= parseInt(sourceAmount [7].text) &&
		intence_repair + i > 50) {
			intence_repair += i/(12-jj); 
			if (lastItemUsed.damage != 0) {
				smithing_xp += Math.sqrt(repair*5 + prices [j] [k] [11] + prices [j] [k] [12] + prices [j] [k] [13] + prices [j] [k] [14])/jj;
				crafting_xp += Math.sqrt(repair*5 + prices [j] [k] [7] + prices [j] [k] [8] + prices [j] [k] [9] + prices [j] [k] [10])/jj;
				repairConsume(lastItemUsed, true);
			}
		} else {
			intence_repair += i; 
			if (lastItemUsed.damage != 0) {
				smithing_xp += Math.sqrt(repair*5 + prices [j] [k] [11] + prices [j] [k] [12] + prices [j] [k] [13] + prices [j] [k] [14])/30;
				crafting_xp += Math.sqrt(repair*5 + prices [j] [k] [7] + prices [j] [k] [8] + prices [j] [k] [9] + prices [j] [k] [10])/30;
			}
		} 
		if (intence_repair > 85 && intence_repair < 100) {chat.print("I better slow down or I will end up breaking the tool");}
		if (sTiming > 16) {sound.playSoundUI("sound.Repairing"); sTiming = 0;}
	}
}

function placeBlock() {for (i = 0; i <= 4; i += 0.1) {
check = [Math.floor(vec.x*i + pos.x), Math.floor(vec.y*i + pos.y), Math.floor(vec.z*i + pos.z)];
checkID = world.getBlockID(check[0], check[1], check[2]);
if (checkID != 0 && (checkID < 8 || checkID > 11) && timing > 4 && checkID != 171) 
{if (Math.floor(pos.x) == lastAirPos[0] && (Math.floor(pos.y) == lastAirPos[1]
|| Math.floor(pos.y - 1) == lastAirPos[1]) && Math.floor(pos.z) == lastAirPos[2]) {break;}
for (ii = 0; ii < sCond.length; ii++) {if (world.getBlockID (lastAirPos[0], lastAirPos[1]-1, 
lastAirPos[2]) == sCond [ii]) {ii = sCond.length + 5;}} if (ii != sCond.length + 6 && sCond != 0) {break;}
world.setBlockIDAndMetadata(lastAirPos[0], lastAirPos[1], lastAirPos[2], setID, meta?setMD:0);
pinv.consumeItemAmount(lastItemUsed.itemID, lastItemUsed.damage, 1); timing = 0;
if (falling == true) {for (j = 1; world.getBlockID(lastAirPos[0], lastAirPos[1]-j, lastAirPos[2]) == 0
|| (world.getBlockID(lastAirPos[0], lastAirPos[1]-j, lastAirPos[2]) >= 8 &&
world.getBlockID(lastAirPos[0], lastAirPos[1]-j, lastAirPos[2]) <= 11) 
&& world.getBlockID(lastAirPos[0], lastAirPos[1]-j, lastAirPos[2]) == 171; j++) {} j -= 1; lastAirPos[1] -= j;}
bnArray = ""; i = lastAirPos[0]; if (i < 1000 && i > -1000) {if (i < 100 && i > -100) {if (i < 10 && i > -10) 
{bnArray += "000" + i;} else {bnArray += "00" + i;}} else {bnArray += "0" + i;}} else {bnArray += i;} i = lastAirPos[1];
if (i < 1000 && i > -1000) {if (i < 100 && i > -100) {if (i < 10 && i > -10) 
{bnArray += "000" + i;} else {bnArray += "00" + i;}} else {bnArray += "0" + i;}} else {bnArray += i;} i = lastAirPos[2];
if (i < 1000 && i > -1000) {if (i < 100 && i > -100) {if (i < 10 && i > -10) {bnArray += "000" + i;} 
else {bnArray += "00" + i;}} else {bnArray += "0" + i;}} else {bnArray += i;} i = bnArray;
if (blockArray [i] == undefined) {blockArray [i] = [i, lastAirPos[0], lastAirPos[1], lastAirPos[2]];
blockSave = "" + blockSave + i + "," + lastAirPos[0] + "," + lastAirPos[1] + "," + lastAirPos[2] + ",";}
if (pinv.getCurrentItem() != null) {if (pinv.getCurrentItem().itemID == itemID) {player.swingMainHand();}}
if (pinv.getOffhandItem() != null) {if (pinv.getOffhandItem().itemID == itemID) {player.swingOffHand();}}
whenPlaced(); break;} lastAirPos = [check[0], check[1], check[2]];}}

function repairSource() {
	if (breakLabelHP.alpha > 0) {
		breakLabelHP.alpha -= 0.1; breakLabel.alpha -= 0.1;
		breakLabelHP.v = 40 + (0.5-intence_repair/125) * 120; breakLabelHP.green = 1-intence_repair/100;
		breakLabelHP.red = intence_repair/100; breakLabelHP.blue = 0; 
		breakLabelHP.y = height/2 + 5 + (0.5-intence_repair/125) * 120;
	}
	if (sourceLabel.alpha > 0) {
		sourceLabel.x = width/2 - 100 - sourceLabel.alpha*(width/2 - 100); 
		sourceLabel2.x = width/2 + 4 + sourceLabel.alpha*(width/2 - 100);
		sourceAmount [0].x = sourceLabel.x + 56; sourceAmount [1].x = sourceLabel.x + 56;
		sourceAmount [2].x = sourceLabel.x + 56; sourceAmount [3].x = sourceLabel.x + 56;
		sourceAmount [4].x = sourceLabel2.x + 56; sourceAmount [5].x = sourceLabel2.x + 56;
		sourceAmount [6].x = sourceLabel2.x + 56; sourceAmount [7].x = sourceLabel2.x + 56;
		sourceLabel.alpha -= 0.1; sourceLabel2.alpha -= 0.1;
		for (i = 0; sourceAmount [i] != undefined; i++)
			sourceAmount [i].alpha -= 0.1;
	}
	if (getBlock != null) {
		j = 0;
		for (i = 0; repairArray [i] != undefined; i++) {
			if (world.getBlockID(getBlock.x, getBlock.y, getBlock.z) == 206 &&
			world.getMetadata(getBlock.x, getBlock.y, getBlock.z) == 8) {
				if (intence_repair > 0) {
					breakLabelHP.alpha = Math.min(1, breakLabelHP.alpha + 0.2);  
					breakLabel.alpha = Math.min(1, breakLabel.alpha + 0.2); 
				}
				sourceLabel.alpha = Math.min(1, sourceLabel.alpha + 0.2); 
				sourceLabel2.alpha = Math.min(1, sourceLabel2.alpha + 0.2);
				for (k = 0; sourceAmount [k] != undefined; k++) 
					sourceAmount [k].alpha = Math.min(1, sourceAmount [k].alpha + 0.16);
				if (repairArray [i] [1] [0] == 0 && repairArray [i] [1] [1] == 0 && repairArray [i] [1] [2] == 0) {
					repairArray [i] = [true, [getBlock.x, getBlock.y, getBlock.z], 0, 0, 0, 0, 0, 0, 0, 0];
				}
			}
			if (repairArray [i] [1] [0] == getBlock.x &&
			repairArray [i] [1] [1] == getBlock.y && repairArray [i] [1] [2] == getBlock.z) {
				for (ii = 0; sourceAmount [ii] != undefined; ii++) { 
					if (repairArray [i] [ii+2] < 0)
						repairArray [i] [ii+2] = 0;
					sourceAmount [ii].text = Math.round(repairArray [i] [ii+2]*10)/10;
				}
				j = 1; break;
			}
		}
		if (j == 0 && world.getBlockID(getBlock.x, getBlock.y, getBlock.z) == 206 &&
			world.getMetadata(getBlock.x, getBlock.y, getBlock.z) == 8)
			repairArray [i] = [true, [getBlock.x, getBlock.y, getBlock.z], 0, 0, 0, 0, 0, 0, 0, 0];
	}
}

function repairConsume(ent, repairReduce) {
if (blockID == 206 && blockMD == 8 && prices [j] [k] [7] != undefined) {
	for (i = 0; repairArray [i] != undefined; i++) {
		if (repairArray [i] [1] [0] == getBlock.x && repairArray [i] [1] [1] == getBlock.y && 
		repairArray [i] [1] [2] == getBlock.z) {break;}
	} 
	j = ent.itemID; k = ent.damage;
	if (ent.maxDamage != 0) {k = 0;} 
	if (repairReduce == false) {
		pinv.consumeItemAmount(ent.itemID, ent.damage, 1);
		for (ii = 0; ii < 8; ii++) 
			repairArray [i] [ii+2] += prices [j] [k] [ii+7];
	}
	else {
		for (ii = 0; ii < 8; ii++)
			repairArray [i] [ii+2] -= prices [j] [k] [ii+7]/(140 - intense_repair)*10;
	}
	for (ii = 0; sourceAmount [ii] != undefined; ii++) {
		sourceAmount [ii].text = Math.round(repairArray [i] [ii+2]*10)/10;
	}
}}

function getItemAmount(id) {
	ii = 0;
	for (k = 0; k < 36; k++) {
		if (pinv.getItemInSlot(k) != null && pinv.getItemInSlot(k).itemID == id)
			ii += pinv.getItemInSlot(k).quantity;
	}
	return ii;
}

function drawCubeDust(i, ii, j) {
	effect.spawnParticle("reddust", Math.ceil(i), Math.ceil(ii), Math.ceil(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.ceil(i), Math.ceil(ii), Math.floor(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.ceil(i), Math.floor(ii), Math.ceil(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.floor(i), Math.ceil(ii), Math.ceil(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.ceil(i), Math.floor(ii), Math.floor(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.floor(i), Math.floor(ii), Math.ceil(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.floor(i), Math.ceil(ii), Math.floor(j), 0.0, 0.1, 0.0);
	effect.spawnParticle("reddust", Math.floor(i), Math.floor(ii), Math.floor(j), 0.0, 0.1, 0.0);
}

function xpGain() {
	i = 0; achievCompleted = 0; for (ii = 0; ii < achievCount; ii++) if (achievSet [ii] == 1) {achievCompleted++}
	bonusXP = 1 + achievCompleted/100;
	if (fishing_xp > 0 || skillVar [i] [1] != fishing_lvl) 
		{skillVar [i] [0] += fishing_xp*bonusXP; fishing_xp = 0; fishing_lvl = skillVar [i] [1];} i++
	if (sword_xp > 0 || skillVar [i] [1] != sword_lvl) 
		{skillVar [i] [0] += sword_xp*bonusXP; sword_xp = 0; sword_lvl = skillVar [i] [1];} i++
	if (blunt_xp > 0 || skillVar [i] [1] != blunt_lvl) 
		{skillVar [i] [0] += blunt_xp*bonusXP; blunt_xp = 0; blunt_lvl = skillVar [i] [1];} i++
	if (harvesting_xp > 0 || skillVar [i] [1] != harvesting_lvl) 
		{skillVar [i] [0] += harvesting_xp*bonusXP; harvesting_xp = 0; harvesting_lvl = skillVar [i] [1];} i++
	if (gardening_xp > 0 || skillVar [i] [1] != gardening_lvl) 
		{skillVar [i] [0] += gardening_xp*bonusXP; gardening_xp = 0; gardening_lvl = skillVar [i] [1];} i++
	if (cooking_xp > 0 || skillVar [i] [1] != cooking_lvl) 
		{skillVar [i] [0] += cooking_xp*bonusXP; cooking_xp = 0; cooking_lvl = skillVar [i] [1];} i++
	if (smithing_xp > 0 || skillVar [i] [1] != smithing_lvl) 
		{skillVar [i] [0] += smithing_xp*bonusXP; smithing_xp = 0; smithing_lvl = skillVar [i] [1];} i++
	if (mining_xp > 0 || skillVar [i] [1] != mining_lvl) 
		{skillVar [i] [0] += mining_xp*bonusXP; mining_xp = 0; mining_lvl = skillVar [i] [1];} i++
	if (woodcut_xp > 0 || skillVar [i] [1] != woodcut_lvl) 
		{skillVar [i] [0] += woodcut_xp*bonusXP; woodcut_xp = 0; woodcut_lvl = skillVar [i] [1];} i++
	if (crafting_xp > 0 || skillVar [i] [1] != crafting_lvl) 
		{skillVar [i] [0] += crafting_xp*bonusXP; crafting_xp = 0; crafting_lvl = skillVar [i] [1];} i++
	if (light_xp > 0 || skillVar [i] [1] != light_lvl) 
		{skillVar [i] [0] += light_xp*bonusXP; light_xp = 0; light_lvl = skillVar [i] [1];} i++
	if (heavy_xp > 0 || skillVar [i] [1] != heavy_lvl) 
		{skillVar [i] [0] += heavy_xp*bonusXP; heavy_xp = 0; heavy_lvl = skillVar [i] [1];} i++
	if (digging_xp > 0 || skillVar [i] [1] != digging_lvl) 
		{skillVar [i] [0] += digging_xp*bonusXP; digging_xp = 0; digging_lvl = skillVar [i] [1];} i++
	if (unarmed_xp > 0 || skillVar [i] [1] != unarmed_lvl) 
		{skillVar [i] [0] += unarmed_xp*bonusXP; unarmed_xp = 0; unarmed_lvl = skillVar [i] [1];} i++
	if (range_xp > 0 || skillVar [i] [1] != range_lvl) 
		{skillVar [i] [0] += range_xp*bonusXP; range_xp = 0; range_lvl = skillVar [i] [1];} i++
}