class 1 follower_dummy : default_npc
{
parameter:
	string	fnHi = "follower_dummy001.htm";
	string	fnReg = "follower_dummy007.htm";
	string	fnRegComplite = "follower_dummy008.htm";
	string	fnRegList = "follower_dummy009.htm";
	string	fnRegListNoFirst = "follower_dummy010.htm";
	string	fnNoTeleport = "follower_dummy011.htm";
	string	fnBattle = "follower_dummy003.htm";
	string	fnNotRespawn = "follower_dummy002.htm";
	string	fnNoMoreTicket = "follower_dummy004.htm";
	string	fnNoEnterItem = "follower_dummy005.htm";
	string	fnNoOrSmallParty = "follower_dummy006.htm";
	int	GM_ID = 8;
	int	GM_ID1 = 24;
	int	GM_ID2 = 25;
	int	GM_ID3 = 7;
	int	GM_ID4 = 10;
	int	SizeParty = 5;
	int	Timer = 120;
	int	TimerKickAfteDie = 20;
	int	test = 0;
	string	LevelName = "Frintezza";

handler:
	EventHandler CREATED(i0,c0,room0,rlist0,gg)
	{
		myself.i_quest0 = 0;
		myself.i_quest1 = 0;
		myself.i_quest2 = 0;
		myself.i_quest3 = 0;
		myself.i_quest4 = 0;
		myself.i_ai0 = 0;
		i0 = gg::CreateRoomInfoList(LevelName,1);
		rlist0 = gg::GetRoomInfoList(LevelName);
		if( gg::IsNull(rlist0) )
		{
			myself::Say("!!! Error Room Created !!!");
		}
		else
		{
			room0 = rlist0::GetRoomInfo(0);
			room0.status::Exchange(0);
			room0::Clear();
		}
		i0 = myself::GetGlobalMap(GM_ID);
		if( i0 != -1 )
		{
			c0 = myself::GetCreatureFromIndex(i0);
			if( c0.alive )
			{
				if( c0.db_value != 0 )
				{
					if( gg::IsNull(rlist0) )
					{
						myself::Say("!!! Error Room Created !!!");
					}
					else
					{
						room0 = rlist0::GetRoomInfo(0);
						room0.status::Exchange(1);
						myself.i_ai0 = gg::GetTimeOfDay();
					}
					myself::AddTimerEx(3002,5000);
				}
			}
		}
		else
		{
			myself::InstantTeleportInMyTerritory(146832,-55904,-2776,100);
		}
		myself::AddTimerEx(2002,1000);
	}

	EventHandler TALKED(talker)
	{
		myself::ShowPage(talker,fnHi);
	}

