//===== eAthena Script =======================================
//= elRO Airship
//===== By: ==================================================
//= Edited And removed irrelevent comments by eAthena Dev Team
//= Draike\Bluto\Hephaestus
//===== Current Version: =====================================
//= 2.0 eAthena Release
//===== Compatible With: =====================================
//= eAthena SVN 02/05/2005 +
//===== Description: =========================================
//= It's the elRO airship. XD
//===== Additional Comments: =================================
//= ALWAYS HAVE AT LEAST TWELVE (12) LOCATIONS AS THE MINIMUM.  This is unless you modify to OnMinutes and change the schedule around.
//= If you have "airplane.gat,103,72,0	warp	airs02a	1,1,airplane.gat,102,200" as a warp, remove it.  Where it's supposed to go, I have no clue.
//============================================================ 
payon.gat,153,43,5	script	itinsetter	-1,{

//This is just OnInit stuff to set the hourly intinerary.
OnInit:
deletearray $locationsname$[0],500;
deletearray $locationsmap$[0],500;
deletearray $locationsx[0],500;
deletearray $locationsy[0],500;
deletearray $alreadygoneto[0],500;
setarray $locationsname$[0],"Airport"; 
setarray $locationsname$[1],"Prontera"; 
setarray $locationsname$[2],"Payon"; 
setarray $locationsname$[3],"Aldebaran"; 
setarray $locationsname$[4],"Alberta"; 
setarray $locationsname$[5],"Geffen"; 
setarray $locationsname$[6],"Morocc"; 
setarray $locationsname$[7],"Glast Heim"; 
setarray $locationsname$[8],"Umbala"; 
setarray $locationsname$[9],"Comodo"; 
setarray $locationsname$[10],"Amatsu"; 
setarray $locationsname$[11],"Niflheim"; 
setarray $locationsname$[12],"Lutie"; 
setarray $locationsname$[13],"Louyang"; 
setarray $locationsname$[14],"Gonryun"; 
setarray $locationsname$[15],"Yuno"; 
setarray $locationsname$[16],"Ant Hell"; 
setarray $locationsname$[17],"Jawaii"; 
setarray $locationsname$[18],"Orc Village"; 
setarray $locationsname$[19],"Mjolnir Coal Mines"; 
setarray $locationsname$[20],"Gefenia Ruins"; 
setarray $locationsname$[21],"Ayothaya"; 
setarray $locationsname$[22],"Lighthalzen"; 
setarray $locationsname$[23],"Juperos"; 
setarray $locationsmap$[0],"airport.gat"; 
setarray $locationsmap$[1],"prt_fild08.gat"; 
setarray $locationsmap$[2],"pay_fild08.gat"; 
setarray $locationsmap$[3],"mjolnir_12.gat"; 
setarray $locationsmap$[4],"pay_fild03.gat"; 
setarray $locationsmap$[5],"gef_fild00.gat"; 
setarray $locationsmap$[6],"moc_fild10.gat"; 
setarray $locationsmap$[7],"glast_01.gat"; 
setarray $locationsmap$[8],"umbala.gat"; 
setarray $locationsmap$[9],"comodo.gat"; 
setarray $locationsmap$[10],"amatsu.gat"; 
setarray $locationsmap$[11],"niflheim.gat"; 
setarray $locationsmap$[12],"xmas.gat"; 
setarray $locationsmap$[13],"louyang.gat"; 
setarray $locationsmap$[14],"gonryun.gat"; 
setarray $locationsmap$[15],"yuno.gat"; 
setarray $locationsmap$[16],"moc_fild04.gat"; 
setarray $locationsmap$[17],"jawaii.gat"; 
setarray $locationsmap$[18],"gef_fild10.gat"; 
setarray $locationsmap$[19],"mjolnir_02.gat"; 
setarray $locationsmap$[20],"gefenia01.gat"; 
setarray $locationsmap$[21],"ayothaya.gat"; 
setarray $locationsmap$[22],"lighthalzen.gat";
setarray $locationsmap$[23],"jupe_gate.gat";
setarray $locationsx[0],148; 
setarray $locationsx[1],206; 
setarray $locationsx[2],159; 
setarray $locationsx[3],62; 
setarray $locationsx[4],194; 
setarray $locationsx[5],50; 
setarray $locationsx[6],163; 
setarray $locationsx[7],196; 
setarray $locationsx[8],187;
setarray $locationsx[9],203; 
setarray $locationsx[10],115;
setarray $locationsx[11],132;
setarray $locationsx[12],232;
setarray $locationsx[13],36; 
setarray $locationsx[14],82; 
setarray $locationsx[15],58;
setarray $locationsx[16],209;
setarray $locationsx[17],248; 
setarray $locationsx[18],158;
setarray $locationsx[19],76;
setarray $locationsx[20],98; 
setarray $locationsx[21],183;
setarray $locationsx[22],99;
setarray $locationsx[23],46;
setarray $locationsy[0],45; 
setarray $locationsy[1],280;
setarray $locationsy[2],92; 
setarray $locationsy[3],381;
setarray $locationsy[4],182;
setarray $locationsy[5],365;
setarray $locationsy[6],172;
setarray $locationsy[7],327;
setarray $locationsy[8],98;
setarray $locationsy[9],76; 
setarray $locationsy[10],79;
setarray $locationsy[11],241;
setarray $locationsy[12],308;
setarray $locationsy[13],279; 
setarray $locationsy[14],96; 
setarray $locationsy[15],194;
setarray $locationsy[16],326;
setarray $locationsy[17],175; 
setarray $locationsy[18],95;
setarray $locationsy[19],363;
setarray $locationsy[20],21; 
setarray $locationsy[21],104;
setarray $locationsy[22],240; 
setarray $locationsy[23],19;
goto resetgoneto;
end;

setrandomitin:
set $@settervariable,$@settervariable + 1;
setarray $locationn[$@settervariable],rand(0,getarraysize($locationsname$) - 1);
if($alreadygoneto[$locationn[$@settervariable]]==1)set $@settervariable,$@settervariable - 1; 
if($alreadygoneto[$locationn[$@settervariable]]==1)goto setrandomitin;
setarray $alreadygoneto[$locationn[$@settervariable]], 1;
if($@settervariable<12)goto setrandomitin;
end;

resetgoneto:
deletearray $alreadygoneto[0], 500;
set $@currenttime, 0;
goto setrandomitin;

OnMinute00:
set $@currenttime, 1;
callfunc "F_Itinreset",12,1,2;

OnMinute03:
set $destination,250;
end;

OnMinute05:
set $@currenttime, 2;
callfunc "F_Itinreset",1,2,3;

OnMinute08:
set $destination,250;
end;

OnMinute10:
set $@currenttime, 3;
callfunc "F_Itinreset",2,3,4;

OnMinute13:
set $destination,250;
end;

OnMinute15:
set $@currenttime, 4;
callfunc "F_Itinreset",3,4,5;

OnMinute18:
set $destination,250;
end;

OnMinute20:
set $@currenttime, 5;
callfunc "F_Itinreset",4,5,6;

OnMinute23:
set $destination,250;
end;

OnMinute25:
set $@currenttime, 6;
callfunc "F_Itinreset",5,6,7;

OnMinute28:
set $destination,250;
end;

OnMinute30:
set $@currenttime, 7;
callfunc "F_Itinreset",6,7,8;

OnMinute33:
set $destination,250;
end;

OnMinute35:
set $@currenttime, 8;
callfunc "F_Itinreset",7,8,9;

OnMinute38:
set $destination,250;
end;

OnMinute40:
set $@currenttime, 9;
callfunc "F_Itinreset",8,9,10;

OnMinute43:
set $destination,250;
end;

OnMinute45:
set $@currenttime, 10;
callfunc "F_Itinreset",9,10,11;

OnMinute48:
set $destination,250;
end;

OnMinute50:
set $@currenttime, 11;
callfunc "F_Itinreset",10,11,12;

OnMinute53:
set $destination,250;
end;

OnMinute55:
set $@currenttime, 12;
callfunc "F_Itinreset",11,12,1;

OnMinute58:
set $destination,250;
end;
}
function	script	F_Porter	{
	if($destination==getarg(0))goto Board;
	if($destination!=getarg(0))goto Notime;

Board:
	mes "^FF0000[Porter]^000000";
	mes "The plane is currently ported.  Would you like to board?";
	menu "Yes.",L_Yes,"No.",L_Nope,"View Hourly Itinerary.",Itin;

L_Yes:
	if($destination!=getarg(0))goto Notime;
	warp "airplane.gat", 105, 72;
	specialeffect2 501;
L_Nope:
	mes "^FF0000[Porter]^000000";
	mes "Have a good day.  Thank you for traveling with Airship.";
	close;

Notime:
	mes "^FF0000[Porter]^000000";
	if(sex==0) mes "Sorry, ma'am, but the plane currently isn't ported.  However, you can view the airplane's hourly itinerary.";
	if(sex==1) mes "Sorry, sir, but the plane currently isn't ported.  However, you can view the airplane's hourly itinerary.";
	menu "Yes, please.",Itin,"No thanks.",L_Nope;
	close;
	end;

Itin:
next;
mes "^FF0000[Porter]^000000";
callfunc "F_Itin";
}
airport.gat,153,43,5	script	Airport Porter	774,{
callfunc "F_Porter",0;
}
prt_fild08.gat,206,279,5	script	Porter	774,{
callfunc "F_Porter",1;
}
gef_fild00.gat,50,364,5	script	Porter	774,{
callfunc "F_Porter",5;
}
moc_fild10.gat,163,173,5	script	Porter	774,{
callfunc "F_Porter",6;
}
mjolnir_12.gat,61,380,5	script	Porter	774,{
callfunc "F_Porter",3;
}
pay_fild08.gat,159,91,5	script	Porter	774,{
callfunc "F_Porter",2;
}
pay_fild03.gat,194,181,5	script	Porter	774,{
callfunc "F_Porter",4;
}
glast_01.gat,196,326,1	script	Porter	774,{
callfunc "F_Porter",7;
}
umbala.gat,188,98,3	script	Porter	774,{
callfunc "F_Porter",8;
}
comodo.gat,203,75,8	script	Porter	774,{
callfunc "F_Porter",9;
}
amatsu.gat,115,78,8	script	Porter	774,{
callfunc "F_Porter",10;
}
niflheim.gat,132,242,5	script	Porter	774,{
callfunc "F_Porter",11;
}
xmas.gat,232,309,5	script	Porter	774,{
callfunc "F_Porter",12;
}
louyang.gat,35,279,8	script	Porter	774,{
callfunc "F_Porter",13;
}
gonryun.gat,82,95,7	script	Porter	774,{
callfunc "F_Porter",14;
}
yuno.gat,58,195,4	script	Porter	774,{
callfunc "F_Porter",15;
}
moc_fild04.gat,210,326,2	script	Porter	774,{
callfunc "F_Porter",16;
}
jawaii.gat,247,174,7	script	Porter	774,{
callfunc "F_Porter",17;
}
gef_fild10.gat,159,95,2	script	Porter	774,{
callfunc "F_Porter",18;
}
mjolnir_02.gat,76,364,5	script	Porter	774,{
callfunc "F_Porter",19;
}
gefenia01.gat,97,22,6	script	Porter	774,{
callfunc "F_Porter",20;
}
ayothaya.gat,182,105,5	script	Porter	774,{
callfunc "F_Porter",21;
}
lighthalzen.gat,99,241,4	script	Porter	774,{
callfunc "F_Porter",22;
}
jupe_gate.gat,46,18,7	script	Porter	774,{
callfunc "F_Porter",23;
}
airport.gat,141,43,5	script	Itinerary Schedule	837,{
mes "^FF0000[Itinerary]^000000";
callfunc "F_Itin";
}
airplane.gat,102,68,5	script	Docker	852,{
	if($destination == 250) goto Nowhere;
	mes "^FF0000[Airplane Attendant]^000000";
	if($destination == 250)goto Notime;
	set @dockky, $destination;
	if($destination != 250)mes "We are currently docked at "+$locationsname$[$destination]+".  Would you like to exit?";
	menu "Yes.",Lyes,"No.",Lnope;

Lyes:
	if($destination == 250)goto Notime;
	if($destination != @dockky)goto Notime;
	warp $locationsmap$[$destination], $locationsx[$destination], $locationsy[$destination];
	specialeffect2 501;

Lnope:
	next;
	mes "^FF0000[Airplane Attendant]^000000";
	mes "Have a good day.  Thank you for traveling with us.";
	close;

Notime:
	mes "^FF0000[Airplane Attendant]^000000";
	if(sex==0) mes "Sorry, ma'am, but the plane currently isn't docked.  Please wait.";
	if(sex==1) mes "Sorry, sir, but the plane currently isn't docked.  Please wait.";
	close;

Nowhere:
	mes "^FF0000[Airplane Attendant]^000000";
	mes "We're currently in air. Please wait until the pilot has announced that we have safely landed.";
	close;
}
function	script	F_Itin	{
//This is the itinerary's function.  It should work well enough.
if($@currenttime==0)mes "Try again later.  A recent server reboot or rehash has messed the itinerary up for a bit.";
if($@currenttime==0)close;
if($@currenttime==0)end;
set @tempo, 0;
set @tempo, $@currenttime - 1;
goto seta;
close;

seta:
set @tempo, @tempo + 1;
set @time, gettime(3);
set @minutes, 5 * @tempo - 5;
set @minutess, 5 * @tempo - 2;
if(@minutes<10)set @minutes$, "0" + @minutes;
if(@minutes>9)set @minutes$, @minutes;
if(@minutess<10)set @minutess$, "0" + @minutess;
if(@minutess>9)set @minutess$, @minutess;
if(@time<12)set @time$,@time;
if(@time==12)set @time$,12;
if(@time>12)set @time$,@time - 12;
if(@time<12)mes @time$+":"+ @minutes$ + " A.M. - "+@time$+ ":"+ @minutess$ + " A.M. - "+"^FF0000"+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time==12)mes @time$+":"+ @minutes$ + " P.M. - "+@time$+ ":"+ @minutess$ + " P.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time>12 && time<24)mes @time$ +":"+ @minutes$ + " P.M. - "+@time$ + ":"+ @minutess$ + " P.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time==24)mes @time$+":"+ @minutes$ + " A.M. - "+@time$+ ":"+ @minutess$ + " A.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
if(@tempo<12)goto seta;
set @tempo, 0;
goto setb;

