//===== eAthena Script =======================================
//= Socket Enchant
//===== By: ==================================================
//= eAthena dev team
//===== Current Version: =====================================
//= 1.4
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
//= item loses all element refinement and upgrades but
//= cards too?
//===== Additional Comments: =================================
//= 0.1a added missing L_No: to 2 funcs [Lupus]
//= 0.1b Removed duplicates [Toms]
//= 0.2	Added missing next;'s [Evera]
//= 0.3 Fixed Zweihander[+] id [Lupus]
//= 1.0 Fixed ingredients check [Lupus]
//= 1.1	Updated to official. [SinSloth]
//= 1.1b Optimized/cleaned [ultramage]
//= 1.2 Fixed some typos and a nasty bug. [SinSloth]
//= 1.3 Fixed a wrong item ID with Sphinx Hat. [SinSloth]
//= 1.4 Corrected NPC names to fall within proper restrictions. [L0ne_W0lf]
//============================================================

payon,140,151,5	script	Seiyablem	84,{

	mes "[Seiyablem]";
	mes "I'm an engineer that specializes in adding Slots to normal Weapons and Armor.";
	mes "My service fee, the required materials and the chance of success all depend on the specific item I'm working on.";
	next;
	mes "[Seiyablem]";
	mes "Adding Slots may seem simple, but it's far more complicated than it looks.";
	mes "If you're interested in my service, let me know.";
	next;
	switch( select( "Add Slot to Weapon","Add Slot to Armor","Slot Attempt Info","Cancel" ) )
	{
		case 1:
			mes "[Seiyablem]";
			mes "You want to add a Slot to a weapon?";
			mes "I categorize weapons by their difficulty in adding a Slot, C Class being easiest and S Class the most difficult.";
			mes "Which class would you like to try?";
			set @sockettype,1;
			next;
			switch( select( "C Class","B Class","A Class","S Class" ) )
			{
				case 1:
					mes "[Seiyablem]";
					mes "C Class, eh?";
					mes "Now, I can only upgrade certain equipment in that class, so please choose one of the following items, so we can try to add a Slot to it.";
					next;
					switch( select( "Trident","Rope","Violin","Book of Billows","Book of Mother Earth","Book of the Blazing Sun","Book of Gust of Wind" ) )
					{
						case 1: callfunc "Func_Socket",1,1460,1461,40,66,200,1010,10; break;
						case 2: callfunc "Func_Socket",1,1950,1951,40,66,200,1010,10; break;
						case 3: callfunc "Func_Socket",1,1901,1902,40,66,200,1010,10; break;
						case 4: callfunc "Func_Socket",1,1553,1568,40,66,200,1010,10; break;
						case 5: callfunc "Func_Socket",1,1554,1569,40,66,200,1010,10; break;
						case 6: callfunc "Func_Socket",1,1555,1570,40,66,200,1010,10; break;
						case 7: callfunc "Func_Socket",1,1556,1571,40,66,200,1010,10; break;
					}
				break;
				
				case 2:
					mes "[Seiyablem]";
					mes "B Class?";
					mes "Alright, this is the average equipment category.";
					mes "Please choose the weapon to which you'd like me to try to add a Slot.";
					next;
					switch( select( "Chain","Gladius","Gakkung Bow","Pike","Haedonggum","Lute","Wire","Waghnakh","Arbalest Bow","Orcish Axe","Scimitar","Spike" ) )
					{
						case 1: callfunc "Func_Socket",1,1519,1520,40,61,300,1010,10; break;
						case 2: callfunc "Func_Socket",2,1219,1220,40,61,300,984,1,999,5; break;
						case 3: callfunc "Func_Socket",2,1714,1716,40,61,300,984,2,999,5; break;
						case 4: callfunc "Func_Socket",1,1407,1408,40,61,300,1010,10; break;
						case 5: callfunc "Func_Socket",2,1123,1128,40,61,300,984,2,999,5; break;
						case 6: callfunc "Func_Socket",1,1905,1906,40,61,300,1011,10; break;
						case 7: callfunc "Func_Socket",1,1954,1955,40,61,300,1011,10; break;
						case 8: callfunc "Func_Socket",1,1801,1802,40,61,300,1010,10; break;
						case 9: callfunc "Func_Socket",2,1713,1715,40,61,300,984,2,999,5; break;
						case 10: callfunc "Func_Socket",1,1304,1309,40,61,200,984,1; break;
						case 11: callfunc "Func_Socket",1,1113,1114,40,61,200,984,1; break;
						case 12: callfunc "Func_Socket",1,1523,1538,40,61,300,984,1; break;
					}
				break;
				
				case 3:
					mes "[Seiyablem]";
					mes "Ooh, A Class.";
					mes "This is some high risk territory!";
					mes "Alright, which weapon would you like me to try adding a Slot?";
					next;
					switch( select( "Hunter Bow","Survivor's Rod(INT)","Zweihander","Flamberge","Infiltrator","Ballista","Stunner","Berserk","Claymore","Dragon Killer","Katar of Frozen Icicle","Katar of Quaking","Katar of Raging Blaze","Katar of Piercing Wind","Golden Mace","Oriental Lute","Queen's Whip","Phantom Spear","Schweizersabel" ) )
					{
						case 1: callfunc "Func_Socket",2,1718,1726,40,61,500,984,2,999,10; break;
						case 2: callfunc "Func_Socket",2,1619,1620,40,61,500,984,2,999,10; break;
						case 3: callfunc "Func_Socket",2,1168,1171,40,61,800,984,5,999,10; break;
						case 4: callfunc "Func_Socket",2,1129,1149,40,61,500,984,2,999,10; break;
						case 5: callfunc "Func_Socket",2,1261,1266,40,61,700,984,5,999,10; break;
						case 6: callfunc "Func_Socket",2,1722,1727,40,61,500,984,5,999,10; break;
						case 7: callfunc "Func_Socket",2,1522,1532,40,61,700,984,2,999,10; break;
						case 8: callfunc "Func_Socket",2,1814,1816,40,61,700,984,5,999,10; break;
						case 9: callfunc "Func_Socket",2,1163,1172,40,61,700,984,5,999,10; break;
						case 10: callfunc "Func_Socket",1,13001,13030,40,61,500,984,2; break;
						case 11: callfunc "Func_Socket",1,1256,1275,40,61,500,984,2; break;
						case 12: callfunc "Func_Socket",1,1257,1276,40,61,500,984,2; break;
						case 13: callfunc "Func_Socket",1,1258,1277,40,61,500,984,2; break;
						case 14: callfunc "Func_Socket",1,1259,1278,40,61,500,984,2; break;
						case 15: callfunc "Func_Socket",1,1524,1539,40,61,500,984,2; break;
						case 16: callfunc "Func_Socket",1,1918,1922,40,61,500,984,2; break;
						case 17: callfunc "Func_Socket",1,1970,1976,40,61,500,984,2; break;
						case 18: callfunc "Func_Socket",1,1477,1479,40,61,500,984,2; break;
						case 19: callfunc "Func_Socket",1,1167,1178,40,61,500,984,2; break;
					}
				break;
				
				case 4:
					mes "[Seiyablem]";
					mes "Whoa, whoa, whoa...";
					mes "S class? Alright...";
					mes "It'd be a near miracle if I can actually pull this off.";
					mes "Okay... Which weapon shall we try adding a Slot to?";
					next;
					switch( select( "Gungnir","Poison Knife","Ice Pick","Sucsamad","Ginnungagap","Cutlas","Crescent Scythe","Survivor's Rod(DEX)","Zephyrus","Mailbreaker","Swordbreaker","Assassin Dagger","Grand Cross","Executioner" ) )
					{
						case 1: callfunc "Func_Socket",2,1413,1418,40,51,1000,984,5,999,10; break;
						case 2: callfunc "Func_Socket",2,1239,13016,40,51,1000,984,5,999,10; break;
						case 3: callfunc "Func_Socket",2,1230,13017,40,51,2000,984,5,999,10; break;
						case 4: callfunc "Func_Socket",2,1236,13018,40,51,1000,984,5,999,10; break;
						case 5: callfunc "Func_Socket",2,13002,13019,40,51,1000,984,5,999,10; break;
						case 6: callfunc "Func_Socket",2,1135,13400,40,51,1000,984,5,999,10; break;
						case 7: callfunc "Func_Socket",2,1466,1476,40,51,1000,984,5,999,10; break;
						case 8: callfunc "Func_Socket",2,1617,1618,40,51,2000,984,5,999,10; break;
						case 9: callfunc "Func_Socket",2,1468,1481,40,51,1000,984,5,999,10; break;
						case 10: callfunc "Func_Socket",2,1225,13032,40,51,1000,984,5,999,10; break;
						case 11: callfunc "Func_Socket",2,1224,13031,40,51,1000,984,5,999,10; break;
						case 12: callfunc "Func_Socket",2,1232,13033,40,51,1000,984,5,999,10; break;
						case 13: callfunc "Func_Socket",2,1528,1540,40,51,1000,984,5,999,10; break;
						case 14: callfunc "Func_Socket",2,1169,1179,40,51,1000,984,5,999,10; break;
					}
				break;
			}
		break;
		
		case 2:
			mes "[Seiyablem]";
			mes "Armor, you said?";
			mes "Sure, no problem.";
			mes "Armor is divided into 4 different classes, depending on the work difficulty.";
			mes "C Class is the easiest one, and S Class he hardest one.";
			mes "Which class would you like to try?";
			set @sockettype,2;
			next;
			switch( select( "C Class","B Class","A Class","S Class" ) )
			{
				case 1:
					mes "[Seiyablem]";
					mes "C Class Armor, eh?";
					mes "Sounds reasonable.";
					mes "Which armor would you like to try adding a Slot?";
					next;
					switch( select( "Mantle","Coat","Circlet","Biretta","Sunflower","Ph.D Hat","Big Ribbon","Boys Cap" ) )
					{
						case 1: callfunc "Func_Socket",1,2307,2308,40,66,200,999,3; break;
						case 2: callfunc "Func_Socket",1,2309,2310,40,66,200,999,3; break;
						case 3: callfunc "Func_Socket",1,2232,2233,40,66,200,999,3; break;
						case 4: callfunc "Func_Socket",1,2216,2217,40,66,200,999,3; break;
						case 5: callfunc "Func_Socket",1,2253,5351,40,66,200,999,3; break;
						case 6: callfunc "Func_Socket",1,5012,5347,40,66,200,999,3; break;
						case 7: callfunc "Func_Socket",1,2244,5348,40,66,200,999,5; break;
						case 8: callfunc "Func_Socket",1,5016,5349,40,66,200,999,5; break;
					}
				break;
				
				case 2:
					mes "[Seiyablem]";
					mes "You have chosen average B Class.";
					mes "So, what kind of armor do you have?";
					next;
					switch( select( "Mirror Shield","Chain Mail","Saint Robe","Silk Robe","Boots","Shoes","Muffler","Guard","Buckler","Shield","Bongun Hat","Skull Ring","High Heels" ) )
					{
						case 1:  callfunc "Func_Socket",1,2107,2108,40,61,250,999,5; break;
						case 2:  callfunc "Func_Socket",1,2314,2315,40,61,250,999,5; break;
						case 3:  callfunc "Func_Socket",1,2325,2326,40,61,300,999,5; break;
						case 4:  callfunc "Func_Socket",1,2321,2322,40,61,300,999,5; break;
						case 5:  callfunc "Func_Socket",1,2405,2406,40,61,300,999,5; break;
						case 6:  callfunc "Func_Socket",1,2403,2404,40,61,300,999,5; break;
						case 7:  callfunc "Func_Socket",1,2503,2504,40,61,300,999,5; break;
						case 8:  callfunc "Func_Socket",1,2101,2102,40,61,300,999,5; break;
						case 9:  callfunc "Func_Socket",1,2103,2104,40,61,300,999,5; break;
						case 10: callfunc "Func_Socket",1,2105,2106,40,61,250,999,5; break;
						case 11: callfunc "Func_Socket",1,5046,5168,40,61,250,999,5; break;
						case 12: callfunc "Func_Socket",1,2609,2715,40,61,300,999,5; break;
						case 13: callfunc "Func_Socket",1,2409,2432,40,61,300,999,5; break;
					}
				break;
				
				case 3:
					mes "[Seiyablem]";
					mes "Ooh, A Class.";
					mes "This is some high risk territory!";
					mes "Alright, which armor would you like me to try adding a Slot?";
					next;
					switch( select( "Gemmed Sallet","Bucket Hat","Memory Book","Tights","Legion Plate Armor","Full Plate","Thief Clothes","Greaves","Coif","Manteau","Helm","Ninja Suit","Orc Helm","Ancient Cape","Monk Hat","Golden Gear","Brooch","Munak Hat","Pirate Bandana","Black Leather Boots" ) )
					{
						case 1:  callfunc "Func_Socket",1,2230,2231,40,61,400,985,1; break;
						case 2:  callfunc "Func_Socket",1,5114,5120,40,61,400,985,1; break;
						case 3:  callfunc "Func_Socket",1,2109,2121,40,61,400,985,1; break;
						case 4:  callfunc "Func_Socket",1,2330,2331,40,61,400,985,1; break;
						case 5:  callfunc "Func_Socket",1,2341,2342,40,61,400,985,1; break;
						case 6:  callfunc "Func_Socket",1,2316,2317,40,61,400,985,1; break;
						case 7:  callfunc "Func_Socket",1,2335,2336,40,61,400,985,1; break;
						case 8:  callfunc "Func_Socket",1,2411,2412,40,61,400,985,1; break;
						case 9:  callfunc "Func_Socket",1,5092,5093,40,61,400,985,1; break;
						case 10: callfunc "Func_Socket",1,2505,2506,40,61,400,985,1; break;
						case 11: callfunc "Func_Socket",1,2228,2229,40,61,400,985,1; break;
						case 12: callfunc "Func_Socket",1,2337,2359,40,61,400,985,1; break;
						case 13: callfunc "Func_Socket",1,2299,5157,40,61,400,985,1; break;
						case 14: callfunc "Func_Socket",1,2507,2525,40,61,400,985,1; break;
						case 15: callfunc "Func_Socket",1,2251,5158,40,61,400,985,1; break;
						case 16: callfunc "Func_Socket",1,2246,5159,40,61,400,985,1; break;
						case 17: callfunc "Func_Socket",1,2605,2625,40,61,400,985,1; break;
						case 18: callfunc "Func_Socket",1,2264,5167,40,61,300,985,1; break;
						case 19: callfunc "Func_Socket",1,2287,5350,40,61,500,985,1; break;
						case 20: callfunc "Func_Socket",1,2425,2434,40,61,500,985,1; break;
					}
				break;
				
				case 4:
					mes "[Seiyablem]";
					mes "Um... S Class?";
					mes "You sure about this?";
					mes "Alright... Let me know the Armor to which you'd like to add a Slot, and I'll tell what I need to try it.";
					next;
					switch( select( "Majestic Goat","Spiky Band","Bone Helm","Corsair","Crown","Tiara","Sphinx Hat","Robe of Cast","Earring","Ring","Bow Thimble","Mage Coat","Holy Robe","Sacred Mission","Undershirt","Pantie" ) )
					{
						case 1:  callfunc "Func_Socket",1,2256,5160,40,51,2000,985,2; break;
						case 2:  callfunc "Func_Socket",1,2258,5161,40,51,2000,985,2; break;
						case 3:  callfunc "Func_Socket",1,5017,5162,40,51,2000,985,2; break;
						case 4:  callfunc "Func_Socket",1,5019,5163,40,51,2000,985,2; break;
						case 5:  callfunc "Func_Socket",1,2235,5165,40,51,2000,985,2; break;
						case 6:  callfunc "Func_Socket",1,2234,5164,40,51,2000,985,2; break;
						case 7:  callfunc "Func_Socket",1,5053,5166,40,51,1000,985,2; break;
						case 8:  callfunc "Func_Socket",1,2343,2360,40,51,1000,985,2; break;
						case 9:  callfunc "Func_Socket",1,2602,2622,40,51,1000,985,2; break;
						case 10: callfunc "Func_Socket",1,2601,2621,40,51,1000,985,2; break;
						case 11: callfunc "Func_Socket",1,2619,2671,40,51,1000,985,2; break;
						case 12: callfunc "Func_Socket",1,2334,2372,40,51,1000,985,1; break;
						case 13: callfunc "Func_Socket",1,2327,2373,40,51,1000,985,1; break;
						case 14: callfunc "Func_Socket",1,2111,2128,40,51,1000,985,1; break;
						case 15: callfunc "Func_Socket",1,2522,2523,40,51,1000,985,1; break;
						case 16: callfunc "Func_Socket",1,2339,2371,40,51,1000,985,1; break;
					}
				break;
			}
		break;
		
		case 3:
			mes "[Seiyablem]";
			mes "Well, I haven't really refined the art of Slot Addition.";
			mes "It's so complicated that I'd be lying if I told you that I knew every factor that affected the process.";
			mes "Still, I do notice a few trends...";
			next;
			mes "[Seiyablem]";
			mes "In some towns, Slot addition attempts are more successful for equipment with fewer upgrades.";
			mes "In other towns, the opposite is true.";
			mes "isn't that really peculiar?";
			next;
			mes "[Seiyablem]";
			mes "Oh, theres also something really important that you should know.";
			mes "If you ask me to add a Slot to something, make sure that you don't have multiples of it in your inventory.";
			next;
			mes "[Seiyablem]";
			mes "Heres an example: if you have a +7 Manteau and a normal Manteau in your inventory, then I will randomly pick on of them for my Slot Addition attempt.";
			mes "Just remember to be careful.";
			next;
			mes "[Seiyablem]";
			mes "Again, ^FF0000only carry one of the equipment to wich you want me to add a Slot^000000.";
			mes "All other equipment with the same name should be placed in your Kafra Storage, got it?";
			close;
			
		case 4:
			mes "[Seiyablem]";
			mes "Take it easy, adventurer.";
			mes "If you ever want to try adding a Slot to some of your equipment, come back and let me know.";
			mes "Seeya~";
			close;
	}
}
				
