class 1 ssq_npc_merchant_of_mammon : citizen
{
parameter:
	int	PosX1 = 0;
	int	PosY1 = 0;
	int	PosZ1 = 0;
	int	PosX2 = 0;
	int	PosY2 = 0;
	int	PosZ2 = 0;
	int	PosX3 = 0;
	int	PosY3 = 0;
	int	PosZ3 = 0;
	int	PosX4 = 0;
	int	PosY4 = 0;
	int	PosZ4 = 0;
	int	PosX5 = 0;
	int	PosY5 = 0;
	int	PosZ5 = 0;
	int	PosX6 = 0;
	int	PosY6 = 0;
	int	PosZ6 = 0;
	int	PosX7 = 0;
	int	PosY7 = 0;
	int	PosZ7 = 0;
	int	PosX8 = 0;
	int	PosY8 = 0;
	int	PosZ8 = 0;

property:
	BuySellList SellList0 = {};

handler:
	EventHandler CREATED()
	{
		myself::AddTimerEx(5098,( ( 30 * 60 ) * 1000 ));
	}

	EventHandler TALKED(talker)
	{
		if( myself::GetSSQStatus() != 3 )
		{
			myself::Despawn();
			return;
		}
		if( myself::GetSSQPart(talker) != 0 && myself::GetSSQSealOwner(1) == myself::GetSSQPart(talker) )
		{
			myself::ShowPage(talker,fnHi);
		}
		else
		{
			myself::ShowPage(talker,"merchant_of_mammon002.htm");
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0)
	{
		if( timer_id == 5098 )
		{
			i0 = gg::Rand(80);
			if( i0 <= 10 && PosX1 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX1,PosY1,PosZ1);
			}
			else if( i0 > 10 && i0 <= 20 && PosX2 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX2,PosY2,PosZ2);
			}
			else if( i0 > 20 && i0 <= 30 && PosX3 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX3,PosY3,PosZ3);
			}
			else if( i0 > 30 && i0 <= 40 && PosX4 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX4,PosY4,PosZ4);
			}
			else if( i0 > 40 && i0 <= 50 && PosX5 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX5,PosY5,PosZ5);
			}
			else if( i0 > 50 && i0 <= 60 && PosX6 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX6,PosY6,PosZ6);
			}
			else if( i0 > 60 && i0 <= 70 && PosX7 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX7,PosY7,PosZ7);
			}
			else if( PosX8 != 0 )
			{
				myself::InstantTeleport(myself.sm,PosX8,PosY8,PosZ8);
			}
			myself::AddTimerEx(5098,( ( 30 * 60 ) * 1000 ));
		}
		else if( timer_id == 5099 )
		{
			if( myself::GetSSQStatus() == 1 )
			{
				myself::Despawn();
			}
			else
			{
				myself::AddTimerEx(5099,( 60 * 1000 ));
			}
		}
	}

}
