//===== eAthena Script =======================================
//= ĤG𫰾
//===== By: ==================================================
//= L0ne_W0lf
//===== Current Version: =====================================
//= 2.0
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
//= WoE SE cǨ а Castle 3 (N)
//============================================================

arug_cas03,1,1,0	script	Manager#aru03_02	111,{
	end;

OnInterIfInitOnce:
	GetCastleData "arug_cas03",0,"::OnRecvCastleAr03";
	end;

OnRecvCastleAr03:
	RequestGuildInfo GetCastleData("arug_cas03",1);
	if (GetCastleData("arug_cas03",1) == 0) {
		donpcevent "Manager#aru03_02::Onstart";
	}
	end;

OnAgitStart2:
	if (agitcheck2()) {
		MapRespawnGuildID "arug_cas03",GetCastleData("arug_cas03",1),2;
		GvgOn "arug_cas03";
		donpcevent "Manager#aru03_02::Onstart";
	}
	else {
		donpcevent "#aru03_RL00::OnDisable";
		donpcevent "#aru03_RL01::OnDisable";
		donpcevent "#aru03_RL02::OnDisable";
		donpcevent "#aru03_RL03::OnDisable";
	}
	end;

OnAgitEnd2:
	GvgOff "arug_cas03";
	if (GetCastleData("arug_cas03",1)) {
		KillMonster "arug_cas03","޲zH#aru03::OnStartArena";
		donpcevent "Manager#aru03_02::Onreset";
		donpcevent "޲zH#aru03::Onstop";
	}
	end;

Onstart:
	// 1st Guardian stone, 2nd Guardian stone, Barrier 1, Barrier 2, Barrier 3, Summon Guardians
	// Settings for all but Summon Guardians
	// 0 = Okay; 1 = Destroyed; 2 = Repairing
	// Summon Guardians
	// 0 = Do not Summon; 1 = Summon
	if (GetCastleData("arug_cas03",1)) {
		setarray $agit_ar03[0],0,0,0,0,0,0;
		donpcevent "#aru03_df01::OnEnable";
		donpcevent "#aru03_df02::OnEnable";
		donpcevent "#aru03_RL00::OnEnable";
		donpcevent "#aru03_RL01::OnEnable";
		donpcevent "#aru03_RL02::OnEnable";
		donpcevent "#aru03_RL03::OnEnable";
	}
	monster "arug_cas03",141,293,"R",1288,1,"޲zH#aru03::OnStartArena";
	end;

Onreset:
	donpcevent "#aru03_df01::OnDisable";
	donpcevent "#aru03_df02::OnDisable";
	donpcevent "#aru03_gard01::Onreset";
	donpcevent "#aru03_gard02::Onreset";
	donpcevent "#aru03_RL00::OnDisable";
	donpcevent "#aru03_RL01::OnDisable";
	donpcevent "#aru03_RL02::OnDisable";
	donpcevent "#aru03_RL03::OnDisable";
	donpcevent "1u@#aru03::OnDisable";
	donpcevent "2u@#aru03::OnDisable";
	donpcevent "˸m01#aru03::OnDisable";
	donpcevent "˸m02#aru03::OnDisable";
	donpcevent "˸m03#aru03::OnDisable";
	if (agitcheck2()) {
		setarray $agit_ar03[0],0,0,1,1,1,0;
	}
	end;

Onchange:
	setarray $agit_ar03[0],2,2,1,1,2,0;
	monster "arug_cas03",141,293,"R",1288,1,"޲zH#aru03::OnStartArena";
	donpcevent "˸m03#aru03::OnEnable";
	donpcevent "1u@#aru03::OnEnable";
	donpcevent "2u@#aru03::OnEnable";
	end;

OnClock0001:
	if (!GetCastleData("arug_cas03",1)) end;
	killmonster "arug_cas03","Manager#aru03_02::OnTreasureDied";

	if (GetCastleData("arug_cas03",4)) {
		set .@Economy,GetCastleData("arug_cas03",2);
		SetCastleData "arug_cas03",2,.@Economy + GetCastleData("arug_cas03",4) + (rand(2) && getgdskilllv(.@GID,10014));
		if (GetCastleData("arug_cas03",2) > 100) SetCastleData "arug_cas03",2,100;
		setcastledata "arug_cas03",4,0;
	}
	if (GetCastleData("arug_cas03",5)) {
		set .@Defence,GetCastleData("arug_cas03",3);
		SetCastleData "arug_cas03",3,.@Defence + GetCastleData("arug_cas03",5);
		if (GetCastleData("arug_cas03",3) > 100) SetCastleData "arug_cas03",3,100;
		setcastledata "arug_cas03",5,0;
	}

	set .@Treasure,GetCastleData("arug_cas03",2)/5+4;
	if (.@Treasure) {
		monster "arug_cas03",291,276,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		monster "arug_cas03",292,276,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		monster "arug_cas03",293,276,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		monster "arug_cas03",294,276,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 5) end;
		monster "arug_cas03",295,276,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 6) end;
		monster "arug_cas03",296,276,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 7) end;
		monster "arug_cas03",293,274,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 8) end;
		monster "arug_cas03",294,274,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 9) end;
		monster "arug_cas03",295,274,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 10) end;
		monster "arug_cas03",296,274,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 11) end;
		monster "arug_cas03",297,274,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 12) end;
		monster "arug_cas03",298,274,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 13) end;
		monster "arug_cas03",291,272,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 14) end;
		monster "arug_cas03",292,272,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 15) end;
		monster "arug_cas03",293,272,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 16) end;
		monster "arug_cas03",294,272,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 17) end;
		monster "arug_cas03",295,272,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 18) end;
		monster "arug_cas03",296,272,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 19) end;
		monster "arug_cas03",293,269,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 20) end;
		monster "arug_cas03",294,269,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 21) end;
		monster "arug_cas03",295,269,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 22) end;
		monster "arug_cas03",296,269,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 23) end;
		monster "arug_cas03",297,269,"_cl",1945,1,"Manager#aru03_02::OnTreasureDied";
		if (.@Treasure < 24) end;
		monster "arug_cas03",298,269,"_cl",1324,1,"Manager#aru03_02::OnTreasureDied";
	}
	end;

OnTreasureDied:
	end;
}