function	script	Func_Socket	{

	mes "[Seiyablem]";
	mes "You want to add a Slot to a " +getitemname(getarg(1))+ "?";
	if (getarg(0) == 1)
	{
		if(getarg(5) > 999) mes "Alright, please bring me ^FF0000" +getarg(7)+ " " +getitemname(getarg(6))+ "s^000000, and my^FF0000 " +getarg(5) / 1000+",000,000 zeny^000000 service fee.";
		else mes "Alright, please bring me ^FF0000" +getarg(7)+ " " +getitemname(getarg(6))+ "s^000000, and my^FF0000 " +getarg(5)+",000 zeny^000000 service fee.";
	}
	else if (getarg(0) == 2)
	{
		if(getarg(5) > 999) mes "Alright, please bring me ^FF0000" +getarg(7)+ " " +getitemname(getarg(6))+ "^000000, ^FF0000" +getarg(9)+ " " +getitemname(getarg(8))+ "^000000 and my^FF0000 " +getarg(5) / 1000+",000,000 zeny^000000 service fee.";
		else mes "Alright, please bring me ^FF0000" +getarg(7)+ " " +getitemname(getarg(6))+ "^000000, ^FF0000" +getarg(9)+ " " +getitemname(getarg(8))+ "^000000 and my^FF0000 " +getarg(5)+",000 zeny^000000 service fee.";
	}
	mes "Ah, and don't forget to bring that " +getitemname(getarg(1))+ "!";
	next;

	if(@sockettype == 1)
	{
		mes "[Seiyablem]";
		mes "I can try to add a slot now if you have the required items and zeny.";
		mes "However, you should know that there's a chance that I might fail.";
		mes "Therefore, I need to give you a fair warning...";
		next;
		mes "[Seiyablem]";
		mes "If this attempt to add a Slot to your Weapon fails, then the ^FF0000Weapon^000000, ^FF0000and any Cards compounded to it will be destroyed^000000.";
		mes "Do you still want to try to add a Slot?";
		next;
	}
	else if(@sockettype == 2)
	{
		mes "[Seiyablem]";
		mes "If you have all the required materials, my zeny service fee and the Armor, then we can go ahead with the Slot Addition attempt.";
		mes "But before that, I must warn you of the risk.";
		next;
		mes "[Seiyablem]";
		mes "If this attempt to add a Slot to your Armor fails, then the ^FF0000Armor^000000, ^FF0000it's upgrades^000000 ^FF0000and any Cards compounded to it will be destroyed^000000.";
		mes "Do you still want to try to add a Slot?";
		next;
	}

	if ( select("Attempt Slot Addition","Cancel") == 2 )
	{
		mes "[Seiyablem]";
		mes "Need some time to think about it, huh?";
		mes "Alright, I can understand.";
		mes "Just remember that life's no fun if you're always playing it safe~";
		close;
	}

	switch(getarg(0))
	{
		case 1:		
			if((Zeny < getarg(5)*1000) || (countitem(getarg(6)) < getarg(7)) || (!countitem(getarg(1))))
			{
				mes "[Seiyablem]";
				mes "I'd like to go ahead with this Slot Addition attempt, but you're missing a few things.";
				mes "You sure that you have the equipment, required materials and the zeny?";
				close;
			}
			break;
	
		case 2:
			if((Zeny < getarg(5)*1000) || (countitem(getarg(6)) < getarg(7)) || (countitem(getarg(8)) < getarg(9)) || (!countitem(getarg(1))))
			{
				mes "[Seiyablem]";
				mes "I'd like to go ahead with this Slot Addition attempt, but you're missing a few things.";
				mes "You sure that you have the equipment, required materials and the zeny?";
				close;
			}
			break;
	}
	
	mes "[Seiyablem]";
	mes "Alright then, let the work begin!";
	mes "You'd better pray for a successful result.";
	next;
	set .@socketrand,rand(1,100);
	if((.@socketrand > getarg(3)) && (.@socketrand < getarg(4)))
	{
		if(getarg(4) == 51) specialeffect 90;
		else specialeffect 83;
		mes "[Seiyablem]";
		mes "Great, it seems to be successful.";
		mes "It looks pretty well done. Congratulations!";
		delitem getarg(1),1;
		delitem getarg(6),getarg(7);
		if(getarg(0) == 2) delitem getarg(8),getarg(9);
		set Zeny,Zeny - getarg(5)*1000;
		getitem getarg(2),1;
		next;
		mes "[Seiyablem]";
		mes "See you again, buddy!";
		close;
	}
	else
	{
		specialeffect 108;
		mes "[Seiyablem]";
		mes "Wah! ...I am so sorry, it failed.";
		mes "However, I am completely innocent.";
		mes "This is your luck, and it is destined by god, okay?";
		mes "Don't be so disappointed, and try next time.";
		delitem getarg(1),1;
		delitem getarg(6),getarg(7);
		if(getarg(0) == 2) delitem getarg(8),getarg(9);
		set Zeny,Zeny - getarg(5)*1000;
		next;
		mes "[Seiyablem]";
		mes "I wish you good luck next time!";
		close;
	}
}

