//===== eAthena Script =======================================
//= War of Emperium Guild Flags Function
//===== By: ==================================================
//= jAthena - kalen (1.0)
//= 1.1 by Akaru, ho|yAnge|X, and Valaris
//===== Current Version: =====================================
//= 1.5
//===== Compatible With: =====================================
//= eAthena 0.1+; RO Episode 4+
//===== Description: =========================================
//= Flags display messages stating whether or not a guild castle has been captured.
//= Allows the guild members to return to a captured castle.
//======================================
//= Break down of arguments used in the function:
//=   arg(0): name of City.
//=   arg(1): name of guild castle.
//=   arg(2): x1 coordinate for warp
//=   arg(3): y1 coordinate for warp
//=   arg(4): Teleportable (0/1) 
//=   arg(5): Display Flag Dialog (0/1)
//===== Additional Comments: =================================
//= v1.2: All Guild flags scripts use this function. [kobra_k88]
//= v1.3: Can now only flag in from outside the castle [Kayla]
//= v1.3a: Implemented k3dt's exploit fix [Vicious]
//= v1.4: By default town flags are set to no longer show text. [L0ne_W0lf]
//= v1.5: Updated remaining dialog to iRO standards. [L0ne_W0lf]
//============================================================

function	script	F_Flags	{

	if (getarg(5) == 0) return;

	set @GID, GetCastleData(getarg(1),1);
	if (@GID != 0) goto L_Startg;

	mes " [ Edict of the Divine Rune Midgard Kingdom ]";
	mes " ";
	mes "1. Follow the ordinance of The Divine Rune Midgard Kingdom, ";
	mes "We declare that";
	mes "there is no formal master of this castle.";
	mes " ";
	mes "2. To the one who can ";
	mes "overcome all trials";
	mes "and destroy the Emperium,";
	mes "the king will endow the one with";
	mes "ownership of this castle.";
	return;
L_Startg:
	if ((getcharid(2) == @GID) && (getarg(4) == 1)) goto L_Startg2;
	mes "[ Edict of the Divine Rune Midgard Kingdom ]";
	mes " ";
	mes "1. Following the ordinance of the";
	mes "Divine Rune Midgard Kingdom,";
	mes "we approve that this place is in";
	mes "the private possession of ^ff0000" + GetGuildName(@GID) + "^000000 Guild.";
	mes " ";
	mes "2. The guild Master of ^ff0000"+ GetGuildName(@GID) + "^000000 Guild is";
	mes "^FF0000" + GetGuildMaster(@GID) + "^000000";
	mes "If there is anyone who objects to this,";
	mes " prove your strength and honor with a steel blade in your hand.";
	return;
L_Startg2:
	mes "Brave ones...";
	mes "Do you wish to return to your honorable place?";
	next;
	menu "Return to the guild castle.",M_Enter,"Quit.",-;
	return;

	M_Enter:
		if (getcharid(2) == GetCastleData(getarg(1),1)) warp getarg(1),getarg(2),getarg(3);
		return;
}