arug_cas03,146,315,3	script	Ĭ#aru03_01	868,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (.@GID == 0) {
		mes "[Ĭ]";
		mes "\H?";
		mes "ЧA֤@I}oya!";
		close;
	}
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) != getguildmaster(.@GID)) {
			mes "[p̴]";
			mes "ڬOtdu@,";
			mes "ԲӪeڷQDH";
			close;
		}
		else {
			if (agitcheck2() == 0) {
				mes "[Ĭ]";
				mes "I am Yehsus, guardian of";
				mes "this stronghold. For now,";
				mes "all is quiet in this place.";
				next;
				switch(select("Converse:")) {
				case 1:
					mes "[Ĭ]";
					mes "Do you have any questions";
					mes "about this stronghold?";
					next;
					switch(select("u@:mu:Ŷʨt:Battle Strategy:")) {
					case 1:
						mes "[Ĭ]";
						mes "There is one Emperium";
						mes "and two Guardian Stones in";
						mes "each fortress. These stones";
						mes "are the first line of defense,";
						mes "and must be destroyed before";
						mes "enemies can even enter.";
						next;
						mes "[Ĭ]";
						mes "The stones are located in";
						mes "^4D4DFFGate Houses^000000 which must be";
						mes "protected to prevent enemies";
						mes "from reaching the Emperium.";
						mes "Guardian Stones can ^4D4DFFrecall";
						mes "your Guardians^000000 for protection.";
						next;
						mes "[Ĭ]";
						mes "Fortresses with higher levels";
						mes "of defense can summon more";
						mes "Guardians: this is why it is";
						mes "so important for guilds to";
						mes "invest in Defense Growth.";
						next;
						mes "[Ĭ]";
						mes "Guardian Stones that have";
						mes "been destroyed can be revived";
						mes "after a certain time, but one of^FFFFFF ^000000 the guild members must give";
						mes "me the order. I can also report^FFFFFF ^000000 the status of the Guardian Stones.";
						close;
					case 2:
						mes "[Ĭ]";
						mes "^4D4DFFFortress Gates^000000 are the second ^FFFFFF ^000000 line of guild stronghold defense,";
						mes "and are protected by extra barricades activated by the Guardian Stones.";
						mes "These gates are located in three different parts of the fortress.";
						next;
						mes "[Ĭ]";
						mes "Barricades are protected by";
						mes "Guardian Stones, and are";
						mes "restored when the Guardian";
						mes "Stones are retrieved. However,";
						mes "it is not as easy to restore";
						mes "destroyed Fortress Gates.";
						next;
						mes "[Ĭ]";
						mes "Fortress Gates can only be";
						mes "restored when the ^4D4DFFguild";
						mes "master of a stronghold";
						mes "changes^000000, or if ^4D4DFFrestoration";
						mes "is requested by the guild";
						mes "master of the stronghold^000000.";
						close;
					case 3:
						mes "[Ĭ]";
						mes "Strongholds have many";
						mes "Link Flags that allow you";
						mes "to access vital areas within";
						mes "restrictions placed by the";
						mes "Barricades. Usually, ^4D4DFFFlag 1";
						mes "links to the Gate House^000000.";
						next;
						mes "[Ĭ]";
						mes "Many flags link directly to";
						mes "the flag near the Emperium.";
						mes "The final numbered flag is";
						mes "linked to the Convenience";
						mes "Facility of the stronghold's";
						mes "owner. Keep this in mind.";
						close;
					case 4:
						mes "[Ĭ]";
						mes "Strategy? It would be better";
						mes "to develop your battle plan to";
						mes "exploit your guild's advantages";
						mes "and your enemies' weaknesses.";
						mes "Use the Gate Houses and Barricades, and rebuild as quickly as you can!";
						close;
					case 5:
						mes "[Ĭ]";
						mes "You have no questions";
						mes "to ask of me? Well, I'm";
						mes "here to serve your needs.";
						close;
					}
				case 2:
					mes "[Ĭ]";
					mes "I'm always here, so";
					mes "feel free to request my";
					mes "assistance whenever";
					mes "the need arises.";
					close;
				}
			}
			else {
				mes "[Ĭ]";
				mes "Greetings, "+strcharinfo(0)+".";
				mes "What are your orders?";
				next;
				switch(select("Increase Stronghold Defense:ˬdmA:")) {
				case 1:
					if ($agit_ar03[5] == 0) {
						if (getgdskilllv(.@GID,10002) == 0) {
							mes "[Ĭ]";
							mes "I'm sorry, but the Guardian";
							mes "Stones aren't powerful enough";
							mes "to summon Guardians yet. We";
							mes "need to accumulate more";
							mes "knowledge before they can";
							mes "summon any Guardians.";
							close;
						}
						else {
							mes "[Ĭ]";
							mes "I shall endeavor to summon";
							mes "a Guardian through a Guardian";
							mes "Stone. However, keep in mind";
							mes "that this will not work if the";
							mes "Guardian Stone is destroyed.";
							setarray $agit_ar03[5],1;
							if ($agit_ar03[0] == 0) {
								donpcevent "#aru03_gard01::OnEnable";
							}
							if ($agit_ar03[1] == 0) {
								donpcevent "#aru03_gard02::OnEnable";
							}
							close;
						}
					}
					else {
						mes "[Ĭ]";
						mes "You've already commanded";
						mes "me to summon a Guardian";
						mes "to defend the stronghold.";
						close;
					}
				case 2:
					mes "[Ĭ]";
					mes "ڭ̪mAO...";
					if ($agit_ar03[0] == 1) {
						mes "1u@: ^FF0000Q}a^000000";
					}
					else if ($agit_ar03[0] == 2) {
						mes "1u@: ^008000״_^000000";
					}
					else {
						mes "1u@: ^4D4DFF`^000000";
					}
					if ($agit_ar03[1] == 1) {
						mes "2u@: ^FF0000Q}a^000000";
					}
					else if ($agit_ar03[1] == 2) {
						mes "2u@: ^008000״_^000000";
					}
					else {
						mes "2u@: ^4D4DFF`^000000";
					}
					if ($agit_ar03[2] == 1) {
						mes "1mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar03[2] == 2) {
						mes "1mu: ^008000״_^000000";
					}
					else {
						mes "1mu: ^4D4DFF`^000000";
					}
					if ($agit_ar03[3] == 1) {
						mes "2mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar03[3] == 2) {
						mes "2mu: ^008000״_^000000";
					}
					else {
						mes "2mu: ^4D4DFF`^000000";
					}
					if ($agit_ar03[4] == 1) {
						mes "3mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar03[4] == 2) {
						mes "3mu: ^008000״_^000000";
					}
					else {
						mes "3mu: ^4D4DFF`^000000";
					}
					close;
				case 3:
					mes "[Ĭ]";
					mes "Hɦb,";
					mes "Աz";
					close;
				}
			}
		}
	}
	else {
		mes "[Ĭ]";
		mes "\H?";
		mes "ЧA֤@I}oya!";
		close;
	}

OnInit:
	setarray $agit_ar03[0],0,0,0,0,0,0;
	end;
}

