//===== rAthena Script ======================================= 
//= Episode 12 Socket Enchant NPC
//===== By: ================================================== 
//= Gepard
//===== Current Version: ===================================== 
//= 1.1a
//===== Compatible With: ===================================== 
//= rAthena SVN
//===== Description: ========================================= 
//= [Official Conversion]
//= Adds slots to selected weapons and armor.
//===== Additional Comments: ================================= 
//= 1.0 First version.
//= 1.1 Duplicates now spawn from floating NPCs. [L0ne_W0lf]
//= 1.1a Added 'disable_items' command. [Euphy]
//============================================================ 

-	script	ǲ#dummy::SocketEnchant2	-1,{
	if (checkweight(1201,1) == 0)
	{
		mes "- Ǹ !! -";
		mes "- ڶ̫. -";
		mes "- ȥһ. -";
		close;
	}
	mes "[ǲ]";
	mes ",ҽǲ,";
	mes "óǸװ.";
	mes "ȻѶ,ϲ.";
	mes "ҲΪҵеԺ.";
	next;
	mes "[ǲ]";
	mes "ѾӸǲѧٶ,";
	mes "Ҿãһвȱ.";
	mes "ԭ,,";
	mes "ҵ.";
	next;
	mes "[ǲ]";
	mes "ʵ...粻ԸңĻͻĶ.";
	mes ",Ǿܵ.";
	next;
	mes "[ǲ]";
	mes "ĺܸл,ѧô.";
	mes "Լ㲻ô߰о";
	mes ",һܹ,ӵ.";
	next;
	mes "[ǲ]";
	mes "ʵ,һҸҲҪȥ,Ҳѹ...";
	mes ",,ұ!";
	next;
	mes "[ǲ]";
	mes ",˵,ûҪ򶴵װ?";
	mes "ҵշ,Ҫ,Լɹ";
	mes "ȫȡҪʲôϴ.";
	next;
	switch(select("Ϊ:Ϊߴ:˵ʲôȤ:˵:û"))
	{
		case 1:
			mes "[ǲ]";
			mes "OK..";
			mes "ֵȼ,ֲͬĳɹ.";
			mes "C򵥣S.";
			mes "Ҫʲôȼ?";
			next;
			switch(select("C:B:A:S"))
			{
				case 1:
					mes "[ǲ]";
					mes "C?";
					mes "ô,ѡҪ򶴵װ.";
					next;
					switch(select("֮:ˮ֮:֮:֮"))
					{
						case 1: callfunc "Func_Socket2",1554,1569,40,66,200,1010,10;
						case 2: callfunc "Func_Socket2",1553,1568,40,66,200,1010,10;
						case 3: callfunc "Func_Socket2",1556,1571,40,66,200,1010,10;
						case 4: callfunc "Func_Socket2",1555,1570,40,66,200,1010,10;
					}
				case 2:
					mes "[ǲ]";
					mes "ѡһB.";
					mes "Ҫһ?";
					next;
					switch(select("˸:䵶:ä֮"))
					{
						case 1: callfunc "Func_Socket2",1304,1309,40,66,200,984,1;
						case 2: callfunc "Func_Socket2",1113,1114,40,66,200,984,1;
						case 3: callfunc "Func_Socket2",1523,1538,40,61,300,984,1;
					}
				case 3:
					mes "[ǲ]";
					mes "A? ...ð.";
					mes "Ҫʲô?";
					next;
					switch(select("̽:ȭ:ȭ:ȭ:ȭ:ƽ֮::Ůı:ֵǹ:Ұì:֮"))
					{
						case 1:  callfunc "Func_Socket2",13001,13030,40,61,500,984,2;
						case 2:  callfunc "Func_Socket2", 1257, 1276,40,66,500,984,2;
						case 3:  callfunc "Func_Socket2", 1258, 1277,40,66,500,984,2;
						case 4:  callfunc "Func_Socket2", 1256, 1275,40,66,500,984,2;
						case 5:  callfunc "Func_Socket2", 1259, 1278,40,66,500,984,2;
						case 6:  callfunc "Func_Socket2", 1524, 1539,40,61,500,984,2;
						case 7:  callfunc "Func_Socket2", 1918, 1922,40,61,500,984,2;
						case 8:  callfunc "Func_Socket2", 1970, 1976,40,61,500,984,2;
						case 9:  callfunc "Func_Socket2", 1477, 1479,40,56,500,984,2;
						case 10: callfunc "Func_Socket2", 1474, 1480,40,56,500,984,2;
						case 11: callfunc "Func_Socket2", 1167, 1178,40,61,500,984,2;
					}
				case 4:
					mes "[ǲ]";
					mes ", S?! ...?*ԲԲԲ~*";
					mes "ô,һSװô?!";
					next;
					switch(select("֮ì:Ƽ׶̽::ж̽:̽ Թ:Gʥ ʮ:֮"))
					{
						case 1: callfunc "Func_Socket2",1468, 1481,40,51,1000,984,5,999,10;
						case 2: callfunc "Func_Socket2",1225,13032,40,51,1000,984,5,999,10;
						case 3: callfunc "Func_Socket2",1166, 1180,40,51,1000,984,5,999,10;
						case 4: callfunc "Func_Socket2",1224,13031,40,51,1000,984,5,999,10;
						case 5: callfunc "Func_Socket2",1232,13033,40,51,1000,984,5,999,10;
						case 6: callfunc "Func_Socket2",1528, 1540,40,51,1000,984,5,999,10;
						case 7: callfunc "Func_Socket2",1169, 1179,40,51,1000,984,5,999,10;
					}
			}
		case 2:
			mes "[ǲ]";
			mes "ҪԷߴѽ,õ.";
			mes "ֵȼķ,ֲͬĳɹ.";
			mes "C.S.";
			mes "Ҫʲôȼķ?";
			next;
			switch(select("C:B:A:S"))
			{
				case 1:
					mes "[ǲ]";
					mes "C.";
					mes "ôҪһַ?";
					next;
					switch(select("տͷ:ѧʿñ::ѧñ"))
					{
						case 1: callfunc "Func_Socket2",2253,5351,40,66,100,999,3;
						case 2: callfunc "Func_Socket2",5012,5347,40,66,100,999,3;
						case 3: callfunc "Func_Socket2",2244,5348,40,66,100,999,5;
						case 4: callfunc "Func_Socket2",5016,5349,40,66,100,999,5;
					}
				case 2:
					mes "[ǲ]";
					mes "ѡBװŶ.";
					mes "ôҪһװ?";
					next;
					switch(select("ýָ:ħЬ"))
					{
						case 1: callfunc "Func_Socket2",2609,2715,40,61,300,999,5;
						case 2: callfunc "Func_Socket2",2409,2432,40,61,300,999,5;
					}
				case 3:
					mes "[ǲ]";
					mes "A? ...ð˵.";
					mes "ʲôװ?";
					next;
					switch(select("ͷ:ɫƤﳤѥ"))
					{
						case 1: callfunc "Func_Socket2",2287,5350,50,61,500,985,1; // 50,61 - it's not a typo
						case 2: callfunc "Func_Socket2",2425,2434,40,51,500,985,1;
					}
				case 4:
					mes "[ǲ]";
					mes "S?! ...?*ԲԲԲ~*";
					mes "ô,Sװô?!";
					next;
					switch(select("ħ::ʹ֮::ǿ"))
					{
						case 1: callfunc "Func_Socket2",2334,2372,40,51,1000,985,1; // Mage Coat has 10% success chance
						case 2: callfunc "Func_Socket2",2327,2373,45,51,1000,985,1; // the rest has 5%
						case 3: callfunc "Func_Socket2",2111,2128,45,51,1000,985,1;
						case 4: callfunc "Func_Socket2",2522,2523,45,51,1000,985,1;
						case 5: callfunc "Func_Socket2",2339,2371,45,51,1000,985,1;
					}
			}
		case 3:
			mes "[ǲ]";
			mes "ʵ...Ҳûʲô,ΪⲢ.";
			mes "ĲҸŪʧ,һ˰. ";
			next;
			mes "[ǲ]";
			mes "...Ȼɹʺܸ,Ҫܶ,";
			mes "ȻȥҲߵ. ";
			mes "ľüʹҿ,ܷܹ֧ҲǸܴ.";
			next;
			mes "[ǲ]";
			mes "......";
			next;
			mes "[ǲ]";
			mes ".............";
			next;
			mes "[ǲ]";
			mes ".............";
			next;
			mes "[ǲ]";
			mes "Ȥ.";
			mes "ð,Ҿͺ˵һ. ";
			mes "Ǳ֤,Ҫй¶.";
			mes "Ҹ緢Ҹ,Ҿ군!";
			next;
			mes "[ǲ]";
			mes "ķ 90% ĳɹ,";
			mes "Ҫ^ff0000ƽ^000000^ff0000 Zeny^000000.";
			mes "ҿΪ̫ͷ.";
			next;
			mes "[ǲ]";
			mes "羯ңʹԶʱ,Ҳǲⶥñϴ򶴵. ";
			mes "Ҿð,̲סҪȥ̽һµĺ,";
			mes "رǶЩֹĶ.";
			mes ",ҪǲҸҴ,...";
			next;
			switch(select(",Ҫʹô˷","Ի"))
			{
				case 1:
					mes "[ǲ]";
					mes ".................";
					next;
					mes "[ǲ]";
					mes ".................";
					next;
					mes "[ǲ]";
					mes "...ʲ... ʲô? Ҫ!";
					mes "!";
					mes "Ҫ!˵˲Ҫ!ҪǲҪ!!";
					next;
					mes "[ǲ]";
					mes "Ҫ,Ҳ!";
					next;
					mes "[ǲ]";
					mes "Ҳ...";
					next;
					mes "[ǲ]";
					mes "Ҳ... ...";
					next;
					mes "[ǲ]";
					mes ".................";
					next;
					mes "[ǲ]";
					mes "...";
					next;
					mes "[ǲ]";
					mes "Ǻ,ֻһ.";
					mes "˭Ҫ,رҸ,";
					mes "Ҫŵ!";
					next;
					mes "[ǲ]";
					mes "ô";
					mes "^FF00002ƽ  2,000,000 Zeny ,";
					mes "^FF0000һ ̫ͷ.";
					mes "^FF0000֪ɹΪ 90% Ķ԰?^000000";
					mes "ȴ,!";
					next;
					if ((Zeny > 199999999) && (countitem(969) > 1) && (countitem(5022) > 0))
					{
						mes "[ǲ]";
						mes "ʼ.";
						mes ",ף.";
						next;
						set .@a, rand(1,100);
						if ((.@a > 4) && (.@a < 95))
						{
							specialeffect EF_LORD;
							mes "[ǲ]";
							mes "! 봫е 90% ɹʲǿѨ!";
							mes ",Ĵ!ϲϲ!";
							delitem 5022,1; //Helm_Of_Sun
							delitem 969,2; //Gold
							set Zeny, Zeny - 200000000;
							getitem 5353,1; //Helm_Of_Sun_
							next;
							mes "[ǲ]";
							mes "ǵһ,Ҳһ.";
							mes "Ҫκ,?";
							close;
						}
						else
						{
							specialeffect EF_SUI_EXPLOSION;
							mes "[ǲ]";
							mes "! ҵ,ʧ!";
							mes ",ײ...";
							mes "Ǹô? ...Ҳǳзԭ!";
							delitem 5022,1; //Helm_Of_Sun
							delitem 969,2; //Gold
							set Zeny, Zeny - 200000000;
							next;
							mes "[ǲ]";
							mes ",ٽ!ټ!";
							close;
						}
					}
					else
					{
						mes "[ǲ]";
						mes "...";
						next;
						mes "[ǲ]";
						mes "û㹻Ĳϰ,?.";
						mes "ٸ,ʹ.ټ~";
						close;
					}
				case 2:
					mes "[ǲ]";
					mes "˭Ҫ,?";
					close;
			}
		case 4:
			mes "[ǲ]";
			mes "֪Ϣ?";
			mes "ûʲôرҪ,иСʾ.";
			next;
			mes "[ǲ]";
			mes "ԱĴ򶴳ɹ,";
			mes "ȡľȺʹԱ˵.";
			mes "ȻǷ100%׼,";
			mes "ҺĿÿԱɹǲͬ.";
			next;
			mes "[ǲ]";
			mes "ٸ,һĴԱܹڸ߾װ򶴵ʱ򷢻ӳߵĳɹʵ,";
			mes "һϵĴԱ;װ򶴵ʱᷢӳߵĳɹ.";
			next;
			mes "[ǲ]";
			mes "ʧܵʱ,.";
			mes "һᾡ,Ǵ򶴵ȷܸ.";
			next;
			mes "[ǲ]";
			mes "мҪҪס.";
			mes "^FF0000򶴵ʱͬҪƷ.";
			mes "^FF0000Ļ,ʦҲ֪㵽ҪһװĶ,";
			mes "^FF0000Ȼһ.ҲʱصĶOVER.^000000";
			next;
			mes "[ǲ]";
			mes "ϣ԰ﵽæ.лл.";
			close;
		case 5:
			mes "[ǲ]";
			mes ",õ.";
			close;
	}
}

