//===== eAthena Script =======================================
//= Refining NPCs
//===== By: ==================================================
//= Syrus22 (1.1)
//===== Current Version: =====================================
//= 1.3
//===== Compatible With: =====================================
//= Any Athena Version
//===== Description: =========================================
//= Refining NPCs and Metal Salesmen.
//===== Additional Comments: =================================
//= 1.0 by A bunch of people!
//= Syrus22 - Completely redid the script using functions... also
//= added the option for auto safe refining and multiple refining.
//= 1.1 Negative input bug fixed [Lupus]
//= 1.2 Added additional reparimen in morroc and payon.  Added
//= Christopher the blacksmith in Geffen.  Edited some dialogue [kobra_k88]
//= 1.3 New Payon Locations [Darkchild]
//= Corrected zeny subtraction thx to jpnmania77.[kobra_k88]
//= 1.3a Temporary corrected an expliot.  Need to check sources 
//= to fully fix bug [Shinigami]
//= Fixed repairman prices [shadowlady]
//============================================================


//=========================================================
// Christopher: Geffen Blacksmith
//=========================================================
geffen_in.gat,110,172,2	script	Christopher	63,{
	mes "[Christopher Guillenrow]";
	mes "Welcome to Christopher's Workshop.  Ye can find all yer forging equipment here.  So what can I help ye with?";
	M_Menu:
	next;
	menu "Purchase Anvil",M_0, "Purchase Forging Item",M_1, "Purchase Metal",M_2, "Purify Rough Ores",M_3, "Cancel",M_End;
	
	M_0:
		mes "[Christopher Guillenrow]";
		mes "Higher quality Anvils gives ye a better chance ta make better weapons, ye know.  But they cost more than yer typical ones.";
		next;
		menu	"Anvil - 30000z.",sM_Anvil, "Oridecon Anvil - 120000z.",sM_OriAnvil, "Golden Anvil - 300000z.",sM_GolAnvil,
			"Better Anvil than others",sM_BetAnvil, "Cancel",M_Menu;

		sM_Anvil:
			if(Zeny < 30000) goto L_NoZeny;
			mes "[Christopher Guillenrow]";
			mes "This is the cheapest one but it's very efficient.";
			set Zeny, Zeny - 30000;
			getitem 986,1;
			next;
			goto L_Thanks;
		sM_OriAnvil:
			if(Zeny < 120000) goto L_NoZeny;
			mes "[Christopher Guillenrow]";
			mes "Ah! Ye have a good eye for anvils.  This here is the proper anvil for a Blacksmith.";
			set Zeny, Zeny - 120000;
			getitem 987,1;
			next;
			goto L_Thanks;
		sM_GolAnvil:
			if(Zeny < 300000) goto L_NoZeny;
			mes "[Christopher Guillenrow]";
			mes "This is the best anvil in my workshop!  With this ye'll be the best Blasksmith in no time.";
			set Zeny, Zeny - 300000;
			getitem 988,1;
			next;
			goto L_Thanks;
		sM_BetAnvil:
			mes "[Christopher Guillenrow]";
			mes "I'm sorry but I don't have anything better than a Golden Anvil.";
			mes "Maybe 'Ringgel' the legendary Anvil maker would have one... but he be a hard fellow ta find.";
			close;

	M_1:
		mes "[Christopher Guillenrow]";
		mes "A respectable Blacksmith uses fine tools.  Ye will come ta know my tools as being the finest around!";
		mes "Choose anything you want.";
		sM_Menu1:
		next;
		menu 	"Mini-Furnace - 150z.",sM_Furn, "Iron Hammer - 1000z.",sM_IrHam, "Golden Hammer - 3000z.",sM_GldHam,
			"Oridecon Hammer - 5000z.",sM_OriHam, "Cancel",M_Menu;
		
		sM_Furn:
			mes "[Christopher Guillenrow]";
			mes "This is a prerequisite for Metal refining!!";
			mes "So, how many do ye wish to buy? If you want to quit, please input the number '0'. However, you the maximum amount you can buy is 1000";
			set @input, 0;
			input @input;
			next;
			if(@input < 1 ) goto sM_Menu1;
			if(@input > 1000 ) goto sM_Max;
			if(Zeny < 150 * @input) goto L_NoZeny;
			set Zeny, Zeny - (150 * @input);
			getitem 612, @input;
			goto L_Thanks;
		sM_IrHam:
			if(Zeny < 1000) goto L_NoZeny;
			set Zeny, Zeny - 1000;
			getitem 613,1;
			goto L_Thanks;
		sM_GldHam:
			if(Zeny < 3000) goto L_NoZeny;
			set Zeny, Zeny - 3000;
			getitem 614,1;
			goto L_Thanks;
		sM_OriHam:
			if(Zeny < 5000) goto L_NoZeny;
			set Zeny, Zeny - 5000;
			getitem 615,1;
			goto L_Thanks;
		sM_Max:
			mes "[Christopher Guillenrow]";
			mes "Sorry, you can't buy more than 1000 furnace at a time.";
			close;

	M_2:
		mes "[Christopher Guillenrow]";
		mes "I have 2 kinds of metals for sale.  Which do ye like?";
		set @chris, 1;
		set @name$, "Christopher Guillenrow";
		callfunc "phramain";

	M_3:
		mes "[Christopher Guillenrow]";
		mes "I can purify yer rough Oridecon and rough Elunium ores.  I'll need 5 rough ores to make 1 pure one.";
		mes "Well... which one do ye want ta make?";
		set @chris, 1;
		set @name$, "Christopher Guillenrow";
		callfunc "orimain";

	M_End:
		close;
		
	L_NoZeny:
		mes "[Christopher Guillenrow]";
		mes "I don't think I can let ye have this at a lower price.  I can't afford ta loose profits because of ye.";
		emotion 4;
		close;

	L_Thanks:
		mes "[Christopher Guillenrow]";
		mes "Thank you for shopping at my workshop. Feel free to come anytime whenever you need.";
		emotion 15;
		close;

}