arug_cas03,1,1,0	script	#aru03_gard01	-1,{
OnEnable:
	set .@Defence,GetCastleData("arug_cas03",3);
	guardian "arug_cas03",130,60,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //0;
	if ((.@Defense > 10) && (.@Defense < 31)) {
		set .MyMobCount,2;
		guardian "arug_cas03",128,77,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //1;
	}
	else if ((.@Defense > 30) && (.@Defense < 51)) {
		set .MyMobCount,3;
		guardian "arug_cas03",128,77,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //1;
		guardian "arug_cas03",128,90,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //2;
	}
	else if ((.@Defense > 50) && (.@Defense < 71)) {
		set .MyMobCount,4;
		guardian "arug_cas03",128,77,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //1;
		guardian "arug_cas03",128,90,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //2;
		guardian "arug_cas03",128,100,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //3;
	}
	else if (.@Defense > 70) {
		set .MyMobCount,5;
		guardian "arug_cas03",128,77,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //1;
		guardian "arug_cas03",128,90,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //2;
		guardian "arug_cas03",128,100,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //3;
		guardian "arug_cas03",110,96,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //4;
	}
	else {
		set .MyMobCount,2;
		guardian "arug_cas03",66,157,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //1;
	}
	initnpctimer;
	end;

OnTimer300000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",91,53,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //5;
	mapannounce "arug_cas03","bI 1l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",65,71,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //6;
	mapannounce "arug_cas03","bI 2l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer1800000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",65,103,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //7;
	mapannounce "arug_cas03","bI 3l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer2700000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",110,96,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //8;
	mapannounce "arug_cas03","bI 4l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer3600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",128,100,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //9;
	mapannounce "arug_cas03","bI 5l[lX@H]F",bc_map,"0xff4500";
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "arug_cas03",128,77,"Ch@H]",1899,"#aru03_gard01::OnGuardianDied"; //10;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "arug_cas03","#aru03_gard01::OnGuardianDied";
	end;
}

arug_cas03,1,2,0	script	#aru03_gard02	-1,{
OnEnable:
	set .@Defence,GetCastleData("arug_cas03",3);
	guardian "arug_cas03",156,101,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //11;
	if ((.@Defense > 10) && (.@Defense < 31)) {
		set .MyMobCount,2;
		guardian "arug_cas03",172,95,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //12;
	}
	else if ((.@Defense > 30) && (.@Defense < 51)) {
		set .MyMobCount,3;
		guardian "arug_cas03",172,95,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //12;
		guardian "arug_cas03",154,90,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //13;
	}
	else if ((.@Defense > 50) && (.@Defense < 71)) {
		set .MyMobCount,4;
		guardian "arug_cas03",172,95,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //12;
		guardian "arug_cas03",154,90,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //13;
		guardian "arug_cas03",156,77,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //14;
	}
	else if (.@Defense > 70) {
		set .MyMobCount,5;
		guardian "arug_cas03",172,95,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //12;
		guardian "arug_cas03",154,90,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //13;
		guardian "arug_cas03",156,77,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //14;
		guardian "arug_cas03",155,60,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //15;
	}
	else {
		set .MyMobCount,2;
		guardian "arug_cas03",211,159,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //12;
	}
	initnpctimer;
	end;

OnTimer600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",187,54,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //16;
	end;

OnTimer1200000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",212,67,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //17;
	end;

OnTimer2100000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",211,105,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //18;
	end;

OnTimer3000000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",155,60,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //19;
	end;

OnTimer3900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas03",156,77,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //20;
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "arug_cas03",172,95,"Ch@H]",1899,"#aru03_gard02::OnGuardianDied"; //21;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "arug_cas03","#aru03_gard02::OnGuardianDied";
	end;
}

arug_cas03,1,3,0	script	#aru03_df01	-1,{
OnEnable:
	guardian "arug_cas03",65,171," 1 u@",1907,"#aru03_df01::OnGuardianStoneDied"; //22;
	end;

