//===================================================================
//Ragnarok Online EP2.5 GVG Script	ev_agit_common      by kalen
//ÿ趨 by Deme
//  : FPE
// Jathena++ ̳http://www.foxofice.net/bbs
//===================================================================

//=========================================================================
// սĿʼʱ
//	const.txtȡ趨ʱ
//	GvGWeekDay, GvGTimeST, GvGTimeST, GvGTime*ST, GvGTime*ED
//
// MAP60֮жǷʼ
//-------------------------------------------------------------------------

-	script	#AgitConfig	-1,{
	end;
OnInit:
	if(GvGWeekDay == 0)
		end;
	//пսôӦλԪΪ1
	for(set '@i,0; '@i<7; set '@i,'@i+1) {
		set '@mask,1<<'@i;
		set 'open['@i],(GvGWeekDay & '@mask)? 1: 0;
	}
	//趨ÿܹսʼʱ
	if(GvGTimeST == GvGTimeED) {
		setarray 'dbt,GvGTime0ST,GvGTime1ST,GvGTime2ST,GvGTime3ST,GvGTime4ST,GvGTime5ST,GvGTime6ST;
		setarray 'fin,GvGTime0ED,GvGTime1ED,GvGTime2ED,GvGTime3ED,GvGTime4ED,GvGTime5ED,GvGTime6ED;
	}
	//ÿ춼ͬʱ
	else {
		cleararray 'dbt,GvGTimeST,7;
		cleararray 'fin,GvGTimeED,7;
	}
	set 'flag,1;
	initnpctimer;
	end;

