//@unloadnpc Gatcha II
//@loadnpc npc/valhalla/gatcha2.txt

office,136,22,4	script	Gatcha II	2_DROP_MACHINE,{

	if(rvspin && !spinning2){
		mes "[ ^ff0000Gotcha II^000000 ]";
		mes "* * * ^ff0000B L I N K I N G^000000 * * *";
		mes "It looks like the coin slot is jammed.";
		mes "What do you like to do?";
		next;
		if(select("Kick the machine.") == 1){
			specialeffect(EF_COIN, AREA, "Gatcha II");
			sleep2(500);
			specialeffect(EF_COIN, AREA, "Gatcha II");
			sleep2(500);
			specialeffect(EF_COIN, AREA, "Gatcha II");
			mes "[ ^ff0000Gotcha II^000000 ]";
			mes "* * * ^ff0000B L I N K I N G^000000 * * *";
			mes "Refunding credits. . . . please wait...";
			if(rvspin){
				getitem 30368,rvspin * 20;
				dispbottom "You have been refunded "+rvspin*20+" "+getitemname(30368);
				rvspin  = 0;
				close;
			}
			close;
		}
	}
	if(spinning1 == 1 || spinning2 == 1){
		mes "[ ^ff0000Gotcha II^000000 ]";
		mes "Please wait a moment. Spinning session is on going.";
		close;
	}
	mes "[ ^ff0000Gatcha II^000000 ]";
	mes " Hello ^00CC00"+strcharinfo(PC_NAME)+"^000000!";
	mes " I present to you a unique costume that is tradable and enhance to give cool stats. Remember it's purely random.";
	next;
	mes "[ ^ff0000Gatcha II^000000 ]";
	mes "Would you like to try the vending machine? Here is the prizes that you may get.";
	next;
	mes "[ ^ff0000Gatcha II^000000 ]";
	mes "Random Items from the list:";
mes "> "+Itemlink(30373);
mes "> "+Itemlink(30374);
mes "> "+Itemlink(30375);
mes "> "+Itemlink(30376);
mes "> "+Itemlink(30377);
mes "> "+Itemlink(30378);
mes "> "+Itemlink(30379);
mes "> "+Itemlink(30380);
mes "> "+Itemlink(30381);
mes "> "+Itemlink(30382);

mes "> "+Itemlink(19158);
mes "> "+Itemlink(20147);
mes "> "+Itemlink(20201);
mes "> "+Itemlink(20315);
mes "> "+Itemlink(20318);
mes "> "+Itemlink(20405);
mes "> "+Itemlink(20430);
mes "> "+Itemlink(20798);
mes "> "+Itemlink(31250);
mes "> "+Itemlink(31299);
mes "> "+Itemlink(31301);
mes "> "+Itemlink(31302);
mes "> "+Itemlink(31315);
mes "> "+Itemlink(31383);
mes "> "+Itemlink(31395);
mes "> "+Itemlink(31398);
mes "> "+Itemlink(31399);
mes "> "+Itemlink(31437);
mes "> "+Itemlink(31438);
mes "> "+Itemlink(31509);
mes "> "+Itemlink(31512);
mes "> "+Itemlink(31531);
mes "> "+Itemlink(31564);
mes "> "+Itemlink(31565);
mes "> "+Itemlink(31572);
mes "> "+Itemlink(20404);	
mes "> "+Itemlink(20132);	
mes "> "+Itemlink(20146);	
mes "> "+Itemlink(31396);	
mes "> "+Itemlink(31433);	
mes "> "+Itemlink(19742);	
mes "> "+Itemlink(20249);	
mes "> "+Itemlink(19570);	

	mes "Do you want to try?";
	next;
	switch(select(
	  "Use ^ff000020 "+getitemname(30368)+"^000000:"+
	  "Exchange ^00CC00"+getitemname(30019)+"^000000 to ^ff0000"+getitemname(30368)+"^000000:"+
	  "Refund for ^0055FF10 Red Voucher^000000:"+ 	
	  "^777777Never mind.^000000"
	)) {
	case 1:
		if( countitem(30368) < 20){
			mes "[ ^ff0000Gotcha II^000000 ]";
			mes "Sorry, you don't have enough ^ff0000"+getitemname(30368)+"^000000.  You can buy the voucher from Item Mall";
			mes "You may also exchange:";
			mes "- -";
			mes "  5x ^00CC00"+getitemname(30019)+"^000000 = 1x ^ff0000"+getitemname(30368)+"^000000";
			mes "- -";
			close();
		} else {
			close2;
			callfunc "F_Gatcha2",20;
			end;
		}
	case 2:
		mes "[ ^ff0000Gotcha II^000000 ]";
		mes "You have: "+countitem(30019)+" ^00CC00"+getitemname(30019)+"^000000";
		mes "Conversion Rate:";
		mes "- - -";
		mes "5x ^00CC00"+getitemname(30019)+"^000000 = 1x ^ff0000"+getitemname(30368)+"^000000";
		mes "How many ^ff0000"+getitemname(30368)+"^000000 do you need?";
		next;
		input .@rvneed;
		if(countitem(30019) >= .@rvneed * 5){
			delitem 30019, .@rvneed * 5;
			getitem 30368, .@rvneed;
			close;
		}
		mes "[ ^ff0000Gotcha II^000000 ]";
		mes "Sorry, you do not have enough ^00CC00"+getitemname(30019)+"^000000";
		close;
	case 3:
		callshop "g2shop",2;
		npcshopattach "g2shop";
		end;
				
	default: 
		mes "[ ^ff0000Gatcha II^000000 ]";
		mes "Okay, take your time and come back when you are ready.";
		close();
	}
	end;


OnSellItem:
	if (getarraysize(@sold_nameid) > 1) {
		dispbottom "Please sell 1 item at a time only.";
		deletearray @sold_quantity, getarraysize(@sold_quantity);
		deletearray @sold_nameid, getarraysize(@sold_nameid);
		end;
	}
	.@ok = 0;
	setarray .@g2hg[0],
30373, //Royal Mantle Costume +
30374, //Neev Barrette Costume +
30375, //Hanging Dolls Costume +
30376, //Red Baloon Hat Costume +
30377, //Bouquet Hat Costume +
30378, //Rabbit Hopping Costume +
30379, //Floating Ball Costume +
30380, //Protect Cloth Costume +
30381, //Striking Hat Costume +
30382, //Thanatos Sword Costume +
19158, //GeminiS58 Eyes Blue Costume +
20147, //Pigeon On Shoulder Costume +
20201, //Banshee Master Kiss Costume +
20315, //Analyze Eye Costume +
20318, //Charleston Antenna Costume +
20405, //Eremes Scarf Costume +
20430, //Loyal Servant of Devil Morocc Costume +
20798, //Gemini Red Eyes Costume +
31250, //Wonderful Beast Ear Costume +
31299, //White Rabbit Costume +
31301, //Blinking Eyes Costume +
31302, //Black Magenta Ribbon Costume +
31315, //Stall of Angel Costume +
31383, //Volume Low Twin Costume +
31395, //Book of Magic Costume +
31398, //Blinking Thin Eyes Costume +
31399, //Darkness Veil Costume +
31437, //Baby Penguin Costume +
31438, //Fluffy Angel Cape Costume +
31509, //Fawn Ear Costume +
31512, //Panda Rabbit Costume +
31531, //Loevey Heart Cap Costume +
31564, //Variant Veil Costume
31565, //Princess Ribbon Crown Costume +
31572, //Mobile Pursuit System Costume +
20404,	// Costume Blessing of Angel	Mid
20132,	// Costume Aura Vicious Mind	Lower
20146,	// Costume Angel of Ghost	Mid
31396,	// Costume Sorcerer Hood	Upper
31433,	// Costume Celestial Circle	Upper
19742,	// Costume Small Golden Wings	Mid
20249,	// Costume Red Strong Hair	Upper
19570;	// Costume Mercury Helm		Upper

	for (.@i = 0; .@i < getarraysize(.@g2hg); ++.@i) {
		if(@sold_nameid == .@g2hg[.@i]) {
			.@ok = 1;
		}
	}
	if (.@ok) {
		getitem Red_Voucher,10;
		delitem @sold_nameid,@sold_quantity;
	} else {
		dispbottom "You can only exchange Special Costumes here.";
	}
	deletearray @sold_quantity, getarraysize(@sold_quantity);
	deletearray @sold_nameid, getarraysize(@sold_nameid);
	end;

OnInit:
	.gatcha2 = 20;
	end;
}