OnDisable:
	killmonster "arug_cas03","#aru03_df01::OnGuardianStoneDied";
	setarray $agit_ar03[0],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 1st Guardian Stone is Destroyed
	setarray $agit_ar03[0],1;
	if (($agit_ar03[0] == 1) || ($agit_ar03[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_ar03[1] == 1) || ($agit_ar03[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "arug_cas03","u@ۥ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru03_RL00::OnDisable";
		donpcevent "#aru03_gard01::Onreset";
	}
	else {
		mapannounce "arug_cas03","1u@ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru03_gard01::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "1u@#aru03::OnEnable";
	setarray $agit_ar03[0],2; //Global Variable
	stopnpctimer;
	end;
}

arug_cas03,65,171,0	script	1u@#aru03	844,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "}au@ۭnsΦF,";
		mes "YnsΦ pUһݤUCq";
		next;
		mes " 1,";
		mes "T 1,";
		mes "Y 30,";
		mes "Ŧ]Oq 5,";
		mes "]Oq 5,";
		mes "]Oq 5";
		next;
		mes "аݭn~򪺶i@~?";
		switch(select(":i")) {
		case 1:
			mes "Ҧ@~QF";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "n̾";
				mes "Y,T,ݪǨӰtm,";
				mes "FnsΦ";
				mes "ntm]O]Oq";
				next;
				switch(select("T::Y")) {
				case 1:
					mes "bWT";
					next;
					break;
				case 2:
					mes "bW";
					next;
					break;
				case 3:
					mes "bWY";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "tmT";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "tm";
					next;
					break;
				case 3:
					mes "tmY";
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "Tb̤W";
					next;
					break;
				case 2:
					mes "⯫ݩb̤W";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "Yb̤W";
					next;
					break;
				}
				mes "HI]k";
				mes "ntm]O]Oq,";
				mes "]OʽηǳƪĪGHKio";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_ar03[0] == 0) {
						mes "u@ۭsΦwgQF";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "]]O۪Ĭ";
							mes "u@ۭsΦѤF";
							close;
						}
						else {
							mes "wF]Oq۪tm,";
							mes "u@۪sΦO\!!!";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#aru03_df01::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "1u@#aru03";
							setarray $agit_ar03[0],0;
							set .@df_all,$agit_ar03[0]+$agit_ar03[1];
							if (.@df_all == 0) {
								mapannounce "arug_cas03","u@ۤw״_ }ljĵ٤F",bc_map,"0x00ff00";
								donpcevent "#aru03_RL00::OnEnable";
							}
							else {
								mapannounce "arug_cas03","1u@ۭsΦ w\F!",bc_map,"0x00ff00";
							}
							if ($agit_ar03[5] == 1) {
								donpcevent "#aru03_gard01::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "Ҧ@~.. ININT";
					mes "S󪺤";
					mes "ݼˤlOѪˤl,";
					mes "hF";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "ƨäOܥR";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "1u@#aru03";
	end;

OnEnable:
	enablenpc "1u@#aru03";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "1u@#aru03";
	end;
}

arug_cas03,1,4,0	script	#aru03_df02	-1,{
OnEnable:
	guardian "arug_cas03",212,149," 2 u@",1908,"#aru03_df02::OnGuardianStoneDied"; //23;
	end;

OnDisable:
	killmonster "arug_cas03","#aru03_df02::OnGuardianStoneDied";
	setarray $agit_ar03[1],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 2nd Guardian Stone is Destroyed
	setarray $agit_ar03[1],1;
	if (($agit_ar03[0] == 1) || ($agit_ar03[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_ar03[1] == 1) || ($agit_ar03[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "arug_cas03","u@ۥ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru03_RL00::OnDisable";
		donpcevent "#aru03_gard02::Onreset";
	}
	else {
		mapannounce "arug_cas03","2u@ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru03_gard02::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "2u@#aru03::OnEnable";
	setarray $agit_ar03[1],2; //Global Variable
	stopnpctimer;
	end;
}

arug_cas03,212,149,0	script	2u@#aru03	844,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "}au@ۭnsΦF,";
		mes "YnsΦ pUһݤUCq";
		next;
		mes " 1,";
		mes "T 1,";
		mes "Y 30,";
		mes "Ŧ]Oq 5,";
		mes "]Oq 5,";
		mes "]Oq 5";
		next;
		mes "аݭn~򪺶i@~?";
		switch(select(":i")) {
		case 1:
			mes "Ҧ@~QF";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "n̾";
				mes "Y,T,ݪǨӰtm,";
				mes "FnsΦ";
				mes "ntm]O]Oq";
				next;
				switch(select("T::Y")) {
				case 1:
					mes "bWT";
					next;
					break;
				case 2:
					mes "bW";
					next;
					break;
				case 3:
					mes "bWY";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "tmT";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "tm";
					mes "with some Oridecon.^000000";
					next;
					break;
				case 3:
					mes "tmY";
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "Tb̤W";
					next;
					break;
				case 2:
					mes "⯫ݩb̤W";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "Yb̤W";
					next;
					break;
				}
				mes "HI]k";
				mes "ntm]O]Oq,";
				mes "]OʽηǳƪĪGHKio";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_ar03[1] == 0) {
						mes "u@ۭsΦwgQF";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "]]O۪Ĭ";
							mes "u@ۭsΦѤF";
							close;
						}
						else {
							mes "wg]Oq۪tm,";
							mes "u@۪sΦO\!!!";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#aru03_df02::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "2u@#aru03";
							setarray $agit_ar03[1],0;
							set .@df_all,$agit_ar03[0]+$agit_ar03[1];
							if (.@df_all == 0) {
								mapannounce "arug_cas03","u@ۤw״_ }ljĵ٤F",bc_map,"0x00ff00";
								donpcevent "#aru03_RL00::OnEnable";
							}
							else {
								mapannounce "arug_cas03","2u@ۭsΦ w\F!",bc_map,"0x00ff00";
							}
							if ($agit_ar03[5] == 1) {
								donpcevent "#aru03_gard02::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "Ҧ@~.. ININT";
					mes "S󪺤";
					mes "ݼˤlOѪˤl,";
					mes "hF";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "ƨäOܥR";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "2u@#aru03";
	end;

OnEnable:
	enablenpc "2u@#aru03";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "2u@#aru03";
	end;
}

// Barrier Summoners
arug_cas03,2,1,0	script	#aru03_RL00	-1,{
OnEnable:
	setwall "arug_cas03",138,110,8,6,0,"aru03_RL00";
	guardian "arug_cas03",139,111," ",1905,"#aru03_RL00::OnBarrierDestroyed"; //24;
	guardian "arug_cas03",141,111," ",1905,"#aru03_RL00::OnBarrierDestroyed"; //25;
	guardian "arug_cas03",143,111," ",1905,"#aru03_RL00::OnBarrierDestroyed"; //26;
	guardian "arug_cas03",145,111," ",1905,"#aru03_RL00::OnBarrierDestroyed"; //27;
	end;

OnDisable:
	delwall "aru03_RL00";
	killmonster "arug_cas03","#aru03_RL00::OnBarrierDestroyed";
	end;

OnBarrierDestroyed:
	end;
}

arug_cas03,2,2,0	script	#aru03_RL01	-1,{
OnEnable:
	set .MyMobCount,6;
	setwall "arug_cas03",139,158,6,6,1,"aru03_RL01";
	guardian "arug_cas03",140,157," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //28;
	guardian "arug_cas03",142,157," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //29;
	guardian "arug_cas03",144,157," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //30;
	guardian "arug_cas03",139,156," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //31;
	guardian "arug_cas03",141,156," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //32;
	guardian "arug_cas03",143,156," ",1905,"#aru03_RL01::OnBarrierDestroyed"; //33;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar03[2],1;
		mapannounce "arug_cas03","1mu Q}F",bc_map,"0x00ff00";
		delwall "aru03_RL01";
	}
	end;

OnDisable:
	delwall "aru03_RL01";
	killmonster "arug_cas03","#aru03_RL01::OnBarrierDestroyed";
	end;
}

arug_cas03,2,3,0	script	#aru03_RL02	-1,{
OnEnable:
	set .MyMobCount,6;
	setwall "arug_cas03",138,210,8,6,1,"aru03_RL02";
	guardian "arug_cas03",140,209," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //34;
	guardian "arug_cas03",142,209," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //35;
	guardian "arug_cas03",144,209," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //36;
	guardian "arug_cas03",139,208," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //37;
	guardian "arug_cas03",141,208," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //38;
	guardian "arug_cas03",143,208," ",1905,"#aru03_RL02::OnBarrierDestroyed"; //39;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar03[3],1;
		mapannounce "arug_cas03","2mu Q}F",bc_map,"0x00ff00";
		delwall "aru03_RL02";
	}
	end;

OnDisable:
	delwall "aru03_RL02";
	killmonster "arug_cas03","#aru03_RL02::OnBarrierDestroyed";
	end;
}

arug_cas03,2,4,0	script	#aru03_RL03	-1,{
OnEnable:
	set .MyMobCount,4;
	setwall "arug_cas03",138,263,8,6,1,"aru03_RL03";
	guardian "arug_cas03",139,262," ",1905,"#aru03_RL03::OnBarrierDestroyed"; //40;
	guardian "arug_cas03",141,262," ",1905,"#aru03_RL03::OnBarrierDestroyed"; //41;
	guardian "arug_cas03",143,262," ",1905,"#aru03_RL03::OnBarrierDestroyed"; //42;
	guardian "arug_cas03",145,262," ",1905,"#aru03_RL03::OnBarrierDestroyed"; //43;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar03[4],1;
		mapannounce "arug_cas03","3mu Q}F!!",bc_map,"0x00ff00";
		delwall "aru03_RL03";
	}
	end;

OnDisable:
	delwall "aru03_RL03";
	killmonster "arug_cas03","#aru03_RL03::OnBarrierDestroyed";
	end;
}

arug_cas03,136,158,0	script	˸m01#aru03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar03[2] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru03_RL01::OnEnable";
							disablenpc "˸m01#aru03";
							mapannounce "arug_cas03"," 1 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar03[2],0;
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m01#aru03";
	end;

OnEnable:
	enablenpc "˸m01#aru03";
	end;

OnDisable:
	disablenpc "˸m01#aru03";
	end;
}

