{
	saved_FirstTime [1]

	saved_DeathToll [0]
	saved_DeathMax [2]
	
	saved_pathtaken [0]

	Init [()
	{
		SetNationality(1);

		if (saved_FirstTime = 1)
		{
			Rgun = Random(0, 1);
			switch(Rgun)
			{
				case 0
				{
					GiveWeapon (53);
				}
				case 1
				{
					GiveWeapon (56);
				}
			}
			PlayAnimation (7);
			SetRunning();
			SetHealth (256);

			saved_FirstTime = 0;
		}

		DropWeaponOnDeath (false);

	}]

	GoPatrol [()
	{
		who = GetID();
		switch (who)
		{
			case "wave1a"
			{
				FollowPath("wav1_path", 0);
				FollowPathCallback(127, "Killem");	
			}
			case "wave1b"
			{
				path = Random(0,1);
				switch (path)
				{
					case 0	
					{
						saved_pathtaken = 0;
						FollowPath("wav2_patha", 0);
						FollowPathCallback(127, "Killem");
					}
					case 1
					{
						saved_pathtaken = 1;
						FollowPath("wav2_pathb", 0);
						FollowPathCallback(127, "Killem");	
					}
				}	
			}
			case "wave1c"
			{
				FollowPath("wav3_path", 0);
				FollowPathCallback(127, "Killem");	
			}
		}	
	}]
	
	Killem [()
	{
		who = GetID();
		switch (who)
		{
			case "wave1a"
			{
				Rdom = Random(3, 4, 5);
				SetRunning();
				SetAttackDistance (11, 6);
				SetState_Patrol (0);
				SetLineOfSight(0);
				SetWander (0);
				Delay(Rdom, 10);		
			}
			case "wave1c"
			{
				Rdom = Random(3, 4, 5);
				SetRunning();
				SetAttackDistance (11, 6);
				SetState_Patrol (0);
				SetLineOfSight(0);
				SetWander (0);
				Delay(Rdom, 10);		
			}
			case "wave1b"
			{
				if(saved_pathtaken = 0)
				{ 	
					Rdom = Random(3, 4, 5);
					SetCrouching();
					PlayAnimation(12);
					Attack(Level.GetPlayer());
					TurnTo(Level.GetPlayer());
					SetAttackDistance (11, 6);
					// SetState_Patrol (0);
					SetLineOfSight(0);
					SetWander (0);
					Delay(Rdom, 10);		
				}
				if(saved_pathtaken = 1)
				{
					Rdom = Random(3, 4, 5);
					SetRunning();
					PlayAnimation (7);
					SetAttackDistance (11, 6);
					SetState_Patrol (0);
					SetLineOfSight(0);
					SetWander (0);
					Delay(Rdom, 10);	
				}
			}	
		}
	}]
	
	Hidem[()
	{
		who = GetID();
		switch (who)
		{    
			case "wave1a"
			{
				SetCrouching();
				SetState_Idle();
				Rdom = Random(3, 4);
				PlayAnimation(10);
				Delay(Rdom, 20); 
			}
			case "wave1c"
			{
				SetCrouching();
				SetState_Idle();
				Rdom = Random(3, 4);
				PlayAnimation(10);
				Delay(Rdom, 20); 	
			}
			case "wave1b"
			{
				if(saved_pathtaken = 0)
				{
					SetCrouching();
					SetState_Idle();
					Rdom = Random(3, 4);
					PlayAnimation(10);
					Delay(Rdom, 20); 		
				}
				if(saved_pathtaken = 1)
				{
					SetCrouching();
					SetState_Idle();
					Rdom = Random(3, 4);
					PlayAnimation(10);
					Delay(Rdom, 20);	
				}	
			}
			
		}
	}]
	

	ReSpawn [()
	{

		who = GetID();

		xpos = Random (24704, 27733);
		ypos = 23736;
		zpos = -647;

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

		Rgun = Random(0, 1);
		switch(Rgun)
		{
			case 0
			{
				GiveWeapon (53);
			}
			case 1
			{
				GiveWeapon (56);
			}
		}
		GoPatrol ();
	}]
	
	DelayReached[(x)
	{
		if(x = 10)
		{
			if(not self.IsDead())
			{
				Hidem();	
			}	
		}
		if(x = 20)
		{
			if(not self.IsDead())
			{
				Killem ();
			}
		}	
	}]

	OnDecay [()
	{
		if (GetID()="wave1a" )
		{
			Boba = Level.GetEntity ("wave1a");
			Boba.saved_DeathMax = toInt(Boba.saved_DeathMax);
			if (Boba.saved_DeathToll < Boba.saved_DeathMax)
			{
				Level.Log("Boba is dead");
				Boba.saved_DeathToll = Boba.saved_DeathToll +1;
				Boba.saved_DeathToll = toInt(Boba.saved_DeathToll);
				Boba.ReSpawn ();
			}
			else
			{

				Level.saved_Wave1Toll = Level.saved_Wave1Toll +1;
				Level.CheckDead ();
				Level.Log ("	#### CheckDead3####");
				Level.CheckDead3 ();
			}
		}
		if (GetID()= "wave1b" )
		{
			Bobb = Level.GetEntity ("wave1b");
			Bobb.saved_DeathMax = toInt(Bobb.saved_DeathMax);
			if (Bobb.saved_DeathToll < Bobb.saved_DeathMax)
			{
				Level.Log("BobB is dead");
				Bobb.saved_DeathToll = Bobb.saved_DeathToll +1;
				Bobb.saved_DeathToll = toInt(Bobb.saved_DeathToll);
				Bobb.ReSpawn ();
			}
			else
			{
				Level.saved_Wave1Toll = Level.saved_Wave1Toll +1;
				Level.CheckDead ();
				Level.Log ("	#### CheckDead3####");
				Level.CheckDead3 ();
			}
		}


		if (GetID() = "wave1c")
		{
			Bobc = Level.GetEntity ("wave1c");
			Bobc.saved_DeathMax = toInt(Bobc.saved_DeathMax);
			if (Bobc.saved_DeathToll < Bobc.saved_DeathMax)
			{
				Level.Log("Bobc is dead");
				Bobc.saved_DeathToll = Bobc.saved_DeathToll +1;
				Bobc.saved_DeathToll = toInt(Bobc.saved_DeathToll);
				Bobc.ReSpawn ();
			}
			else
			{

				Level.saved_Wave1Toll = Level.saved_Wave1Toll +1;
				Level.CheckDead ();
				Level.Log ("	#### CheckDead3####");
				Level.CheckDead3 ();
			}
		}
	}]
}