class 1 freya_s_steward : citizen
{
parameter:
	string	fnHi = "freya_deacon001.htm";
	int	time_out = 2100000;
	int	GM_ID = 12;

handler:
	EventHandler CREATED(i0)
	{
		myself::InstantTeleportInMyTerritory(115600,-125770,-3432,10);
		myself.i_ai0 = 0;
		myself.i_ai1 = 0;
		myself::AddTimerEx(10022,10000);
		i0 = myself::GetGlobalMap(GM_ID);
		if( i0 != -1 )
		{
			myself::Shout("Record to Ice Queen Castle siege open.");
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id,party0,c0,target)
	{
		if( timer_id == 1001 )
		{
			myself::InstantTeleportInMyTerritory(115600,-125770,-3432,10);
			myself::Shout("Record to Ice Queen Castle siege open again.");
			myself.i_ai0 = 0;
			myself.i_ai1 = 0;
		}
		if( timer_id == 1002 )
		{
			party0 = myself::GetParty(myself.c_ai0);
			c0 = myself::GetLeaderOfParty(party0);
			myself::AddUseSkillDesire(c0,1109505,0,1,1000000);
			myself::AddTimerEx(10021,5000);
		}
		if( timer_id == 10021 )
		{
			myself::InstantTeleport(myself.sm,115625,-125595,-3432);
		}
		if( timer_id == 10022 )
		{
			if( myself.i_ai1 == 0 )
			{
				myself::InstantTeleportInMyTerritory(115600,-125770,-3432,10);
			}
			myself::AddTimerEx(10022,10000);
		}
		super;
	}

	EventHandler TALK_SELECTED(talker,party0,fhtml0,c0,c1,i0,i1,s0)
	{
		i0 = myself::GetGlobalMap(GM_ID);
		if( i0 != -1 )
		{
			c0 = myself::GetCreatureFromIndex(i0);
			if( c0.alive == 0 )
			{
				myself::ShowPage(talker,"freya_deacon002.htm");
				return;
			}
		}
		else
		{
			myself::ShowPage(talker,"freya_deacon002.htm");
			return;
		}
		if( myself.i_ai0 > 0 )
		{
			i0 = gg::GetDateTime(0,4);
			if( myself.i_ai0 > 59 )
			{
				if( i0 < 34 )
				{
					i0 = ( i0 + 60 );
				}
			}
			i0 = ( myself.i_ai0 - i0 );
			myself::FHTML_SetFileName(fhtml0,"freya_deacon_q0656_01.htm");
			s0 = myself::IntToStr(i0);
			myself::FHTML_SetStr(fhtml0,"minute",s0);
			myself::ShowFHTML(talker,fhtml0);
			return;
		}
		party0 = myself::GetParty(talker);
		if( myself::IsNullParty(party0) )
		{
			myself::ShowPage(talker,"freya_deacon_q0656_06.htm");
			return;
		}
		else
		{
			c0 = myself::GetLeaderOfParty(party0);
			if( talker != c0 )
			{
				myself::ShowPage(talker,"freya_deacon_q0656_02.htm");
				return;
			}
			i1 = myself::Party_GetCount(c0);
			if( i1 < 5 )
			{
				myself::ShowPage(talker,"freya_deacon_q0656_06.htm");
				return;
			}
			if( i1 != 0 )
			{
				for(i0 = 0; i0 < i1; i0 = ( i0 + 1 ))
				{
					c1 = myself::Party_GetCreature(c0,i0);
					if( myself::OwnItemCount(c1,8057) < 10 )
					{
						myself::FHTML_SetFileName(fhtml0,"freya_deacon_q0656_03.htm");
						myself::FHTML_SetStr(fhtml0,"name",c1.name);
						myself::ShowFHTML(talker,fhtml0);
						return;
					}
					if( c1.level < 50 || c1.level > 68 )
					{
						myself::ShowPage(talker,"freya_deacon_q0656_14.htm");
						return;
					}
				}
				for(i0 = 0; i0 < i1; i0 = ( i0 + 1 ))
				{
					c1 = myself::Party_GetCreature(c0,i0);
					myself::DeleteItem1(c1,8057,10);
				}
				myself.i_ai1 = 1;
				myself::TeleportParty(party0.id,113600,-126170,-3512,0,0);
				myself::AddTimerEx(1002,5000);
				myself::InstantTeleport(myself.sm,113760,-126255,-3512);
			}
			myself.i_ai0 = gg::GetDateTime(0,4);
			myself.i_ai0 = ( myself.i_ai0 + 35 );
			myself::AddTimerEx(1001,time_out);
		}
	}

}