arug_cas03,135,212,0	script	˸m02#aru03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar03[3] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru03_RL02::OnEnable";
							disablenpc "˸m02#aru03";
							mapannounce "arug_cas03"," 2 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar03[3],0; //Global Variable
							setarray $agit_ar03[2],2; //Global Variable
							donpcevent "˸m01#aru03::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m02#aru03";
	end;

OnEnable:
	enablenpc "˸m02#aru03";
	end;

OnDisable:
	disablenpc "˸m02#aru03";
	end;
}

arug_cas03,134,266,0	script	˸m03#aru03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar03[4] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru03_RL03::OnEnable";
							disablenpc "˸m03#aru03";
							mapannounce "arug_cas03"," 3 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar03[4],0;
							setarray $agit_ar03[3],2;
							donpcevent "˸m02#aru03::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m03#aru03";
	end;

OnEnable:
	enablenpc "˸m03#aru03";
	end;

OnDisable:
	disablenpc "˸m03#aru03";
	end;
}

// Link Flags
arug_cas03,122,314,0	script	LF-01#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select(" 1 I: 2 I:")) {
		case 1:
			warp "arug_cas03",84,158;
			end;
		case 2:
			warp "arug_cas03",197,136;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,125,314,0	script	LF-02#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-1:ma 1-2:")) {
		case 1:
			warp "arug_cas03",65,94;
			end;
		case 2:
			warp "arug_cas03",211,97;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,128,314,0	script	LF-03#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-3:ma 1-4:")) {
		case 1:
			warp "arug_cas03",112,73;
			end;
		case 2:
			warp "arug_cas03",171,73;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,131,314,0	script	LF-04#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 2-1:ma 2-2:")) {
		case 1:
			warp "arug_cas03",112,152;
			end;
		case 2:
			warp "arug_cas03",172,152;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,134,314,0	script	LF-05#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 2-3:ma 2-4:")) {
		case 1:
			warp "arug_cas03",120,186;
			end;
		case 2:
			warp "arug_cas03",162,186;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,149,314,0	script	LF-06#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 3-1:ma 3-2:")) {
		case 1:
			warp "arug_cas03",116,235;
			end;
		case 2:
			warp "arug_cas03",164,235;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,152,314,0	script	LF-07#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-1:ma 2-1:ma 3-1:")) {
		case 1:
			warp "arug_cas03",65,94;
			end;
		case 2:
			warp "arug_cas03",112,152;
			end;
		case 3:
			warp "arug_cas03",116,235;
			end;
		case 4:
			close;
		}
	}
	end;
}

arug_cas03,155,314,0	script	LF-08#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-2:ma 2-2:ma 3-2:")) {
		case 1:
			warp "arug_cas03",211,97;
			end;
		case 2:
			warp "arug_cas03",172,152;
			end;
		case 3:
			warp "arug_cas03",164,235;
			end;
		case 4:
			close;
		}
	}
	end;
}

arug_cas03,158,314,0	script	LF-09#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-4:ma 2-4:")) {
		case 1:
			warp "arug_cas03",171,73;
			end;
		case 2:
			warp "arug_cas03",162,186;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas03,161,314,0	script	LF-10#arug_cas03	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "iHʨ쬰F|̪KQҧΦϰ,";
		mes "аݧAnʶ?";
		switch(select("ʨKQϰ:")) {
		case 1:
			warp "arug_cas03",321,57;
			end;
		case 2:
			close;
		}
	}
	end;
}

arug_cas03,45,158,0	script	N#LF_ar03_01::LF_ar03_01	111,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "ʨ즳RݤԲa,";
		mes "аݧAnϥζ?";
		switch(select(":")) {
		case 1:
			warp "arug_cas03",121,318;
			end;
		case 2:
			close;
		}
	}
	end;
}

arug_cas03,226,156,0	duplicate(LF_ar03_01)	N#LF_ar03_01	111
arug_cas03,134,62,4	duplicate(LF_ar03_01)	N#LF_ar03_02	111
arug_cas03,149,62,4	duplicate(LF_ar03_01)	N#LF_ar03_03	111
arug_cas03,123,154,0	duplicate(LF_ar03_01)	N#LF_ar03_04	111
arug_cas03,160,154,0	duplicate(LF_ar03_01)	N#LF_ar03_05	111
arug_cas03,135,205,0	duplicate(LF_ar03_01)	N#LF_ar03_06	111
arug_cas03,148,205,0	duplicate(LF_ar03_01)	N#LF_ar03_07	111
arug_cas03,134,260,0	duplicate(LF_ar03_01)	N#LF_ar03_08	111
//arug_cas03,204,142,0	duplicate(LF_ar03_01)	N#LF_ar03_09	111

arug_cas03,148,103,4	script	N#LF_ar03_10::LF_ar03_02	722,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "ʨ즳RݤԲa,";
		mes "аݧAnϥζ?";
		switch(select(":")) {
		case 1:
			warp "arug_cas03",121,318;
			end;
		case 2:
			close;
		}
	}
	end;

OnRecvCastleAr03:
	FlagEmblem GetCastleData("arug_cas03",1);
	end;
}

arug_cas03,135,103,4	duplicate(LF_ar03_02)	N#LF_ar03_11	722
arug_cas03,63,51,7	duplicate(LF_ar03_02)	N#LF_ar03_12	722
arug_cas03,214,51,1	duplicate(LF_ar03_02)	N#LF_ar03_13	722