OnTimer60000:
	//60ж
	if('flag) {
		set '@day,gettime(4);
		set '@min,gettime(3)*100+gettime(2);
		//ǰʱΪսʱ
		if('open['@day] && '@min>='dbt['@day] && '@min<'fin['@day]) {
			announce "ս¿ʼ",8;
			debugmes "ս¿ʼ [ " +gettimestr("%H:%M",6)+ " ]";
			agitstart;
		}
		set 'flag,0;
		setnpctimer gettime(1)*1000;	//ʱΪ0ʱ
		end;
	}
	if(gettime(1) > 0)	//1Ͻʱ
		setnpctimer gettime(1)*1000;
	else
		initnpctimer;
	//24ʱ⴦
	set '@day,gettime(4);
	set '@min,gettime(3)*100+gettime(2);
	if('@min == 0) {
		set '@prev,('@day>0)? '@day-1: 6;
		if('open['@prev] && 'fin['@prev]==2400) {
			if('open['@day]==0 || 'dbt['@day]>0) {
				announce "ս",8;
				debugmes "ս [ " +gettimestr("%H:%M",6)+ " ]";
				agitend;
			}
			end;
		}
	}
	if('open['@day]==0)
		end;
	if('@min == 'dbt['@day]) {
		announce "սʼ",8;
		debugmes "սʼ [ " +gettimestr("%H:%M",6)+ " ]";
		agitstart;
	}
	else if('@min == 'fin['@day]) {
		announce "ս",8;
		debugmes "ս [ " +gettimestr("%H:%M",6)+ " ]";
		agitend;
	}
	end;
}


//-----GMרõĵԳ-----
//===========================================================
//prontera.gat,152,208,0	script	GvG̨	111,{
//	if(getgmlevel()==0)
//		end;
//	mes "[GvG-Control^ff0000(GMר)^000000]";
//	mes "սģʽ趨";
//	next;
//	switch (select("ʼ","ֹͣ","","ȡ")) {
//	case 1:
//		announce "սʼ",0;
//		agitstart;
//		break;
//	case 2:
//		announce "ս",0;
//		agitend;
//		break;
//	case 3:
//		setarray '@chr$,"","һ","","","","","";
//		for(set '@i,0; '@i<7; set '@i,'@i+1)
//			mes '@chr$['@i]+ "  " +(getelementofarray( getvariableofnpc('open,"#AgitConfig"),'@i ))? "": "";
//		next;
//		if(GvGTimeST != GvGTimeED) {
//			mes "ÿʱ䡡" +GvGTimeST+ "  " +GvGTimeED;
//			break;
//		}
//		for(set '@i,0; '@i<7; set '@i,'@i+1) {
//			mes '@chr$['@i]+ "  " +getelementofarray( getvariableofnpc('dbt,"#AgitConfig"),'@i )+
//						"  " +getelementofarray( getvariableofnpc('fin,"#AgitConfig"),'@i );
//		}
//		break;
//	}
//	close;
//}
//===========================================================

//--------------------------------------------------------------------
prontera.gat,159,208,0	script	ᱦ̨	111,{
	if ( !(getgmlevel()) ) close;
	mes "[TBOX Control^ff0000(GMר)^000000]";
	mes "Ҫˢᱦ";
	next;
	if ( select("","") == 2 ) close;
	callsub Ltbox;
	mes "[TBOX Control^ff0000(GMר)^000000]";
	mes "Ѿˢᱦˡ";
	close;
OnClock0000:
	callsub Ltbox;
	end;
Ltbox:
	callfunc "make_t_box","aldeg_cas01.gat",114,218,123,227,1324,1325;
	callfunc "make_t_box","aldeg_cas02.gat",130,226,139,235,1326,1327;
	callfunc "make_t_box","aldeg_cas03.gat",220,264,229,273,1328,1329;
	callfunc "make_t_box","aldeg_cas04.gat",80,8,89,17,1330,1331;
	callfunc "make_t_box","aldeg_cas05.gat",58,8,67,17,1332,1333;
	callfunc "make_t_box","gefg_cas01.gat",150,108,157,115,1334,1335;
	callfunc "make_t_box","gefg_cas02.gat",136,112,145,118,1336,1337;
	callfunc "make_t_box","gefg_cas03.gat",266,286,273,293,1338,1339;
	callfunc "make_t_box","gefg_cas04.gat",112,114,119,123,1340,1341;
	callfunc "make_t_box","gefg_cas05.gat",140,106,147,113,1342,1343;
	callfunc "make_t_box","payg_cas01.gat",286,4,295,7,1344,1345;
	callfunc "make_t_box","payg_cas02.gat",140,140,149,143,1346,1347;
	callfunc "make_t_box","payg_cas03.gat",154,164,162,172,1348,1349;
	callfunc "make_t_box","payg_cas04.gat",142,44,151,51,1350,1351;
	callfunc "make_t_box","payg_cas05.gat",152,128,161,131,1352,1353;
	callfunc "make_t_box","prtg_cas01.gat",7,205,15,212,1354,1355;
	callfunc "make_t_box","prtg_cas02.gat",198,224,205,231,1356,1357;
	callfunc "make_t_box","prtg_cas03.gat",184,128,192,135,1358,1359;
	callfunc "make_t_box","prtg_cas04.gat",266,158,273,165,1360,1361;
	callfunc "make_t_box","prtg_cas05.gat",272,174,279,181,1362,1363;
	return;
}

//====================================================================
//Function
//====================================================================
//---------------------------------------------------------------
//ܻݲ
//callfunc "resetcastledata",MAP,"::OnRecvCastleYYY","kapra_XXXgYY",@GIDXX,"::OnGDEMPSetYYY";
function	script	resetcastledata	{
	killmonsterall getarg(0);
	disablenpc getarg(2);
	setcastledata getarg(0),1,0;
	setcastledata getarg(0),2,1;
	setcastledata getarg(0),3,1;
	setcastledata getarg(0),4,0;
	setcastledata getarg(0),5,0;
	setcastledata getarg(0),6,0;
	setcastledata getarg(0),7,0;
	setcastledata getarg(0),8,0;
	setcastledata getarg(0),9,0;
	setcastledata getarg(0),10,0;
	setcastledata getarg(0),11,0;
	setcastledata getarg(0),12,0;
	setcastledata getarg(0),13,0;
	setcastledata getarg(0),14,0;
	setcastledata getarg(0),15,0;
	setcastledata getarg(0),16,0;
	setcastledata getarg(0),17,0;
	getcastledata getarg(0),0,getarg(1);
	announce "ܻ [" + getcastlename(getarg(0)) + "]  [" + getguildname(getarg(3)) + "] óˡ",0;
	maprespawnguildid getarg(0),getcastledata(getarg(0),1),7;
	if (agitcheck(0)) donpcevent getarg(4);
	end;
	return;
}
//---------------------------------------------------------------
//ƻܻݸ
//callfunc "resetcastledata2","MAP","::OnRecvCastleYYY";
function	script	resetcastledata2	{
	killmonsterall getarg(0);
	set @WinGuildID,getcharid(2);
	if (@WinGuildID <= 0) end;
	setcastledata getarg(0),1,@WinGuildID;
	set @Economy,getcastledata(getarg(0),2)-5;
	if (@Economy<1) set @Economy,1;
	setcastledata getarg(0),2,@Economy;
	set @Deffence,getcastledata(getarg(0),3)-5;
	if (@Deffence<1) set @Deffence,1;
	setcastledata getarg(0),3,@Deffence;
	setcastledata getarg(0),4,0;
	setcastledata getarg(0),5,0;
	setcastledata getarg(0),6,0;
	setcastledata getarg(0),7,0;
	setcastledata getarg(0),8,0;
	setcastledata getarg(0),9,0;
	setcastledata getarg(0),10,0;
	setcastledata getarg(0),11,0;
	setcastledata getarg(0),12,0;
	setcastledata getarg(0),13,0;
	setcastledata getarg(0),14,0;
	setcastledata getarg(0),15,0;
	setcastledata getarg(0),16,0;
	setcastledata getarg(0),17,0;
	announce "ܻ [" + getcastlename(getarg(0)) + "]  [" + getguildname(@WinGuildID) + "] ռˡ",0;
	mapannounce getarg(0),"ƻ",17;
	getcastledata getarg(0),0,getarg(1);
	return;
}
//---------------------------------------------------------------
//ɢʱܻݸ
//callfunc "resetcastledata3","MAP","::OnRecvCastleYYY","::OnGDEMPSetYYY";
function	script	resetcastledata3	{
	killmonsterall getarg(0);
	setcastledata getarg(0),1,0;
	setcastledata getarg(0),2,1;
	setcastledata getarg(0),3,1;
	setcastledata getarg(0),4,0;
	setcastledata getarg(0),5,0;
	setcastledata getarg(0),6,0;
	setcastledata getarg(0),7,0;
	setcastledata getarg(0),8,0;
	setcastledata getarg(0),9,0;
	setcastledata getarg(0),10,0;
	setcastledata getarg(0),11,0;
	setcastledata getarg(0),12,0;
	setcastledata getarg(0),13,0;
	setcastledata getarg(0),14,0;
	setcastledata getarg(0),15,0;
	setcastledata getarg(0),16,0;
	setcastledata getarg(0),17,0;
	getcastledata getarg(0),0,getarg(1);
	maprespawnguildid getarg(0),getcastledata(getarg(0),1),7;
	if (agitcheck(0)) donpcevent getarg(2);
	end;
	return;
}
//---------------------------------------------------------------
//ᱦˢ´
//callfunc "make_t_box","MAP",x0,y0,x1,y1,MobID1,MobID2;
function	script	make_t_box	{
	setcastledata getarg(0),2,getcastledata(getarg(0),2)+getcastledata(getarg(0),4);
	setcastledata getarg(0),3,getcastledata(getarg(0),3)+getcastledata(getarg(0),5);
	setcastledata getarg(0),4,0;//ͶҵȵĴ
	setcastledata getarg(0),5,0;//ͶʷȵĴ
	killmonster getarg(0),"TresureBox";
	set $@boxnum1,2+(getcastledata(getarg(0),2)+5)/10;
	set $@boxnum2,2+getcastledata(getarg(0),2)/10;
	if ($@boxnum1 > 12)	set $@boxnum1,12;
	if ($@boxnum2 > 12)	set $@boxnum2,12;
	areamonster getarg(0),getarg(1),getarg(2),getarg(3),getarg(4),"",getarg(5),$@boxnum1,"TresureBox";
	areamonster getarg(0),getarg(1),getarg(2),getarg(3),getarg(4),"",getarg(6),$@boxnum2,"TresureBox";
	return;
}
//---------------------------------------------------------------
//սʼ
//callfunc "agitstarting","MAP","OnGDEMPSetYYY";
function	script	agitstarting	{
	maprespawnguildid getarg(0),getcastledata(getarg(0),1),2;
	donpcevent getarg(1);
	GvgOn getarg(0);
	return;
}
//---------------------------------------------------------------
//
//callfunc "flagsc","MAP",AreaFlag,ReturnFlag,X,Y;
//*AreaFlag 1=Aldebaran,2=Other
//*ReturnFlag 1=Allow,2=Deny
function	script	flagsc	{
	set @GID,getcastledata(getarg(0),1);
	if (@GID != 0) goto LStartg;
		mes "[ ¡   ]";
		mes " ";
		mes "1.";
		switch ( getarg(1) ) {
		case 1:	mes "¡";
			mes "޷ȹ͹Э";
			break;
		case 2:	mes "¡";
			mes "¡";
		}
		mes "﹫ΪûʽȨ";
		next;
		mes " ";
		mes "2.";
		mes "սʤĿµĿ֮";
		mes "ƻ";
		mes "辭֤ܻȨ";
		close;
LStartg:
		if ((getcharid(2) == @GID) && (getarg(2) == 1)) goto LStartg2;
		mes "[ ¡   ]";
		mes " ";
		mes "1.";
		switch ( getarg(1) ) {
		case 1:	mes "¡";
			mes "޷ȹ͹Э";
			break;
		case 2:	mes "¡";
			mes "¡";
		}
		mes "ﱻ϶Ϊ ^ff0000 " + getguildname(@GID) + " ^000000 ˽";
		next;
		mes " ";
		mes "2.";
		mes "^ff0000 " + getguildname(@GID) + " ^000000 ";
		mes "^ff0000 " + getguildmaster(@GID) + " ^000000 ";
		mes "˭ߣ";
		mes "ĽԼɡ";
Lclose:
		close;
LStartg2:
		mes "[  ]";
		mes "ʿ";
		mes "Ҫص֮";
		next;
		menu "صܻ",-,"ȡ",Lclose;
			warp getarg(0),getarg(3),getarg(4);end;
		return;
}
//==============================================================================
//-------------------------------------------------------
//˲˵
//callfunc "Steward_menu0","MAP","NAME";
function	script	Steward_menu0	{
	set @GID,getcastledata(getarg(0),1);
	if (@GID == 0) goto LStart;
	if (getcharid(2) != @GID) goto LStart2;
	if (getcharid(0) == getguildmasterid(@GID)) goto LStart3;
	goto LStart2;
LStart:
	mes "["+getarg(1)+"]";
	mes "ҽҵ";
	mes "ڵȴҵˡ";
	mes "ʿ";
	mes "һ˰ɡ";
	close;
LStart2:
	mes "["+getarg(1)+"]";
	mes "ôв";
	mes "ֻԸ׷ҵ^ff0000" + getguildmaster(@GID);
	mes "^000000໤ѽ";
	mes "Ͽļһ߰ɣ";
	close;
LStart3:
	mes "["+getarg(1)+"]";
	mes "ӭ٣ҵ ^ff0000"+getguildmaster(@GID)+"^000000 /С㡣";
	mes "뾡ܷԸҽҳϵΪ";
	next;
	return;
}
//-------------------------------------------------------
//˲˵`1鿴ܻ״(ȫ) ̨2004/08/05jRO
//callfunc "Steward_menu1","MAP","NAME";
function	script	Steward_menu1	{
	mes "["+getarg(1)+"]";
	mes "ܻص״";
	mes " ";
	mes "^0000ffҵչ"+getcastledata(getarg(0),2)+"";
	if (getcastledata(getarg(0),4) != 0) mes "- ڹȥ1֮ڣͶ "+getcastledata(getarg(0),4)+" Ρ";
	mes "ڵķ"+getcastledata(getarg(0),3)+"^000000";
	if (getcastledata(getarg(0),5) != 0) mes "^0000ff- ڹȥ1֮ڣͶ "+getcastledata(getarg(0),5)+" Ρ^000000";
	mes " ";
	mes "ϡ";
	close;
	return;
}
//-------------------------------------------------------
//˲˵`Ͷҵչȡ(ȫ) ̨2004/08/25jRO
//callfunc "Steward_menu2","MAP","NAME";
function	script	Steward_menu2	{
	mes "["+getarg(1)+"]";
	mes "ҵչȵĻ";
	mes "ڹƷ";
	mes "ΪԺĻ";
	mes "ܲͶʰ";
	next;
	mes "["+getarg(1)+"]";
	mes "ԭȵķʽһֻͶһ";
	mes "ึһǮĻ";
	mes "һͶΡ";
	next;
	set @TriggerE,getcastledata(getarg(0),4);
	set @Economy,getcastledata(getarg(0),2);
	if(@Economy == 100) goto L2_error2;
	set @tmp,(@Economy-@TriggerE)/5;
	set @InvestE,5000*(1+(1+@tmp)*@tmp/2)*(1+3*@TriggerE);
	if (@TriggerE == 0) goto L2_1;
	if (@TriggerE == 1) goto L2_2;
		mes "["+getarg(1)+"]";
		mes "^ff0000Ѿڽ֮Ͷ";
		mes "ٲͶˡ";
		mes "^000000÷չȸϿ";
		mes "ڴŸӆ";
		close;
L2_1:
	mes "["+getarg(1)+"]";
	mes "ҪͶʽ";
	mes "^ff0000"+ @InvestE +"^000000 Zeny";
	mes "ҪͶ";
	next;
	menu "ҵչͶ",L2_1_1,"ȡ",L2_1_0;
L2_2:
	mes "["+getarg(1)+"]";
	mes "ѾͶһ";
	mes "ҪͶ";
	mes "Ҫ ^ff0000"+ @InvestE +"^000000 Zeny";
	next;
	menu "ҵչͶ",L2_1_1,"ȡ",L2_1_0;
	L2_1_0:
		mes "["+getarg(1)+"]";
		mes "ˡ";
		mes "Ҫ̫żġ";
		mes "ʲôҪʱҡ";
		close;
	L2_1_1:
		if(Zeny < @InvestE) goto L2_error;
		set Zeny,Zeny-@InvestE;
		setcastledata getarg(0),4,@TriggerE+1;
		mes "["+getarg(1)+"]";
		mes "˳Ͷˣ";
		mes "ӽԽԽ֡";
		mes "쿪ʼչȻġ";
		close;
L2_error:/*Ǯ*/
	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "û㹻ĽͶʡ";
	mes "Ͷʱȡˡ";
	close;
L2_error2:/*Ͷʶ*/
	mes "["+getarg(1)+"]";
	mes "^ff0000ڵķչѾֵˡ";
	mes "^000000ԲҪͶˡ";
 	close;
	return;
}

//-------------------------------------------------------
//˲˵`Ͷʷȡ(ȫ) ̨2004/08/25jRO
//callfunc "Steward_menu3","MAP","NAME";
function	script	Steward_menu3	{
	mes "["+getarg(1)+"]";
	mes "߷Ļ";
	mes "໤˺ͻ;öȻӡ";
	mes "ǵԺս";
	mes "ǿȲϲߡ";
	next;
	mes "["+getarg(1)+"]";
	mes "ԭȵķʽһֻͶһ";
	mes "ึһǮĻ";
	mes "һͶΡ";
	next;
	set @TriggerD,getcastledata(getarg(0),5);
	set @Deffence,getcastledata(getarg(0),3);
	if(@Deffence == 100) goto L3_error2;
	set @tmp,(@Deffence-@TriggerD)/5;
	set @InvestD,10000*(1+(1+@tmp)*@tmp/2)*(1+3*@TriggerD);
	if (@TriggerD == 0) goto L3_1;
	if (@TriggerD == 1) goto L3_2;
		mes "["+getarg(1)+"]";
		mes "^ff0000Ѿڽ֮Ͷ";
		mes "ٲͶˡ";
		mes "^000000ڴȵļǿ";
		close;
L3_1:
	mes "["+getarg(1)+"]";
	mes "ҪͶʽ^ff0000"+ @InvestD +"^000000 Zeny";
	mes "ҪͶ";
	next;
	menu "ԷͶ",L3_1_1,"ȡ",L3_1_0;
L3_2:
	mes "["+getarg(1)+"]";
	mes "ѾͶһ";
	mes "ҪͶ";
	mes "Ҫ ^ff0000"+ @InvestD +"^000000 Zeny";
	next;
	menu "ԷͶ",L3_1_1,"ȡ",L3_1_0;
	L3_1_0:
		mes "["+getarg(1)+"]";
		mes "ˡ";
		mes "Ҫ̫żġ";
		mes "ʲôҪʱҡ";
		close;
	L3_1_1:
		if(Zeny < @InvestD) goto L3_error;
		set Zeny,Zeny-@InvestD;
		setcastledata getarg(0),5,@TriggerD+1;
		mes "["+getarg(1)+"]";
		mes "˳Ͷˣ";
		mes "ӽԽԽ֡";
		mes "쿪ʼȻġ";
		close;
L3_error:/*Ǯ*/
	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "û㹻ĽͶʡ";
	mes "Ͷʱȡˡ";
	close;
L3_error2:/*Ͷʶ*/
	mes "["+getarg(1)+"]";
	mes "^ff0000ڷѾ100%ˡ";
	mes "^000000ԲҪͶˡ";
	close;
	return;
}
//-------------------------------------------------------
//˲˵`ü໤ˡ()
//callfunc "Steward_menu4","MAP","NAME";
function	script	Steward_menu4	{
	mes "["+getarg(1)+"]";
	mes "Ҫü໤";
	mes "໤˼Ϊ";
	mes "ܻصҳػߡ";
	mes "ѡҪõļ໤ˡ";
	next;
	menu	"໤ 1",L4_1,
		"໤ 2",L4_2,
		"໤ 3",L4_3,
		"໤ 4",L4_4,
		"໤ 5",L4_5,
		"໤ 6",L4_6,
		"໤ 7",L4_7,
		"໤ 8",L4_8;

//ʵʵMenu(οB5)
//menu " ໤ - δ",L_MENU_1," ໤ - δ",L_MENU_2,"ʿ ໤ - δ",L_MENU_3,"ʿ ໤ - δ",L_MENU_4,"ʿ ໤ - δ",L_MENU_5,"ʿ ໤ - δ",L_MENU_6,"ʿ ໤ - δ",L_MENU_7," ໤ - δ (31214 / 31214)",L_MENU_8;
//
//OäǤ뤫ʤαʾȡӤHPʾ롣
//ޤӤϤǤOÄܤǤꡢΈHP؏ͤ뤳Ȥ롣
		L4_1:
			if (getcastledata(getarg(0),10) == 1) goto L4Error2;
			set @GDnum,10;goto L4_9;
		L4_2:
			if (getcastledata(getarg(0),11) == 1) goto L4Error2;
			set @GDnum,11;goto L4_9;
		L4_3:
			if (getcastledata(getarg(0),12) == 1) goto L4Error2;
			set @GDnum,12;goto L4_9;
		L4_4:
			if (getcastledata(getarg(0),13) == 1) goto L4Error2;
			set @GDnum,13;goto L4_9;
		L4_5:
			if (getcastledata(getarg(0),14) == 1) goto L4Error2;
			set @GDnum,14;goto L4_9;
		L4_6:
			if (getcastledata(getarg(0),15) == 1) goto L4Error2;
			set @GDnum,15;goto L4_9;
		L4_7:
			if (getcastledata(getarg(0),16) == 1) goto L4Error2;
			set @GDnum,16;goto L4_9;
		L4_8:
			if (getcastledata(getarg(0),17) == 1) goto L4Error2;
			set @GDnum,17;goto L4_9;
L4Error:
	mes "["+getarg(1)+"]";
	mes "ˡйü໤˵о֪ʶ";
	mes "ȫȻ֪ࡡ";
	mes "Ҫۻü໤֪ʶĻ";
	mes "ҪѧϰἼеġ";
	mes "^ff0000໤о";
	close;
L4Error2:/*Ѿ˼໤*/
	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "Ѿü໤ˡ";
	mes " ";
	mes "ü໤˱ȡˡ";
	close;
L4Error3:/*Ǯ*/
	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "û㹻ĽͶʡ";
	mes "Ͷʱȡˡ";
	close;
	L4_9:
		mes "["+getarg(1)+"]";
		mes "ȷҪѡļ໤";
		mes "ʱҪ^ff0000 10000 ^000000Zeny";
		next;
		menu "",L4_9_1,"ȡ",-;
			mes "["+getarg(1)+"]";
			mes "ˡ";
			mes "еʽϿԣĻ";
			mes "ü໤˲ϲߡ";
			close;
		L4_9_1:
		if (getgdskilllv(@GID,GD_GUARDIANRESEARCH) == 0) goto L4Error;
		if (Zeny < 10000) goto L4Error3;
		set Zeny,Zeny-10000;
		setcastledata getarg(0),@GDnum,1;
	return;
}
//-------------------------------------------------------
//˲˵`ͿԼ(ȫ)
//callfunc "Steward_menu5","MAP","NAME","Kapra_xxx";
function	script	Steward_menu5	{
	if (getcastledata(getarg(0),9) == 1) goto Lkafra_dimi;
//(When Karfa off) Employment
	mes "["+getarg(1)+"]";
	mes "Ϳܹ˾Լ";
	mes "Ҫܻ棬ÿְԱ";
	mes "ʱҪ^ff0000 10000 ^000000Zeny";
	next;
	menu "",-,"ȡ",L_k_e;
		if (getgdskilllv(@GID,GD_KAFRACONTACT) != 0) goto L_k_0;
		mes "["+getarg(1)+"]";
		mes "ˡܺͿܹ˾Լ";
		mes "ԼĻ";
		mes "ǲܹÿְԱġ";
		next;
		mes "["+getarg(1)+"]";
		mes "Ҫܹ˾ǩԼĻ";
		mes "ҪѧϰἼе";
		mes "^ff0000ͿԼ^000000";
		close;
	L_k_0:/*Ǯ*/
		if (Zeny > 10000) goto L_k_1;
		mes "["+getarg(1)+"]";
		mes "ˣ㰡";
		close;
	L_k_1:/*ɹԼ*/
		set Zeny,Zeny-10000;
		enablenpc getarg(2);
		setcastledata getarg(0),9,1;
		mes "["+getarg(1)+"]";
		mes "ɹĺͿܹ˾Լ";
		next;
		cutin "kafra_01",2;
		mes "[ ְԱ]";
		mes "";
		mes "ܹ˾ĿְԱ";
		mes "Ҳùմ۵㣬һŬĹ";
		next;
		cutin "kafra_01",255;
		mes "["+getarg(1)+"]";
		mes "ΪάֹͿ˾Լ";
		mes "ÿ½һZeny";
		mes "(δʵװ)";
		close;
L_k_e:
		mes "["+getarg(1)+"]";
		mes "ˡ";
		mes "ǣΪ˸Աṩ㣬";
		mes "չÿְԱϲߡ";
		close;
//(When karfa ON) Dismissal
Lkafra_dimi:
	mes "["+getarg(1)+"]";
	mes "ҪͿְԱ";
	next;
	menu "",-,"ȡ",L_D_1;
		cutin "kafra_01",2;
		mes "[ ְԱ]";
		mes "ȥʲôطŪ";
		mes "һӱСĵġ";
		mes "ԭҵĹɡ";
		next;
		menu "",-,"ȡ",L_D_2;
				mes "[ ְԱ]";
				mes "۰ˣô ~";
				next;
				disablenpc getarg(2);
				setcastledata getarg(0),9,0;
				cutin "kafra_01",255;
				mes "["+getarg(1)+"]";
				mes "";
				mes "ѾȡͿԼˡ";
				close;
			L_D_2:
				mes "[ ְԱ]";
				mes "лл";
				mes "һ߾ȫΪǷģ";
				close2;
				cutin "kafra_01",255;
				end;
		L_D_1:
			mes "["+getarg(1)+"]";
			mes "ˡ";
			close;
	return;
}
//-------------------------------------------------------
//˲˵`6˷䡹(ȫ) ̨2004/08/25jRO
//callfunc "Steward_menu6","MAP","Name",x,y;
function	script	Steward_menu6	{
	mes "["+getarg(1)+"]";
	mes "ҪƷķ";
	mes "ֻ˽ķ䡣";
	next;
	menu "˷",-,"ȡ",L6_1;
		mes "["+getarg(1)+"]";
		mes "ҽΪͨ";
		mes "ʱ򣬰ܿؼɡ";
		close2;
		warp getarg(0),getarg(2),getarg(3);
		end;
	L6_1:
		mes "["+getarg(1)+"]";
		mes "Ʒһֻһ";
		mes "Ʒ浽ʱͲˡ";
		mes "Ϊ˹ķչ";
		mes "Ӧþʱȥȡ";
		close;
		return;
}
//-------------------------------------------------------
//˲˵`7óܻء()
//callfunc "Steward_menu7","MAP","NAME";
function	script	Steward_menu7	{

	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "Ҫóܻ𣡣";
	mes " ";
	mes "¿ǰɣˣ";
	next;

	menu "óܻ",L7_1,"ȡ",L7_2;

L7_1:
	mes "["+getarg(1)+"]";
	mes "ˣ";
	mes "¿һɡ";
	mes "˼а!!!!!!!!";
	next;

	menu "ȡ",L7_2,"óܻ",-;

	mes "["+getarg(1)+"]";
	mes "!!";
	mes "Ҫ";
	next;
	return;

L7_2:
	mes "["+getarg(1)+"]";
	mes "^^!";
	mes "ˣʹǿЦһβҪٽЦ^^.";
	close;
}
//-------------------------------------------------------
//Ὺ
//callfunc "gdswitch","MAP",x,y;
function	script	gdswitch	{
	mes "СƸˡ";
	mes "Ҫ";
	next;
	menu "",-,"",L2;
	warp getarg(0),getarg(1),getarg(2);
	end;
L2:
	close;
	return;
}
//-------------------------------------------------------
//Ὺ
//callfunc "gdswitch2","MAP1","MAP2",x,y;
function	script	gdswitch2	{
	mes "[]";
	mes "ͨΪˡȥѰ·";
	next;
	mes " ";
	mes "СƸˡ";
	mes "Ҫ";
	next;
	menu "",-,"",L2;
	set @GID,getcastledata(getarg(0),1);
	if (getcharid(2) != @GID) goto L1n;
	if (0 == @GID) goto L1n;
	warp getarg(1),getarg(2),getarg(3);
	end;
L1n:
	mes " ";
	mes "ûзκ顣";
L2:
	close;
	return;
}
//==============================================================================
//-------------------------------------------------------
//˵
//callfunc "gkfmenu","MAP";
function	script	gkfmenu	{
	cutin "kafra_01",2;
	set @GID,getcastledata(getarg(0),1);
	if (getcharid(2) == @GID) goto LStartg;
	mes "[ ְԱ]";
	mes "ǩԼרΪ";
	mes "^ff0000" + getguildname(@GID) + "^000000ĻԱ";
	mes "ʹطĿְԱ";
	mes "в֮¡";
	close2;
	cutin "kafra_01",255;
	end;
LStartg:
	mes "[ ְԱ]";
	mes "ӭ^ff0000" + getguildname(@GID) + "^000000ĻԱ";
	mes "(޹˾)ԶڸλΪ";
	next;
	return;
}
//-------------------------------------------------------
//ռƶ
//callfunc "gkfwarp","JMAPNAME","MAP",x,y;
function	script	gkfwarp	{
	mes "[ ְԱ]";
	mes "ѡĿĵذɡ";
	next;
	menu ""+getarg(0)+" -> 200 z",L3_1,"ȡ",L3_2;
		L3_1:
			if (Zeny < 200) goto Lerror3;
			set Zeny,Zeny-200;set KF_PIT,KF_PIT+20;
			warp getarg(1),getarg(2),getarg(3);
			end;
		L3_2:
				mes "[ ְԱ]";
				mes "лл";
				mes "ӭٴʹá";
				close2;
				cutin "kafra_01",255;
				end;
		Lerror3:
				mes "[ ְԱ]";
				mes "Ա/С";
				mes "ֽ㣬ȷϡ";
				cutin "kafra_01",255;
				close2;
				cutin "kafra_01",255;
				end;
	return;
}