{
	saved_FirstTime[1]
	Init[()
	{
		if(saved_FirstTime = 1)
		{
			SetNationality(0); SetCrouching(); PlayAnimation(8); GiveWeapon(43); SetInvulnerable(true);
			PlayAnimation(7);
			saved_FirstTime = 0;
		}
	}]

	DelayReached[(s)
	{
		if(s = 1)
		{
			TurnToLocation(30880,12688); PlaySound(87);
		}

		if(s = 2)
		{
			joey = Level.GetEntity("joe");
			TurnToLocation(6169,18662); TurnTo(joey); Attack(joey);
		}
		if(s = 3)
		{
			Level.Victory();
			Delay(4, 4);
		}
		if(s = 4)
		{
			Level.LoadLevel("S_BOM1_Foy");
		}
	}]

	TaskMaster[()
	{
		if(Level.saved_CurObjective = 2)
		{
			AdvanceObjectives(1);
			AdvanceObjectives(0);
		}
		else
		{
			AdvanceObjectives(1);
		}
	}]

	AdvanceObjectives[ (hideLast)
	{
		if( Level.saved_CurObjective < Level.saved_NumObjectives )
		{
			NextObj = (Level.saved_CurObjective+1);
			DropObj = (Level.saved_CurObjective-2);

			Level.ObjectiveComplete( Level.saved_CurObjective );

			if( NextObj < Level.saved_NumObjectives )
			{
				if( hideLast = 1 )
				{
					Level.SetObjectiveActive( Level.saved_CurObjective, false );
				}

				Level.SetObjectiveActive( NextObj, true );

				if( Level.saved_CurObjective > 1 )
				{
					Level.SetObjectiveActive( NextObj, true );
					Level.SetObjectiveActive( DropObj, false );
				}
			}
			Level.saved_CurObjective = NextObj;
		}
	}]

	Charge[()
	{
		SetRunning(); PlayAnimation(0); FollowPath("Foley_Charge", 0); FollowPathCallback(4, "Duck");
	}]

	Duck[()
	{
		SetCrouching(); PlayAnimation(8); Delay(2, 1);
	}]

	ClearOut[()
	{
		SetPosition(11392,12928,192); FollowPath("Foley_CoverMe"); SetRunning(); PlayAnimation(0); FollowPathCallback(127,"Delay",4,2);
	}]

	ClearBuilding[()
	{
		SetState_Patrol(0);
		SetAttackDistance(14, 2);
		SetLineOfSight(1,180); 
		SetRunning();
		FollowPath("Foley_ClearBuilding",0); 
		FollowPathCallback(127, "ClearReady");
	}]

	ClearReady[()
	{
		SetState_Idle();
		StopFollowingPath();
		SetCrouching();
		PlayAnimation(8);
	}]

	GoGraveyard[()
	{
		StopFollowingPath();
		SetState_Patrol(0);
		SetAttackDistance(14, 2);
		SetLineOfSight(1,120);
		PlayAnimation(0);
		SetRunning();
		FollowPath("Foley_Follow_1",0);
		FollowPathCallback(5,"GoIdle");
		FollowPathCallback(127,"CrouchReady");
	}]

	ToFlak[()
	{
		StopFollowingPath();
		SetPosition(18803,39347);
		SetCrouching();
		PlayAnimation(8);
	}]

	FlakFollow[()
	{
		SetState_Idle();
		FollowPath("Foley_Follow_2");
		SetRunning();
		PlayAnimation(0);
		FollowPathCallback(127, "TurnNFight");
	}]

	TurnNFight[()
	{
		StopFollowingPath();
		SetState_Patrol(0);
		SetAttackDistance(14, 2);
		SetLineOfSight(1,120);
	}]

	WarpEnd[()
	{
		SetPosition(30080,25728,256);
		FollowPath("Foley_Follow_3",0);
	}]

	VicPath[()
	{
		DoKill("rusher");
		StopFollowingPath();
		FollowPath("Foley_Follow_4");
		SetState_Idle();
		FollowPathCallback(127, "VicSpeech");
	}]

	VicSpeech[()
	{
		StopFollowingPath();
		TurnTo( (Level.GetPlayer()) );
		Level.GetPlayer().PlaySound(89);
		Delay(10, 3);
	}]

	DoKill[( who)
	{
		dude = Level.GetEntity(who);
		if( not dude.IsDead() )
		{
			dude.Kill();
		}
	}]
	
	CrouchReady[()
	{
		Level.Log("FOLEY CROUCHREADY");
		StopFollowingPath();
//		SetState_Idle();
		SetCrouching();
		SetState_Patrol(0);
		SetAttackDistance(14,4);
		SetLineOfSight(1,190);
		SetWander(0);
	}]
	
	GoIdle[()
	{
		SetState_Idle();	
	}]
}