// Guild Manager
arug_cas03,328,98,3	script	޲zH#aru03	55,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (.@GID == 0) {
		mes "[ ޲zH ]";
		mes "ڦbݧڪDH... i_Ḭ! lHARBa!";
		close;
	}
	if (getcharid(2) != .@GID || strcharinfo(0) != getguildmaster(.@GID)) {
		mes "[ ޲zH ]";
		mes "ާA̫¯٧,ڥu@NlHڪDH ^FF0000" + getguildmaster(.@GID) + "^000000 !";
		mes "@HA̦b̧r!";
		mes "֧oǵLzå̻a!";
		close;
	}
	mes "[ ޲zH ]";
	mes "w{,ڪDH ^FF0000" + getguildmaster(.@GID) + "^000000/pj...";
	mes "оާhJ,ڱNۦaA";
	next;
	switch(select("dݯKap:ӷ~oi:꨾m: / Ѷ ܮw¾:iJDHж")) {
	case 1:
		mes "[ ޲zH ]";
		mes "{bVAiKap";
		mes "{bӷ~oi׬O ^0000ff" + GetCastleData("arug_cas03",2) + " ";
		if (GetCastleData("arug_cas03",4) > 0) {
			mes "bLh@Ѥ,";
			mes "F " + GetCastleData("arug_cas03",4) + " ";
		}
		next;
		mes "[ ޲zH ]";
		mes "{bm׬O " + GetCastleData("arug_cas03",3) + " ";
		if (GetCastleData("arug_cas03",5) > 0) {
			mes "bLh@Ѥ,";
			mes "F " + GetCastleData("arug_cas03",5) + " ";
		}
		mes " ";
		mes "i";
		close;
	case 2:
		set .@Economy,GetCastleData("arug_cas03",2);
		if (.@Economy < 6) { set .@eco_invest,5000; }
		else if ((.@Economy >= 6) && (.@Economy <= 10)) { set .@eco_invest,10000; }
		else if ((.@Economy >= 11) && (.@Economy <= 15)) { set .@eco_invest,20000; }
		else if ((.@Economy >= 16) && (.@Economy <= 20)) { set .@eco_invest,35000; }
		else if ((.@Economy >= 21) && (.@Economy <= 25)) { set .@eco_invest,55000; }
		else if ((.@Economy >= 26) && (.@Economy <= 30)) { set .@eco_invest,80000; }
		else if ((.@Economy >= 31) && (.@Economy <= 35)) { set .@eco_invest,110000; }
		else if ((.@Economy >= 36) && (.@Economy <= 40)) { set .@eco_invest,145000; }
		else if ((.@Economy >= 41) && (.@Economy <= 45)) { set .@eco_invest,185000; }
		else if ((.@Economy >= 46) && (.@Economy <= 50)) { set .@eco_invest,230000; }
		else if ((.@Economy >= 51) && (.@Economy <= 55)) { set .@eco_invest,280000; }
		else if ((.@Economy >= 56) && (.@Economy <= 60)) { set .@eco_invest,335000; }
		else if ((.@Economy >= 61) && (.@Economy <= 65)) { set .@eco_invest,395000; }
		else if ((.@Economy >= 66) && (.@Economy <= 70)) { set .@eco_invest,460000; }
		else if ((.@Economy >= 71) && (.@Economy <= 75)) { set .@eco_invest,530000; }
		else if ((.@Economy >= 76) && (.@Economy <= 80)) { set .@eco_invest,605000; }
		else if ((.@Economy >= 81) && (.@Economy <= 85)) { set .@eco_invest,685000; }
		else if ((.@Economy >= 86) && (.@Economy <= 90)) { set .@eco_invest,770000; }
		else if ((.@Economy >= 91) && (.@Economy <= 95)) { set .@eco_invest,860000; }
		else if ((.@Economy >= 96) && (.@Economy <= 100)) { set .@eco_invest,955000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("arug_cas03",4)) {
			set .@eco_invest,.@eco_invest*4;
		}
		mes "[ ޲zH ]";
		mes "ӷ~oiת,bu|̥Ͳ~ƶq|W[,FH۷Q,ण";
		mes " ";
		mes "ӭ覡,@ѥu@,phI@I,@ѥiH⦸";
		mes " ";
		if (.@Economy == 100) {
			mes "[ ޲zH ]";
			mes "^FF0000ثemץHgO100F,AwgݭnA[JF^000000";
			close;
		}
		if (GetCastleData("arug_cas03",4) == 2) {
			mes "[ ޲zH ]";
			mes "^FF0000iOAwgbѤF⦸AF,^000000oi׻֤Wɴݵ۴IQlo";
			close;
		}
		if (GetCastleData("arug_cas03",4) == 0) {
			mes "[ ޲zH ]";
			mes "{bݭnꪺBO ^FF0000" + .@eco_invest + "^000000 ,аݧAn?";
		}
		else {
			mes "{bAwg@F...";
			mes "٭nA? ٻݭnl[^FF0000" + .@eco_invest + "^000000";
			mes "";
		}
		next;
		switch(select("ӷ~oi:")) {
		case 1:
			if (Zeny < .@eco_invest) {
				mes "[ ޲zH ]";
				mes "DH,ASiHӷ~oi";
				end;
			}
			set zeny,zeny-.@eco_invest;
			SetCastleData "arug_cas03",4,GetCastleData("arug_cas03",4)+1;
			mes "[ ޲zH ]";
			mes "QaF!";
			mes "ݵۧڭ̩n{,Ѫܵoi׷|W";
			close;
		case 2:
			mes "[ ޲zH ]";
			mes "ڱN̷ӧAhJh,OڪDH";
			mes "... ݭnӵ۫,ڭ̷|oܦn";
			close;
		}
	case 3:
		set .@Defence,GetCastleData("arug_cas03",3);
		if (.@Defence < 6) { set .@def_invest,10000; }
		else if ((.@Defence >= 6) && (.@Defence <= 10)) { set .@def_invest,20000; }
		else if ((.@Defence >= 11) && (.@Defence <= 15)) { set .@def_invest,40000; }
		else if ((.@Defence >= 16) && (.@Defence <= 20)) { set .@def_invest,70000; }
		else if ((.@Defence >= 21) && (.@Defence <= 25)) { set .@def_invest,110000; }
		else if ((.@Defence >= 26) && (.@Defence <= 30)) { set .@def_invest,160000; }
		else if ((.@Defence >= 31) && (.@Defence <= 35)) { set .@def_invest,220000; }
		else if ((.@Defence >= 36) && (.@Defence <= 40)) { set .@def_invest,290000; }
		else if ((.@Defence >= 41) && (.@Defence <= 45)) { set .@def_invest,370000; }
		else if ((.@Defence >= 46) && (.@Defence <= 50)) { set .@def_invest,460000; }
		else if ((.@Defence >= 51) && (.@Defence <= 55)) { set .@def_invest,560000; }
		else if ((.@Defence >= 56) && (.@Defence <= 60)) { set .@def_invest,670000; }
		else if ((.@Defence >= 61) && (.@Defence <= 65)) { set .@def_invest,790000; }
		else if ((.@Defence >= 66) && (.@Defence <= 70)) { set .@def_invest,920000; }
		else if ((.@Defence >= 71) && (.@Defence <= 75)) { set .@def_invest,1060000; }
		else if ((.@Defence >= 76) && (.@Defence <= 80)) { set .@def_invest,1210000; }
		else if ((.@Defence >= 81) && (.@Defence <= 85)) { set .@def_invest,1370000; }
		else if ((.@Defence >= 86) && (.@Defence <= 90)) { set .@def_invest,1540000; }
		else if ((.@Defence >= 91) && (.@Defence <= 95)) { set .@def_invest,1720000; }
		else if ((.@Defence >= 96) && (.@Defence <= 100)) { set .@def_invest,1910000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("arug_cas03",5)) {
			set .@def_invest,.@def_invest*4;
		}
		mes "[ ޲zH ]";
		mes "m{ת,@HMRݪ@[׷|W[,Ҽ{쩹᪺Ԫ,o,";
		mes " ";
		mes "ӭ覡,@ѥu@,phI@I,@ѥiH⦸";
		mes " ";
		if (GetCastleData("arug_cas03",3) == 100) {
			mes "^FF0000ثemץHgO100F,AwgݭnA[JF^000000";
			close;
		}
		if (GetCastleData("arug_cas03",5) == 2) {
			mes "^FF0000iOAwgbѤF⦸AF,^000000oi׻֤Wɴݵ۴IQlo";
			close;
		}
		if (GetCastleData("arug_cas03",5) == 0) {
			mes "{bݭnꪺBO ^FF0000" + .@def_invest + "^000000 ,аݧAn?";
		}
		else {
			mes "{bAwg@F...";
			mes "٭nA? ٻݭnl[ ^FF0000" + .@def_invest + "^000000";
			mes "";
		}
		next;
		switch(select("꨾m:")) {
		case 1:
			if (Zeny < .@def_invest) {
				mes "[ ޲zH ]";
				mes "DH,ASiH꨾m";
				close;
			}
			set zeny,zeny-.@def_invest;
			SetCastleData "arug_cas03",5,GetCastleData("arug_cas03",5)+1;
			mes "[ ޲zH ]";
			mes "QaF!";
			mes "ݵۧڭ̩n{,Ѫܵoi׷|W";
			close;
		case 2:
			mes "[ ޲zH ]";
			mes "ڱN̷ӧAhJh,OڪDH";
			mes "... ݭnӵ۫,ڭ̷|oܦn";
			close;
		}
	case 4:
		if (GetCastleData("arug_cas03",9) == 1) {
			mes "[ ޲zH ]";
			mes "аݱznѶdԪAȤH?";
			next;
			switch(select("Ѷ:")) {
			case 1:
				cutin "kafra_01",2;
				mes "[ d ¾ ]";
				mes "ڰFƶ?pGڦƪ,бz̧,Aڤ@|?";
				next;
				switch(select("Ѷ:")) {
				case 1:
					mes "[ d ¾ ]";
					mes "~򬰱zAȯuOڳ̤j...";
					next;
					cutin "kafra_01",255;
					break;
				case 2:
					mes "[ d ¾ ]";
					mes "ڷ|VOԾĪzAȪ!";
					close;
				}
				break;
			case 2:
				mes "[ ޲zH ]";
				mes "DH,ڷQڭӭndU{bod¾,]owgܺɩүaڭ̪AȤF!";
				close;
			}
			disablenpc "d ¾#aru03";
			SetCastleData "arug_cas03",9,0;
			mes "[ ޲zH ]";
			mes "d¾wgѶF... LFW|۷Q,Υd¾W";
			close;
		}
		else {
			mes "[ ޲zH ]";
			mes "Md`qq,QnbKa̭,Υd¾?";
			mes "QnΪ,ݭn ^FF000010,000 ^000000";
			next;
			switch(select(":")) {
			case 1:
				if (getgdskilllv(.@GID,10001) == 0) {
					mes "[ ޲zH ]";
					mes "DH,p٨Sd`qqp,ҥH٤නΥd¾,pQnd`qñq,Ƿ|u|ޯत ^FF0000Mdԭq^000000ޯa";
					close;
				}
				if (Zeny < 10000) {
					mes "[ ޲zH ]";
					mes "DH,ASiHΥd¾";
					close;
				}
				set zeny,zeny-10000;
				enablenpc "d ¾#aru03";
				SetCastleData "arug_cas03",9,1;
				mes "[ ޲zH ]";
				mes "\Md`qñqF,zΤF@d¾!";
				next;
				cutin "kafra_01",2;
				mes "[ d ¾ ]";
				mes "zn?ڬO`qӪd¾!ڱN|ܺɩүazA!";
				next;
				cutin "kafra_01",255;
				mes "[ ޲zH ]";
				mes "Ϊd¾N^FF00001 Ӥ몺ɶ^000000bA,ɶFᥲsñq";
				close;
			case 2:
				mes "[ ޲zH ]";
				mes "ڤwgӧAhJF,L]nFW|۷Q,鶱Υd¾W";
				close;
			}
		}
	case 5:
		mes "[ ޲zH ]";
		mes "nڭ̥Ͳ~yn,uQ~ж?";
		mes "ӦaOFڭ̪DH,MݩAa...";
		mes "FA~,䥦HӤJ";
		next;
		mes "[ ޲zH ]";
		mes "|~,qЯSO`N,";
		mes "ҥHFڭ̤|oi,ЮXɶӦ~";
		next;
		switch(select("niJDHж:")) {
		case 1:
			mes "[ ޲zH ]";
			mes "ڱNAAȨ쯦KqD,иڨ,";
			mes "^ӪɭԫUKsYi";
			close2;
			warp "arug_cas03",292,266;
			end;
		case 2:
			mes "[ ޲zH ]";
			mes "Ͳ~@ѥuͲ@...";
			mes "pSYɦ,U@NiӤF";
			mes "ҥHFڭ̤u|oi,ɶqIɶh";
			close;
		}
	}

