class 1 janitor : citizen
{
parameter:
	string	fnHi = "defaultagitinfo.htm";
	string	fnFeudInfo = "defaultagitinfo.htm";
	string	fnNoFeudInfo = "noagitinfo.htm";
	string	fnOwner = "agitjanitorhi.htm";
	string	fnWyvernOwner = "wyvernagitjanitorhi.htm";
	string	fnNoAuthority = "noauthority.htm";
	string	fnDoor = "agitdoor.htm";
	string	fnAfterDoorOpen = "agitjanitorafterdooropen.htm";
	string	fnAfterDoorClose = "agitjanitorafterdoorclose.htm";
	string	fnMyLord = "wkeeper001_temp.htm";
	string	fnNotMyLord = "wkeeper002_agit.htm";
	string	fnStriderHelp = "wkeeper003_temp.htm";
	string	fnAfterRide = "wkeeper004.htm";
	string	fnStriderNotReady = "wkeeper005.htm";
	string	fnNotEnoughFee = "wkeeper006.htm";
	int	ride_wyvern_level = 55;
	int	ride_wyvern_fee = 25;
	int	Is_Wyvern = 0;
	int	ain_x1 = 0;
	int	ain_y1 = 0;
	int	ain_z1 = 0;
	int	ain_x2 = 0;
	int	ain_y2 = 0;
	int	ain_z2 = 0;
	int	ain_x3 = 0;
	int	ain_y3 = 0;
	int	ain_z3 = 0;

handler:
	EventHandler TALKED(talker,fhtml0)
	{
		if( myself::IsMyLord(talker) || ( myself::HavePledgePower(talker,4) && myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) )
		{
			if( Is_Wyvern == 1 )
			{
				myself::FHTML_SetFileName(fhtml0,fnWyvernOwner);
			}
			else
			{
				myself::FHTML_SetFileName(fhtml0,fnOwner);
			}
			myself::FHTML_SetStr(fhtml0,"my_pledge_name",myself::Castle_GetPledgeName());
			myself::ShowFHTML(talker,fhtml0);
		}
		else if( myself.sm.residence_id > 0 )
		{
			if( myself::Castle_GetPledgeId() )
			{
				myself::FHTML_SetFileName(fhtml0,fnFeudInfo);
				myself::FHTML_SetStr(fhtml0,"my_pledge_name",myself::Castle_GetPledgeName());
				myself::FHTML_SetStr(fhtml0,"my_owner_name",myself::Castle_GetOwnerName());
				myself::FHTML_SetInt(fhtml0,"current_tax_rate",myself::Residence_GetTaxRateCurrent());
			}
			else
			{
				myself::FHTML_SetFileName(fhtml0,fnNoFeudInfo);
			}
		}
		myself::ShowFHTML(talker,fhtml0);
	}

	EventHandler MENU_SELECTED(talker,ask,reply,fhtml0,i0,i1,i2,i3,s0,s1)
	{
		if( ask == 0 || ( ask == -201 && reply == 0 ) )
		{
			if( myself::IsMyLord(talker) || ( myself::HavePledgePower(talker,4) && myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) )
			{
				if( Is_Wyvern == 1 )
				{
					myself::FHTML_SetFileName(fhtml0,fnWyvernOwner);
				}
				else
				{
					myself::FHTML_SetFileName(fhtml0,fnOwner);
				}
				myself::FHTML_SetStr(fhtml0,"my_pledge_name",myself::Castle_GetPledgeName());
				myself::ShowFHTML(talker,fhtml0);
			}
			else if( myself.sm.residence_id > 0 )
			{
				if( myself::Castle_GetPledgeId() )
				{
					myself::FHTML_SetFileName(fhtml0,fnFeudInfo);
					myself::FHTML_SetStr(fhtml0,"my_pledge_name",myself::Castle_GetPledgeName());
					myself::FHTML_SetStr(fhtml0,"my_owner_name",myself::Castle_GetOwnerName());
					myself::FHTML_SetInt(fhtml0,"current_tax_rate",myself::Residence_GetTaxRateCurrent());
				}
				else
				{
					myself::FHTML_SetFileName(fhtml0,fnNoFeudInfo);
				}
			}
			myself::ShowFHTML(talker,fhtml0);
		}
		else if( ask == -203 )
		{
			if( myself::IsMyLord(talker) || ( myself::HavePledgePower(talker,4) && myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) )
			{
				switch(reply)
				{
					case 1:
					{
						myself::Castle_GateOpenClose(0);
						myself::ShowPage(talker,fnAfterDoorOpen);
						break;
					}
					case 2:
					{
						myself::Castle_GateOpenClose(1);
						myself::ShowPage(talker,fnAfterDoorClose);
						break;
					}
				}
			}
			else
			{
				myself::ShowPage(talker,fnNoAuthority);
			}
		}
		else if( ask == -204 )
		{
			if( myself::IsMyLord(talker) )
			{
				myself::FHTML_SetFileName(fhtml0,fnMyLord);
				myself::FHTML_SetInt(fhtml0,"ride_wyvern_level",ride_wyvern_level);
				myself::FHTML_SetInt(fhtml0,"ride_wyvern_fee",ride_wyvern_fee);
				myself::ShowFHTML(talker,fhtml0);
			}
			else
			{
				myself::ShowPage(talker,fnNoAuthority);
			}
		}
		else if( ask == -17 )
		{
			if( reply == 1 )
			{
				myself::FHTML_SetFileName(fhtml0,fnStriderHelp);
				myself::FHTML_SetInt(fhtml0,"ride_wyvern_level",ride_wyvern_level);
				myself::FHTML_SetInt(fhtml0,"ride_wyvern_fee",ride_wyvern_fee);
			}
			else if( reply == 2 )
			{
				if( talker.yongma_type == 1 && talker.strider_level >= ride_wyvern_level )
				{
					if( myself::OwnItemCount(talker,1460) >= ride_wyvern_fee )
					{
						myself::DeleteItem1(talker,1460,ride_wyvern_fee);
						myself::RideWyvern(talker,1012621);
						myself::FHTML_SetFileName(fhtml0,fnAfterRide);
					}
					else
					{
						myself::FHTML_SetFileName(fhtml0,fnNotEnoughFee);
						myself::FHTML_SetInt(fhtml0,"ride_wyvern_fee",ride_wyvern_fee);
					}
				}
				else
				{
					myself::FHTML_SetFileName(fhtml0,fnStriderNotReady);
					myself::FHTML_SetInt(fhtml0,"ride_wyvern_level",ride_wyvern_level);
					myself::FHTML_SetInt(fhtml0,"ride_wyvern_fee",ride_wyvern_fee);
				}
			}
			myself::ShowFHTML(talker,fhtml0);
		}
	}

}