	EventHandler MENU_SELECTED(talker,ask,reply,i0,i1,i2,c0,c1,party0,fhtml0,room0,rlist0,gg)
	{
		if( ask == -94 )
		{
			if( reply == 1 )
			{
				if( test == 1 )
				{
					myself::InstantTeleportInMyTerritory(146832,-55904,-2776,100);
					myself::CreateOnePrivateEx(1018328,"hall_alarm_device",0,0,174081,-77264,-5050,0,0,0,0);
					myself::CreateOnePrivateEx(1018328,"hall_alarm_device1",0,0,174081,-74778,-5050,0,0,0,0);
					i0 = myself::GetGlobalMap(GM_ID);
					if( i0 != -1 )
					{
						c0 = myself::GetCreatureFromIndex(i0);
						gg::SendScriptEvent(c0,0,0);
					}
					rlist0 = gg::GetRoomInfoList(LevelName);
					if( gg::IsNull(rlist0) )
					{
						myself::Say("!!! Error Room Created !!!");
					}
					else
					{
						party0 = myself::GetParty(talker);
						room0 = rlist0::GetRoomInfo(0);
						room0.status::Exchange(1);
						room0::SetParty(party0.id);
					}
					myself::AddTimerEx(3002,10000);
					return;
				}
				rlist0 = gg::GetRoomInfoList(LevelName);
				if( gg::IsNull(rlist0) )
				{
					myself::Say("!!! Error Room Created !!!");
				}
				else
				{
					room0 = rlist0::GetRoomInfo(0);
					if( room0.status.value == 0 )
					{
						i0 = myself::GetGlobalMap(GM_ID);
						if( i0 != -1 )
						{
							c0 = myself::GetCreatureFromIndex(i0);
							if( c0.alive )
							{
								if( c0.db_value != 0 )
								{
									myself::ShowPage(talker,fnBattle);
								}
								else
								{
									myself::ShowPage(talker,fnReg);
								}
							}
							else
							{
								myself::ShowPage(talker,fnNotRespawn);
							}
						}
						else
						{
							myself::ShowPage(talker,fnNotRespawn);
						}
					}
					else
					{
						myself::ShowPage(talker,fnBattle);
					}
				}
			}
			if( reply == 2 )
			{
				c1 = myself::Party_GetLeader(talker);
				party0 = myself::GetParty(talker);
				i1 = myself::Party_GetCount(talker);
				if( c1 != talker )
				{
					myself::ShowPage(talker,"follower_dummy016.htm");
					return;
				}
				else if( myself::IsNullParty(party0) || i1 < SizeParty )
				{
					myself::ShowPage(talker,fnNoOrSmallParty);
					return;
				}
				else if( myself::OwnItemCount(c1,8073) < 1 )
				{
					myself::ShowPage(talker,fnNoEnterItem);
					return;
				}
				else if( ( c1 == myself.c_quest0 && myself.i_quest0 == 1 ) || ( ( c1 == myself.c_quest1 && myself.i_quest1 == 1 ) || ( ( c1 == myself.c_quest2 && myself.i_quest2 == 1 ) || ( ( c1 == myself.c_quest3 && myself.i_quest3 == 1 ) || ( c1 == myself.c_quest4 && myself.i_quest4 == 1 ) ) ) ) )
				{
					myself::ShowPage(talker,"follower_dummy012.htm");
					return;
				}
				if( myself::IsNullCreature(myself.c_quest0) || myself.c_quest0.is_pc == 0 || myself.c_quest0.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest0)) )
				{
					myself.i_quest0 = 0;
				}
				if( myself::IsNullCreature(myself.c_quest1) || myself.c_quest1.is_pc == 0 || myself.c_quest1.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest1)) )
				{
					myself.i_quest1 = 0;
				}
				if( myself::IsNullCreature(myself.c_quest2) || myself.c_quest2.is_pc == 0 || myself.c_quest2.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest2)) )
				{
					myself.i_quest2 = 0;
				}
				if( myself::IsNullCreature(myself.c_quest3) || myself.c_quest3.is_pc == 0 || myself.c_quest3.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest3)) )
				{
					myself.i_quest3 = 0;
				}
				if( myself::IsNullCreature(myself.c_quest4) || myself.c_quest4.is_pc == 0 || myself.c_quest4.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest4)) )
				{
					myself.i_quest4 = 0;
				}
				if( myself.i_quest0 == 1 && myself.i_quest1 == 1 && myself.i_quest2 == 1 && myself.i_quest3 == 1 && myself.i_quest4 == 1 )
				{
					myself::ShowPage(talker,fnNoMoreTicket);
					return;
				}
				if( myself.i_quest0 == 0 )
				{
					myself.c_quest0 = c1;
					myself.i_quest0 = 1;
					myself::ShowPage(talker,fnRegComplite);
					return;
				}
				else if( myself.i_quest1 == 0 )
				{
					myself.c_quest1 = c1;
					myself.i_quest1 = 1;
					myself::ShowPage(talker,fnRegComplite);
					return;
				}
				else if( myself.i_quest2 == 0 )
				{
					myself.c_quest2 = c1;
					myself.i_quest2 = 1;
					myself::ShowPage(talker,fnRegComplite);
					return;
				}
				else if( myself.i_quest3 == 0 )
				{
					myself.c_quest3 = c1;
					myself.i_quest3 = 1;
					myself::ShowPage(talker,fnRegComplite);
					return;
				}
				else if( myself.i_quest4 == 0 )
				{
					myself.c_quest4 = c1;
					myself.i_quest4 = 1;
					myself::ShowPage(talker,fnRegComplite);
					return;
				}
			}
			if( reply == 3 )
			{
				if( talker == myself.c_quest0 && myself.i_quest0 == 1 )
				{
					myself::FHTML_SetFileName(fhtml0,fnRegList);
				}
				else
				{
					myself::FHTML_SetFileName(fhtml0,fnRegListNoFirst);
				}
				myself::FHTML_SetStr(fhtml0,"name0","None");
				myself::FHTML_SetStr(fhtml0,"name1","None");
				myself::FHTML_SetStr(fhtml0,"name2","None");
				myself::FHTML_SetStr(fhtml0,"name3","None");
				myself::FHTML_SetStr(fhtml0,"name4","None");
				myself::FHTML_SetInt(fhtml0,"k0",0);
				myself::FHTML_SetInt(fhtml0,"k1",0);
				myself::FHTML_SetInt(fhtml0,"k2",0);
				myself::FHTML_SetInt(fhtml0,"k3",0);
				myself::FHTML_SetInt(fhtml0,"k4",0);
				if( myself.i_quest0 == 1 )
				{
					myself::FHTML_SetStr(fhtml0,"name0",myself.c_quest0.name);
					i2 = myself::Party_GetCount(myself.c_quest0);
					myself::FHTML_SetInt(fhtml0,"k0",i2);
				}
				if( myself.i_quest1 == 1 )
				{
					myself::FHTML_SetStr(fhtml0,"name1",myself.c_quest1.name);
					i2 = myself::Party_GetCount(myself.c_quest1);
					myself::FHTML_SetInt(fhtml0,"k1",i2);
				}
				if( myself.i_quest2 == 1 )
				{
					myself::FHTML_SetStr(fhtml0,"name2",myself.c_quest2.name);
					i2 = myself::Party_GetCount(myself.c_quest2);
					myself::FHTML_SetInt(fhtml0,"k2",i2);
				}
				if( myself.i_quest3 == 1 )
				{
					myself::FHTML_SetStr(fhtml0,"name3",myself.c_quest3.name);
					i2 = myself::Party_GetCount(myself.c_quest3);
					myself::FHTML_SetInt(fhtml0,"k3",i2);
				}
				if( myself.i_quest4 == 1 )
				{
					myself::FHTML_SetStr(fhtml0,"name4",myself.c_quest4.name);
					i2 = myself::Party_GetCount(myself.c_quest4);
					myself::FHTML_SetInt(fhtml0,"k4",i2);
				}
				myself::ShowFHTML(talker,fhtml0);
			}
			if( reply == 4 )
			{
				if( talker == myself.c_quest0 )
				{
					myself.i_quest1 = 0;
					myself::ShowPage(talker,"follower_dummy014.htm");
				}
				else
				{
					myself::ShowPage(talker,fnReg);
				}
			}
			if( reply == 5 )
			{
				if( talker == myself.c_quest0 )
				{
					myself.i_quest2 = 0;
					myself::ShowPage(talker,"follower_dummy014.htm");
				}
				else
				{
					myself::ShowPage(talker,fnReg);
				}
			}
			if( reply == 6 )
			{
				if( talker == myself.c_quest0 )
				{
					myself.i_quest3 = 0;
					myself::ShowPage(talker,"follower_dummy014.htm");
				}
				else
				{
					myself::ShowPage(talker,fnReg);
				}
			}
			if( reply == 7 )
			{
				if( talker == myself.c_quest0 )
				{
					myself.i_quest4 = 0;
					myself::ShowPage(talker,"follower_dummy014.htm");
				}
				else
				{
					myself::ShowPage(talker,fnReg);
				}
			}
			if( reply == 8 )
			{
				if( talker == myself.c_quest0 && myself.i_quest0 == 1 )
				{
					myself.i_quest0 = 0;
					myself.i_quest1 = 0;
					myself.i_quest2 = 0;
					myself.i_quest3 = 0;
					myself.i_quest4 = 0;
					myself::ShowPage(talker,fnReg);
				}
				else
				{
					myself::ShowPage(talker,fnReg);
				}
			}
		}
	}

	EventHandler TELEPORT_REQUESTED(talker,i0,c0,party0,room0,rlist0,gg)
	{
		if( myself::IsNullCreature(myself.c_quest0) || myself.c_quest0.is_pc == 0 || myself.c_quest0.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest0)) )
		{
			myself.i_quest0 = 0;
			myself.i_quest1 = 0;
			myself.i_quest2 = 0;
			myself.i_quest3 = 0;
			myself.i_quest4 = 0;
		}
		if( myself::IsNullCreature(myself.c_quest1) || myself.c_quest1.is_pc == 0 || myself.c_quest1.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest1)) )
		{
			myself.i_quest1 = 0;
		}
		if( myself::IsNullCreature(myself.c_quest2) || myself.c_quest2.is_pc == 0 || myself.c_quest2.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest2)) )
		{
			myself.i_quest2 = 0;
		}
		if( myself::IsNullCreature(myself.c_quest3) || myself.c_quest3.is_pc == 0 || myself.c_quest3.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest3)) )
		{
			myself.i_quest3 = 0;
		}
		if( myself::IsNullCreature(myself.c_quest4) || myself.c_quest4.is_pc == 0 || myself.c_quest4.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest4)) )
		{
			myself.i_quest4 = 0;
		}
		if( myself.i_quest0 == 1 && myself.i_quest1 == 1 && myself.i_quest2 == 1 && myself.i_quest3 == 1 && myself.i_quest4 == 1 )
		{
			myself::InstantTeleportInMyTerritory(146832,-55904,-2776,100);
			myself::CreateOnePrivateEx(1018328,"hall_alarm_device",0,0,174081,-77264,-5050,0,0,0,0);
			myself::CreateOnePrivateEx(1018328,"hall_alarm_device1",0,0,174081,-74778,-5050,0,0,0,0);
			i0 = myself::GetGlobalMap(GM_ID);
			if( i0 != -1 )
			{
				c0 = myself::GetCreatureFromIndex(i0);
				gg::SendScriptEvent(c0,0,0);
			}
			rlist0 = gg::GetRoomInfoList(LevelName);
			if( gg::IsNull(rlist0) )
			{
				myself::Say("!!! Error Room Created !!!");
			}
			else
			{
				room0 = rlist0::GetRoomInfo(0);
				room0.status::Exchange(1);
				party0 = myself::GetParty(myself.c_quest0);
				room0::SetParty(party0.id);
			}
			myself::AddTimerEx(3002,5000);
			myself::AddTimerEx(2003,5000);
		}
		else
		{
			myself::ShowPage(talker,fnNoTeleport);
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0,i1,c0,c1,party0,room0,rlist0,gg)
	{
		if( timer_id == 2002 )
		{
			if( myself::IsNullCreature(myself.c_quest0) || myself.c_quest0.is_pc == 0 || myself.c_quest0.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest0)) || myself::DistFromMe(myself.c_quest0) > 1500 )
			{
				myself.i_quest0 = 0;
				myself.i_quest1 = 0;
				myself.i_quest2 = 0;
				myself.i_quest3 = 0;
				myself.i_quest4 = 0;
			}
			if( myself::IsNullCreature(myself.c_quest1) || myself.c_quest1.is_pc == 0 || myself.c_quest1.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest1)) || myself::DistFromMe(myself.c_quest1) > 1500 )
			{
				myself.i_quest1 = 0;
			}
			if( myself::IsNullCreature(myself.c_quest2) || myself.c_quest2.is_pc == 0 || myself.c_quest2.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest2)) || myself::DistFromMe(myself.c_quest2) > 1500 )
			{
				myself.i_quest2 = 0;
			}
			if( myself::IsNullCreature(myself.c_quest3) || myself.c_quest3.is_pc == 0 || myself.c_quest3.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest3)) || myself::DistFromMe(myself.c_quest3) > 1500 )
			{
				myself.i_quest3 = 0;
			}
			if( myself::IsNullCreature(myself.c_quest4) || myself.c_quest4.is_pc == 0 || myself.c_quest4.alive == 0 || myself::IsNullParty(myself::Party_GetCount(myself.c_quest4)) || myself::DistFromMe(myself.c_quest4) > 1500 )
			{
				myself.i_quest4 = 0;
			}
			myself::AddTimerEx(2002,1000);
		}
		if( timer_id == 3002 )
		{
			rlist0 = gg::GetRoomInfoList(LevelName);
			if( gg::IsNull(rlist0) )
			{
				myself::Say("!!! Error Room Created !!!");
			}
			else
			{
				room0 = rlist0::GetRoomInfo(0);
				if( test == 1 )
				{
					gg::Announce("Room Time Create" + myself::IntToStr(room0.time));
					i0 = ( ( gg::GetTimeOfDay() - room0.time ) / 60 );
					gg::Announce("Room Time Dif" + myself::IntToStr(i0));
					gg::Announce("Room Status " + myself::IntToStr(room0.status.value));
				}
				if( ( ( ( gg::GetTimeOfDay() - room0.time ) / 60 ) >= Timer && room0.status.value == 1 && myself.i_ai0 == 0 ) || ( ( ( gg::GetTimeOfDay() - myself.i_ai0 ) / 60 ) >= Timer && room0.status.value == 1 && myself.i_ai0 != 0 ) )
				{
					myself::AddTimerEx(3001,1000);
				}
				else if( room0.status.value == 0 )
				{
					i0 = myself::GetGlobalMap(GM_ID);
					if( i0 != -1 )
					{
						c0 = myself::GetCreatureFromIndex(i0);
						if( c0.alive != 0 )
						{
							myself::AddTimerEx(3001,100);
						}
					}
					else
					{
						myself::AddTimerEx(3001,( ( TimerKickAfteDie * 60 ) * 1000 ));
					}
				}
				else
				{
					myself::AddTimerEx(3002,60000);
				}
			}
		}
		if( timer_id == 3001 )
		{
			i0 = myself::GetGlobalMap(GM_ID1);
			if( i0 != -1 )
			{
				c0 = myself::GetCreatureFromIndex(i0);
				gg::SendScriptEvent(c0,0,0);
			}
			i1 = myself::GetGlobalMap(GM_ID2);
			if( i1 != -1 )
			{
				c1 = myself::GetCreatureFromIndex(i1);
				gg::SendScriptEvent(c1,0,0);
			}
			myself::InstantTeleportInMyTerritory(146832,-55904,-2776,100);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01a",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01b",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01c",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01d",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01e",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01f",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01g",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door01h",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02a",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02b",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_1a",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_1b",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_1c",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_1d",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_2a",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_2b",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_2c",1);
			myself::Castle_GateOpenClose2("Godad_fritezza_door02_2d",1);
			myself.i_quest0 = 0;
			myself.i_quest1 = 0;
			myself.i_quest2 = 0;
			myself.i_quest3 = 0;
			myself.i_quest4 = 0;
			myself.i_ai0 = 0;
		}
		if( timer_id == 2003 )
		{
			party0 = myself::GetParty(myself.c_quest0);
			myself::DeleteItem1(myself.c_quest0,8073,1);
			myself::TeleportParty(party0.id,173990,-75920,-5104,1000,0);
			party0 = myself::GetParty(myself.c_quest1);
			myself::DeleteItem1(myself.c_quest1,8073,1);
			myself::TeleportParty(party0.id,174074,-75957,-5104,1000,0);
			party0 = myself::GetParty(myself.c_quest2);
			myself::DeleteItem1(myself.c_quest2,8073,1);
			myself::TeleportParty(party0.id,173941,-76148,-5104,1000,0);
			party0 = myself::GetParty(myself.c_quest3);
			myself::DeleteItem1(myself.c_quest3,8073,1);
			myself::TeleportParty(party0.id,175383,-76084,-5104,1000,0);
			party0 = myself::GetParty(myself.c_quest4);
			myself::DeleteItem1(myself.c_quest4,8073,1);
			myself::TeleportParty(party0.id,172899,-76050,-5104,1000,0);
		}
	}

}