Onstop:
	stopnpctimer;
	end;

OnStartArena:
	set .@GID,getcharid(2);
	// Lower castle Economy
	set .@Economy,GetCastleData("arug_cas03",2) - 5;
	if (.@Economy < 0) set .@Economy, 0;
	SetCastleData "arug_cas03", 2, .@Economy;
	// Lower Castle Defence
	set .@Defence,GetCastleData("arug_cas03",3) - 5;
	if (.@Defence < 0) set .@Defence, 0;
	SetCastleData "arug_cas03", 3, .@Defence;
	// Set new owner
	SetCastleData "arug_cas03",1, .@GID;
	// Clear castle's data.
	for( set .@i, 4; .@i <= 9; set .@i, .@i+1 )
		SetCastleData "arug_cas03", .@i, 0;
	// Disable Kafra
	disablenpc "d ¾#aru03";

	set .msg,2;
	if (.msg == 1) {
		announce "Ka [" + GetCastleName("arug_cas03") + "] 'N'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		donpcevent "Manager#aru03_02::Onstart";
	}
	else if (.msg == 2) {
		announce "Ka [" + GetCastleName("arug_cas03") + "] 'N'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		mapannounce "arug_cas03","RݤwQ}aF",bc_map,"0x00FF00";
		if (agitcheck2()) {
			donpcevent "Manager#aru03_02::Onreset";
			initnpctimer;
		}
		else {
			donpcevent "Manager#aru03_02::Onreset";
			stopnpctimer;
		}
	}
	else if (.msg == 0) {
		announce "Ka [" + GetCastleName("arug_cas03") + "] 'N'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		donpcevent "Manager#aru03_02::Onreset";
		stopnpctimer;
		end;
	}
	MapRespawnGuildID "arug_cas03",GetCastleData("arug_cas03",1),2;
	GetCastleData "arug_cas03",0,"::OnRecvCastleAr03";
	end;

