//===== rAthena Script =======================================
//= Episode 11.1 Socket Enchant NPC
//===== By: ==================================================
//= rAthena Dev Team
//===== Current Version: =====================================
//= 2.0a
//===== Compatible With: =====================================
//= rAthena SVN
//===== Description: =========================================
//= [Official Conversion]
//= Adds slots to selected weapons and armor.
//===== 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]
//= 1.5 Removed Ontouch trigger area from NPCs. [L0ne_W0lf]
//= 1.6 Replaced effect numerics with constants. [Samuray22]
//= 1.7 Adjusted prices on some armor and weapons. [L0ne_W0lf]
//= 1.8 Added missing Gae Bolg and Dragon Slayer. [Kisuka]
//= 1.9 Moved Episode 12 items to separate NPC.
//=     Some cleanup & optimization. [Gepard]
//= 2.0 Duplicates now spawn from floating NPCs. [L0ne_W0lf]
//= 2.0a Added 'disable_items' command. [Euphy]
//============================================================

-	script	Seiyablem#dummy::SocketEnchant	-1,{
	if (checkweight(1201,1) == 0)
	{
		mes "- һ!! -";
		mes "- ĿǰЯƷѾ -";
		mes "- һ¸֮ -";
		mes "- Ұ -";
		close;
	}
	mes "[ǲ]";
	mes "һд׵Ĵʦ";
	mes "װĲͬԼĲϣĳɹĻҲͬ";
	next;
	mes "[ǲ]";
	mes "ȻΪװ׿ܼ򵥣ʵԶеĻҪӣ֤ݾǣ֮ӵд˼..";
	mes "ԴȤ,ҿ˵,֪";
	next;
	switch(select("Ϊ:Ϊߴ:˵:ȡ"))
	{
		case 1:
			mes "[ǲ]";
			mes "Ϊ?";
			mes "ݴ׵׳̶ԼΪ4ּC׵ģSѵġ";
			mes "ѡ׶ˮ׼";
			next;
			switch(select("C:B:A:S"))
			{
				case 1:
					mes "[ǲ]";
					mes "CѶȣ";
					mes "򵥵ˡ";
					mes "ϣΪһCأ";
					next;
					switch(select("::С"))
					{
						case 1: callfunc "Func_Socket",1460,1461,40,66,200,1010,10;
						case 2: callfunc "Func_Socket",1950,1951,40,66,200,1010,10;
						case 3: callfunc "Func_Socket",1901,1902,40,66,200,1010,10;
					}
				case 2:
					mes "[ǲ]";
					mes "BѶȣ";
					mes "ͨѶȵ";
					mes "ϣΪһBأ";
					next;
					switch(select(":̽:ǹ:ì::³::צȭ:ǲ׹"))
					{
						case 1: callfunc "Func_Socket",1519,1520,40,61,300,1010,10;
						case 2: callfunc "Func_Socket",1219,1220,40,61,300, 984, 1,999,5;
						case 3: callfunc "Func_Socket",1714,1716,40,61,300, 984, 2,999,5;
						case 4: callfunc "Func_Socket",1407,1408,40,61,200,1010,10;
						case 5: callfunc "Func_Socket",1123,1128,40,61,300, 984, 2,999,5;
						case 6: callfunc "Func_Socket",1905,1906,40,61,300,1011,10;
						case 7: callfunc "Func_Socket",1954,1955,40,61,300,1011,10;
						case 8: callfunc "Func_Socket",1801,1802,40,61,300,1010,10;
						case 9: callfunc "Func_Socket",1713,1715,40,61,300, 984, 2,999,5;
					}
				case 3:
					mes "[ǲ]";
					mes "ŶAѶȣ";
					mes "ķջܸأ";
					mes "ϣΪһAأ";
					next;
					switch(select("֮:ħ(INT):޴˫ֽ:ˮ֮:ɱȭ:˹ǿ:֮:ȭ :ʮ־޽"))
					{
						case 1: callfunc "Func_Socket",1718,1726,40,61,500,984,2,999,10;
						case 2: callfunc "Func_Socket",1619,1620,40,61,500,984,5,999,10;
						case 3: callfunc "Func_Socket",1168,1171,40,61,800,984,5,999,10;
						case 4: callfunc "Func_Socket",1129,1149,40,61,500,984,2,999,10;
						case 5: callfunc "Func_Socket",1261,1266,40,61,700,984,5,999,10;
						case 6: callfunc "Func_Socket",1722,1727,40,61,500,984,5,999,10;
						case 7: callfunc "Func_Socket",1522,1532,40,61,500,984,2,999,10;
						case 8: callfunc "Func_Socket",1814,1816,40,61,500,984,5,999,10;
						case 9: callfunc "Func_Socket",1163,1172,40,61,500,984,2,999,10; // NPC says "5 Oridecon" (Aegis) but takes only 2
					}
				case 4:
					mes "[ǲ]";
					mes ",,...";
					mes "Sȼ?ȷ....";
					mes "£⽫һ档";
					mes "ϣΪһSأ";
					next;
					switch(select("ì:޶̽:Ƽ׶׶:ɳ̽:ս:֮:֮:ħ(DEX)"))
					{
						case 1: callfunc "Func_Socket", 1413, 1418,40,51,1000,984,5,999,10;
						case 2: callfunc "Func_Socket", 1239,13016,40,51,1000,984,5,999,10;
						case 3: callfunc "Func_Socket", 1230,13017,40,51,2000,984,5,999,10;
						case 4: callfunc "Func_Socket", 1236,13018,40,51,1000,984,5,999,10;
						case 5: callfunc "Func_Socket",13002,13019,40,51,1000,984,5,999,10;
						case 6: callfunc "Func_Socket", 1135,13400,40,51,1000,984,5,999,10;
						case 7: callfunc "Func_Socket", 1466, 1476,40,51,1000,984,5,999,10;
						case 8: callfunc "Func_Socket", 1617, 1618,40,51,2000,984,5,999,10;
					}
			}
		case 2:
			mes "[ǲ]";
			mes "..?";
			mes "Ȼ,û";
			mes "ݴ׵׳̶ԼΪ4ּC׵ģSѵġ";
			mes "ҪѡʲôȼԴ?";
			next;
			switch(select("C:B:A:S"))
			{
				case 1:
					mes "[ǲ]";
					mes "Cȼ,?";
					mes "ܺ";
					mes "볢Ϊʲôߴ?";
					next;
					switch(select(";;ͷ;ʥְ֮ñ"))
					{
						case 1: callfunc "Func_Socket",2307,2308,40,66,200,999,3;
						case 2: callfunc "Func_Socket",2309,2310,40,66,200,999,3;
						case 3: callfunc "Func_Socket",2232,2233,40,66,200,999,3;
						case 4: callfunc "Func_Socket",2216,2217,40,66,200,999,3;
					}
				case 2:
					mes "[ǲ]";
					mes "ѡBȼ.";
					mes "ô,Ҫѡʲôķ?";
					next;
					switch(select(":Ӽ:ʥְ֮:˿:սʿѥ:ѥ:::Բ:ֶ:ñ"))
					{
						case 1:  callfunc "Func_Socket",2107,2108,40,61,250,999,5;
						case 2:  callfunc "Func_Socket",2314,2315,40,61,250,999,5;
						case 3:  callfunc "Func_Socket",2325,2326,40,61,300,999,5;
						case 4:  callfunc "Func_Socket",2321,2322,40,61,300,999,5;
						case 5:  callfunc "Func_Socket",2405,2406,40,61,300,999,5;
						case 6:  callfunc "Func_Socket",2403,2404,40,61,300,999,5;
						case 7:  callfunc "Func_Socket",2503,2504,40,61,300,999,5;
						case 8:  callfunc "Func_Socket",2101,2102,40,61,300,999,5;
						case 9:  callfunc "Func_Socket",2103,2104,40,61,300,999,5;
						case 10: callfunc "Func_Socket",2105,2106,40,61,250,999,5;
						case 11: callfunc "Func_Socket",5046,5168,40,61,250,999,5;
					}
				case 3:
					mes "[ǲ]";
					mes "Ŷ! A ȼ.";
					mes "һܸ߷յս!";
					mes "ð,ҪַϳԴף";
					next;
					switch(select("ʯͷ:ñ:Լ¼::::֮:ѥ:Ůñ::ͷ:̷ Ѫӣ:ͷ::ʥ֮ñ:ƽñ:ݱ:ʬñ"))
					{
						case 1:  callfunc "Func_Socket",2230,2231,40,61,400,985,1;
						case 2:  callfunc "Func_Socket",5114,5120,40,61,400,985,1;
						case 3:  callfunc "Func_Socket",2109,2121,40,61,400,985,1;
						case 4:  callfunc "Func_Socket",2330,2331,40,61,400,985,1;
						case 5:  callfunc "Func_Socket",2341,2342,40,61,400,985,1;
						case 6:  callfunc "Func_Socket",2316,2317,40,61,400,985,1;
						case 7:  callfunc "Func_Socket",2335,2336,40,61,400,985,1;
						case 8:  callfunc "Func_Socket",2411,2412,40,61,400,985,1;
						case 9:  callfunc "Func_Socket",5092,5093,40,61,400,985,1;
						case 10: callfunc "Func_Socket",2505,2506,40,61,400,985,1;
						case 11: callfunc "Func_Socket",2228,2229,40,61,400,985,1;
						case 12: callfunc "Func_Socket",2337,2359,40,61,400,985,1;
						case 13: callfunc "Func_Socket",2299,5157,40,61,400,985,1;
						case 14: callfunc "Func_Socket",2507,2525,40,61,400,985,1;
						case 15: callfunc "Func_Socket",2251,5158,40,61,400,985,1;
						case 16: callfunc "Func_Socket",2246,5159,40,61,400,985,1;
						case 17: callfunc "Func_Socket",2605,2625,40,61,400,985,1;
						case 18: callfunc "Func_Socket",2264,5167,40,61,300,985,1;
					}
				case 4:
					mes "[ǲ]";
					mes "....Sȼ?";
					mes "ȷ?";
					mes "Ҫʲôߴ,һŬԣõĳƷ!";
					next;
					switch(select("ɽͷ:ǷȦ:ͷ:ñ:::ʨñ:::ָ:"))
					{
						case 1:  callfunc "Func_Socket",2256,5160,40,51,2000,985,2;
						case 2:  callfunc "Func_Socket",2258,5161,40,51,2000,985,2;
						case 3:  callfunc "Func_Socket",5017,5162,40,51,2000,985,2;
						case 4:  callfunc "Func_Socket",5019,5163,40,51,2000,985,2;
						case 5:  callfunc "Func_Socket",2235,5165,40,51,2000,985,2;
						case 6:  callfunc "Func_Socket",2234,5164,40,51,2000,985,2;
						case 7:  callfunc "Func_Socket",5053,5166,40,51,1000,985,2;
						case 8:  callfunc "Func_Socket",2343,2360,40,51,1000,985,2;
						case 9:  callfunc "Func_Socket",2602,2622,40,51,1000,985,2;
						case 10: callfunc "Func_Socket",2601,2621,40,51,1000,985,2;
						case 11: callfunc "Func_Socket",2619,2671,40,51,1000,985,2;
					}
			}
		case 3:
			mes "[ǲ]";
			mes "ʲô...ҪһʾĻ˵Ĵʦۻ˷ḻľ֮Ŵ´˹ģܾ¡ֵԽߵװ򶴵ĳɹԽ";
			next;
			mes "[ǲ]";
			mes "Ȼ΢ܾԽǵ;װԽ״ʧ..";
			mes "ȻһʧܵĻװҲȫ...ɹʵĻֵһԵġ";
			next;
			mes "[ǲ]";
			mes "⣬Ҫעһǣ...";
			mes "˵ϴ+7ûĶȻίи׵Ļ߼һһأ";
			next;
			mes "[ǲ]";
			mes "ǡ...";
			mes "Ҳ˵ͬƵװʱǲ뷨ѡһװд׵ģ";
			next;
			mes "[ǲ]";
			mes "^FF0000һװд׵ĻֻҪһͬƵװϾˡֲͬ׵װ÷ŵĲֿ⣬Ȼң^000000";
			next;
			mes "[ǲ]";
			mes "ûƴĻһ㲻ϣ׵װϽдףĻҿǲ..";
			mes "סм";
			next;
			mes "[ǲ]";
			mes "Ҳ˵˰ɣ";
			mes "ˣŲһ";
			mes "ҪҪսһ´أ";
			mes "ҲҪڹӰ";
			close;
		case 4:
			mes "[ǲ]";
			mes ",ðռҡ";
			mes "ҪԸװ,ô뽫װҿ";
			mes "ټ~";
			close;
	}
}

