//===== eAthena Script ======================================= 
//= Cash Shop  Functions
//===== By: ================================================== 
//= L0ne_W0lf
//===== Current Version: ===================================== 
//= 1.0
//===== Compatible With: ===================================== 
//= eAthena SVN
//===== Description: ========================================= 
//= Used explicitly in the Item Database for Cash shop items
//= - Kafra Card
//= - Giant Fly Wing
//= - Neuralizer
//= - Dungeon Teleport Scroll
//===== Additional Comments: ================================= 
//= 1.0 First version. [L0ne_W0lf]
//=	F_CashPartyCall Optimized by Trancid.
//============================================================ 

// Kafra Card
//============================================================ 
// - Open player's storage.
// - No arguments.
function	script	F_CashStore	{
	cutin "kafra_01",2;
	mes "[Kafra Employee]";
	mes "Welcome to the Kafra Corporation.";
	mes "Here, let me open your Storage for you.";
	close2;
	openstorage;
	cutin "",255;
	return;
}


// Giant Fly Wing
//============================================================ 
// - Warp party leader to random spot on the map.
// - Summon Party members on party leader map to that location.
// - No arguments.
function	script	F_CashPartyCall	{
	warp "Random",0,0;
	if(getpartyleader(getcharid(1),2) == getcharid(0)) {
		getmapxy .@mapl$, .@xl, .@yl, 0;
		getpartymember getcharid(1);
		set .@partymembercount, $@partymembercount;
		copyarray .@partymembername$[0], $@partymembername$[0], .@partymembercount;
		for(set .@i, 0; .@i < .@partymembercount; set .@i, .@i + 1)
		if(!(getmapxy(.@mapm$, .@xm, .@ym, 0, .@partymembername$[.@i])) && (.@mapm$ == .@mapl$))
		warpchar .@mapl$, .@xl, .@yl, getcharid(0, .@partymembername$[.@i]);
	}
	return;
}

// Neuralizer
//============================================================ 
// - Reset players skills. Weight must be 0, options must be off.
// - No arguments.
function	script	F_CashReset	{
	if (Class != Job_Novice) {
		if (Weight < 1) { 
			if (checkriding() || checkfalcon() || checkcart()) return;
			else {
				resetskill;
				sc_end SC_ALL;
			}
		}
	}
	return;
}

// Dungeon Teleport Scroll
//============================================================ 
// - Warp player to random location of selected dungeon
//   due to lack of information.
// - No arguments.
function	script	F_CashDungeon	{
	switch(select("Nogg Road:Mjolnir Dead Pit:Umbala Dungeon:Payon Caves:Toy Factory:Glast Heim Prison:Louyang Dungeon:Kunlun Dungeon:Izlude Undersea Tunnel:Turtle Island:Clocktower 3F:Clocktower B3F:Glast Heim Sewers 2F:Sphinx Dungeon 4F:Pyramid Dungeon 4F:Prontera Culverts 3F:Amatsu Dungeon 1F:Somatology Laboratory 1F:Ayotaya Dungeon 2F"))
	{
	case 1: warp "mag_dun01",0,0; end; // Nogg Road
	case 2: warp "mjo_dun01",0,0; end; // Mjolnir Dead Pit
	case 3: warp "um_dun01",0,0; end; // Umbala Dungeon
	case 4: warp "pay_dun00",0,0; end; // Payon Caves
	case 5: warp "xmas_dun01",0,0; end; // Toy Factory
	case 6: warp "gl_prison",0,0; end; // Glast Heim Prison
	case 7: warp "lou_dun01",0,0; end; // Louyang Dungeon
	case 8: warp "gon_dun01",0,0; end; // Kunlun Dungeon
	case 9: warp "iz_dun00",0,0; end; // Izlude Undersea Tunnel
	case 10: warp "tur_dun01",0,0; end; // Turtle Island
	case 11: warp "c_tower3",0,0; end; // Clocktower 3F
	case 12: warp "alde_dun03",0,0; end; // Clocktower B3F
	case 13: warp "gl_sew02",0,0; end; // Glast Heim Sewers 2F
	case 14: warp "in_sphinx4",0,0; end; // Sphinx Dungeon 4F
	case 15: warp "moc_pryd04",0,0; end; // Pyramid Dungeon 4F
	case 16: warp "prt_sewb3",0,0; end; // Prontera Culverts 3F
	case 17: warp "ama_dun01",0,0; end; // Amatsu Dungeon 1F
	case 18: warp "lhz_dun01",0,0; end; // Somatology Laboratory 1F
	case 19: warp "ayo_dun02",0,0; end; // Ayotaya Dungeon 2F
	}
	return;
}

// Cities Teleport Scroll
//============================================================ 
// - Warp player to differents Citys acording to the Scroll
// - Arg(0) = type of scroll.
function	script	F_CashCity	{
	switch(getarg(0))
	{
		// Yellow
		case 1: switch(select("Prontera:Geffen:Payon:Morroc:Aldebaran:Alberta")) {
			case 1: warp "prontera",0,0; end;
			case 2: warp "geffen",0,0; end;
			case 3: warp "payon",0,0; end;
			case 4: warp "morocc",0,0; end;
			case 5: warp "aldebaran",0,0; end;
			case 6: warp "alberta",0,0; end;
			}
		break;
		// Green
		case 2: switch(select("Juno:Lighthalzen:Einbroch:Hugel")) {
			case 1: warp "yuno",0,0; end;
			case 2: warp "lighthalzen",0,0; end;
			case 3: warp "einbroch",0,0; end;
			case 4: warp "hugel",0,0; end;
			}
		break;
		// Red
		case 3: switch(select("Rachel:Veins")) {
			case 1: warp "rachel",0,0; end;
			case 2: warp "veins",0,0; end;
			}
		break;
		// Blue
		case 4: switch(select("Ayothaya:Amatsu:Louyang:Gonryun")) {
			case 1: warp "ayothaya",0,0; end;
			case 2: warp "amatsu",0,0; end;
			case 3: warp "louyang",0,0; end;
			case 4: warp "gonryun",0,0; end;
			}
		break;
	}
	return;
}
