//===== Hercules Script ======================================
//= Warper
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.4b
//===== Description: =========================================
//= A complete - but very condensed - warper script.
//= Some coordinates written by Tekno-Kanix and ToastOfDoom.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Added missing duplicates and fixed coordinates.
//= 1.2 Added new episodes and simplified functions.
//= 1.3 Added Renewal checks and Instances menu.
//=     Aligned coordinates with @go.
//= 1.4 Added new Guild Dungeons.
//= 1.4a Slight edits.
//= 1.4b Added Wolfchev's Laboratory warp.
//============================================================

-	script	Warper	FAKE_NPC,{
function Go; function Disp; function Pick; function Restrict;

// --------------------------------------------------
//	Main Menu:
// --------------------------------------------------
mes .npc$;
if(questprogress(31004) == 1 && countitem(30106) > 0 ){
	mes "Welcome to Kafra Warp Serv~~";
	mes "Oh! My apologies! Force of habit.  I think that I've heard that you are new in town!";
	next;
	mes .npc$;
	mes "I'm the famous Warper of the Kafra Agency!";
	mes "Kafras are a legendary hospitality group who are here to help you on your journey! I'm party of the Warp Division which was formerly housed with each Kafra's city chief.";
	mes "But that's all part of my work now - and I dare to say that I'm pretty good at it!";
	next;
	mes .npc$;
	mes "If there's any place that you want to go - we've got you covered.";
	mes "There's a Warper in lots of locations, and we can get you to where you need to go.";
	mes "Although there are a few locations that we don't cover, we can take you to most major cities, dungeon entrances, and more in an instant!";
	next;
	mes .npc$;
	mes "When you're ready to go somewhere, just speak with us!  We'll get you there professionally and quickly.";
	nov_train2++;
		switch (BaseLevel){
			case 1: getexp 9,0; break;
			case 2: getexp 16,0; break;
			case 3: getexp 25,0; break;
			case 4: getexp 36,0; break;
			case 5: getexp 77,0; break;
			case 6: getexp 112,0; break;
			case 7: getexp 153,0; break;
			case 8: getexp 200,0; break;
			case 9: getexp 253,0; break;
			case 10: getexp 320,0; break;
			case 11: getexp 385,0; break;
			case 12: getexp 490,0; break;
			case 13: getexp 585,0; break;
			case 14: getexp 700,0; break;
			case 15: getexp 830,0; break;
			case 16: getexp 970,0; break;
			case 17: getexp 1120,0; break;
			case 18: getexp 1260,0; break;
			case 19: getexp 1420,0; break;
		}
	switch (JobLevel) {
		case 1: getexp 0,10; break;
		case 2: getexp 0,18; break;
		case 3: getexp 0,28; break;
		case 4: getexp 0,40; break;
		case 5: getexp 0,91; break;
		case 6: getexp 0,151; break;
		case 7: getexp 0,205; break;
		case 8: getexp 0,258; break;
		case 9: getexp 0,340; break;
	}
	//add job
	delitem 30106,countitem(30106);
	if(nov_train2 == 3){
		next;
		mes .npc$;
		mes "Well then, I think that you've completed your mission!";
		mes "Go back to ^ff0000Hannibal^000000 now to continue your training quest";
		completequest(31004);
		setquest(31005);
		close;
	}
	close;	
}
cutin "kafra_04",2;
mes "Welcome to Kafra Warp Service.  We can warp you to many different places for free.";
menu	"[ ^FF0000"+lastwarpt$+"^000000 ]",-,
		"Towns",Towns,
		"Dungeons",Dungeons,
		"PvP",PvP;
		//" ~ Guild Castles",Castles,
		//" ~ Guild Dungeons",Guild_Dungeons;
		//" ~ Instances",Instances,
		//" ~ Special Areas",Special;
	if (lastwarpt$ == "") {
		message strcharinfo(PC_NAME),"You haven't warped anywhere yet.";
		cutin "",255;
		close2;
	} else {
		cutin "",255;
		warp lastwarp$,lastwarpx,lastwarpy;
	}
	end;

// ------------------- Functions -------------------
// * Go("<map>",<x>,<y>);
//	~ Warps directly to a map.
//
// * Disp("<Menu Option>",<first option>,<last option>);
// * Pick("<map_prefix>"{,<index offset>});
//	~ Dynamic menu and map selection (auto-numbered).
//
// * Disp("<Option 1>:<Option 2>:<etc.>");
// * Pick("","<map1>","<map2>","<etc.>");
//	~ Manual menu and map selection (listed).
//
// * Restrict("<RE | Pre-RE>"{,<menu option numbers>});
//	~ Only allows map for Renewal or Pre-Renewal modes.
//     If menu option numbers are given, only those maps
//     will be restricted (i.e. not for "Go").
//
// Other notes:
//   ~ Array @c[] holds all (x,y) coordinates.
//   ~ Use @c[2] EXCEPT when maps begin dynamically
//	  at 0: use @c[0] and Pick() offset 1.
// --------------------------------------------------

function Go {
	if (getarg(0) == "pvp_y_room"){
		set @mode$, "Yoyo";
		set @players1, 128;
		set @players2, 128;
		set @room1$, "Prontera";
		set @room2$, "Izlude";
		set @room3$, "Payon";
		set @room4$, "Alberta";
		set @room5$, "Morroc";
	}
	if (getarg(0) == "guild_vs1"){
		if(!$deathmatch) {
			next;
			mes .npc$;
			mes "Sorry ^FF5533'PvP Deathmatch'^000000 is currently not available at this time. Please try later.";
			cutin "",255;
			close;	
		}
		if (getcharid(CHAR_ID_PARTY)){
			next;
			mes .npc$;
			mes "Please leave your party before joining ^FF5533'PvP Deathmatch'^000000.";
			cutin "",255;
			close;
		}
		getmapxy(.@map$, @x, @y, 0);
		set dlastmap$,.@map$;
		set dlastx,@x;
		set dlasty,@y;
		set deathmatch,1;
		set dhp,Hp;
		set dsp,Sp;
		chanmsg("#battle",""+strcharinfo(0)+" has entered DeathMatch Arena ("+(1+getmapusers("guild_vs1"))+" users).");
		warp "guild_vs1",0,0;
		percentheal 100,100;
		sleep2 1000;
		skilleffect AL_BLESSING,0;
		sc_start SC_BLESSING,240000,10;
		skilleffect AL_INCAGI,0;
		sc_start SC_INC_AGI,240000,10;
		heal -15,0;
		sleep2 1000;
		end;
	}
	lastwarp$ = getarg(0);
	lastwarpx = getarg(1,0);
	lastwarpy = getarg(2,0);
	lastwarpt$ = getarg(3,0);
	warp getarg(0),getarg(1,0),getarg(2,0);
	end;
}
function Disp {
	if (getargcount() < 3)
		@menu$ = getarg(0);
	else {
		@menu$ = "";
		for (.@i = getarg(1); .@i <= getarg(2); .@i++)
			@menu$ = @menu$+getarg(0)+" "+.@i+":";
	}
	return;
}
function Pick {
	.@warp_block = @warp_block;
	@warp_block = 0;
	.@select = select(@menu$);
	if (getarg(0) == "") {
		.@i = .@select;
		.@map$ = getarg(.@i);
	} else {
		.@i = .@select-getarg(1,0);
		.@map$ = getarg(0)+((.@i<10)?"0":"")+.@i;
	}
	if (.@warp_block & (1<<.@select)) {
		message strcharinfo(PC_NAME),"This map is not enabled in "+(RENEWAL?"":"Pre-")+"Renewal.";
		end;
	}
	.@x = @c[.@i*2];
	.@y = @c[.@i*2+1];
	deletearray @c[0],getarraysize(@c);
	Go(.@map$,.@x,.@y);
}
function Restrict {
	if ((getarg(0) == "RE" && !RENEWAL) || (getarg(0) == "Pre-RE" && RENEWAL)) {
		if (getarg(1,0)) {
			@warp_block = 0;
			for (.@i = 1; .@i < getargcount(); .@i++)
				@warp_block = @warp_block | (1<<getarg(.@i));
		} else {
			message strcharinfo(PC_NAME),"This map is not enabled in "+(RENEWAL?"":"Pre-")+"Renewal.";
			end;
		}
	}
	return;
}

// --------------------------------------------------
	PvP:
// --------------------------------------------------
menu	"PvP DeathMatch",P1, 
	"PvP Yoyo Mode",P2;

P1: Go("guild_vs1",0,0,"PvP Deathmatch");
P2: Go("pvp_y_room",51,23,"PvP Yoyo Mode");

// --------------------------------------------------
	Towns:
// --------------------------------------------------
menu	"Prontera",T1, 
	"Alberta",T2, 
	"Aldebaran",T3, 
	"Amatsu",T4, 
	"Ayothaya",T5,
	"Comodo",T7, 
	"Einbech",T10,
	"Einbroch",T11, 
	"Geffen",T13, 
	"Gonryun",T14, 
	"Hugel",T15,
	"Izlude",T16, 
	"Jawaii",T17, 
	"Lighthalzen",T18, 
	"Louyang",T19, 
	"Lutie",T20,
	"Morroc",T26, 
	"Payon",T30, 
	"Rachel",T31, 
	"Umbala",T34, 
	//"Veins",T35, 
	"Yuno",T36;

T1: Go("prontera",155,183,"Prontera");
T2: Go("alberta",28,234,"Alberta");
T3: Go("aldebaran",140,131,"Aldebaran");
T4: Go("amatsu",198,84,"Amatsu");
T5: Go("ayothaya",208,166,"Ayothaya");
T7: Go("comodo",187,150,"Comodo");
T10: Go("einbech",63,35,"Einbech");
T11: Go("einbroch",64,200,"Einbroch");
T13: Go("geffen",119,59,"Geffen");
T14: Go("gonryun",160,120,"Gonryun");
T15: Go("hugel",96,145,"Hugel");
T16: Go("izlude",128,89,"Izlude");
T17: Go("jawaii",251,132,"Jawaii");
T18: Go("lighthalzen",158,92,"Lighthalzen");
T19: Go("louyang",217,100,"Louyang");
T20: Go("xmas",147,134,"Lutie");
T26: Go("morocc",156,93,"Morocc");
T30: Go("payon",179,100,"Payon");
T31: Go("rachel",130,110,"Rachel");
T34: Go("umbala",97,153,"Umbala");
T35: Go("veins",216,123,"Veins");
T36: Go("yuno",157,181,"Juno");

// --------------------------------------------------
	Dungeons:
// --------------------------------------------------
menu		"Amatsu Dungeon",D1, 
		"Anthell",D2,
		"Ayothaya Dungeon",D3, 
		"Byalan Dungeon",D4,
		"Coal Mines",D5, 
		"Einbroch Dungeon",D6,
		"Glast Heim",D7,
		"Glast Heim Churchyard",D8,
		"Glast Heim Prison",D9,
		"Hidden Dungeon",D10,
		"Ice Dungeon",D11,
		"Juperos Core",D12, 
		"Kiel Hyre Dungeon",D13,
		"Kokomo Beach",D14, 
		"Lighthalzen Dungeon",D15,
		"Louyang Dungeon",D16,
		"Magma Dungeon",D17, 
		"Orc Dungeon",D18,
		"Payon Dungeon",D19, 
		"Prontera Culvert",D20, 
		"Pyramids",D21,
		"Sphinx",D22, 
		"Sunken Ship",D23,
		"Thanatos Tower",D24, 
		"Toy Factory",D26,
		"Umbala Dungeon",D27;


D1: Go("ama_in02",121,180,"Amatsu Dungeon");
D2: Go("moc_fild15",244,247,"Anthell");
D3: Go("ayo_fild02",272,150,"Ayothaya Dungeon");
D4: Go("iz_dun00",168,168,"Byalan Dungeon");
D5: Go("mjolnir_02",83,357,"Coal Mines");
D6: Go("einbech",139,244,"Einbroch Dungeon");
D7: Go("glast_01",200,289,"Glast Heim");
D8: Go("gl_chyard",147,149,"Glast Heim Churchyard");
D9: Go("gl_prison",15,70,"Glast Heim Prison");
D10: Go("prt_fild01",136,362,"Hidden Dungeon");
D11: Go("ra_fild01",233,327,"Ice Dungeon");
D12: Go("yuno_fild07",218,176,"Juperos Core");
D13: Go("yuno_fild08",75,171,"Kiel Hyre Dungeon");
D14: Go("cmd_fild02",222,372,"Kokomo Beach");		//no return
D15: Go("lhz_in01",30,225,"Lighthalzen Dungeon");		//no return
D16: Go("lou_dun01",215,195,"Louyang Dungeon"); 		//no return
D17: Go("yuno_fild03",38,141,"Magma Dungeon"); 
D18: Go("gef_fild10",70,332,"Orc Dungeon"); 
D19: Go("pay_arche",45,132,"Payon Dungeon"); 
D20: Go("prt_fild05",278,212,"Prontera Culvert"); 
D21: Go("moc_ruins",64,159,"Pyramids");
D22: Go("moc_fild19",107,100,"Sphinx");
D23: Go("alb2trea",91,63,"Sunken Ship");
D24: Go("hu_fild01",140,157,"Thanatos Tower");		//no return
D26: Go("xmas",143,309,"Toy Factory");
D27: Go("um_dun01",42,31,"Umbala Dungeon");

OnInit:
	questinfo(QTYPE_JOB, 1);
	setquestinfo(QINFO_JOB, Job_Novice);
	setquestinfo(QINFO_QUEST, 31004, 1);
	setquestinfo(QINFO_ITEM, 30106, 1,1);
	.npc$ = "[ ^ff0000Warper^000000 ]";
	end;
}