OnTimer10000:
	donpcevent "Manager#aru03_02::Onchange";
	mapannounce "arug_cas03","bUӾIMmu״_I wnF",bc_map,"0x00FF00";
	end;
}

// Guild Kafra
arug_cas03,315,98,5	script	d ¾#aru03	117,{
	cutin "kafra_01",2;
	set .@GID, GetCastleData("arug_cas03",1);
	if (getcharid(2) == .@GID && getgdskilllv(.@GID,10001)) {
		mes "[d ¾]";
		mes "w{ ^FF0000" + GetGuildName(.@GID) + "^000000 |,";
		mes "dԪA";
		mes "ûbU쨭䬰zAȪ";
		next;
		switch(select("ϥέܮwA:ϥΪŶʪA:ϥΤA:")) {
		case 1:
			if (basicskillcheck() && getskilllv(1) < 6) {
				mes "[d ¾]";
				mes "藍_";
				mes "QnϥέܮwAȪ,Ǫ̪򥻧ޯ൥ŭnF6ťHW";
			}
			else {
				openstorage;
			}
			break;
		case 2:
			mes "[d ¾]";
			mes "лXتaa";
			next;
			switch(select("Ի  -> 200 z:")) {
			case 1:
				if (Zeny < 200) {
					mes "[d ¾]";
					mes "zB,";
					mes "ЦAT{";
					close2;
					cutin "kafra_01",255;
					end;
				}
				set zeny,zeny-200;
				warp "rachel",115,125;
				end;
			case 2:
				cutin "kafra_01",255;
			}
			break;
		case 3:
			if (BaseClass != Job_Merchant) {
				mes "[d ¾]";
				mes "ܩp,";
				mes "OӤHMKK,NvMΪA";
			}
			else if (checkcart() == 1) {
				mes "[d ¾]";
				mes "zwgLF";
			}
			else {
				mes "[d ¾]";
				mes "ϥζOάO 800 ";
				mes "znϥζ?";
				next;
				switch(select("ϥ:")) {
				case 1:
					if (Zeny < 800) {
						mes "[d ¾]";
						mes "zB,";
						mes "ϥζOάO 800 ";
						close2;
						cutin "kafra_01",255;
						end;
					}
					set zeny,zeny-800;
					setcart;
					break;
				case 2:
					break;
				}
			}
			break;
		case 4:
			mes "[d ¾]";
			mes "ڭ̥dԪAȷ|ѧ󧹬AȩMY檺~Ⱥ޲z,UUȦw߫KQϥά̤jؼ";
			mes "P§AϥΥdԪA";
			close2;
			cutin "kafra_01",255;
			end;
		}
		close2;
		cutin "kafra_01",255;
		end;
	}
	else {
		mes "[d ¾]";
		mes "ڤwñqM^FF0000" + GetGuildName(.@GID) + "^000000|A,ШϥΧڭ̨䥦a誺d¾,pKBqШ";
		close2;
		cutin "kafra_01",255;
		end;
	}

OnRecvCastleAr03:
	if (GetCastleData("arug_cas03",1) == 0) {
		monster "arug_cas03",0,0,"x",1117,10;
		monster "arug_cas03",0,0,"dQ",1132,4;
		monster "arug_cas03",0,0,"`WMh",1219,3;
		monster "arug_cas03",0,0,"D",1205,1;
		monster "arug_cas03",0,0,"Ǯ",1216,10;
		monster "arug_cas03",0,0,"",1193,18;
		monster "arug_cas03",0,0,"j]",1269,9;
		monster "arug_cas03",0,0,"F}b",1276,12;
		monster "arug_cas03",0,0,"eH",1208,3;
		monster "arug_cas03",0,0,"RRk",1275,1;
		monster "arug_cas03",0,0,"{Mh",1268,2;
		monster "arug_cas03",0,0,"·t",1272,2;
		monster "arug_cas03",0,0,"u@",1270,4;
	}
	if (GetCastleData("arug_cas03",9) < 1) {
		disablenpc "d ¾#aru03";
	}
	end;
}

arug_cas03,299,277,0	script	#aru03_switch	111,{
	mes " ";
	mes "ӬYؤp˸m,аݧAnާ@?";
	next;
	switch(select("ާ@:")) {
	case 1:
		warp "arug_cas03",321,57;
		end;
	case 2:
		close;
	}
}

aru_gld,60,174,0	script	N#flag_Ar03_1::Ar03_Flag	722,{
	set .@GID, GetCastleData("arug_cas03",1);
	if (.@GID == 0) {
		mes "[ cǨ а iO ]";
		mes "The Holy Kingdom of";
		mes "Arunafeltz declares that";
		mes "one has yet to claim lordship";
		mes "over this stronghold. The one";
		mes "that breaks the Emperium will";
		mes "be recognized as its new owner.";
		close;
	}
	else {
		if (getcharid(2) == .@GID) {
			mes "[ TGn ]";
			mes "i̭...";
			mes "An^A WAɨ?";
			next;
			switch(select("^쯵Ka:")) {
			case 1:
				set .@GID, GetCastleData("arug_cas03",1);
				if (getcharid(2) == .@GID) {
					warp "arug_cas03",121,318;
					end;
				}
				close;
			case 2:
				close;
			}
		}
		mes "[ cǨ а iO ]";
		mes " ";
		mes "1. ھڳo̪,cǨ аO";
		mes "o̳Q{w ^FF0000" + GetGuildName(.@GID) + "^000000|";
		mes "p";
		mes " ";
		mes "2. ^FF0000" + GetGuildName(.@GID) + "^000000 |DHO";
		mes "@@^FF0000" + GetGuildMaster(.@GID) + "^000000,L׬O";
		mes "@@oƱN";
		mes " ";
		mes "ЧA|_zC,ۤvWAa";
		close;
	}

OnRecvCastleAr03:
	FlagEmblem GetCastleData("arug_cas03",1);
	end;
}

aru_gld,74,174,0	duplicate(Ar03_Flag)	N#flag_Ar03_2	722,{