//===== eAthena Script =======================================
//= War of Emperium - Payon Guild Wars Events
//===== By: ==================================================
//= jAthena (1.0)
//= 1.1 by Akaru and ho|yAnge|
//===== Current Version: =====================================
//= 1.5
//===== Compatible With: =====================================
//= eAthena 0.1+; RO Episode 4+
//===== Description: =========================================
//= Event Triggers of Payon Guild Wars
//===== Additional Comments: =================================
//= v1.2 Now using functions for OnAgitStart and OnAgitBreak. [kobra_k88]
//= 1.3 Added code for abandoning captured castles on /breakguild [Lupus]
//= 1.4 Small updated. Changed "EMPERIUM" to "Emperium". [L0ne_W0lf]
//= 1.5 Quick fix "emps not respawning if the emp breaker logs off".
//=     (from r11630 bureport:369) [FlavioJS]
//============================================================


// Castle 1 ================================================================
payg_cas01,139,139,0	script	Agit_Py01	-1,{
OnInterIfInitOnce:
	GetCastleData "payg_cas01",0,"::OnRecvCastlePy01";
	end;
OnRecvCastlePy01:
	RequestGuildInfo GetCastleData("payg_cas01",1);
	end;
OnAgitStart:
	callfunc "F_AgitStart","payg_cas01","Py01",139,139;
	end;
OnAgitBreak:
	callfunc "F_AgitBreak","payg_cas01","Py01";
	goto OnAgitEliminate;
OnGuildBreak:
	callfunc "F_GuildBreak","payg_cas01","Py01";
	end;
OnAgitEliminate:
	sleep getbattleflag("gvg_eliminate_time");
	MapRespawnGuildID "payg_cas01",GetCastleData("payg_cas01",1),6;
	sleep 6333-getbattleflag("gvg_eliminate_time");// wait for emp animation to end
	Monster "payg_cas01",139,139,"Emperium",1288,1,"Agit_Py01::OnAgitBreak";
	end;
OnAgitEnd:
	callfunc "F_AgitEnd","payg_cas01","Py01";
	end;
}

// Castle 2 ================================================================
payg_cas02,39,25,0	script	Agit_Py02	-1,{
OnInterIfInitOnce:
	GetCastleData "payg_cas02",0,"::OnRecvCastlePy02";
	end;
OnRecvCastlePy02:
	RequestGuildInfo GetCastleData("payg_cas02",1);
	end;
OnAgitStart:
	callfunc "F_AgitStart","payg_cas02","Py02",39,25;
	end;
OnAgitBreak:
	callfunc "F_AgitBreak","payg_cas02","Py02";
	goto OnAgitEliminate;
OnGuildBreak:
	callfunc "F_GuildBreak","payg_cas02","Py02";
	end;
OnAgitEliminate:
	sleep getbattleflag("gvg_eliminate_time");
	MapRespawnGuildID "payg_cas02",GetCastleData("payg_cas02",1),6;
	sleep 6333-getbattleflag("gvg_eliminate_time");// wait for emp animation to end
	Monster "payg_cas02",39,25,"Emperium",1288,1,"Agit_Py02::OnAgitBreak";
	end;
OnAgitEnd:
	callfunc "F_AgitEnd","payg_cas02","Py02";
	end;
}

// Castle 3 ================================================================
payg_cas03,269,265,0	script	Agit_Py03	-1,{
OnInterIfInitOnce:
	GetCastleData "payg_cas03",0,"::OnRecvCastlePy03";
	end;
OnRecvCastlePy03:
	RequestGuildInfo GetCastleData("payg_cas03",1);
	end;
OnAgitStart:
	callfunc "F_AgitStart","payg_cas03","Py03",269,265;
	end;
OnAgitBreak:
	callfunc "F_AgitBreak","payg_cas03","Py03";
	goto OnAgitEliminate;
OnGuildBreak:
	callfunc "F_GuildBreak","payg_cas03","Py03";
	end;
OnAgitEliminate:
	sleep getbattleflag("gvg_eliminate_time");
	MapRespawnGuildID "payg_cas03",GetCastleData("payg_cas03",1),6;
	sleep 6333-getbattleflag("gvg_eliminate_time");// wait for emp animation to end
	Monster "payg_cas03",269,265,"Emperium",1288,1,"Agit_Py03::OnAgitBreak";
	end;
OnAgitEnd:
	callfunc "F_AgitEnd","payg_cas03","Py03";
	end;
}

// Castle 4 ================================================================
payg_cas04,271,29,0	script	Agit_Py04	-1,{
OnInterIfInitOnce:
	GetCastleData "payg_cas04",0,"::OnRecvCastlePy04";
	end;
OnRecvCastlePy04:
	RequestGuildInfo GetCastleData("payg_cas04",1);
	end;
OnAgitStart:
	callfunc "F_AgitStart","payg_cas04","Py04",271,29;
	end;
OnAgitBreak:
	callfunc "F_AgitBreak","payg_cas04","Py04";
	goto OnAgitEliminate;
OnGuildBreak:
	callfunc "F_GuildBreak","payg_cas04","Py04";
	end;
OnAgitEliminate:
	sleep getbattleflag("gvg_eliminate_time");
	MapRespawnGuildID "payg_cas04",GetCastleData("payg_cas04",1),6;
	sleep 6333-getbattleflag("gvg_eliminate_time");// wait for emp animation to end
	Monster "payg_cas04",271,29,"Emperium",1288,1,"Agit_Py04::OnAgitBreak";
	end;
OnAgitEnd:
	callfunc "F_AgitEnd","payg_cas04","Py04";
	end;
}

// Castle 5 ================================================================
payg_cas05,30,30,0	script	Agit_Py05	-1,{
OnInterIfInitOnce:
	GetCastleData "payg_cas05",0,"::OnRecvCastlePy05";
	end;
OnRecvCastlePy05:
	RequestGuildInfo GetCastleData("payg_cas05",1);
	end;
OnAgitStart:
	callfunc "F_AgitStart","payg_cas05","Py05",30,30;
	end;
OnAgitBreak:
	callfunc "F_AgitBreak","payg_cas05","Py05";
	goto OnAgitEliminate;
OnGuildBreak:
	callfunc "F_GuildBreak","payg_cas05","Py05";
	end;
OnAgitEliminate:
	sleep getbattleflag("gvg_eliminate_time");
	MapRespawnGuildID "payg_cas05",GetCastleData("payg_cas05",1),6;
	sleep 6333-getbattleflag("gvg_eliminate_time");// wait for emp animation to end
	Monster "payg_cas05",30,30,"Emperium",1288,1,"Agit_Py05::OnAgitBreak";
	end;
OnAgitEnd:
	callfunc "F_AgitEnd","payg_cas05","Py05";
	end;
}
