class 1 citizen : default_npc
{
parameter:
	string	fnTradeSkill0 = "";
	string	fnTradeSkill1 = "";
	string	fnTradeSkill2 = "";
	string	fnHi = "chi.htm";
	string	fnFeudInfo = "defaultfeudinfo.htm";
	string	fnNoFeudInfo = "nofeudinfo.htm";
	string	fnYouAreChaotic = "wyac.htm";
	string	fnBracketL = "[";
	string	fnBracketR = "]";
	int	MoveAroundSocial = 0;
	int	MoveAroundSocial1 = 0;
	int	MoveAroundSocial2 = 0;
	int	HavePet = 0;
	int	silhouette = 1020130;
	int	FriendShip1 = 0;
	int	FriendShip2 = 0;
	int	FriendShip3 = 0;
	int	FriendShip4 = 0;
	int	FriendShip5 = 0;
	string	fnNoFriend = "";
	int	NoFnHi = 0;

handler:
	EventHandler TALKED(talker)
	{
		if( talker.karma > 0 )
		{
			myself::ShowPage(talker,fnYouAreChaotic);
			return;
		}
		if( NoFnHi == 1 )
		{
			return;
		}
		if( FriendShip1 == 0 )
		{
			myself::ShowPage(talker,fnHi);
		}
		else if( myself::OwnItemCount(talker,FriendShip1) > 0 || myself::OwnItemCount(talker,FriendShip2) > 0 || myself::OwnItemCount(talker,FriendShip3) > 0 || myself::OwnItemCount(talker,FriendShip4) > 0 || myself::OwnItemCount(talker,FriendShip5) > 0 )
		{
			myself::ShowPage(talker,fnHi);
		}
		else
		{
			myself::ShowPage(talker,fnNoFriend);
		}
	}

	EventHandler CREATED()
	{
		if( MoveAroundSocial > 0 || MoveAroundSocial1 > 0 )
		{
			myself::AddTimerEx(1671,10000);
		}
		if( HavePet == 1 )
		{
			myself::CreateOnePrivateEx(silhouette,"pet_around_pet_manager",0,0,myself::FloatToInt(( myself.sm.x + 10 )),myself::FloatToInt(( myself.sm.y + 10 )),myself::FloatToInt(myself.sm.z),0,0,0,0);
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 1671 )
		{
			if( myself.sm.hp > ( myself.sm.max_hp * 0.400000 ) && myself.sm.alive != 0 && myself.p_state != 3 )
			{
				if( MoveAroundSocial > 0 || MoveAroundSocial1 > 0 )
				{
					if( MoveAroundSocial > 0 && gg::Rand(100) < 40 )
					{
						myself::AddEffectActionDesire(myself.sm,3,( ( MoveAroundSocial * 1000 ) / 30 ),50);
					}
					else if( MoveAroundSocial1 > 0 && gg::Rand(100) < 40 )
					{
						myself::AddEffectActionDesire(myself.sm,2,( ( MoveAroundSocial1 * 1000 ) / 30 ),50);
					}
				}
			}
			myself::AddTimerEx(1671,10000);
		}
		super;
	}

	EventHandler MENU_SELECTED(talker,ask,reply,fhtml0)
	{
		if( ask == -1000 )
		{
			switch(reply)
			{
				case 0:
				{
					myself::ShowPage(talker,fnHi);
					break;
				}
				case 1:
				{
					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);
						}
						if( myself.sm.residence_id < 7 )
						{
							myself::FHTML_SetStr(fhtml0,"kingdom_name",myself::MakeFString(1001000,"","","","",""));
						}
						else
						{
							myself::FHTML_SetStr(fhtml0,"kingdom_name",myself::MakeFString(1001100,"","","","",""));
						}
						myself::FHTML_SetStr(fhtml0,"feud_name",myself::MakeFString(( 1001000 + myself.sm.residence_id ),"","","","",""));
						myself::ShowFHTML(talker,fhtml0);
					}
					break;
				}
			}
		}
		if( ask == -303 )
		{
			if( reply == 203 )
			{
				if( myself::GetSSQStatus() == 3 )
				{
					if( myself::GetSSQPart(talker) != 0 )
					{
						myself::ShowMultisell(reply,talker);
					}
				}
			}
			else if( reply == 532 || reply == 549 )
			{
				if( gg::IsEventServer() == 1 )
				{
					myself::ShowMultisell(reply,talker);
				}
			}
			else
			{
				myself::ShowMultisell(reply,talker);
			}
		}
	}

}