//=====================================================================================
//= 				Weapon/Armor Refiners
//=====================================================================================
prt_in.gat,63,60,4	script	Hollengrhen	85,{
	set @name$,"Hollengrhen";
	callfunc "refinemain";
	break;
}
morocc_in.gat,73,38,4	script	Aragham	99,{
	set @name$,"Aragham";
	callfunc "refinemain";
	break;
}
payon.gat,144,173,4	script	Antonio	88,{
	set @name$,"Antonio";
	callfunc "refinemain";
	break;
}
alberta_in.gat,28,58,4	script	Fredrik	85,{
	set @name$,"Fredrik";
	callfunc "refinemain";
	break;
}
yuno_in01.gat,164,26,6	script	Disturb	88,{
	set @name$,"Disturb";
	callfunc "refinemain";
	break;
}

//============================================================
//= Main Refiner Function
//============================================================
//= To allow auto safe refining/multiple refining set the
//= @features variable to 1
//============================================================
function	script	refinemain	{
	set @features,0;

	mes "[" + @name$ + "]";
	mes "I am the Armsmith... I can refine any weapon or piece of armor you choose!";
	mes "Which piece of equipment do you want to refine?";
	M_Menu:
	next;
	menu	getequipname(1),PART1,getequipname(2),PART2,getequipname(3),PART3,getequipname(4),PART4,getequipname(5),PART5,
		getequipname(6),PART6,getequipname(7),PART7,getequipname(8),PART8,getequipname(9),PART9,getequipname(10),PART10;

	//Head Gear
	PART1:
		set @part,1;
		if (getequipisequiped(1)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "Do you want me to refine your dumb brain?";
		emotion 6;
		goto M_Menu;
	//Armor
	PART2:
		set @part,2;
		if (getequipisequiped(2)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "Do you want me to melt your body with blazing heat...?";
		emotion 6;
		goto M_Menu;
	//Left Hand
	PART3:
		set @part,3;
		if (getequipisequiped(3)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "I can't make your left hand into an ultimate weapon...";
		emotion 4;
		goto M_Menu;
	//Right Hand
	PART4:
		set @part,4;
		if (getequipisequiped(4)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "I can't make your right hand into an ultimate weapon...";
		emotion 4;
		goto M_Menu;
	//Garment
	PART5:
		set @part,5;
		if (getequipisequiped(5)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "Look here... you don't have any Garments on....";
		goto M_Menu;
	//Foot Gear
	PART6:
		set @part,6;
		if (getequipisequiped(6)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "Ack!! Those are some stinky feet.  I definately can't refine those.... uck!!";
		emotion 16;
		goto M_Menu;
	//Accessory1
	PART7:
		set @part,7;
		if (getequipisequiped(7)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "What do you mean by Accessory? Which One?";
		emotion 20;
		goto M_Menu;
	//Accessory2
	PART8:
		set @part,8;
		if (getequipisequiped(8)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "What do you mean by Accessory? Which One?";
		emotion 20;
		goto M_Menu;
	PART9:
		set @part,9;
		if (getequipisequiped(9)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "What do you want from me? There's nothing equiped there...";
		emotion 20;
		goto M_Menu;
	PART10:
		set @part,10;
		if (getequipisequiped(10)) goto CHECK1;
		mes "[" + @name$ + "]";
		mes "What do you want from me? There's nothing equiped there...";
		emotion 20;
		goto M_Menu;

//Check if the item is refinable...
CHECK1:
	if(getequipisenableref(@part)) goto CHECK2;
	mes "[" + @name$ + "]";
	mes "I can't work on this item...";
	close;
//Check if the item is identified... (Don't know why this is in here... but kept it anyway)
CHECK2:
	if(getequipisidentify(@part)) goto CHECK3;
	mes "[" + @name$ + "]";
	mes "You must appraise this item first.";
	close;
//Check to see if the items is already +10
CHECK3:
	if(getequiprefinerycnt(@part) < 10) goto REFINE0;
	mes "[" + @name$ + "]";
	mes "This weapon is allready at its maximum level and can no longer be refined.";
	close;

//Refine Armor
REFINE0:
	if(getequipweaponlv(@part) > 0) goto REFINE1;
	set @matname$,"Elunium";
	set @material,985;
	set @price,2000;
	set @safe,4;
	if(@features == 1) callfunc "refinefeatures";
	callfunc "refinenormal";
//Refine Level 1 Weapon
REFINE1:
	if(getequipweaponlv(@part) > 1) goto REFINE2;
	set @matname$,"Phracon";
	set @material,1010;
	set @price,50;
	set @safe,7;
	if(@features == 1) callfunc "refinefeatures";
	callfunc "refinenormal";
//Refine Level 2 Weapon
REFINE2:
	if(getequipweaponlv(@part) > 2) goto REFINE3;
	set @matname$,"Emveretarcon";
	set @material,1011;
	set @price,200;
	set @safe,6;
	if(@features == 1) callfunc "refinefeatures";
	callfunc "refinenormal";
//Refine Level 3 Weapon
REFINE3:
	if(getequipweaponlv(@part) > 3) goto REFINE4;
	set @matname$,"Oridecon";
	set @material,984;
	set @price,5000;
	set @safe,5;
	if(@features == 1) callfunc "refinefeatures";
	callfunc "refinenormal";
//Refine Level 4 Weapon
REFINE4:
	set @matname$,"Oridecon";
	set @material,984;
	set @price,20000;
	set @safe,4;
	if(@features == 1) callfunc "refinefeatures";
	callfunc "refinenormal";
}

// Normal Refining Functions =========================
function	script	refinenormal	-1,{
	mes "[" + @name$ + "]";	
	mes "To refine this stuff,I need ^ff9999" + @matname$ + "^000000 and the fee " + @price + " Zeny.";
	mes "Continue?";
	next;
	menu "Yes",-,"No",Lcancel;

		if (getequippercentrefinery(@part) == 100) goto L_Sub;
		mes "[" + @name$ + "]";
		mes "Hmm... Hold on! This piece of equipment has already been refined to its maximum safety level.";
		mes "I must warn you if it is refined ANYMORE, It could be DESTROYED and become USELESS!!";
		next;
		mes "["+@name$+"]";
		mes "Do you still wish you refine it? If so I will not be able to gaurantee my work...";
		next;
		menu "Yes",L_Sub,"No",Lcancel1;

		L_Sub:
			if ((countitem(@material) < 1) || (Zeny < @price)) goto Lcancel2;
			delitem @material,1;
			set Zeny,Zeny-@price;

Lrefine:
	if (getequippercentrefinery(@part)<=rand(100)) goto Lfail;
	mes "["+@name$+"]";
	mes "Clang! Clang! Clang!";
	successrefitem @part;
	next;
	mes "["+@name$+"]";
	mes "HAHA! It seems my skills haven't gotten rusty yet! Splendid... just splendid...";
	emotion 21;
	close;

Lfail:
	mes "[" + @name$ + "]";
	mes "Clang! Clang! Clang!";
	failedrefitem @part;
	next;
	mes "["+@name$+"]";
	mes "Aaahhh!! Oh no....!!";
	emotion 16;
	next;
	mes "["+@name$+"]";
	mes "Eh..Ehem... I'm sorry but the refining proccess ^ff0000failed^000000.";
	next;
	mes "["+@name$+"]";
	mes "I am deeply ashamed of what I've done... but I DID warn you earlier about the risks.";
	close;

Lcancel:
	mes "[" + @name$ + "]";
	mes "You said so..Hmm so be it...";
	close;

Lcancel1:
	mes "[" + @name$ + "]";
	mes "Good Choice.";
	mes "Ah... good choice.  I'd feel awfull if I'd destroyed another persons piece of equipment with my own hands.";
	close;

Lcancel2:
	mes "[" + @name$ + "]";
	mes "Is that all you got? Unfortunately I can't work for you at a lower price.  Try putting yourself in my shoes.";
	close;
}

// New Refining Functions ========================
function	script	refinefeatures	{
	if(getequiprefinerycnt(@part) >= @safe) goto Lnosafe;
	mes "[" + @name$ + "]";
	mes "I can refine this to the safe limit or a desired number of times... it's your choice...";
	next;
	menu "To the safe limit please.",Lsafe,"I'll decide how many times.",Lnosafe,"I've changed my mind...",Lcancel;

Lsafe:
	set @refinecnt,@safe - getequiprefinerycnt(@part);
	set @fullprice,@price * @refinecnt;
	mes "[" + @name$ + "]";
	mes "That will cost you " + @refinecnt + " " + @matname$ + " and " + @fullprice + " Zeny. Is that ok?";
	next;
	menu "Yes",-,"No...",Lcancel;
	if((countitem(@material) < @refinecnt) || (Zeny < @fullprice)) goto Lcancel2;
	delitem @material,@refinecnt;
	set Zeny,Zeny - @fullprice;
	callfunc "refinesafe";
	break;

Lnosafe:
	mes "[" + @name$ + "]";
	mes "So how many times would you like me to refine your item?";
	next;
	input @refinecnt;
	if (@refinecnt<1) goto Lcancel3; //fixed by Lupus
	set @refinecheck,@refinecnt + getequiprefinerycnt(@part);
	if(@refinecheck > 10) goto Lcancel3;
	set @fullprice,@price * @refinecnt;
	mes "[" + @name$ + "]";
	mes "This will cost you " + @refinecnt + " " + @matname$ + " and " + @price + " Zeny... Is that ok?";
	next;
	menu "Yes...",-,"No...",Lcancel;
		if(@refinecheck > @safe) goto Lwarn;
		if((countitem(@material) < @refinecnt) || (Zeny < @fullprice)) goto Lcancel2;
		delitem @material,@refinecnt;
		set Zeny,Zeny - @fullprice;
		callfunc "refinenumber";
		break;

		Lwarn:
			set @refinecheck,@refinecheck - @safe;
			mes "[" + @name$ + "]";
			mes "This will try to refine the equipment " + @refinecheck + " times past the safe limit. Your equipment may be destroyed... is that ok?";
			next;
			menu "Yes",-,"No...",Lcancel1;
				if((countitem(@material) < @refinecnt) || (Zeny < @fullprice)) goto Lcancel2;
				delitem @material,@refinecnt;
				set Zeny,Zeny - @fullprice;
				callfunc "refinenumber";
				break;
Lcancel:
	mes "[" + @name$ + "]";
	mes "If you say so... See you again soon I hope.";
	close;
Lcancel1:
	mes "[" + @name$ + "]";
	mes "Good... I don't like to break people's equipment...";
	close;
Lcancel2:
	mes "[" + @name$ + "]";
	mes "Sorry but you don't have everything I need...";
	close;
Lcancel3:
	mes "[" + @name$ + "]";
	mes "I can't refine this item that many times.";
	close;
}

// Function: Safe Refine ---------------------
function	script	refinesafe	{
	mes "Clang, clang!!!";
	successrefitem @part;
	emotion 21;
	set @refinecnt,@refinecnt - 1;
	next;
	if(@refinecnt == 0) goto Lend;
	callfunc "refinesafe";
	break;

	Lend:
		mes "[" + @name$ + "]";
		mes "All finished... Come again soon.";
		close;
}
// Function: Refine 
function	script	refinenumber	{
	mes "Clang, clang!!!";
	if (getequippercentrefinery(@part)<=rand(100)) goto Lfail;
	successrefitem @part;
	emotion 21;
	set @refinecnt,@refinecnt - 1;
	next;
	if(@refinecnt == 0) goto Lend;
	callfunc "refinenumber";
	break;

	Lend:
		mes "[" + @name$ + "]";
		mes "All finished... Come again soon.";
		close;

	Lfail:
		failedrefitem @part;
		emotion 23;
		mes "[" + @name$ + "]";
		mes "WAHHHH!!! I'm so sorry... I warned you this could happen...";
		set @refinecnt,@refinecnt - 1;
		if(@refinecnt == 0) goto Lend2;
		mes "Here's the unused Zeny and Material back...";
		getitem @material,@refinecnt;
		set @fullprice,@refinecnt * @price;
		set Zeny,Zeny + @fullprice;

	Lend2:
		close;
}



//==============================================================================
//= 				Material Salesmen
//==============================================================================
prt_in.gat,56,69,4	script	Vurewell	86,{
	set @name$,"Vurewell";
	callfunc "phramain";
	break;
}
payon.gat,145,178,4	script	Begnahd	88,{
	set @name$,"Begnahd";
	callfunc "phramain";
	break;
}
morocc_in.gat,65,37,4	script	Sade	99,{
	set @name$,"Sade";
	callfunc "phramain";
	break;
}
alberta_in.gat,18,59,5	script	Kahlamanlith	86,{
	set @name$,"Kahlamanlith";
	callfunc "phramain";
	break;
}
yuno_in01.gat,171,26,6	script	Dillemat	88,{
	set @name$,"Dillemat";
	callfunc "phramain";
	break;
}

//============================================================
//= Material Salesmen Functions
//============================================================
function	script	phramain	{
	if(@chris == 1) goto M_Menu;
	mes "[" + @name$ + "]";
	mes "Hello, Im selling metals I just mined.";
	mes "They are Pharacon and Emvertacon.";
	mes "Would you like to buy some?";
	M_Menu:
	set @chris, 0;
	next;
	menu"Pharacon - 200z",PHARA,"Emveretarcon - 1000z",EMVER;

	PHARA:
		set @itemid,1010;
		set @value,200;
		goto CONTINUE;

	EMVER:
		set @itemid,1011;
		set @value,1000;

CONTINUE:
	mes "[" + @name$ + "]";
	mes "How many would you like?";
	next;
	input @ammount;
	if (@ammount <= 0) goto L_BELOW;
	if (@ammount > 999) goto L_ABOVE;
	if (zeny<@value*@ammount) goto L_NOZENY;
	if (checkweight(@item,@ammount) == 0) goto L_WEIGHT;
	getitem @itemid,@ammount;
	set Zeny,Zeny-@value*@ammount;
	mes "[" + @name$ + "]";
	mes "Here you go.";
	close;

L_NOZENY:
	mes "You do not have enough zeny!";
	close;
L_WEIGHT:
	mes "You cant hold that many of that item";
	close;
L_BELOW:
	mes "You have to buy a POSITIVE amount of items!";
	close;
L_ABOVE:
	mes "You cant buy this much of this item!";
	close;
}



//==============================================================================
//= 				Ori/Elu Refiners
//==============================================================================
prt_in.gat,63,69,4	script	Dietrich	84,{
	set @name$,"Dietrich";
	callfunc "orimain";
	break;
}
payon.gat,137,178,4	script	Hakhim	88,{
	set @name$,"Hakhim";
	callfunc "orimain";
	break;
}
morocc_in.gat,72,32,4	script	Abdul	99,{
	set @name$,"Abdul";
	callfunc "orimain";
	break;
}
alberta_in.gat,21,63,5	script	Xenophon	84,{
	set @name$,"Xenophon";
	callfunc "orimain";
	break;
}
yuno_in01.gat,171,22,6	script	Delayt	88,{
	set @name$,"Delayt";
	callfunc "orimain";
break;
}

//============================================================
//= Ori/Elu Functions
//============================================================
function	script	orimain	{
	if(@chris == 1) goto M_Menu;
	mes "[" + @name$ + "]";
	mes "If you bring Rough Oridecons and";
	mes "Rough Eluniums to me,";
	mes "I can refine them for you.";
	mes "However, you must bring 5 of each.";
	M_Menu:
	set @chris, 0;
	next;
	menu "Make Oridecon",M_Ori, "Make Elunium",M_Elu, "Ask about enchanted stones",M_Stones;

	M_Ori:
		if ((countitem(756) < 5)) goto L_NoOri;
		delitem 756,5;
		getitem 984,1;
		mes "[" + @name$ + "]";
		mes "As promised, here's your oridecon.";
		mes "Come back again anytime.";
		close;

		L_NoOri:
			mes "[" + @name$ + "]";
			mes "Huh? You're kidding, right? Didn't I say I can't make you an Oridecon unless you bring me 5 rough ones?";
			close;
	M_Elu:
		if ((countitem(757) < 5)) goto L_NoElu;
		delitem 757,5;
		getitem 985,1;
		mes "[" + @name$ + "]";
		mes "As promised, here's your elunium.";
		mes "Come back again anytime.";
		close;

		L_NoElu:
			mes "[" + @name$ + "]";
			mes "Huh? You're kidding, right? Didn't I say I can't make you an Elunium unless you bring me 5 rough ones?";
			close;
	M_Stones:
		mes "[" + @name$ + "]";
		mes "Enchanted stones, huh ....";
		next;
		mes "[" + @name$ + "]";
		mes "Well, in the 20 years that I've been a stonesmith I've heard of them many times... though I've never actually seen them before.";
		next;
		mes "[" + @name$ + "]";
		mes "I've been told that enchanted stones possess different elemental properties such as ^5533FFWater, Earth, Fire, and Wind^000000.";
		next;
		mes "[" + @name$ + "]";
		mes "If someone combines an Enchanted Stone with a weapon durring the refining process, that weapon will possess the same property as the stone.";
		next;
		mes "[" + @name$ + "]";
		mes "Of course, that person needs to be skillfull enough to work on it.";
		goto M_Menu;
}



//=====================================================================================
//= 				Equipment Repairmen
//=====================================================================================
prt_in.gat,62,54,2	script	Grendal	84,{
	set @name$,"Grendal";
	callfunc "repairmain";
	break;
}

//Temp Spot, Not Shure Where To place
payon.gat,149,182,2	script	Repairman	88,{
	set @name$,"Repairman";
	callfunc "repairmain";
	break;
}

morocc_in.gat,71,40,2	script	Repairman	99,{
	set @name$,"Repairman";
	callfunc "repairmain";
	break;
}

//============================================================
//= Equipment Repair Function
//============================================================
function	script	repairmain	{
	set @repairprice,5000;
	mes "[" + @name$ + "]";
	mes "I am the Repair Smith and I can repair any Arms you want.";
	mes "Tell me which Equipment you want to repair.";
	set @broken1,getbrokenid(1);
	set @broken2,getbrokenid(2);
	set @broken3,getbrokenid(3);
	set @broken4,getbrokenid(4);
	set @broken5,getbrokenid(5);
	set @broken6,getbrokenid(6);
	set @broken7,getbrokenid(7);
	set @broken8,getbrokenid(8);
	set @broken9,getbrokenid(9);
	set @broken10,getbrokenid(10);
	next;
	if(@broken1==NULL) goto L_CANCEL_3;
	menu	getitemname(@broken1),REPAIR1,getitemname(@broken2),REPAIR2,getitemname(@broken3),REPAIR3,
		getitemname(@broken4),REPAIR4,getitemname(@broken5),REPAIR5,getitemname(@broken6),REPAIR6,
		getitemname(@broken7),REPAIR7,getitemname(@broken8),REPAIR8,getitemname(@broken9),REPAIR9,
		getitemname(@broken10),REPAIR10;
	REPAIR1:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(1);
			goto L_CLOSE;
	REPAIR2:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(2);
			goto L_CLOSE;
	REPAIR3:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(3);
			goto L_CLOSE;
	REPAIR4:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(4);
			goto L_CLOSE;
	REPAIR5:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(5);
			goto L_CLOSE;
	REPAIR6:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(6);
			goto L_CLOSE;
	REPAIR7:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(7);
			goto L_CLOSE;
	REPAIR8:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(8);
			goto L_CLOSE;
	REPAIR9:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(9);
			goto L_CLOSE;
	REPAIR10:
		mes "[" + @name$ + "]";
		mes "You're gonna repair " + getitemname(@broken1) + ".";
		mes "To repair this, I need ^ff9999One Steel^000000, and " + @repairprice + " Zeny.";
		mes "Continue?";
		next;
		menu "Yes",-,"No",L_CANCEL_2;
		if (countitem(999) < 1 || Zeny < @repairprice) goto L_CANCEL_1;
			delitem 999,1;
			set Zeny,Zeny-@repairprice;
			repair(10);
			goto L_CLOSE;

L_CANCEL_1:
	mes "[" + @name$ + "]";
	mes "Is it all you got?";
	mes "Unfortunately, I have kids to feed...";
	goto L_CLOSE;
L_CANCEL_2:
	mes "[" + @name$ + "]";
	mes "Ok, but don't expect to be using that...";
	goto L_CLOSE;
L_CANCEL_3:
	mes "[" + @name$ + "]";
	mes "Looks like you don't need anything repaired today...";
	goto L_CLOSE;
L_CLOSE:
	close;
}