ama_in02,124,182,4	duplicate(Warper)	Warper#amd	4_F_KHELLISIA
moc_fild15,242,251,4	duplicate(Warper)	Warper#ant	4_F_KHELLISIA
ayo_fild02,276,154,4	duplicate(Warper)	Warper#ayd	4_F_KHELLISIA
einbech,142,245,4	duplicate(Warper)	Warper#eid	4_F_KHELLISIA
glast_01,194,291,4	duplicate(Warper)	Warper#gls	4_F_KHELLISIA
prt_fild01,140,365,4	duplicate(Warper)	Warper#hid	4_F_KHELLISIA
yuno_fild07,214,179,4	duplicate(Warper)	Warper#cor	4_F_KHELLISIA
yuno_fild08,75,181,4	duplicate(Warper)	Warper#kie	4_F_KHELLISIA
yuno_fild03,40,143,4	duplicate(Warper)	Warper#mag	4_F_KHELLISIA
moc_fild19,107,97,4	duplicate(Warper)	Warper#sph	4_F_KHELLISIA
xmas,139,311,4	duplicate(Warper)	Warper#toy	4_F_KHELLISIA
lighthalzen,154,86,0	duplicate(Warper)	Warper#lhz	4_F_KHELLISIA
// --------------------------------------------------
//	Duplicates:
// --------------------------------------------------
alb2trea,57,70,6	duplicate(Warper)	Warper#tre	4_F_KHELLISIA
alberta,28,240,4	duplicate(Warper)	Warper#alb	4_F_KHELLISIA
aldebaran,145,118,4	duplicate(Warper)	Warper#alde	4_F_KHELLISIA
amatsu,203,87,4	duplicate(Warper)	Warper#ama	4_F_KHELLISIA
ayothaya,209,169,6	duplicate(Warper)	Warper#ayo	4_F_KHELLISIA
comodo,198,148,4	duplicate(Warper)	Warper#com	4_F_KHELLISIA
einbech,59,38,6	duplicate(Warper)	Warper#einbe	4_F_KHELLISIA
einbroch,69,202,4	duplicate(Warper)	Warper#einbr	4_F_KHELLISIA
gef_fild10,71,339,4	duplicate(Warper)	Warper#orc	4_F_KHELLISIA
geffen,122,62,2	duplicate(Warper)	Warper#gef	4_F_KHELLISIA
glast_01,372,308,4	duplicate(Warper)	Warper#glh	4_F_KHELLISIA
gonryun,155,122,4	duplicate(Warper)	Warper#gon	4_F_KHELLISIA
izlu2dun,110,92,4	duplicate(Warper)	Warper#izd	4_F_KHELLISIA
izlude,134,91,4	duplicate(Warper)	Warper#izl	4_F_KHELLISIA	//Pre-RE: (132,120)
jawaii,253,138,4	duplicate(Warper)	Warper#jaw	4_F_KHELLISIA
louyang,208,103,6	duplicate(Warper)	Warper#lou	4_F_KHELLISIA
mjolnir_02,85,364,4	duplicate(Warper)	Warper#mjo	4_F_KHELLISIA
moc_ruins,64,164,4	duplicate(Warper)	Warper#moc	4_F_KHELLISIA
morocc,159,97,4	duplicate(Warper)	Warper#mor	4_F_KHELLISIA
niflheim,205,179,4	duplicate(Warper)	Warper#nif	4_F_KHELLISIA
pay_arche,42,134,4	duplicate(Warper)	Warper#arc	4_F_KHELLISIA
payon,179,106,4	duplicate(Warper)	Warper#pay	4_F_KHELLISIA
prontera,152,192,4	duplicate(Warper)	Warper#prt	4_F_KHELLISIA
prt_fild05,279,223,6	duplicate(Warper)	Warper#cul	4_F_KHELLISIA
umbala,89,158,3	duplicate(Warper)	Warper#umb	4_F_KHELLISIA
xmas,150,136,6	duplicate(Warper)	Warper#xmas	4_F_KHELLISIA
yuno,145,185,4	duplicate(Warper)	Warper#yuno	4_F_KHELLISIA
hugel,101,151,4	duplicate(Warper)	Warper#hug	4_F_KHELLISIA
rachel,132,117,4	duplicate(Warper)	Warper#ra	4_F_KHELLISIA
ra_fild01,237,331,4	duplicate(Warper)	Warper#raf	4_F_KHELLISIA