//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2012-2015  Hercules Dev Team
//= Copyright (C)  L0ne_W0lf
//= Copyright (C)  ultramage
//= Copyright (C)  KarLaeda
//= Copyright (C)  Avaj
//= Copyright (C)  Lupus
//= Copyright (C)  kobra_k88
//= Copyright (C)  Akaru
//= Copyright (C)  ho|yAnge|
//= Copyright (C)  kalen
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program.  If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= War of Emperium - WoE Auto-Start
//================= Description ===========================================
//= Auto Start for War of Emperium
//================= Current Version =======================================
//= 2.0a
//================= Additional Comments ===================================
//= To know how to set up WoE times, see doc/woe_time_explanation.txt
//=========================================================================

//== WoE Start/Stop times ==================================
-	script	Agit_Event	FAKE_NPC,{
	end;

OnClock2100:	//start time for Tues(2), Thurs(4)
OnClock2300:	//end time for Tues(2), Thurs(4)
OnClock1600:	//start time for Sat(6)
OnClock1800:	//end time for Sat(6)

OnAgitInit:
	// starting time checks
	if((gettime(GETTIME_WEEKDAY) == TUESDAY  && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
	   (gettime(GETTIME_WEEKDAY) == THURSDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
	   (gettime(GETTIME_WEEKDAY) == SATURDAY && gettime(GETTIME_HOUR) >= 16 && gettime(GETTIME_HOUR) < 18)) {
		if (!agitcheck()) {
			agitstart;
			callsub S_DisplayOwners;
		}
		end;
	}

	// end time checks
	if ((gettime(GETTIME_WEEKDAY) == 2 && gettime(GETTIME_HOUR) == 23) ||
	    (gettime(GETTIME_WEEKDAY) == 4 && gettime(GETTIME_HOUR) == 23) ||
	    (gettime(GETTIME_WEEKDAY) == 6 && gettime(GETTIME_HOUR) == 18)) {
		if (agitcheck()) {
			agitend;
			callsub S_DisplayOwners;
		}
		end;
	}
	end;

S_DisplayOwners:
	setarray .@maps$[0],"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05";
	setarray .@maps$[5],"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05";
	setarray .@maps$[10],"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05";
	setarray .@maps$[15],"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05";
	for (.@i = 0; .@i <= 19; ++.@i) {
		if (getcastledata(.@maps$[.@i],1))
			announce "The [" + getcastlename(.@maps$[.@i]) + "] castle has been conquered by the [" + getguildname(getcastledata(.@maps$[.@i],1)) + "] guild.",bc_all|bc_woe;
		else
			announce "The [" + getcastlename(.@maps$[.@i]) + "] castle is currently unoccupied.",bc_all|bc_woe;
	}
	end;
}
