//===== eAthena Script ======================================= 
//= Kafra Express - Dungeon Warps Module
//===== By: ================================================== 
//= Skotlex 
//===== Current Version: ===================================== 
//= 4.2
//===== Compatible With: ===================================== 
//= eAthena SVN R3424+, RO Episode 8+ (Hugel)
//===== Description: ========================================= 
//= Part of the Kafra Express Script Package.
//= Offers warping to dungeons.
//===== Additional Comments: ================================= 
//= See config.txt for configuration.
//= Flag values used for dungeons:
//= 0x00000001 Abyss Lake
//= 0x00000002 Amatsu
//= 0x00000004 AntHell
//= 0x00000008 Ayothaya
//= 0x00000010 Byalan
//= 0x00000020 Comodo
//= 0x00000040 Clock tower
//= 0x00000080 Coal Mines
//= 0x00000100 Culvert
//= 0x00000200 Einbech
//= 0x00000400 Kiehl
//= 0x00000800 Geffen
//= 0x00001000 GlastHeim
//= 0x00002000 Gon Ryun
//= 0x00004000 Hidden Temple
//= 0x00008000 Juperos
//= 0x00010000 Lighthalzen
//= 0x00020000 Lou Yang
//= 0x00040000 Magma Caves
//= 0x00080000 Orcs
//= 0x00100000 Payon
//= 0x00200000 Pyramid
//= 0x00400000 Sphinx
//= 0x00800000 Sunken Ship
//= 0x01000000 Thanatos
//= 0x02000000 Toy Factory
//= 0x04000000 Turtle Island
//= 0x08000000 Umbala
//= 0x10000000 Odin Temple
//= 0x20000000 Ice Cave
//= 0x40000000 Rachel Temple
//============================================================ 

-	script	keInit_warpDungeon	-1,{
OnInit:	//Load Config
	donpcevent "keConfig::OnLoadWarpDungeon";
	end;
}