function	script	Func_Socket	{

	mes "[ǲ]";
	mes "ҪΪ "+ getitemname(getarg(0))+ " ׶ô";
	mes "ðɣô";
	mes "^FF0000" + getarg(6) + "  " + getitemname(getarg(5)) + (getarg(6) > 1 && getarg(5) != 999 ? "":"") + "^000000, " + (getarg(7,0) != 0 && getarg(8,0) != 0 ? ("^FF0000" + getarg(8,0) + " " + getitemname(getarg(7,0)) + (getarg(8,0) > 1 && getarg(7,0) != 999 ? "":"") + "^000000 ") : "") + "Լ ^FF0000" + (getarg(4) >= 1000 ? (getarg(4)/1000 + ",000") : getarg(4)) + ",000 zeny^000000 ѡ";
	mes "ˣǴҪ׵ " + getitemname(getarg(0)) + "!";
	next;
	mes "[ǲ]";
	if (getiteminfo(getarg(0),5)&2) // EQP_HAND_R = 2, it's a weapon
	{
		mes "׼ҪƷͷãһ᳢ϴס";
		mes "֮ǰ,ұ뾯";
		next;
		mes "[ǲ]";
		mes "Դ׵ʱʧ,ô^FF0000^000000 Լ ^FF0000ϵпƬ^000000,^FF0000ݻ^000000";
	}
	else // armor
	{
		mes "׼ҪƷͷãһ᳢ķϴס";
		mes "֮ǰ,ұ뾯";
		next;
		mes "[ǲ]";
		mes "Դ׵ķʱʧ,ô^FF0000^000000 Լ ^FF0000ϵпƬ^000000,^FF0000ݻ^000000";
	}
	mes "㻹Դ?";
	next;
	switch(select("Ǽ:ȡ"))
	{
		case 1:
			if ((Zeny >= getarg(4)*1000) && (countitem(getarg(5)) >= getarg(6)) && (countitem(getarg(7,512)) >= getarg(8,0)) && (countitem(getarg(0)) > 0)) // if there's no getarg(7) and getarg(8) provided, check itemcount against 0 (we still need a valid item ID though)
			{
				mes "[ǲ]";
				mes "ð,ҿʼ!";
				mes "һɹĽ";
				next;
				set .@a, rand(1,100);
				if ((.@a > getarg(2)) && (.@a < getarg(3)))
				{
					specialeffect getarg(3) == 51 ? EF_LORD : EF_SANCTUARY; // only S Class items have Lord of Vermillion effect
					mes "[ǲ]";
					mes "ܺ,ɹˣ";
					mes "ǳϲ!";
					delitem getarg(0),1;
					delitem getarg(5),getarg(6);
					if (getarg(7,0) != 0 && getarg(8,0) != 0)
						delitem getarg(7),getarg(8);
					set Zeny, Zeny - getarg(4)*1000;
					getitem getarg(1),1;
					next;
					mes "[ǲ]";
					mes "ϣ´ڼ!";
					close;
				}
				else
				{
					specialeffect EF_SUI_EXPLOSION;
					mes "[ǲ]";
					mes "!ҺܱǸ,ʧˡ";
					mes ",ȫ޹ġ";
					mes "RP,ϵŪ,ע,?";
					mes "ôʧ,´ڳһ˵RPᱬ";
					delitem getarg(0),1;
					delitem getarg(5),getarg(6);
					if (getarg(7,0) != 0 && getarg(8,0) != 0)
						delitem getarg(7),getarg(8);
					set Zeny, Zeny - getarg(4)*1000;
					next;
					mes "[ǲ]";
					mes "ף´κ!";
					close;
				}
			}
			else
			{
				mes "[ǲ]";
				mes "ȱһЩɡ";
				mes "ȷҪ׵װ,ҪĲϺ㹻ķ?";
				close;
			}
		case 2:
			mes "[ǲ]";
			mes "ҪһЩʱ,?";
			mes "ð,ҿȫס";
			mes "ס,ðյĻǲȤ~";
			close;
	}
}

payon,140,151,5	duplicate(SocketEnchant)	ǲ#pay	84
lhz_in02,281,35,5	duplicate(SocketEnchant)	ǲ#lhz	84
prt_in,33,70,5	duplicate(SocketEnchant)	ǲ#prt	84
morocc,51,41,4	duplicate(SocketEnchant)	ǲ#moc	84

-	script	Young Man#dummy::SocketMan	-1,{
	mes "[]";
	mes "ڿǳΪһʦ";
	mes "һֶ,Ӳ۵豸,侲,һͼְҵ";
	next;
	mes "[]";
	mes "һ޴ĳɷֲɹӴĲۡ";
	mes "ʧܵʱ,㳬,";
	mes ".?";
	next;
	mes "[]";
	mes "ǲҪ̫";
	mes ".ֻĳЩװԴĲۡ";
	mes "иණұѧϰ֮ǰ,˵һѧͽ";
	close;
}

prt_in,31,57,1	duplicate(SocketMan)	#prt	97
payon,143,143,7	duplicate(SocketMan)	#pay	97
morocc,60,42,3	duplicate(SocketMan)	#moc	97
lhz_in02,269,33,5	duplicate(SocketMan)	#lhz	97