function	script	F_Gatcha2	{
	spinning2 = 0;
	if( countitem(30368) < 20){
		mes "[ ^ff0000Gatcha I^000000 ]";
		mes "Sorry, you don't have enough ^ff0000"+getitemname(30368)+"^000000.  You can buy the voucher from Item Mall";
		mes "You may also exchange:";
		mes "- -";
		mes "  5x ^00CC00"+getitemname(30019)+"^000000 = 1x ^ff0000"+getitemname(30368)+"^000000";
		mes "- -";
		close();
	} else {
		spinning2 = 1;
		rvspin += 1;
		delitem 30368,20;
	}
	setarray .rewardItens[0],

30373, //Royal Mantle Costume +
30374, //Neev Barrette Costume +
30375, //Hanging Dolls Costume +
30376, //Red Baloon Hat Costume +
30377, //Bouquet Hat Costume +
30378, //Rabbit Hopping Costume +
30379, //Floating Ball Costume +
30380, //Protect Cloth Costume +
30381, //Striking Hat Costume +
30382, //Thanatos Sword Costume +
19158, //GeminiS58 Eyes Blue Costume +
20147, //Pigeon On Shoulder Costume +
20201, //Banshee Master Kiss Costume +
20315, //Analyze Eye Costume +
20318, //Charleston Antenna Costume +
20405, //Eremes Scarf Costume +
20430, //Loyal Servant of Devil Morocc Costume +
20798, //Gemini Red Eyes Costume +
31250, //Wonderful Beast Ear Costume +
31299, //White Rabbit Costume +
31301, //Blinking Eyes Costume +
31302, //Black Magenta Ribbon Costume +
31315, //Stall of Angel Costume +
31383, //Volume Low Twin Costume +
31395, //Book of Magic Costume +
31398, //Blinking Thin Eyes Costume +
31399, //Darkness Veil Costume +
31437, //Baby Penguin Costume +
31438, //Fluffy Angel Cape Costume +
31509, //Fawn Ear Costume +
31512, //Panda Rabbit Costume +
31531, //Loevey Heart Cap Costume +
31564, //Variant Veil Costume
31565, //Princess Ribbon Crown Costume +
31572, //Mobile Pursuit System Costume +
20404,	// Costume Blessing of Angel	Mid
20132,	// Costume Aura Vicious Mind	Lower
20146,	// Costume Angel of Ghost	Mid
31396,	// Costume Sorcerer Hood	Upper
31433,	// Costume Celestial Circle	Upper
19742,	// Costume Small Golden Wings	Mid
20249,	// Costume Red Strong Hair	Upper
19570;	// Costume Mercury Helm		Upper

	.@gatcha2 = rand(1,getarraysize(.rewardItens));

	specialeffect(EF_PRIMECHARGE4, AREA, playerattached());
	getitem .rewardItens[.@gatcha2],1;
	announce "[ Gotcha II ]: Attention Heroes! "+strcharinfo(0)+" Just won the item '"+getitemname(.rewardItens[.@gatcha2]), bc_all;
	rvspin = 0;
	spinning2 = 0;
	sleep2(5000);
	cutin("", 255);
	end;

}

-	shop	g2shop	FAKE_NPC,501:50