prontera,132,188,0	script	Allysia	4_M_KNIGHT_GOLD,{
	callfunc "refinemain2","Allysia",1;
	end;
OnInit:
	addmonsterdrop(SOHEE, Elysia_Ring, 700);
	addmonsterdrop(OBEAUNE, Elysia_Ring, 700);
	addmonsterdrop(MUMMY, Elysia_Ring, 700);
	addmonsterdrop(GHOUL, Elysia_Ring, 700);
	end;	
}

//== Main Refiner Function =================================
// To allow auto safe refining/multiple refining set the second argument to '1'
// in the function call.
// If you enable this function, be sure to edit the value of .@safe to the max
// safe refine in refine_db.txt as well.
function	script	refinemain2	{
	disable_items;
	.@features = getarg(1);
	.@material = 985;
	if (countitem2(7508,1,7,0,0,0,0,0)){
		mes "[" + getarg(0) + "]";
		mes "That is my Lost Ring. Accept this reward.";
		delitem2(7508,1,1,7,0,0,0,0,0);
		getitem 6234,1;
		close();
	} 
	if (#e_ref_pass){
		mes "[" + getarg(0) + "]";
		mes "Thank you again for finding my ring.";
		close();	
	}
	if (#e_ref_fail == 2 ){
		mes "[" + getarg(0) + "]";
		mes "Get lost, I seen enough.";
		mes "I'm 100% sure that is";
		mes "the fake ring again.";
		close();	
	}
	if (#e_ref_fail == 1 && getequipid(EQI_ACC_R) != Elysia_Ring ){
		mes "[" + getarg(0) + "]";
		mes "Did you find me";
		mes "the ring?  I hope you";
		mes "did.  Wear the ring so";
		mes "that I can check on it.";
		close();	
	}
	if (getequipid(EQI_ACC_R) == Elysia_Ring && BaseLevel > 79) {
		mes "[" + getarg(0) + "]";
		if (#e_ref_fail == 1 ){
			mes "Whew... Are you sure";
			mes "that is the real one?";
		} else {
			mes "Oh dear, is that my ring?";
			mes "Wait let me check that.  It looks like a FAKE one.";
			next;
			mes "[" + getarg(0) + "]";
			mes "The ring I had can be refined";
			mes "up to +7 safely.";
		}	
		mes "Do you want me to try refine it?.";
		next;
		if(!getequipisequiped(EQI_ACC_R)) { //custom check
			mes "[" + getarg(0) + "]";
			mes "You're not wearing";
			mes "anything there that";
			mes "I can refine.";
			emotion e_an;
			close;
		}
		//Check to see if the items is already +10
		if(getequiprefinerycnt(EQI_ACC_R) >= 7) {
			mes "[" + getarg(0) + "]";
			mes "I can't refine this";
			mes "any more. This is as";
			mes "refined as it gets!";
			close;
		}
		.@refineitemid = getequipid(EQI_ACC_R); // save id of the item
		.@refinerycnt = getequiprefinerycnt(EQI_ACC_R); //save refinery count

		//- New Refining Functions -
		.@menu2 = 2;
		switch(.@menu2){
		case 1:
			.@refinecnt = .@safe - getequiprefinerycnt(getequipisequiped(EQI_ACC_R));
			break;
		case 2:
			break;
		case 3:
			next;
			mes "[" + getarg(0) + "]";
			mes "You said so... So be it.";
			close;
		}
		.@refinecnt = 7;
		mes "[" + getarg(0) + "]";
		mes "Good luck lets start the process.";
		mes "That will cost you " + (.@refinecnt - getequiprefinerycnt(getequipisequiped(EQI_ACC_R))) + " " + getitemname(.@material)+". Is that ok?";
		next;
		if(select("Yes","No...") == 2){
			mes "[" + getarg(0) + "]";
			mes "You said so... So be it.";
			close;
		}
		if(countitem(.@material) < .@refinecnt ) {
			mes "[" + getarg(0) + "]";
			mes "Is that all you got? Unfortunately I can't work for you, bring more Elunium.";
			close;
		}
		delitem .@material,.@refinecnt;
		while(.@refinecnt){
			if (getequipisequiped(EQI_ACC_R) == 0) {
				mes "[" + getarg(0) + "]";
				mes "Look here... you don't have any items on...";
				close;
			}
			if (getequipid(EQI_ACC_R) != .@refineitemid || (.@menu2 == 1 && getequippercentrefinery(EQI_ACC_R,REFINE_CHANCE_TYPE_E_NORMAL) < 100)) {
				mes "[" + getarg(0) + "]";
				mes "Clang... No, but did you imagine I could be so stupid?!";
				mes "You changed it...";
				mes "Get out before I stun you with my Hammer!!";
				close;
			}
			mes "Clang, clang!!!";
			if(.@menu2 == 2 && getequippercentrefinery(EQI_ACC_R,REFINE_CHANCE_TYPE_E_NORMAL) <= rand(100)) {
				#e_ref_fail++;
				failedrefitem(EQI_ACC_R);
				emotion e_omg;
				--.@refinecnt;
				mes "ARRGGGG!!! I'm so sorry... ";
				if(.@refinecnt) { 
					mes "Here's the unused materials back...";
					getitem .@material,.@refinecnt;
				}
				next;
				if (#e_ref_fail == 2) {
					mes "[" + getarg(0) + "]";
					mes ". . . I can't trust you";
					mes "anymore after that.";
					mes "You deserve to die..";
					atcommand("@nuke "+strcharinfo(PC_NAME));
					close();
				}
				mes "[" + getarg(0) + "]";
				mes "Are you trying to FOOL me?";
				mes "I told you... IT's FAKE!!!";
				next;
				mes "[" + getarg(0) + "]";
				mes "You fooled me this time";
				mes "but I will give you a second chance.";	
				close();				 
			}
			successrefitem(EQI_ACC_R);
			emotion e_no1;
			--.@refinecnt;
			next;
		}
		#e_ref_pass = 1;
		mes "[" + getarg(0) + "]";
		mes "Yes!! Yes!!!... ";
		mes "It is my lost Ring";
		announce "[System] Citizens of Midgard, ["+strcharinfo(PC_NAME)+" ] found The Lost Ring and shall be rewarded accordingly.",0; 	
		close;
	} else {
		mes "[" + getarg(0) + "]";
		mes "It was a bad day for me. I lost my ring during my battle on those creepy creatures.";
		next;
		if (BaseLevel < 80) {
			mes "[" + getarg(0) + "]";
			mes "I value that ring very much but I think you are not so strong enought to help me. You mush be level 80.";
		} else {
			mes "[" + getarg(0) + "]";
			mes "I value that ring very much.  If someone STRONG like you recover it, I will surely give a reward.";		
		}
		close();
	}

}
