/**
 * Hercules Script
 *
 * Feature: Hercules Battlegrounds
 * Version: 1.0
 * Author: eAmod & Smokexyz
 *
 * Description: Hercules Battlegrounds plugin.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

-	script	Flavius_SC	FAKE_NPC,{
	end;

OnGuillaumeQuit:
OnCroixQuit:
	setquest 8506; // Deserter
	set @killer_bg_src,0;
	if ($@Arena_Status != 0 && getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") == "Flavius_SC")
		donpcevent "BG_Queue_Handler::OnQueueJoinEvent";
OnGuillaumeDie:
OnCroixDie:
	if ($@Arena_Status == 1 && getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") == "Flavius_SC" && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Stone Carrier
		set .Stone[.@Stone],0;
		getmapxy .@m$, .@x, .@y, 0;
		movenpc "Neutral Stone#" + .@Stone, .@x, .@y;
		mapannounce "bat_b04","Neutral Stone Dropped by [ " + strcharinfo(0) + " ]",1,0xFFFFFF;
		initnpctimer "Neutral Stone#" + .@Stone;
		deltimer "Flavius_SC::OnFlash";
		enablenpc "Neutral Stone#" + .@Stone;
	}
	end;

OnBuildTeams:
	set $@BG_Team1,hBG_team_create("bat_b04",390,10,0,"Flavius_SC::OnGuillaumeQuit","Flavius_SC::OnGuillaumeDie");
	set $@BG_Team2,hBG_team_create("bat_b04",10,290,1,"Flavius_SC::OnCroixQuit","Flavius_SC::OnCroixDie");
	end;

OnReady:
	if (getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC")
		end;

	initnpctimer;
	set .guillaume_score, 0;
	set .croix_score, 0;
	setarray .Stone[1],0,0,0,0,0,0;
	setarray .x[1],177,222,222,177,200,199;
	setarray .y[1],182,182,117,117,105,194;
	for( set .@i, 1; .@i < 7; set .@i, .@i + 1)
		donpcevent "Neutral Stone#" + .@i + "::OnBGStart";

	hBG_updatescore "bat_b04",.guillaume_score,.croix_score;
	sleep 2000;
	bg_warp $@BG_Team1,"bat_b04",328,150;
	bg_warp $@BG_Team2,"bat_b04",62,150;
	sleep 2000;
	donpcevent "#guisc_respawn::OnBGStart";
	donpcevent "#crosc_respawn::OnBGStart";
	end;

OnGuillaumeScore:
	set .guillaume_score, .guillaume_score + 1;
	donpcevent "Flavius_SC::OnValidateScore";
	end;

OnCroixScore:
	set .croix_score, .croix_score + 1;
	donpcevent "Flavius_SC::OnValidateScore";
	end;

OnValidateScore:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC")
		end;
	if (.guillaume_score > 99)
		set .guillaume_score,99;
	if (.croix_score > 99)
		set .croix_score,99;

	hBG_updatescore "bat_b04",.guillaume_score,.croix_score;
	if (.croix_score >= 99 || .guillaume_score >= 99)
		donpcevent "Flavius_SC::OnMatchEnd";
	end;

OnTimer600000:
	mapannounce "bat_b04","The Battle will end in 5 minutes!!",1,0x9ACD32;
	end;

OnTimer840000:
	mapannounce "bat_b04","The Battle will end in 1 minute!!",1,0x9ACD32;
	end;

OnTimer900000:
OnMatchEnd:
	stopnpctimer;
	donpcevent "#guisc_respawn::OnBGStop";
	donpcevent "#crosc_respawn::OnBGStop";
	set $@Arena_Status, 2;
	// =======================================================
	// Team Rewards
	// =======================================================
	if (.guillaume_score > .croix_score) { // Guillaume Won
		hBG_reward $@BG_Team1,7773,30,0,0,"BG_SC",1,5,0;
		hBG_reward $@BG_Team2,7773,15,0,0,"BG_SC",1,5,2;
		mapannounce "bat_b04","The Guillaume army has won the Battle of Flavius Stone Control!",1,0x0000FF;
	} else if (.guillaume_score < .croix_score) { // Croix Won
		hBG_reward $@BG_Team1,7773,15,0,0,"BG_SC",1,5,2;
		hBG_reward $@BG_Team2,7773,30,0,0,"BG_SC",1,5,0;
		mapannounce "bat_b04","The Croix army has won the Battle of Flavius Stone Control!",1,0xFF0000;
	} else {
		hBG_reward $@BG_Team1,7773,15,0,0,"BG_SC",1,5,1;
		hBG_reward $@BG_Team2,7773,15,0,0,"BG_SC",1,5,1;
		mapannounce "bat_b04","The battle is over. This is a Tie...!",1,0x9ACD32;
	}
	// =======================================================
	set .guillaume_score, 0;
	set .croix_score, 0;
	for( set .@i, 1; .@i < 7; set .@i, .@i + 1) { // Stop Running Timers
		stopnpctimer "Neutral Stone#" + .@i;
		stopnpctimer "csp" + .@i; // Croix Stone Point
		stopnpctimer "gsp" + .@i; // Guillaume Stone Point
	}
	sleep 5000;
	setarray .Stone[1],0,0,0,0,0,0;
	donpcevent "BG_Queue_Handler::OnEndArena";
	hBG_updatescore "bat_b04",0,0;
	for( set .@i, 1; .@i < 7; set .@i, .@i + 1) { // Return Stones to Starting Position and Normalize Stone Points
		donpcevent "Neutral Stone#" + .@i + "::OnBGStop";
		donpcevent "csp" + .@i + "::OnBGStop";
		donpcevent "gsp" + .@i + "::OnBGStop";
	}
	end;

OnFlash:
	if ($@Arena_Status == 1 && getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") == "Flavius_SC" && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) {
		getmapxy .@m$, .@x, .@y, 0;
		if (getcharid(4) == $@BG_Team1)
			hBG_viewpointmap "bat_b04",1, .@x, .@y, .@Stone, 0x0000FF;
		else if (getcharid(4) == $@BG_Team2)
			hBG_viewpointmap "bat_b04",1, .@x, .@y, .@Stone, 0xFF0000;
		specialeffect(EF_BOWLINGBASH);
		emotion e_hlp,1;
		addtimer 2000, "Flavius_SC::OnFlash";
		percentheal -5,-5;
	}
	end;
}

// Basic Functions
// *********************************************************************

function	script	SC_StoneCheck	{
	for( set .@i, 1; .@i < 7; set .@i, .@i + 1) {
		if (getvariableofnpc(.Stone[.@i],"Flavius_SC") == getarg(0))
			return .@i;
	}
	return 0;
}

// Neutral Stones
// *********************************************************************

bat_b04,177,182,0	script	Neutral Stone#1	BARRICADE,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1 || getcharid(4) == 0)
		end;
	set .@Stone,atoi(strnpcinfo(2));
	if (getvariableofnpc(.Stone[.@Stone],"Flavius_SC") != 0)
		end; // Already Captured
	if (callfunc("SC_StoneCheck",getcharid(0)) != 0)
		end; // Already with a Stone

	sc_end SC_HIDING;
	sc_end SC_CLOAKING;
	sc_end SC_CHASEWALK;
	sc_end SC_CLOAKINGEXCEED;
	sc_end SC_CAMOUFLAGE;
	sc_end SC__INVISIBILITY;

	disable_items;

	set getvariableofnpc(.Stone[.@Stone],"Flavius_SC"),getcharid(0);
	addtimer 2000, "Flavius_SC::OnFlash";
	disablenpc strnpcinfo(0);
	stopnpctimer;
	end;

OnBGStart:
	initnpctimer;
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, atoi(strnpcinfo(2)), 0xFFFFFF;
	end;

OnBGStop:
	set .@Stone,atoi(strnpcinfo(2));
	movenpc strnpcinfo(0),getvariableofnpc(.x[.@Stone],"Flavius_SC"),getvariableofnpc(.y[.@Stone],"Flavius_SC");
	enablenpc strnpcinfo(0);
	stopnpctimer;
	end;
}

bat_b04,222,182,0	duplicate(Neutral Stone#1)	Neutral Stone#2	BARRICADE,1,1
bat_b04,222,117,0	duplicate(Neutral Stone#1)	Neutral Stone#3	BARRICADE,1,1
bat_b04,177,117,0	duplicate(Neutral Stone#1)	Neutral Stone#4	BARRICADE,1,1
bat_b04,200,105,0	duplicate(Neutral Stone#1)	Neutral Stone#5	BARRICADE,1,1
bat_b04,199,194,0	duplicate(Neutral Stone#1)	Neutral Stone#6	BARRICADE,1,1

// Stone Point - Croix Team
// *********************************************************************

bat_b04,85,159,0	script	Stone Point::csp1	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,78,159,0	script	Stone Point::csp2	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,71,159,0	script	Stone Point::csp3	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,85,140,0	script	Stone Point::csp4	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,78,140,0	script	Stone Point::csp5	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,71,140,0	script	Stone Point::csp6	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team1 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Guillaume Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Croix Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team2 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Croix Stone captured by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		setnpcdisplay strnpcinfo(3),"Croix Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0xFF0000;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnCroixScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

// Stone Point - Guillaume Team
// *********************************************************************

bat_b04,312,159,0	script	Stone Point::gsp1	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,319,159,0	script	Stone Point::gsp2	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,326,159,0	script	Stone Point::gsp3	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,312,140,0	script	Stone Point::gsp4	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,319,140,0	script	Stone Point::gsp5	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

bat_b04,326,140,0	script	Stone Point::gsp6	GAJOMART,1,1,{
	end;

OnTouch:
	if ($@Arena_Status != 1 || getvariableofnpc(.BG_Arena$,"BG_Queue_Handler") != "Flavius_SC" || Hp < 1)
		end;
	if (.point != 0 && getcharid(4) == $@BG_Team2 && callfunc("SC_StoneCheck",getcharid(0)) == 0) { // Croix Stole
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),getcharid(0);
		setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;

		sc_end SC_HIDING;
		sc_end SC_CLOAKING;
		sc_end SC_CHASEWALK;
		sc_end SC_CLOAKINGEXCEED;
		sc_end SC_CAMOUFLAGE;
		sc_end SC__INVISIBILITY;

		disable_items;

		mapannounce "bat_b04","Guillaume Stone has been stolen by [ " + strcharinfo(0) + " ]",1,0xFF0000;

		addtimer 2000, "Flavius_SC::OnFlash";
		set .point,0;
		stopnpctimer;
	} else if (.point == 0 && getcharid(4) == $@BG_Team1 && set(.@Stone,callfunc("SC_StoneCheck",getcharid(0))) > 0) { // Check if user got a Stone
		initnpctimer;
		set .point,.@Stone;
		set .Count, 0;
		deltimer "Flavius_SC::OnFlash";

		enable_items;

		mapannounce "bat_b04","Guillaume Stone captured by [ " + strcharinfo(0) + " ]",1,0x0000FF;

		setnpcdisplay strnpcinfo(3),"Guillaume Stone",BARRICADE;
		set getvariableofnpc(.Stone[.point],"Flavius_SC"),0;
	}
	end;

OnTimer2000:
	initnpctimer;
	getmapxy .@m$, .@x, .@y, 1;
	hBG_viewpointmap "bat_b04",1, .@x, .@y, .point, 0x0000FF;
	specialeffect 223;
	if (set(.Count, .Count + 1) >= 5) {
		set .Count, 0;
		donpcevent "Flavius_SC::OnGuillaumeScore";
	}
	end;

OnBGStop:
	stopnpctimer;
	setnpcdisplay strnpcinfo(3),"Stone Point",GAJOMART;
	set .point, 0;
	set .Count, 0;
	end;
}

// Battleground Respawn
// *********************************************************************

bat_b04,390,10,0	script	#guisc_respawn	HIDDEN_WARP_NPC,{
	end;

OnBGStart:
	initnpctimer;
	end;

OnBGStop:
	stopnpctimer;
	end;

OnTimer24000:
	specialeffect(EF_SANCTUARY);
	end;

OnTimer25000:
	areapercentheal "bat_b04",382,2,397,17,100,100;
	areawarp "bat_b04",382,2,397,17,"bat_b04",311,224;
	initnpctimer;
	end;
}

bat_b04,10,290,0	script	#crosc_respawn	HIDDEN_WARP_NPC,{
	end;

OnBGStart:
	initnpctimer;
	end;

OnBGStop:
	stopnpctimer;
	end;

OnTimer24000:
	specialeffect(EF_SANCTUARY);
	end;

OnTimer25000:
	areapercentheal "bat_b04",2,282,17,297,100,100;
	areawarp "bat_b04",2,282,17,297,"bat_b04",87,75;
	initnpctimer;
	end;
}

// Flags
// *********************************************************************

bat_b04,304,231,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_1	1_FLAG_LION
bat_b04,319,231,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_2	1_FLAG_LION
bat_b04,304,218,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_3	1_FLAG_LION
bat_b04,319,218,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_4	1_FLAG_LION
bat_b04,304,231,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_5	1_FLAG_LION
bat_b04,304,231,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_6	1_FLAG_LION
bat_b04,335,142,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_7	1_FLAG_LION
bat_b04,335,157,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_8	1_FLAG_LION
bat_b04,390,16,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_9	1_FLAG_LION
bat_b04,292,163,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_10	1_FLAG_LION
bat_b04,292,136,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_11	1_FLAG_LION
bat_b04,241,185,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_12	1_FLAG_LION
bat_b04,247,179,1	duplicate(Guillaume camp#bat)	Guillaume camp#sc_13	1_FLAG_LION

bat_b04,96,81,1	duplicate(Croix camp#bat)	Croix camp#sc_1	1_FLAG_EAGLE
bat_b04,96,68,1	duplicate(Croix camp#bat)	Croix camp#sc_2	1_FLAG_EAGLE
bat_b04,79,81,1	duplicate(Croix camp#bat)	Croix camp#sc_3	1_FLAG_EAGLE
bat_b04,79,68,1	duplicate(Croix camp#bat)	Croix camp#sc_4	1_FLAG_EAGLE
bat_b04,96,81,1	duplicate(Croix camp#bat)	Croix camp#sc_5	1_FLAG_EAGLE
bat_b04,96,81,1	duplicate(Croix camp#bat)	Croix camp#sc_6	1_FLAG_EAGLE
bat_b04,59,164,1	duplicate(Croix camp#bat)	Croix camp#sc_7	1_FLAG_EAGLE
bat_b04,59,137,1	duplicate(Croix camp#bat)	Croix camp#sc_8	1_FLAG_EAGLE
bat_b04,10,296,1	duplicate(Croix camp#bat)	Croix camp#sc_9	1_FLAG_EAGLE
bat_b04,110,162,1	duplicate(Croix camp#bat)	Croix camp#sc_10	1_FLAG_EAGLE
bat_b04,110,137,1	duplicate(Croix camp#bat)	Croix camp#sc_11	1_FLAG_EAGLE
bat_b04,152,120,1	duplicate(Croix camp#bat)	Croix camp#sc_12	1_FLAG_EAGLE
bat_b04,158,114,1	duplicate(Croix camp#bat)	Croix camp#sc_13	1_FLAG_EAGLE

// MapFlags
// *********************************************************************

bat_b04	mapflag	battleground	2
bat_b04	mapflag	nomemo
bat_b04	mapflag	nosave	SavePoint
bat_b04	mapflag	noteleport
bat_b04	mapflag	nowarp
bat_b04	mapflag	nowarpto
bat_b04	mapflag	noreturn
bat_b04	mapflag	nobranch
bat_b04	mapflag	nopenalty
//bat_b04	mapflag	noemergencycall