//===== eAthena Script ======================================= 
//= * Sign Your Items *
//===== By: ================================================== 
//= Lupus
//===== Current Version: ===================================== 
//= 1.0
//===== Compatible With: ===================================== 
//= eAthena 1
//===== Description: ========================================= 
//= Write you name on your rare equipment or weapon ^_-
//= Original X-Mas mini-quest(could be used as a permanent one)
//===== Additional Comments: ================================= 
//= 1.0 First release
//============================================================

prt_in.gat,24,61,7	script	Perchik	47,{
	mes "[Perchik]";
	if(BaseJob==Job_Novice || BaseLevel<50) {
		mes "Sorry, I don't help newbies. Go kill more Porings.";
		emotion e_sry;
		close;
	}
	mes "Hi, I can ^000090sign your name^000000 on almost any rare item you can hold.";
	next;
	menu "Tell me more...",-, "Sign my items, please",M_DO;

	mes "[Perchik]";
	mes "I can put your name on any slotless equipment or weapon.";
	emotion e_ic;
	next;
	mes "[Perchik]";
	mes "A week ago, my BOSS told me to send away newbies. I dunno why.";
	next;
	mes "[Perchik]";
	mes "For my work I accept ^0000803 Gift Box^000000es (gray one)";
	mes "plus ^FF00005000z^000000 per each refine of your item.";
	next;
	emotion e_cry;
	mes "[Perchik]";
	mes "Alas, I have 12 hungry children";
	mes "and a very angry wife.";
	next;
	mes "[Perchik]";
	mes "Or it was... 12 angry children";
	mes "and a very hungry wife...";
	emotion e_hmm;
	close;

M_DO:
	mes "[Perchik]";
	mes "Show me your items to sign...";
M_MENU:
	next;
	menu getequipname(1),M_PART1,getequipname(9),M_PART9,getequipname(10),M_PART10,getequipname(2),M_PART2,getequipname(4),M_PART4,
	     getequipname(3),M_PART3,getequipname(5),M_PART5,getequipname(6),M_PART6,getequipname(7),M_PART7,getequipname(8),M_PART8;

	//Head Gear
	M_PART1:
		set @part,1;
		if (getequipisequiped(1)) goto L_CHECK1;
		mes "[Perchik]";
		mes "A bald head under a cheap wig... There's nothing worthy to sign.";
		emotion 6;
		goto M_MENU;
	M_PART9:
		set @part,9;
		if (getequipisequiped(9)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Glasses... I can't see any glasses...";
		emotion 20;
		goto M_MENU;
	M_PART10:
		set @part,10;
		if (getequipisequiped(10)) goto L_CHECK1;
		mes "[Perchik]";
		mes "I don't see any mask here.";
		emotion 20;
		goto M_MENU;
	//Armor
	M_PART2:
		set @part,2;
		if (getequipisequiped(2)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Your belly...? Yes, it's rather fat.";
		emotion 6;
		goto M_MENU;
	//Left Hand
	M_PART3:
		set @part,3;
		if (getequipisequiped(3)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Sign your left hand? I'm not a celebrity, you know...";
		emotion 4;
		goto M_MENU;
	//Right Hand
	M_PART4:
		set @part,4;
		if (getequipisequiped(4)) goto L_CHECK1;
		mes "[Perchik]";
		mes "It isn't an armor... It's a mud!!! Wash your hands more often.";
		emotion 4;
		goto M_MENU;
	//Garment
	M_PART5:
		set @part,5;
		if (getequipisequiped(5)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Look... It's empty...";
		goto M_MENU;
	//Foot Gear
	M_PART6:
		set @part,6;
		if (getequipisequiped(6)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Aw!! I don't like stinky feet.";
		emotion 16;
		goto M_MENU;
	//Accessory1
	M_PART7:
		set @part,7;
		if (getequipisequiped(7)) goto L_CHECK1;
		mes "[Perchik]";
		mes "Yep... a pocket with a huge hole...";
		emotion 20;
		goto M_MENU;
	//Accessory2
	M_PART8:
		set @part,8;
		if (getequipisequiped(8)) goto L_CHECK1;
		mes "[Perchik]";
		mes "I see your fat belly...";
		emotion 20;
		goto M_MENU;

L_CHECK1:
	set @ref,0;
	set @id,getequipid(@part);
	if(getequipisidentify(@part)) goto L_CHECK2;
	mes "[Perchik]";
	mes "How could you equip such unknown item?";
	npctalk "What a sneaky cheater!";
	emotion e_wah;
	close;

L_CHECK2:
	set @ref,getequiprefinerycnt(@part);
	mes "[Perchik]";
	mes "You want me to sign your "+getitemname(@id)+"...";
	if(BaseJob==Job_Novice) {
		mes "But you're a Novice. My BOSS told me to send such weaklings away.";
		emotion e_sry;
		goto M_MENU;
	}
	set @slot0,getequipcardid(@part,0);
	set @slot1,getequipcardid(@part,1);
	set @slot2,getequipcardid(@part,2);
	set @slot3,getequipcardid(@part,3);

	if(@slot0==255 || @slot0==254 || @slot0<0) {
		mes "Alas, this item's already signed.";
		mes "I would never touch masters work.";
		emotion e_hmm;
		goto M_MENU;
	}
	if(@slot0>4000 && @slot0<5000) {
		mes "A card? Here?!";
		mes "As I said before, I don't sign items with cards.";
		emotion e_hmm;
		goto M_MENU;
	}
	if(getiteminfo(@id,10)) {
		mes "Sorry. I don't sign slotted items.";
		emotion e_sry;
		goto M_MENU;
	}

	if(@ref)mes "It has been refined "+@ref+" times... Adding ^FF00005000z^000000 per time.";
	mes "Give me ^0000803 gray Gift Boxes^000000";
	if(@ref)mes "and ^FF0000"+(5000*@ref)+"z^000000.";
	next;
	menu "Ok!",-, "Leave",M_END;
	if(Zeny>=(5000*@ref) && countitem(644)>=3) {
		delitem 644,3;
		set Zeny,Zeny-(5000*@ref);
		goto L_MAKE;
	}
	mes "[Perchik]";
	mes "I don't work for 'thanks'.";
	emotion e_sry;
	close;

L_MAKE:
	if(countitem2(@id,1,@ref,0,@slot0,@slot1,@slot2,@slot3)==0) {
		mes "[Perchik]";
		mes "Where is... "+getitemname(@id)+"?";
		npctalk "You're a snoozy cheater!";
		logmes "CHEATER: Tried to sign an item not having it: "+getitemname(@id);
		emotion e_wah;
		close;
	}
	delitem2 @id,1,1,@ref,0,@slot0,@slot1,@slot2,@slot3;

	mes "[Perchik]";
	mes "Done!";
	emotion e_proud;

	getitem2 @id,1,1,@ref,0,254,0,getcharid(0)&0xffff,(getcharid(0)>>16)&0xffff;
	close;

M_END:
	mes "[Perchik]";
	mes "See you...";
	emotion e_yawn;
	close;
}