setb:
if($@currenttime - 1==@tempo)goto setc;
set @tempo, @tempo + 1;
set @time, gettime(3) + 1;
set @minutes, 5 * @tempo - 5;
set @minutess, 5 * @tempo - 2;
if(@minutes<10)set @minutes$, "0" + @minutes;
if(@minutes>9)set @minutes$, @minutes;
if(@minutess<10)set @minutess$, "0" + @minutess;
if(@minutess>9)set @minutess$, @minutess;
if(@time<12)set @time$,@time;
if(@time==12)set @time$,12;
if(@time>12)set @time$,@time - 12;
if(@time<12)mes @time$+":"+ @minutes$ + " A.M. - "+@time$+ ":"+ @minutess$ + " A.M. - "+"^FF0000"+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time==12)mes @time$+":"+ @minutes$ + " P.M. - "+@time$+ ":"+ @minutess$ + " P.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time>12 && time<24)mes @time$ +":"+ @minutes$ + " P.M. - "+@time$+ ":"+ @minutess$ + " P.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
if(@time==24)mes @time$+":"+ @minutes$ + " A.M. - "+@time$+ ":"+ @minutess$ + " A.M. -"+"^FF0000 "+$locationsname$[$locationn[@tempo]]+"^000000";
goto setb;

setc:
close;
end;
}
function	script	F_Itinreset	{
setarray $alreadygoneto[$locationn[getarg(0)]], 0;
goto sest;

sest:
setarray $locationn[getarg(0)],rand(0,getarraysize($locationsname$) - 1);
if($alreadygoneto[$locationn[getarg(0)]]==1)goto sest;
setarray $alreadygoneto[$locationn[getarg(0)]], 1;
set $destination,$locationn[$@currenttime];
announce "Pilot: The plane has arrived at "+$locationsname$[$locationn[getarg(1)]]+".  Departure to "+ $locationsname$[$locationn[getarg(2)]] + " is in 3 minutes.",16;
end;
}