payon,236,199,3	duplicate(SocketEnchant2)	ǲ#pay	86
lighthalzen,96,137,3	duplicate(SocketEnchant2)	ǲ#lhz	86
prt_in,22,60,6	duplicate(SocketEnchant2)	ǲ#prt	86
moc_ruins,154,86,3	duplicate(SocketEnchant2)	ǲ#moc	86

function	script	Func_Socket2	{

	disable_items;
	mes "[ǲ]";
	if(getarg(7,0) != 0 && getarg(8,0) != 0)
	{
		mes getitemname(getarg(0)) + "... ,Ǿʹ";
		mes "1^FF0000" + (getarg(4) >= 1000 ? (getarg(4)/1000 + ",000") : getarg(4)) + ",000 zeny^000000 . ";
		mes "2^FF0000" + getarg(6) + "^000000  ^FF0000" + getitemname(getarg(5)) + "^000000";
		mes "3^FF0000" + getarg(8) + "^000000  ^FF0000" + getitemname(getarg(7)) + "^000000";
		mes "4˴򶴵 ^FF0000" + getitemname(getarg(0)) + " ^000000";
		mes "ҪЩȫ.";
	}
	else
	{
		mes getitemname(getarg(0)) + "? ,Ǿʹ";
		mes "1^FF0000" + (getarg(4) >= 1000 ? (getarg(4)/1000 + ",000") : getarg(4)) + ",000 zeny^000000 . ";
		mes "2^FF0000" + getarg(6) + "^000000  ^FF0000" + getitemname(getarg(5)) + "^000000";
		mes "3˴򶴵 ^FF0000" + getitemname(getarg(0)) + " ^000000";
		mes "ҪЩȫ.";
	}
	next;
	mes "[ǲ]";
	mes "㶼?";
	mes "Ӵ,ʧ,ǴõĶ,"+(getiteminfo(getarg(0),5)&2 ? "" : "װ")+",ữΪҷɡ";
	mes "ҲҪס^0000FF" + (getiteminfo(getarg(0),5)&2 ? "" : "װ") + ",߲,ôʹɹ˾ֵͿҲʧ^000000.";
	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 EF_LORD;
					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 "Ǳϵ۵ּҵѽ!";
					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;
					next;
					mes "[ǲ]";
					mes "̫Ļ,ټ!";
					close;
				}
			}
			else
			{
				mes "[ǲ]";
				mes "ɵô?";
				mes "˸![г]!";
				close;
			}
		case 2:
			mes "[ǲ]";
			mes "Сʻ괬ô´ټ.";
			close;
	}
}