lhz_in02,281,35,5	duplicate(Seiyablem)	Seiyablem#lhz	84,0,0
prt_in,33,70,5	duplicate(Seiyablem)	Seiyablem#prt	84,0,0
morocc,51,41,5	duplicate(Seiyablem)	Seiyablem#moc	84,0,0

payon,143,143,7	script	Young Man#socket	97,{

	mes "[Young Man]";
	mes "I'm considering becoming a Slotting Engineer.";
	mes "It's a new field where you can add Slots to equipment, and it'd be cool if I can work in such a lucrative career.";
	next;
	mes "[Young Man]";
	mes "There's a huge element of luck involved in successfully adding Slots from what I can understand.";
	mes "You fail sometimes, but if you're super lucky, you can add two Slots.";
	mes "Crazy. Huh?";
	next;
	mes "[Young Man]";
	mes "But don't get too excited.";
	mes "Only certain equipment can handle the addition of two extra Slots.";
	mes "There's so much more I have to learn before I can even be an apprentice...";
	close;
}

lhz_in02,269,33,5	duplicate(Young Man#socket)	Young Man#lhz	97,0,0
prt_in,31,57,1	duplicate(Young Man#socket)	Young Man#prt	97,0,0
morocc,60,42,3	duplicate(Young Man#socket)	Young Man#moc	97,0,0