function	script	F_keDungeonWarps	{

function SF_abyssLake;
function SF_amatsu;
function SF_antHell;
function SF_ayothaya;
function SF_byalan;
function SF_comodo;
function SF_clockTower;
function SF_coalMine;
function SF_culvert;
function SF_einbech;
function SF_gefenia;
function SF_geffen;
function SF_glastHeim;
function SF_gonRyun;
function SF_hiddenTemple;
function SF_juperos;
function SF_kiehl;
function SF_iceCave;
function SF_lightHalzen;
function SF_louYang;
function SF_magma;
function SF_odin;
function SF_orcs;
function SF_payon;
function SF_pyramid;
function SF_rachel;
function SF_sphinx;
function SF_sunkenShip;
function SF_thanatosTower;
function SF_toyFactory;
function SF_turtleIsland;
function SF_umbala;
	//Store player map, will be needed in any of the submenus.
	set @map$, getarg(0);
	do {
		set @discount,callfunc("F_keCost",100,$@kewd_discount);
		if ($@kewd_showOnline) {
			set @kmenu, select (
				"- Cancel",
				"- Abyss Lake ("+$@kewd_abyssLake*@discount/100+"z/"+(getmapusers("abyss_01")
					+getmapusers("abyss_02")+getmapusers("abyss_03"))+" "+$@ked_users$+")",
				"- Amatsu Dungeon ("+$@kewd_amatsu*@discount/100+"z/"+(getmapusers("ama_dun01")
					+getmapusers("ama_dun02")+getmapusers("ama_dun03"))+" "+$@ked_users$+")",
				"- Ant Hell ("+$@kewd_antHell*@discount/100+"z/"+(getmapusers("anthell01")
					+getmapusers("anthell02"))+" "+$@ked_users$+")",
				"- Ayothaya Ancient Shrine ("+$@kewd_ayothaya*@discount/100+"z/"+(getmapusers("ayo_dun01")
					+getmapusers("ayo_dun02"))+" "+$@ked_users$+")",
				"- Byalan Dungeon ("+$@kewd_byalan*@discount/100+"z/"+(getmapusers("iz_dun00")
					+getmapusers("iz_dun01")+getmapusers("iz_dun02")+getmapusers("iz_dun03")
					+getmapusers("iz_dun04"))+" "+$@ked_users$+")",
				"- Comodo Caves ("+$@kewd_comodo*@discount/100+"z/"+(getmapusers("beach_dun")
					+getmapusers("beach_dun2")+getmapusers("beach_dun3"))+" "+$@ked_users$+")",
				"- Clock Tower ("+$@kewd_clockTower*@discount/100+"z/"+(getmapusers("c_tower1")
					+getmapusers("c_tower2")+getmapusers("c_tower3")+getmapusers("c_tower4")
					+getmapusers("alde_dun01")+getmapusers("alde_dun02")+getmapusers("alde_dun03")
					+getmapusers("alde_dun04"))+" "+$@ked_users$+")",
				"- Coal Mine ("+$@kewd_coalMines*@discount/100+"z/"+(getmapusers("mjo_dun01")
					+getmapusers("mjo_dun02")+getmapusers("mjo_dun03"))+" "+$@ked_users$+")",
				"- Culvert ("+$@kewd_culvert*@discount/100+"z/"+(getmapusers("prt_sewb1")+getmapusers("prt_sewb2")
					+getmapusers("prt_sewb3")+getmapusers("prt_sewb4"))+" "+$@ked_users$+")",
				"- Einbroch Station ("+$@kewd_einbech*@discount/100+"z/"+(getmapusers("ein_dun01")
					+getmapusers("ein_dun02"))+" "+$@ked_users$+")",
				"- Gefenia ("+$@kewd_gefenia*@discount/100+"z/"+(getmapusers("gefenia01")+getmapusers("gefenia02")
					+getmapusers("gefenia03")+getmapusers("gefenia04"))+" "+$@ked_users$+")",
				"- Geffen Dungeon ("+$@kewd_geffen*@discount/100+"z/"+(getmapusers("gef_dun00")
					+getmapusers("gef_dun01")+getmapusers("gef_dun02")+getmapusers("gef_dun03"))+" "+$@ked_users$+")",
				"- Glast Heim ("+$@kewd_glastHeim*@discount/100+"z/"+(getmapusers("gl_cas02")+getmapusers("gl_church")
					+getmapusers("gl_chyard")+getmapusers("gl_dun01")+getmapusers("gl_dun02")
					+getmapusers("gl_in01")+getmapusers("gl_knt01")+getmapusers("gl_knt02")
					+getmapusers("gl_prison")+getmapusers("gl_prison1")+getmapusers("gl_sew01")
					+getmapusers("gl_sew02")+getmapusers("gl_sew03")+getmapusers("gl_sew04")
					+getmapusers("gl_step")+getmapusers("glast_01"))+" "+$@ked_users$+")",
				"- Gon Ryun Dungeon ("+$@kewd_gonRyun*@discount/100+"z/"+(getmapusers("gon_dun01")
					+getmapusers("gon_dun02")+getmapusers("gon_dun03"))+" "+$@ked_users$+")",
				"- Hidden Temple ("+$@kewd_hiddenTemple*@discount/100+"z/"+(getmapusers("prt_maze01")
					+getmapusers("prt_maze02")+getmapusers("prt_maze03"))+" "+$@ked_users$+")",
				"- Juperos ("+$@kewd_juperos*@discount/100+"z/"+(getmapusers("juperos_01")+getmapusers("juperos_02")
					+getmapusers("jupe_area1")+getmapusers("jupe_area2")+getmapusers("jupe_core")
					+getmapusers("jupe_gate")+getmapusers("jupe_area1"))+" "+$@ked_users$+")",
				"- Kiehl Doll Factory ("+$@kewd_kiehl*@discount/100+"z/"+(getmapusers("kh_dun01")
					+getmapusers("kh_dun02"))+" "+$@ked_users$+")",
				"- Ice Cave("+$@kewd_iceCave*@discount/100+"z/"+(getmapusers("ice_dun01")
					+getmapusers("ice_dun02")+getmapusers("ice_dun03"))+" "+$@ked_users$+")",
				"- LightHalzen Rekkenber ("+$@kewd_lightHalzen*@discount/100+"z/"+(getmapusers("lhz_dun01")
					+getmapusers("lhz_dun02")+getmapusers("lhz_dun03"))+" "+$@ked_users$+")",
				"- Lou Yang Royal Tomb ("+$@kewd_louYang*@discount/100+"z/"+(getmapusers("lou_dun01")
					+getmapusers("lou_dun02")+getmapusers("lou_dun03"))+" "+$@ked_users$+")",
				"- Magma Dungeon ("+$@kewd_magma*@discount/100+"z/"+(getmapusers("mag_dun01")
					+getmapusers("mag_dun02"))+" "+$@ked_users$+")",
				"- Odin Temple ("+$@kewd_odin*@discount/100+"z/"+(getmapusers("odin_tem01")
					+getmapusers("odin_tem02")+getmapusers("odin_tem03"))+" "+$@ked_users$+")",
				"- Orc Dungeon ("+$@kewd_orc*@discount/100+"z/"+(getmapusers("orcsdun01")
					+getmapusers("orcsdun02"))+" "+$@ked_users$+")",
				"- Payon Dungeon ("+$@kewd_payon*@discount/100+"z/"+(getmapusers("pay_dun00")
					+getmapusers("pay_dun01")+getmapusers("pay_dun02")+getmapusers("pay_dun03")
					+getmapusers("pay_dun04"))+" "+$@ked_users$+")",
				"- Pyramid ("+$@kewd_pyramid*@discount/100+"z/"+(getmapusers("moc_pryd01")+getmapusers("moc_pryd02")
					+getmapusers("moc_pryd03")+getmapusers("moc_pryd04")+getmapusers("moc_pryd05")
					+getmapusers("moc_pryd06")+getmapusers("moc_prydb1"))+" "+$@ked_users$+")",
				"- Rachel Temple ("+$@kewd_rachel*@discount/100+"z/"+(getmapusers("ra_san01")
					+getmapusers("ra_san02")+getmapusers("ra_san03")+getmapusers("ra_san04")
					+getmapusers("ra_san05"))+" "+$@ked_users$+")",
				"- Sphinx ("+$@kewd_sphinx*@discount/100+"z/"+(getmapusers("in_sphinx1")
					+getmapusers("in_sphinx2")+getmapusers("in_sphinx3")+getmapusers("in_sphinx4")
					+getmapusers("in_sphinx5"))+" "+$@ked_users$+")",
				"- Sunken Ship ("+$@kewd_sunkenShip*@discount/100+"z/"+(getmapusers("treasure01")
					+getmapusers("treasure02"))+" "+$@ked_users$+")",
				"- Thanatos Tower ("+$@kewd_thanatosTower*@discount/100+"z/"+(getmapusers("tha_t01")
					+getmapusers("tha_t02")+getmapusers("tha_t03")+getmapusers("tha_t04")
					+getmapusers("tha_t05")+getmapusers("tha_t06")+getmapusers("tha_t07")
					+getmapusers("tha_t08")+getmapusers("tha_t09")+getmapusers("tha_t10")
					+getmapusers("tha_t11")+getmapusers("tha_t12")+getmapusers("thana_step")
					+getmapusers("thana_boss"))+" "+$@ked_users$+")",
				"- Toy Factory ("+$@kewd_toyFactory*@discount/100+"z/"+(getmapusers("xmas_dun01")
					+getmapusers("xmas_dun02"))+" "+$@ked_users$+")",
				"- Turtle Island ("+$@kewd_turtleIsland*@discount/100+"z/"+(getmapusers("tur_dun01")
					+getmapusers("tur_dun02")+getmapusers("tur_dun03")+getmapusers("tur_dun04")
					+getmapusers("tur_dun05")+getmapusers("tur_dun06"))+" "+$@ked_users$+")",
				"- Umbala Dungeon ("+$@kewd_umbala*@discount/100+"z/"+(getmapusers("um_dun01")
					+getmapusers("um_dun02"))+" "+$@ked_users$+")"
			);
		} else {
			set @kmenu, select(
				"- Cancel",
				"- Abyss Lake ("+$@kewd_abyssLake*@discount/100+"z)",
				"- Amatsu Dungeon ("+$@kewd_amatsu*@discount/100+"z)",
				"- Ant Hell ("+$@kewd_antHell*@discount/100+"z)",
				"- Ayothaya Ancient Shrine ("+$@kewd_ayothaya*@discount/100+"z)",
				"- Byalan Dungeon ("+$@kewd_byalan*@discount/100+"z)",
				"- Comodo Caves ("+$@kewd_comodo*@discount/100+"z)",
				"- Clock Tower ("+$@kewd_clockTower*@discount/100+"z)",
				"- Coal Mine ("+$@kewd_coalMines*@discount/100+"z)",
				"- Culvert ("+$@kewd_culvert*@discount/100+"z)",
				"- Einbroch Mine ("+$@kewd_einbech*@discount/100+"z)",
				"- Gefenia ("+$@kewd_gefenia*@discount/100+"z)",
				"- Geffen Dungeon ("+$@kewd_geffen*@discount/100+"z)",
				"- Glast Heim ("+$@kewd_glastHeim*@discount/100+"z)",
				"- Gon Ryun Dungeon ("+$@kewd_gonRyun*@discount/100+"z)",
				"- Hidden Temple ("+$@kewd_hiddenTemple*@discount/100+"z)",
				"- Juperos ("+$@kewd_juperos*@discount/100+"z)",
				"- Kiehl Doll Factory ("+$@kewd_kiehl*@discount/100+"z)",
				"- Ice Cave ("+$@kewd_iceCave*@discount/100+"z)",
				"- LightHalzen Rekkenber ("+$@kewd_lightHalzen*@discount/100+"z)",
				"- Lou Yang Royal Tomb ("+$@kewd_louYang*@discount/100+"z)",
				"- Magma Dungeon ("+$@kewd_magma*@discount/100+"z)",
				"- Odin Temple ("+$@kewd_odin*@discount/100+"z)",
				"- Orcs Dungeon ("+$@kewd_orc*@discount/100+"z)",
				"- Payon Dungeon ("+$@kewd_payon*@discount/100+"z)",
				"- Pyramid ("+$@kewd_pyramid*@discount/100+"z)",
				"- Rachel Temple ("+$@kewd_rachel*@discount/100+"z)",
				"- Sphinx ("+$@kewd_sphinx*@discount/100+"z)",
				"- Sunken Ship ("+$@kewd_sunkenShip*@discount/100+"z)",
				"- Thanatos Tower ("+$@kewd_thanatosTower*@discount/100+"z)",
				"- Toy Factory ("+$@kewd_toyFactory*@discount/100+"z)",
				"- Turtle Island ("+$@kewd_turtleIsland*@discount/100+"z)",
				"- Umbala Dungeon ("+$@kewd_umbala*@discount/100+"z)"
			);
		}
		switch (@kmenu) {
		case 2:
			SF_abyssLake();
			break;
		case 3:
			SF_amatsu();
			break;
		case 4:
			SF_antHell();
			break;
		case 5:
			SF_ayothaya();
			break;
		case 6:
			SF_byalan();
			break;
		case 7:
			SF_comodo();
			break;
		case 8:
			SF_clockTower();
			break;
		case 9:
			SF_coalMine();
			break;
		case 10:
			SF_culvert();
			break;
		case 11:
			SF_einbech();
			break;
		case 12:
			SF_gefenia();
			break;
		case 13:
			SF_geffen();
			break;
		case 14:
			SF_glastHeim();
			break;
		case 15:
			SF_gonRyun();
			break;
		case 16:
			SF_hiddenTemple();
			break;
		case 17:
			SF_juperos();
			break;
		case 18:
			SF_kiehl();
			break;
		case 19:
			SF_iceCave();
			break;
		case 20:
			SF_lightHalzen();
			break;
		case 21:
			SF_louYang();
			break;
		case 22:
			SF_magma();
			break;
		case 23:
			SF_odin();
			break;
		case 24:
			SF_orcs();
			break;
		case 25:
			SF_payon();
			break;
		case 26:
			SF_pyramid();
			break;
		case 27:
			SF_rachel();
			break;
		case 28:
			SF_sphinx();
			break;
		case 29:
			SF_sunkenShip();
			break;
		case 30:
			SF_thanatosTower();
			break;
		case 31:
			SF_toyFactory();
			break;
		case 32:
			SF_turtleIsland();
			break;
		case 33:
			SF_umbala();
			break;
		default:
			return;
		}
	} while (@kmenu > 1);
	return;

//Subfunction SF_check(flag, cost, floor-count, player-map, dungeon-map#, map#1, map#2, ...)
//If kewd_travel is set, the flag needs to match to be to warp there.
//Floor count is the amount of levels the dungeon needs a price for,
//dungeon-map# is the number of maps passed that need to be checked against
//the player's map to see if they are warping from within the entrance.

function SF_check {
	if ($@kewd_travel && !((kewd_travel|#kewd_travel)&getarg(0))) {
		callfunc "F_keIntro", e_sry, "Sorry, but we can only warp you to dungeons you have saved in before.";
		return 0;
	}
	set @cost, getarg(1);
	set @discount,100;
	set @map$, getarg(3);
	set @mapI, getarg(4);

	while (@mapI > 0)
	{
		if (@map$ == getarg(4+@mapI)) {
			set @discount,100-$@kewd_entryDiscount;
			break;
		}
		set @mapI, @mapI-1;
	}
	set @discountKP, callfunc("F_keCost",100,$@kewd_discount);
	set @discount,@discount*@discountKP/100;
	
	set @cost,@cost*@discount/100;

	//@discountKP is used to reverse the price to before the KP discount takes place
	if (@discountKP == 0)
		set @discountKP,1;
	if ($@kewd_deep == 0)
		return 1;

	//Reuse temp variable to set floor costs.
	set @mapI, getarg(2);
	set @inc,@cost*$@kewd_levelCost/100;
	while (@mapI > 1) {
		setd "@cost"+@mapI, @cost+(@mapI-1)*@inc;
		set @mapI, @mapI-1;
	}
	return 1;
}

function SF_abyssLake {
	if (!(SF_check(0x1, $@kewd_abyssLake, 3, @map$, 1, "hu_fild05")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Abyss Lake",
			"- Entrance ("+@cost+"z/"+getmapusers("abyss_01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("abyss_02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("abyss_03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Abyss Lake",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"hu_fild05",173,308;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"abyss_02",272,270;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"abyss_03",116,29;
		break;
	}
}

function SF_amatsu {
	if (!(SF_check(0x2, $@kewd_amatsu, 3, @map$, 1, "ama_in02")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Amatsu Dungeon",
			"- Entrance ("+@cost+"z/"+getmapusers("ama_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("ama_dun02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("ama_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Amatsu Dungeon",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"ama_in02",120,181;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"ama_dun02",34,41;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"ama_dun03",119,14;
		break;
	}
}

function SF_antHell {
	if (!(SF_check(0x4, $@kewd_antHell, 1, @map$, 2, "moc_fild04","moc_fild15")))
		return;
	if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Ant Hell",
			"- Northern Entrance ("+@cost+"z/"+getmapusers("anthell01")+" "+$@ked_users$+")",
			"- Southern Entrance ("+@cost+"z/"+getmapusers("anthell02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Ant Hell",
			"- Northern Entrance ("+@cost+"z)",
			"- Southern Entrance ("+@cost+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"moc_fild04",201,327;
		break;
	case 3:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"moc_fild15",246,251;
		break;
	}
}

function SF_ayothaya {
	if (!(SF_check(0x8, $@kewd_ayothaya, 2, @map$, 1, "ayo_fild02")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Ancient Shrine",
			"- Entrance ("+@cost+"z/"+getmapusers("ayo_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("ayo_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Ancient Shrine",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"ayo_fild02",273,150;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"ayo_dun02",24,28;
		break;
	}
}

function SF_byalan {
	if (!(SF_check(0x10, $@kewd_byalan, 5, @map$, 1, "izlu2dun")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Undersea Tunnel",
			"- Entrance ("+@cost+"z/"+getmapusers("iz_dun00")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("iz_dun01")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("iz_dun02")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("iz_dun03")+" "+$@ked_users$+")",
			"- Level 5 ("+@cost5+"z/"+getmapusers("iz_dun04")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Undersea Tunnel",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Level 5 ("+@cost5+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"izlu2dun",114,84;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun01",253,252;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun02",236,204;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun03",32,63;
		break;
	case 6:	
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"iz_dun04",26,27;
		break;
	}
}

function SF_comodo {
	if (!(SF_check(0x20, $@kewd_comodo, 1, @map$, 2, "comodo","cmd_fild01")))
		return;

	if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Comodo Caves",
			"- Mao, The Eastern Cave ("+@cost+"z/"+getmapusers("beach_dun3")+" "+$@ked_users$+")",
			"- Karu, The Western Cave ("+@cost+"z/"+getmapusers("beach_dun")+" "+$@ked_users$+")",
			"- Ruande, The Northern Cave ("+@cost+"z/"+getmapusers("beach_dun2")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Comodo Caves",
			"- Mao, The Eastern Cave ("+@cost+"z)",
			"- Karu, The Western Cave ("+@cost+"z)",
			"- Ruande, The Northern Cave ("+@cost+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"cmd_fild01",34,325;
		break;
	case 3:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"comodo",32,209;
		break;
	case 4:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"comodo",180,352;
		break;
	}
}

function SF_clockTower {
	if (!(SF_check(0x40, $@kewd_clockTower, 5, @map$, 1, "aldebaran")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Clock Tower",
			"- Entrance ("+@cost+"z/"+getmapusers("c_tower1")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("c_tower2")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("c_tower3")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("c_tower4")+" "+$@ked_users$+")",
			"- Basement 1 ("+@cost2+"z/"+getmapusers("alde_dun01")+" "+$@ked_users$+")",
			"- Basement 2 ("+@cost3+"z/"+getmapusers("alde_dun02")+" "+$@ked_users$+")",
			"- Basement 3 ("+@cost4+"z/"+getmapusers("alde_dun03")+" "+$@ked_users$+")",
			"- Basement 4 ("+@cost5+"z/"+getmapusers("alde_dun04")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Clock Tower",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Basement 1 ("+@cost2+"z)",
			"- Basement 2 ("+@cost3+"z)",
			"- Basement 3 ("+@cost4+"z)",
			"- Basement 4 ("+@cost5+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"aldebaran",140,130;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"c_tower2",268,26;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"c_tower3",68,146;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"c_tower4",185,44;
		break;
	case 6:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"alde_dun01",297,25;
		break;
	case 7:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"alde_dun02",43,24;
		break;
	case 8:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"alde_dun03",18,267;
		break;
	case 9:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"alde_dun04",82,267;
		break;
	}
}

function SF_coalMine {
	if (!(SF_check(0x80, $@kewd_coalMines, 3, @map$, 1, "mjolnir_02")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Mjolnir Dead Pit",
			"- Entrance ("+@cost+"z/"+getmapusers("mjo_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("mjo_dun02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("mjo_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Mjolnir Dead Pit",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"mjolnir_02",89,358;
		break;
	case 3:	
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"mjo_dun02",376,342;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"mjo_dun03",305,260;
		break;
	}
}

function SF_culvert {
	if (!(SF_check(0x100, $@kewd_culvert, 4, @map$, 1, "prt_fild05")))
		return;
	if ($@kewd_deep == 0) {
		set @submenu, 2;
	} else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Prontera Culvert",
			"- Entrance ("+@cost+"z/"+getmapusers("prt_sewb1")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("prt_sewb2")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("prt_sewb3")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("prt_sewb4")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Prontera Culvert",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"prt_fild05",274,208;
		break;
	case 3:	
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"prt_sewb2",19,19;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"prt_sewb3",180,169;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"prt_sewb4",100,92;
		break;
	}
}

function SF_einbech {
	if (!(SF_check(0x200, $@kewd_einbech, 2, @map$, 1, "einbech")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Einbroch Mines",
			"- Entrance ("+@cost+"z/"+getmapusers("ein_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("ein_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Einbech Mines",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"einbech",138,244;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"ein_dun02",290,285;
		break;
	}
}

function SF_geffen {
	if (!(SF_check(0x800, $@kewd_geffen, 3, @map$, 1, "gef_tower")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Geffen Dungeon",
			"- Entrance ("+@cost+"z/"+getmapusers("gef_dun00")+" "+$@ked_users$+")",
			"- Level 1 ("+@cost2+"z/"+getmapusers("gef_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost3+"z/"+getmapusers("gef_dun02")+" "+$@ked_users$+")"
//			"- Level 3 ("+@cost4+"z/"+getmapusers("gef_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Geffen Dungeon",
			"- Entrance ("+@cost+"z)",
			"- Level 1 ("+@cost2+"z)",
			"- Level 2 ("+@cost3+"z)"
//			"- Level 3 ("+@cost4+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"gef_tower",147,35;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gef_dun01",115,236;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"gef_dun02",106,132;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"gef_dun03",203,200;
		break;
	}
}

function SF_gefenia {
	if (!(SF_check(0x400, $@kewd_gefenia, 2, @map$, 4, "gefenia01","gefenia02","gefenia03","gefenia04")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Gefenia",
			"- Level 1 ("+@cost+"z/"+getmapusers("gefenia01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("gefenia02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost2+"z/"+getmapusers("gefenia03")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost+"z/"+getmapusers("gefenia04")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Gefenia",
			"- Level 1 ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost2+"z)",
			"- Level 4 ("+@cost+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"gefenia01",60,169;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gefenia02",116,116;
		break;
	case 4:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gefenia03",119,277;
		break;
	case 5:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"gefenia04",129,86;
		break;
	}
}

function SF_glastHeim {
	if (!(SF_check(0x1000, $@kewd_glastHeim, 7, @map$, 1, "glast_01")))
		return;
	if ($@kewd_deep == 0) {
		if ($@kewd_showOnline) {
			set @submenu, select(
				"- Cancel warp to Glast Heim",
				"- Church Entrance ("+@cost+"z/"+getmapusers("gl_church")+" "+$@ked_users$+")",
				"- Castle Terrace ("+@cost+"z/"+(getmapusers("gl_cas01")+getmapusers("gl_cas02"))+" "+$@ked_users$+")",
				"- Staircase Entrance ("+@cost+"z/"+getmapusers("gl_step")+" "+$@ked_users$+")",
				"- Chivalry Entrance ("+@cost+"z/"+getmapusers("gl_knt01")+" "+$@ked_users$+")"
			);
		} else {
			set @submenu, select(
				"- Cancel warp to Glast Heim",
				"- Church Entrance ("+@cost+"z)",
				"- Castle Terrace ("+@cost+"z)",
				"- Staircase Entrance ("+@cost+"z)",
				"- Chivalry Entrance ("+@cost+"z)"
			);
		}
		if (@submenu > 2) //Churchyard is index 3.
			set @submenu, @submenu+1;
	} else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Glast Heim",
			"- Church Entrance ("+@cost+"z/"+getmapusers("gl_church")+" "+$@ked_users$+")",
			"- Churchyard ("+@cost2+"z/"+getmapusers("gl_chyard")+" "+$@ked_users$+")",
			"- Castle Terrace ("+@cost+"z/"+(getmapusers("gl_cas01")+getmapusers("gl_cas02"))+" "+$@ked_users$+")",
			"- Staircase Entrance ("+@cost+"z/"+getmapusers("gl_step")+" "+$@ked_users$+")",
			"- Chivalry Entrance ("+@cost+"z/"+getmapusers("gl_knt01")+" "+$@ked_users$+")",
			"- Chivalry Level 2 ("+@cost2+"z/"+getmapusers("gl_knt02")+" "+$@ked_users$+")",
			"- Underground Prison 1 ("+@cost2+"z/"+getmapusers("gl_prison")+" "+$@ked_users$+")",
			"- Underground Prison 2 ("+@cost3+"z/"+getmapusers("gl_prison1")+" "+$@ked_users$+")",
			"- Culvert Level 1 ("+@cost4+"z/"+getmapusers("gl_sew01")+" "+$@ked_users$+")",
			"- Culvert Level 2 ("+@cost3+"z/"+getmapusers("gl_sew02")+" "+$@ked_users$+")",
			"- Culvert Level 3 ("+@cost4+"z/"+getmapusers("gl_sew03")+" "+$@ked_users$+")",
			"- Culvert Level 4 ("+@cost5+"z/"+getmapusers("gl_sew04")+" "+$@ked_users$+")",
			"- Underground Cave 1 ("+@cost6+"z/"+getmapusers("gl_dun01")+" "+$@ked_users$+")",
			"- Underground Cave 2 ("+@cost7+"z/"+getmapusers("gl_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Glast Heim",
			"- Church Entrance ("+@cost+"z)",
			"- Churchyard ("+@cost2+"z)",
			"- Castle Terrace ("+@cost+"z)",
			"- Staircase Entrance ("+@cost+"z)",
			"- Chivalry Entrance ("+@cost+"z)",
			"- Chivalry Level 2 ("+@cost2+"z)",
			"- Underground Prison Level 1 ("+@cost2+"z)",
			"- Underground Prison Level 2 ("+@cost3+"z)",
			"- Culvert Level 1 ("+@cost4+"z)",
			"- Culvert Level 2 ("+@cost3+"z)",
			"- Culvert Level 3 ("+@cost4+"z)",
			"- Culvert Level 4 ("+@cost5+"z)",
			"- Underground Cave Level 1 ("+@cost6+"z)",
			"- Underground Cave Level 2 ("+@cost7+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"glast_01",206,136;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gl_chyard",147,15;
		break;
	case 4:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"glast_01",199,335;
		break;
	case 5:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"glast_01",62,107;
		break;
	case 6:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"glast_01",69,193;
		break;
	case 7:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gl_knt02",157,287;
		break;
	case 8:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gl_prison",14,70;
		break;
	case 9:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"gl_prison1",150,14;
		break;
	case 10:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"gl_sew01",258,255;
		break;
	case 11:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"gl_sew02",108,291;
		break;
	case 12:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"gl_sew03",171,283;
		break;
	case 13:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"gl_sew04",68,277;
		break;
	case 14:
		callfunc "F_keWarp",@cost6*100/@discountKP,$@kewd_discount,e_hmm,"gl_dun01",133,271;
		break;
	case 15:
		callfunc "F_keWarp",@cost7*100/@discountKP,$@kewd_discount,e_hmm,"gl_dun02",224,274;
		break;
	}
}

function SF_gonRyun {
	if (!(SF_check(0x2000, $@kewd_gonRyun, 3, @map$, 1, "gonryun")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Gon Ryun Dungeon",
			"- Entrance ("+@cost+"z/"+getmapusers("gon_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("gon_dun02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("gon_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Gon Ryun Dungeon",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"gonryun",161,195;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"gon_dun02",22,114;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"gon_dun03",68,11;
		break;
	}
}

function SF_hiddenTemple {
	if (!(SF_check(0x4000, $@kewd_hiddenTemple, 3, @map$, 1, "prt_fild01")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Laberynth Forest",
			"- Entrance ("+@cost+"z/"+getmapusers("prt_maze01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("prt_maze02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("prt_maze03")+" "+$@ked_users$+")"
		);	
	} else {
		set @submenu, select(
			"- Cancel warp to the Laberynth Forest",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"prt_fild01",136,361;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"prt_maze02",106,62;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"prt_maze03",23,8;
		break;
	}
}

function SF_juperos {
	if (!(SF_check(0x8000, $@kewd_juperos, 3, @map$, 1, "jupe_cave")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Juperos",
			"- Entrance ("+@cost+"z/"+getmapusers("juperos_01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("juperos_02")+" "+$@ked_users$+")",
			"- Core ("+@cost3+"z/"+getmapusers("jupe_core")+" "+$@ked_users$+")"
		);	
	} else {
		set @submenu, select(
			"- Cancel warp to Juperos",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Core ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"jupe_cave",55,52;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"juperos_02",37,63;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"jupe_gate",-1,-1;
		break;
	}
}

function SF_kiehl {
	if (!(SF_check(0x400, $@kewd_kiehl, 3, @map$, 1, "yuno_fild08")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
				"- Cancel warp to Machine Doll Factory",
				"- Entrance ("+@cost+"z/"+getmapusers("kh_dun01")+" "+$@ked_users$+")",
				"- Level 2 ("+@cost2+"z/"+getmapusers("kh_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Machine Doll Factory",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"yuno_fild08",80,179;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"kh_dun02",41,198;
		break;
	}
}

function SF_iceCave {
	if (!(SF_check(0x20000000, $@kewd_iceCave, 3, @map$, 1, "ra_fild01")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Ice Cave",
			"- Entrance ("+@cost+"z/"+getmapusers("ice_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("ice_dun02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("ice_dun03")+" "+$@ked_users$+")"
		);	
	} else {
		set @submenu, select(
			"- Cancel warp to the Ice Cave",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"ra_fild01",233,319;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"ice_dun02",151,151;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"ice_dun03",148,25;
		break;
	}
}

function SF_lightHalzen {
	if (!(SF_check(0x10000, $@kewd_lightHalzen, 3, @map$, 1, "lighthalzen")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
				"- Cancel warp to the Rekkenber",
				"- Entrance ("+@cost+"z/"+getmapusers("lhz_dun01")+" "+$@ked_users$+")",
				"- Level 2 ("+@cost2+"z/"+getmapusers("lhz_dun02")+" "+$@ked_users$+")",
				"- Level 3 ("+@cost3+"z/"+getmapusers("lhz_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Rekkenber",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
//This is the Rekkenber building entrance, which officially is only a dungeon exit.
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"lighthalzen",74,72;
//		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"lighthalzen",303,302;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"lhz_dun02",154,18;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"lhz_dun03",141,132;
		break;
	}
}

function SF_louYang {
	if (!(SF_check(0x20000, $@kewd_louYang, 3, @map$, 1, "louyang")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Royal Tomb",
			"- Entrance ("+@cost+"z/"+getmapusers("lou_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("lou_dun02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("lou_dun03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Royal Tomb",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	};
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"louyang",41,267;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"lou_dun02",281,20;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"lou_dun03",165,39;
		break;
	}
}

function SF_magma {
	if (!(SF_check(0x40000, $@kewd_magma, 2, @map$, 1, "yuno_fild03")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Nogg Road",
			"- Entrance ("+@cost+"z/"+getmapusers("mag_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("mag_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Nogg Road",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"yuno_fild03",35,135;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"mag_dun02",47,30;
		break;
	}
}

function SF_odin {
	if (!(SF_check(0x10000000, $@kewd_odin, 5, @map$, 1, "odin_tem01")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Odin Temple",
			"- Entrance ("+@cost+"z/"+getmapusers("odin_tem01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("odin_tem02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("odin_tem03")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Odin Temple",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"odin_tem01",91,145;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"odin_tem02",25,181;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"odin_tem03",120,54;
		break;
	}
}

function SF_orcs {
	if (!(SF_check(0x80000, $@kewd_orc, 2, @map$, 1, "gef_fild10")))
		return;
	if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Orcs Dungeon",
			"- Front Entrance ("+@cost+"z/"+getmapusers("orcsdun01")+" "+$@ked_users$+")",
			"- Back Entrance ("+@cost+"z/"+getmapusers("orcsdun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Orcs Dungeon",
			"- Front Entrance ("+@cost+"z)",
			"- Back Entrance ("+@cost+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"in_orcs01",34,165;
		break;
	case 3:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"in_orcs01",112,99;
		break;
	}
}

function SF_payon {
	if (!(SF_check(0x100000, $@kewd_payon, 5, @map$, 1, "pay_arche")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Payon Cave",
			"- Entrance ("+@cost+"z/"+getmapusers("pay_dun00")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("pay_dun01")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("pay_dun02")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("pay_dun03")+" "+$@ked_users$+")",
			"- Level 5 ("+@cost5+"z/"+getmapusers("pay_dun04")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Payon Cave",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Level 5 ("+@cost5+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"pay_arche",41,133;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"pay_dun01",19,33;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"pay_dun02",19,63;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"pay_dun03",155,159;
		break;
	case 6:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"pay_dun04",34,202;
		break;
	}
}

function SF_pyramid {
	if (!(SF_check(0x200000, $@kewd_pyramid, 4, @map$,1, "moc_ruins")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Pyramid",
			"- Entrance ("+@cost+"z/"+getmapusers("moc_pryd01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("moc_pryd02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("moc_pryd03")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("moc_pryd04")+" "+$@ked_users$+")",
			"- Basement 1 ("+@cost2+"z/"+getmapusers("moc_pryd05")+" "+$@ked_users$+")",
			"- Basement 2 ("+@cost3+"z/"+getmapusers("moc_pryd06")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Pyramid",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Basement 1 ("+@cost2+"z)",
			"- Basement 2 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {	
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"moc_ruins",62,162;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"moc_pryd02",10,192;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"moc_pryd03",100,92;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"moc_pryd04",18,187;
		break;
	case 6:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"moc_pryd05",94,96;
		break;
	case 7:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"moc_pryd06",192,11;
		break;
	}
}

function SF_rachel {
	if (!(SF_check(0x40000000, $@kewd_rachel, 5, @map$, 1, "ra_temin")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Freya's Temple",
			"- Entrance ("+@cost+"z/"+getmapusers("ra_san01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("ra_san02")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("ra_san03")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("ra_san04")+" "+$@ked_users$+")",
			"- Level 5 ("+@cost5+"z/"+getmapusers("ra_san05")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Freya's Temple",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Level 5 ("+@cost5+"z)"
		);
	}

	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"ra_temin",276,318;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"ra_san02",36,21;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"ra_san03",10,150;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"ra_san04",204,216;
		break;
	case 6:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"ra_san05",149,16;
		break;
	}
}

function SF_sphinx {
	if (!(SF_check(0x400000, $@kewd_sphinx, 5, @map$, 1, "moc_fild19")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to the Sphinx",
			"- Entrance ("+@cost+"z/"+getmapusers("in_sphinx1")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("in_sphinx2")+" "+$@ked_users$+")",
			"- Level 3 ("+@cost3+"z/"+getmapusers("in_sphinx3")+" "+$@ked_users$+")",
			"- Level 4 ("+@cost4+"z/"+getmapusers("in_sphinx4")+" "+$@ked_users$+")",
			"- Level 5 ("+@cost5+"z/"+getmapusers("in_sphinx5")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to the Sphinx",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)",
			"- Level 3 ("+@cost3+"z)",
			"- Level 4 ("+@cost4+"z)",
			"- Level 5 ("+@cost5+"z)"
		);
	}

	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"moc_fild19",107,100;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"in_sphinx2",149,81;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"in_sphinx3",210,54;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"in_sphinx4",10,222;
		break;
	case 6:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"in_sphinx5",100,99;
		break;
	}
}

function SF_sunkenShip {
	if (!(SF_check(0x800000, $@kewd_sunkenShip, 2, @map$, 1, "alb2trea")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Sunken Ship",
			"- Entrance ("+@cost+"z/"+getmapusers("treasure01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("treasure02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Sunken Ship",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}

	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"alb2trea",87,103;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"treasure02",102,27;
		break;
	}
}

function SF_thanatosTower {
	if (!(SF_check(0x1000000, $@kewd_thanatosTower, 13, @map$, 1, "tha_scene01")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Thanatos Tower",
			"- Entrance ("+@cost+"z/"+getmapusers("tha_t01")+" "+$@ked_users$+")",
			"- Floor 2 ("+@cost2+"z/"+getmapusers("tha_t02")+" "+$@ked_users$+")",
			"- Floor 3 ("+@cost3+"z/"+getmapusers("tha_t03")+" "+$@ked_users$+")",
			"- Floor 4 ("+@cost4+"z/"+getmapusers("tha_t04")+" "+$@ked_users$+")",
			"- Floor 5 ("+@cost5+"z/"+getmapusers("tha_t05")+" "+$@ked_users$+")",
			"- Floor 6 ("+@cost6+"z/"+getmapusers("tha_t06")+" "+$@ked_users$+")",
			"- Floor 7 ("+@cost7+"z/"+getmapusers("tha_t07")+" "+$@ked_users$+")",
			"- Floor 8 ("+@cost8+"z/"+getmapusers("tha_t08")+" "+$@ked_users$+")",
			"- Floor 9 ("+@cost9+"z/"+getmapusers("tha_t09")+" "+$@ked_users$+")",
			"- Floor 10 ("+@cost10+"z/"+getmapusers("tha_t10")+" "+$@ked_users$+")",
			"- Floor 11 ("+@cost11+"z/"+getmapusers("tha_t11")+" "+$@ked_users$+")",
			"- Floor 12 ("+@cost12+"z/"+getmapusers("tha_t12")+" "+$@ked_users$+")"
//			"- Terrace ("+@cost13+"z/"+getmapusers("thana_boss")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Thanatos Tower",
			"- Entrance ("+@cost+"z)",
			"- Floor 2 ("+@cost2+"z)",
			"- Floor 3 ("+@cost3+"z)",
			"- Floor 4 ("+@cost4+"z)",
			"- Floor 5 ("+@cost5+"z)",
			"- Floor 6 ("+@cost6+"z)",
			"- Floor 7 ("+@cost7+"z)",
			"- Floor 8 ("+@cost8+"z)",
			"- Floor 9 ("+@cost9+"z)",
			"- Floor 10 ("+@cost10+"z)",
			"- Floor 11 ("+@cost11+"z)",
			"- Floor 12 ("+@cost12+"z)"
//			"- Terrace ("+@cost13+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"tha_scene01",139,201;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"tha_t02",149,136;
		break;
	case 4:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"tha_t03",220,159;
		break;
	case 5:
		callfunc "F_keWarp",@cost4*100/@discountKP,$@kewd_discount,e_hmm,"tha_t04",59,144;
		break;
	case 6:
		callfunc "F_keWarp",@cost5*100/@discountKP,$@kewd_discount,e_hmm,"tha_t05",62,9;
		break;
	case 7:
		callfunc "F_keWarp",@cost6*100/@discountKP,$@kewd_discount,e_hmm,"tha_t06",120,225;
		break;
	case 8:
		callfunc "F_keWarp",@cost7*100/@discountKP,$@kewd_discount,e_hmm,"tha_t07",32,166;
		break;
	case 9:
		callfunc "F_keWarp",@cost8*100/@discountKP,$@kewd_discount,e_hmm,"tha_t08",108,44;
		break;
	case 10:
		callfunc "F_keWarp",@cost9*100/@discountKP,$@kewd_discount,e_hmm,"tha_t09",87,145;
		break;
	case 11:
		callfunc "F_keWarp",@cost10*100/@discountKP,$@kewd_discount,e_hmm,"tha_t10",166,138;
		break;
	case 12:
		callfunc "F_keWarp",@cost11*100/@discountKP,$@kewd_discount,e_hmm,"tha_t11",88,36;
		break;
	case 13:
		callfunc "F_keWarp",@cost12*100/@discountKP,$@kewd_discount,e_hmm,"tha_t12",132,55;
		break;
	case 14:
		callfunc "F_keWarp",@cost13*100/@discountKP,$@kewd_discount,e_hmm,"thana_boss",135,126;
		break;
	}
}

function SF_toyFactory {
	if (!(SF_check(0x2000000, $@kewd_toyFactory, 2, @map$, 1, "xmas")))
		return;

	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Toy Factory",
			"- Entrance ("+@cost+"z/"+getmapusers("xmas_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("xmas_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Toy Factory",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}

	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"xmas",144,306;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"xmas_dun02",129,133;
		break;
	}
}

function SF_turtleIsland {
	if (!(SF_check(0x4000000, $@kewd_turtleIsland, 3, @map$, 1, "tur_dun01")))
		return;
	if ($@kewd_deep == 0) {
		if ($@kewd_turtleCave)
			set @submenu, 3;
		else
			set @submenu, 2;
	} else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Turtle Island",
			"- Island Entrance ("+@cost+"z/"+getmapusers("tur_dun01")+" "+$@ked_users$+")",
			"- Cave Entrance ("+@cost+"z/"+getmapusers("tur_dun02")+" "+$@ked_users$+")",
			"- Cave Level 2 ("+@cost2+"z/"+getmapusers("tur_dun03")+" "+$@ked_users$+")",
			"- Cave Level 3 ("+@cost3+"z/"+getmapusers("tur_dun04")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Turtle Island",
			"- Island Entrance ("+@cost+"z)",
			"- Cave Entrance ("+@cost+"z)",
			"- Cave Level 2 ("+@cost2+"z)",
			"- Cave Level 3 ("+@cost3+"z)"
		);
	}
	switch (@submenu) {
	case 2:	
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"tur_dun01",153,47;
		break;
	case 3:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"tur_dun01",155,234;
		break;
	case 4:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"tur_dun03",132,189;
		break;
	case 5:
		callfunc "F_keWarp",@cost3*100/@discountKP,$@kewd_discount,e_hmm,"tur_dun04",100,192;
		break;
	}
}

function SF_umbala {
	if (!(SF_check(0x8000000, $@kewd_umbala, 2, @map$, 1, "umbala")))
		return;
	if ($@kewd_deep == 0)
		set @submenu, 2;
	else if ($@kewd_showOnline) {
		set @submenu, select(
			"- Cancel warp to Umbala Dungeon",
			"- Entrance ("+@cost+"z/"+getmapusers("um_dun01")+" "+$@ked_users$+")",
			"- Level 2 ("+@cost2+"z/"+getmapusers("um_dun02")+" "+$@ked_users$+")"
		);
	} else {
		set @submenu, select(
			"- Cancel warp to Umbala Dungeon",
			"- Entrance ("+@cost+"z)",
			"- Level 2 ("+@cost2+"z)"
		);
	}
	switch (@submenu) {
	case 2:
		callfunc "F_keWarp",@cost*100/@discountKP,$@kewd_discount,e_hmm,"umbala",113,282;
		break;
	case 3:
		callfunc "F_keWarp",@cost2*100/@discountKP,$@kewd_discount,e_hmm,"um_dun02",48,31;
		break;
	}
}

}

//Invoked when we want to add a map to the list of travelled-to dungeons
function	script	F_keAddTravelDungeon	{
	set @map$, getarg(0);
	if ($@kewd_travel > 1) {
		if (kewd_travel) {	//Copy over character permissions.
			set #kewd_travel,#kewd_travel|kewd_travel;
			set kewd_travel, 0;
		}

		if (@map$ == "hu_fild05")
			set #kewd_travel,#kewd_travel|0x1;
		if (@map$ == "ama_in02")
			set #kewd_travel,#kewd_travel|0x2;
		if (@map$ == "moc_fild04" || @map$ == "moc_fild15")
			set #kewd_travel,#kewd_travel|0x4;
		if (@map$ == "ayo_fild02")
			set #kewd_travel,#kewd_travel|0x8;
		if (@map$ == "izlu2dun")
			set #kewd_travel,#kewd_travel|0x10;
		if (@map$ == "comodo" || @map$ == "cmd_fild01")
			set #kewd_travel,#kewd_travel|0x20;
		if (@map$ == "aldebaran")
			set #kewd_travel,#kewd_travel|0x40;
		if (@map$ == "mjolnir_02")
			set #kewd_travel,#kewd_travel|0x80;
		if (@map$ == "prt_fild05")
			set #kewd_travel,#kewd_travel|0x100;
		if (@map$ == "einbech")
			set #kewd_travel,#kewd_travel|0x200;
		if (@map$ == "yuno_fild08")
			set #kewd_travel,#kewd_travel|0x400;
		if (@map$ == "gef_tower")
			set #kewd_travel,#kewd_travel|0x800;
		if (@map$ == "glast_01")
			set #kewd_travel,#kewd_travel|0x1000;
		if (@map$ == "gonryun")
			set #kewd_travel,#kewd_travel|0x2000;
		if (@map$ == "prt_fild01")
			set #kewd_travel,#kewd_travel|0x4000;
		if (@map$ == "jupe_cave")
			set #kewd_travel,#kewd_travel|0x8000;
		if (@map$ == "lighthalzen")
			set #kewd_travel,#kewd_travel|0x10000;
		if (@map$ == "louyang")
			set #kewd_travel,#kewd_travel|0x20000;
		if (@map$ == "yuno_fild03")
			set #kewd_travel,#kewd_travel|0x40000;
		if (@map$ == "in_orcs01")
			set #kewd_travel,#kewd_travel|0x80000;
		if (@map$ == "pay_arche")
			set #kewd_travel,#kewd_travel|0x100000;
		if (@map$ == "moc_ruins")
			set #kewd_travel,#kewd_travel|0x200000;
		if (@map$ == "moc_fild19")
			set #kewd_travel,#kewd_travel|0x400000;
		if (@map$ == "alb2trea")
			set #kewd_travel,#kewd_travel|0x800000;
		if (@map$ == "tha_scene01")
			set #kewd_travel,#kewd_travel|0x1000000;
		if (@map$ == "xmas")
			set #kewd_travel,#kewd_travel|0x2000000;
		if (@map$ == "tur_dun01")
			set #kewd_travel,#kewd_travel|0x4000000;
		if (@map$ == "umbala")
			set #kewd_travel,#kewd_travel|0x8000000;
		if (@map$ == "odin_tem01")
			set #kewd_travel,#kewd_travel|0x10000000;
		if (@map$ == "ra_fild01")
			set #kewd_travel,#kewd_travel|0x20000000;
		if (@map$ == "ra_temin")
			set #kewd_travel,#kewd_travel|0x40000000;
	} else {
		if (@map$ == "hu_fild05")
			set kewd_travel,kewd_travel|0x1;
		if (@map$ == "ama_in02")
			set kewd_travel,kewd_travel|0x2;
		if (@map$ == "moc_fild04" || @map$ == "moc_fild15")
			set kewd_travel,kewd_travel|0x4;
		if (@map$ == "ayo_fild02")
			set kewd_travel,kewd_travel|0x8;
		if (@map$ == "izlu2dun")
			set kewd_travel,kewd_travel|0x10;
		if (@map$ == "comodo" || @map$ == "cmd_fild01")
			set kewd_travel,kewd_travel|0x20;
		if (@map$ == "aldebaran")
			set kewd_travel,kewd_travel|0x40;
		if (@map$ == "mjolnir_02")
			set kewd_travel,kewd_travel|0x80;
		if (@map$ == "prt_fild05")
			set kewd_travel,kewd_travel|0x100;
		if (@map$ == "einbech")
			set kewd_travel,kewd_travel|0x200;
		if (@map$ == "yuno_fild08")
			set kewd_travel,kewd_travel|0x400;
		if (@map$ == "gef_tower")
			set kewd_travel,kewd_travel|0x800;
		if (@map$ == "glast_01")
			set kewd_travel,kewd_travel|0x1000;
		if (@map$ == "gonryun")
			set kewd_travel,kewd_travel|0x2000;
		if (@map$ == "prt_fild01")
			set kewd_travel,kewd_travel|0x4000;
		if (@map$ == "jupe_cave")
			set kewd_travel,kewd_travel|0x8000;
		if (@map$ == "lighthalzen")
			set kewd_travel,kewd_travel|0x10000;
		if (@map$ == "louyang")
			set kewd_travel,kewd_travel|0x20000;
		if (@map$ == "yuno_fild03")
			set kewd_travel,kewd_travel|0x40000;
		if (@map$ == "in_orcs01")
			set kewd_travel,kewd_travel|0x80000;
		if (@map$ == "pay_arche")
			set kewd_travel,kewd_travel|0x100000;
		if (@map$ == "moc_ruins")
			set kewd_travel,kewd_travel|0x200000;
		if (@map$ == "moc_fild19")
			set kewd_travel,kewd_travel|0x400000;
		if (@map$ == "alb2trea")
			set kewd_travel,kewd_travel|0x800000;
		if (@map$ == "tha_scene01")
			set kewd_travel,kewd_travel|0x1000000;
		if (@map$ == "xmas")
			set kewd_travel,kewd_travel|0x2000000;
		if (@map$ == "tur_dun01")
			set kewd_travel,kewd_travel|0x4000000;
		if (@map$ == "umbala")
			set kewd_travel,kewd_travel|0x8000000;
		if (@map$ == "odin_tem01")
			set kewd_travel,kewd_travel|0x10000000;
		if (@map$ == "ra_fild01")
			set kewd_travel,kewd_travel|0x20000000;
		if (@map$ == "ra_temin")
			set kewd_travel,kewd_travel|0x40000000;
	}
	return;
}
