
morocc,173,101,4	script	DailyShop	4_F_ALCHE_A,{
	mes "[ ^0055FFDaily Coin Shop^000000 ]";
	mes "Hello ^00CC00"+strcharinfo(PC_NAME)+"^000000!";
	mes "You currently have [ ^0055FF"+#DAILYTIME+"^000000 ] pts. Accumulate ^0055FF"+.pointstoclaim+" points^000000 to exchange for ^0055FF 1x "+getitemname(Daily_Coin)+"^000000. You can use this coin to purchase special items from the shop.";
	next;
	switch(select(
	((#DAILYTIME < .pointstoclaim )?":":"- ^0000FFClaim "+getitemname(Daily_Coin)+"^000000:")+
	"- ^777777Check Special Shop^000000:"+
	"- ^777777Close^000000"
	)) {
	case 1: 
		if(BaseLevel >= 65) {
			#DAILYTIME -= .pointstoclaim;
			getitem Daily_Coin, 1;
			close;
		} else {
			mes "[ ^0055FFDaily Coin Shop^000000 ]";
			mes "You must be atleast ^0055FFLevel 65^000000 to complete the exchange.";
			close;
		}
		close;
	case 2: close2; callfunc "dailyshop",1;
	default: close;
	}
	end;	
OnInit:
	delwaitingroom;
	waitingroom "Daily Coin Shop",0;
	.pointstoclaim = 720;
	end;
end;
}


-	script	daily_shop	FAKE_NPC,{
function Add;
OnInit:
	
	freeloop(1);
	set .ShowZeny,1;	// Show Zeny cost, if any? (1: yes / 0: no)
	set .MaxStack,100;	// Max number of quest items purchased at one time.
	setarray .points$[0],"#CASHPOINTS","Cash Points";
	setarray .dailyshops$[1],"Special";
	Add(1,5192,1,0,0,30410,3); //Ribbon_Yellow	bonus bMdef,3;
	Add(1,5506,1,0,0,30410,7); //Blue Night Cap	bonus bBaseAtk,5; bonus bMatkRate,5;
	Add(1,5507,1,0,0,30410,7); //Pink Night Cap 	bonus bBaseAtk,5; bonus bMatkRate,5;
	Add(1,5505,1,0,0,30410,14); //Asara Fairy Hat	skill DC_DONTFORGETME,1; bonus bDex,2; bonus bLuk,2;
	Add(1,18612,1,0,0,30410,15); //White Musang Hat	bonus bStr,2; bonus bVit,2; bonus bLuk,1; bonus bUnbreakableHelm,0;
	Add(1,5184,1,0,0,30410,7); //Captain's Hat	bonus2 bSubEle,Ele_Water,5;
	Add(1,5383,1,0,0,30410,15); //Hunter's Cap	bonus bLuk,1; bonus2 bAddRace,RC_Brute,10; bonus2 bAddRace,RC_DemiPlayer,5;
	Add(1,5397,1,0,0,30410,7); //Scuba Gear		bonus2 bSubEle,Ele_Water, 10; bonus bUnbreakableHelm, 0; 
	Add(1,5377,1,0,0,30410,15); //Antique Smoking Pipe	bonus2 bSubEle,Ele_Water, 10; bonus bUnbreakableHelm, 0; 
	Add(1,5361,1,0,0,30410,15); //Gangster Scarf		bonus2 bSubEle,Ele_Water, 10; bonus bUnbreakableHelm, 0; 




// -----------------------------------------------------------

	freeloop(0);
	set .menu$,"";
	for(set .@i,1; .@i<=getarraysize(.dailyshops$); set .@i,.@i+1) {
		set .menu$, .menu$+.dailyshops$[.@i]+":";
		npcshopdelitem "dailyshop"+.@i,909;
	}
	end;

OnMenu:
	set .@size, getarraysize(@i);
	if (!.@size) set .@i, select(.menu$);
	else if (.@size == 1) set .@i, @i[0];
	else {
		for(set .@j,0; .@j<.@size; set .@j,.@j+1)
			set .@menu$, .@menu$+.dailyshops$[@i[.@j]]+":";
		set .@i, @i[select(.@menu$)-1];
	}
	deletearray @i[0],getarraysize(@i);
	if (.dailyshops$[.@i] == "") {
		message strcharinfo(PC_NAME),"An error has occurred.";
		end;
	}
	dispbottom "Select one item at a time.";
	callshop "dailyshop"+.@i,1;
	npcshopattach "dailyshop"+.@i;
	end;

OnBuyItem:
	disable_items();
	setarray .@d[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
	copyarray .@d[3],getd(".d_"+.@d[0]+"[0]"),getarraysize(getd(".d_"+.@d[0]));
	set .@d[2],.@d[1]*.@d[3];
	if (!.@d[2] || .@d[2] > 30000) {
		message strcharinfo(PC_NAME),"You can't purchase that many "+getitemname(.@d[0])+".";
		end;
	}
	if (!checkweight(.@d[0],.@d[2])) {
		mes "[ Daily Coin Shop ]";
		mes "^FF0000You need "+(((.@d[2]*getiteminfo(.@d[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
		close;
	}
	if (.@d[4]) Zeny -= (.@d[4]*.@d[1]);
	if (.@d[5]) setd .points$[0], getd(.points$[0])-(.@d[5]*.@d[1]);

	if (.@d[6]) for(set .@i,6; .@i<getarraysize(.@d); set .@i,.@i+2){
		if(countitem(.@d[.@i]) < .@d[.@i+1]*.@d[1]) end;
		delitem .@d[.@i],.@d[.@i+1]*.@d[1];
	}
	getitem .@d[0],.@d[2];
	end;

function Add {
	if (getitemname(getarg(1)) == "null") {
		//debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
		return;
	}
	setarray .@j[0],getarg(2),getarg(3),getarg(4);
	for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
		if (getitemname(getarg(.@i)) == "null") {
			//debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
			return;
		} else
			setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
	}
	copyarray getd(".d_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
	npcshopadditem "dailyshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(6):0);
	return;
}

}

function	script	dailyshop	{
	deletearray @i[0],getarraysize(@i);
	for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
		set @i[.@i],getarg(.@i);
	doevent "daily_shop::OnMenu";
	end;

}

// Dummy shop data -- copy as needed.
//============================================================
-	shop	dailyshop1	FAKE_NPC,909:-1

