{
	saved_FirstTime [1]

	saved_DeathToll [0]
	saved_DeathMax [2]

	Init[()
	{
		SetNationality(1);
		DropWeaponOnDeath (true);

		if (saved_FirstTime = 1)
		{
			PlayAnimation (7);
			SetHealth (256);
			ShowEntity(false);

			saved_FirstTime = 0;
		}
	}]

	OnDecay[()
	{
		if (GetID()="ori")
		{
			Boba = Level.GetEntity ("dori");
			Boba.saved_DeathMax = toInt(Boba.saved_DeathMax);

			if (Boba.saved_DeathToll < Boba.saved_DeathMax)
			{
				Boba.saved_DeathToll = Boba.saved_DeathToll +1;
				Boba.saved_DeathToll = toInt(Boba.saved_DeathToll);
				//MAKE YOUR RESPAWN FIRST.
				ReSpawn ();
			}
			else
			{
				Level.saved_FinalWaveToll = Level.saved_FinalWaveToll +1;
				Level.CheckDead5 ();
			}
		}
		if (GetID()="nori")
		{
			Boba = Level.GetEntity ("nori");
			Boba.saved_DeathMax = toInt(Boba.saved_DeathMax);

			if (Boba.saved_DeathToll < Boba.saved_DeathMax)
			{
				Boba.saved_DeathToll = Boba.saved_DeathToll +1;
				Boba.saved_DeathToll = toInt(Boba.saved_DeathToll);
				//MAKE YOUR RESPAWN FIRST.
				ReSpawn ();
			}
			else
			{
				Level.saved_FinalWaveToll = Level.saved_FinalWaveToll +1;
				Level.CheckDead5 ();
			}
		}if (GetID()="oin")
		{
			Boba = Level.GetEntity ("oin");
			Boba.saved_DeathMax = toInt(Boba.saved_DeathMax);

			if (Boba.saved_DeathToll < Boba.saved_DeathMax)
			{
				Boba.saved_DeathToll = Boba.saved_DeathToll +1;
				Boba.saved_DeathToll = toInt(Boba.saved_DeathToll);
				//MAKE YOUR RESPAWN FIRST.
				ReSpawn ();
			}
			else
			{
				Level.saved_FinalWaveToll = Level.saved_FinalWaveToll +1;
				Level.CheckDead5 ();
			}
		}if (GetID()="gloin")
		{
			gloin = Level.GetEntity ("gloin");
			gloin.saved_DeathMax = toInt(gloin.saved_DeathMax);

			if (gloin.saved_DeathToll < gloin.saved_DeathMax)
			{
				gloin.saved_DeathToll = gloin.saved_DeathToll +1;
				gloin.saved_DeathToll = toInt(gloin.saved_DeathToll);
				//MAKE YOUR RESPAWN FIRST.
			}
			else
			{
				Level.saved_FinalWaveToll = Level.saved_FinalWaveToll +1;
				Level.CheckDead5 ();
			}
		}
	}]


	ReSpawn [()
	{
		who = GetID();

		xpos = Random (18841, 30592);
		ypos = 27315;
		zpos = -647;

		SetPosition (xpos, ypos, zpos);
		SetDead (false);
		SetHealth (256);
		SetRunning ();
		PlayAnimation (0);

		Rgun = Random(0, 1);
		switch(Rgun)
		{
			case 0
			{
				GiveWeapon (53);
			}
			case 1
			{
				GiveWeapon (53);
			}
		}
		GoPatrol ();
	}]

	GoPatrol [()
	{
		Level.Log ("-->Inside GoPatrol.");
		Level.Log ("       who: " # GetID());
		SetAttackDistance (40, 6);
		SetState_Patrol (1);
		SetLineOfSight(0);
		SetWander (0);
		SetWalkToDist( Random(7, 8) );
		Level.Log ("        out of Gopatrol");
	}]

	ShowMe[()
	{
		ShowEntity(true);
		Rgun = Random(0, 1);
		switch(Rgun)
		{
			case 0
			{
				GiveWeapon (53);
			}
			case 1
			{
				GiveWeapon (53);
			}
		}
	}]

}
