// Card removal NPC by TyrNemesis^
// DANGEROUS! TODO: Think.. think 8) [Lupus]
// Transelated By Memory.

prt_in.gat,28,73,4	script		78,{

UPGRADEROOT:
	mes "[]";
	mes "ð~~.ҿʹħװϵĿƬ.ϲ?";
	next;
	menu "ǵ.",REMOVEMENU,
	     "շѶٰ?",REMOVEPRICE,
	     ",лл.",CLOSEOUT;

REMOVEPRICE:
	mes "[]";
	mes "....жһװҪ֧^4040FF200000z^000000Zeny.";
	mes "һſƬ^4040FF25000z^000000Zeny.";
	mes ",ҪһЩ^4040FFǵĽ^000000^4040FFɫħʯ^000000.";
	next;
	menu "ǰж.",REMOVEMENU,
	     "뻹.",CLOSEOUT;

REMOVEMENU:
	mes "[]";
	mes "Ұжһװ?";
	next;
	menu "...",CLOSEOUT,
	     getequipname(1),SLOT1,
	     getequipname(2),SLOT2,
	     getequipname(3),SLOT3,
	     getequipname(4),SLOT4,
	     getequipname(5),SLOT5,
	     getequipname(6),SLOT6,
	     getequipname(7),SLOT7,
	     getequipname(8),SLOT8,
	     getequipname(9),SLOT9,
	     getequipname(10),SLOT10;

SLOT1:
	set @part,1;
	goto CARDNUMCHECK;

SLOT2:
	set @part,2;
	goto CARDNUMCHECK;

SLOT3:
	set @part,3;
	goto CARDNUMCHECK;

SLOT4:
	set @part,4;
	goto CARDNUMCHECK;

SLOT5:
	set @part,5;
	goto CARDNUMCHECK;

SLOT6:
	set @part,6;
	goto CARDNUMCHECK;

SLOT7:
	set @part,7;
	goto CARDNUMCHECK;

SLOT8:
	set @part,8;
	goto CARDNUMCHECK;

SLOT9:
	set @part,9;
	goto CARDNUMCHECK;

SLOT10:
	set @part,10;
	goto CARDNUMCHECK;

CARDNUMCHECK:
	if(getequipcardcnt(@part) == 0) goto DENYCARDCOUNT;
	set @cardcount,getequipcardcnt(@part);

	// Ensure there is room for the items.
	if (!checkweight(1202,(@cardcount+1))) { 
		mes "^3355FFJust a minute!";
		mes "I can't offer any of my";
		mes "services to you because";
		mes "you're carrying too much";
		mes "stuff. Put your extra items in";
		mes "Kafra Storage and come again~";
		close;
	}

	if(@cardcount > 1) goto CARDNUMMULTIMSG;
	mes "[]";
	mes "װĲѾ" + @cardcount + "ſƬ. ֧^0000FF" + (200000+(@cardcount * 25000)) + "Zeny^000000^0000FFǵĽ^000000^0000FFɫħʯ^000000.";
	goto CARDNUMPOSTMSG;
CARDNUMMULTIMSG:
	mes "[]";
	mes "װĲѾ" + @cardcount + "ſƬ. ֧^0000FF" + (200000+(@cardcount * 25000)) + "Zeny^000000^0000FFǵĽ^000000^0000FFɫħʯ^000000..";
CARDNUMPOSTMSG:
	next;
	menu ",ʼ.",REMOVECARDWARNING,
	     "һû׼.",CLOSEOUT;

REMOVECARDWARNING:
	mes "[]";
	mes "ڿʼ֮ǰҵȸ--ʹħһʧ.ܻ˿Ƭװ. ^FF4040⳥^000000.𻵵Ļ^FF4040뱣Ƭװ^000000?";
	next;
	menu "...",CLOSEOUT,
	     "װ.",PRIORITYITEM,
	     "Ƭ.",PRIORITYCARD;

PRIORITYITEM:
	set @failtype,1;
	goto REMOVECARD;

PRIORITYCARD:
	set @failtype,2;
	goto REMOVECARD;

REMOVECARD:
	mes "[]";
	mes "ҿʼ.";
	if((zeny < (200000+(@cardcount * 25000))) || (countitem(1000) < 1) || (countitem(715) < 1)) goto DENYMATERIAL;
	set zeny,zeny - (200000+(@cardcount * 25000));
	delitem 1000,1;
	delitem 715,1;
// Replace the constants in the next 3 lines with failure chance values defined in refine_db.txt
// First value = Total failure chance (item and cards destroyed)
// Second value = Partial failure chance (one or the other is destroyed, player decides which one is safe)
// Third value = Harmless failure chance (all that's lost is your investment)

	set @failchance,rand(100);
//	if(@failchance < 2) goto FAILREMOVECARD0;
//	if((@failchance < 8) && (@failtype == 1)) goto FAILREMOVECARD1;
//	if((@failchance < 8) && (@failtype == 2)) goto FAILREMOVECARD2;
	if(@failchance < 10) goto FAILREMOVECARD3;
	successremovecards @part;
	next;
	mes "[]";
	mes "󹦸. ĿƬ͵.ټ.";
	close;

FAILREMOVECARD0:
	failedremovecards @part,0;
	next;
	mes "[]";
	mes "̫.Ƭװ.";
	close;

FAILREMOVECARD1:
	failedremovecards @part,1;
	next;
	mes "[]";
	mes "ĵڷ.Ƭ,Һװ.";
	close;

FAILREMOVECARD2:
	failedremovecards @part,2;
	next;
	mes "[]";
	mes "Ѿ跨ƬװĲж,Ǳ.Һ,װǺõ.";
	close;

FAILREMOVECARD3:
	failedremovecards @part,3;
	next;
	mes "[]";
	mes " Ŷ~װͿƬû.";
	close;

DENYCARDCOUNT:
	mes "[]";
	mes ",û忨.";
	close;

DENYMATERIAL:
	next;
	mes "[]";
	mes "ûаѲϴ.";
	close;

CLOSEOUT:
	mes "[]";
	mes "ܺ,Ժʱ.";
	close;
}
