-----------------------------------------------------------------------------
-- Stage 3-4
-----------------------------------------------------------------------------
-- GLOBALS

G_MAX_SPEED = 3;

--Create a flock of birds. For now, this works best for a Flying V formation, following a path along the -x axis.
function CreateFlock(birdType, numBirds, path, yOffsetMin, yOffsetMax, flockType, speedFactor)
	local alt = 1;
	local offset = 0;
	if flockType == "V" then
		s = 2;
	else
		end   -- end if statement

	for i=0, numBirds-1, 1 do
		entGoose01=EntGame.SpawnBirdOnPath(birdType, path, 0, (s*offset), math.random(yOffsetMin, yOffsetMax), alt*(s*offset), speedFactor);
		Animal.FaceEntity(entGoose01, entCamera);
		alt = alt * (-1);
		if (i - math.floor(i/offset) * offset) == 0 then
			offset = offset + s;
		elseif  i == 0 then
			offset = offset + s;
		else
			end --end if statement
		end -- end for loop
	end;

--Create a group of animals Sharing the same path, with some time and path offset
function CreateGroup(animalType, numAnimals, path, spawnDelayMin, spawnDelayMax, speedFactor)
	for i=0, numAnimals, 1 do
		Script.WaitSec( math.random(spawnDelayMin, spawnDelayMax) );
		if speedFactor == "random" then
			entAnimal01=EntGame.SpawnAnimalOnPath(	animalType, path, 0, ST_WPT_RUN, 0,
												math.random(-1.5, 1.5),
												math.random(-1.5,1.5),
												math.random(0.5,1.0) );
		else
			entAnimal01=EntGame.SpawnAnimalOnPath(  animalType, path, 0, ST_WPT_RUN, 0,
												math.random(-1.5, 1.5),
												math.random(-1.5, 1.5),
												speedFactor );
		end; --end if statement

		Animal.FaceEntity(entAnimal01, entCamera);
		end; --end for loop
	end;

-----------------------------------------------------------------------------

function PostStage()

    EntGame.EnablePlayerControl(false);
    EntGame.ClearFlag(GF_READYTOSTART);
    EntGame.BindCameraToEntity("IntroCamera");

    Sound.Release(smpJeepAcceleration);
	Sound.Release(smpJeepIdle);
	Sound.Release(smpJeepOff);
	
    end;

-----------------------------------------------------------------------------
-- Setup

function Setup()
    -- turn on the "Game running" menu - may not be needed for this game
    EntGame.PushMenu("MenuGameRunning");

    -- load world
    SetupWorld("Maps\\WorldTrenchRun\\TrenchRunCommon.ini", "Maps\\Stage3-4\\Stage3-4.ini","","");
    EntGame.CreatePlayerEntities();

    EntGame.SetGlobalDustColorInitial(1.0, 0.81, .75, .55);
    EntGame.SetGlobalDustColorFinal  (0.0, 0.81, .75, .55);
	
    EntGame.SetStageTimer(191);
 
    -- load sounds
    smpJeepAcceleration  = Sound.Load("Sound\\Environment\\JeepAcceleration.wav");    
	smpJeepOff 			 = Sound.Load("Sound\\Environment\\JeepOff.wav");
	       
	EntGame.LoadAnimal(AID_RHINO_M);
	EntGame.LoadAnimal(AID_KUDU_M);
	EntGame.LoadAnimal(AID_KUDU_F);
	EntGame.LoadAnimal(AID_SPURWINGGOOSE_M);
	EntGame.LoadAnimal(AID_MEERKAT_M);

	StartupSequence("Music\\Call The.ogg");
	
    end;

-----------------------------------------------------------------------------
function Part1()

	Camera.JumpToWaypoint(entCamera, "CamWptBB");
	Camera.SetSpeed(entCamera, 0.0, 0.1);

	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path0a", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 0, ST_WPT_RUN, 0, 1, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path0a", 0, ST_WPT_RUN, 0, -1, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path0a", 0, ST_WPT_RUN, 0, -1, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path0a", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 0, ST_WPT_RUN, 0, 1, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path0a", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path0a", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 0, ST_WPT_RUN, 0, 1, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path0", 0, ST_WPT_RUN, 0, -2, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path0", 0, ST_WPT_RUN, 0, 1, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(2);
	
	a = EntGame.SpawnAnimalOnPath(AID_RHINO_M, "Path2", 0, ST_WPT_RUN, 0, 0, 0, 1);
	Animal.FaceEntity(a, entCamera);
	Animal.SetChargeWhenShot(a, true);
	Animal.SetAttackType(a, ATK_STATIC);
	Animal.SetStaticAttackDist(a, 6.7);
	Animal.SetPostAttackRand(a, false);
	Animal.SetPostAttackDir(a, 90);
	
	Script.WaitSec(3);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 1, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path2", 1, ST_WPT_RUN, 0, -1, 1, 0.5 * G_MAX_SPEED);
	
	end;
---------------------------------------------------------------------------------------------------
function Part2()

	--DRIVE TO CLEARING
	Camera.SetSpeed(entCamera, 8.0, 1.0);

	--Start Engine
	Sound.Play(smpJeepAcceleration, 1, DS2_VOLMAX, DS2_CENTER);
	
	Script.WaitSec(8);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(.5);	
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path2", 0, ST_WPT_RUN, 0, -2, -2, 0.5 * G_MAX_SPEED);
	Script.WaitSec(.5);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path2", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 0, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 0, ST_WPT_RUN, 0, -3, 3, 0.5 * G_MAX_SPEED);

	Camera.SetSpeed(entCamera, 0.0, 0.1);

	--Jeep Ignition off	
    Sound.Play(smpJeepOff, 1, DS2_VOLMAX, DS2_CENTER);
    
	Script.WaitSec(1.5);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path2", 0, ST_WPT_RUN, 0, -3, 3, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1.5);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path2", 0, ST_WPT_RUN, 0, -3, 3, 0.5 * G_MAX_SPEED);
	Script.WaitSec(11.5);

	end;

------------------------------------------------------------------------------------------------
function Part3()

	--DRIVE TO MEERKAT AREA
	Camera.SetSpeed(entCamera, 8.0, 1.0);
	
	--Start Engine
	Sound.Play(smpJeepAcceleration, 1, DS2_VOLMAX, DS2_CENTER);
	
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path3", 1, ST_WPT_RUN, 0, 1.5, 1.5, 1.2);
	Script.WaitSec(1);
	
	--PAN LEFT
	Camera.SetPanOffset(entCamera, -20, .5);
	
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path3", 1, ST_WPT_RUN, 0, 2.5, 2.5, 1.2);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path3", 1, ST_WPT_RUN, 0, 0, 0, 1.2);
		
	Script.WaitSec(2);
	
	--PAN CENTER
	Camera.SetPanOffset(entCamera, 0, 2);
	
	Script.WaitSec(2);
	EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path1", 1, ST_WPT_RUN, 0, -2, 2, 0.5 * G_MAX_SPEED);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 1, ST_WPT_RUN, 0, 0, 0, 0.5 * G_MAX_SPEED);
	Script.WaitSec(2);
	EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path1", 1, ST_WPT_RUN, 0, -1.5, 1.5, 0.5 * G_MAX_SPEED);

	Script.WaitSec(5);
	a = EntGame.SpawnAnimalOnPath(AID_RHINO_M, "Path41", 0, ST_WPT_WALK, 0, -2, -2, 1.8);
	Animal.EnableFear(a, false);
	Entity.SetName(a, "Rhino2");
	
	Script.WaitSec(5);
		
	a = EntGame.SpawnAnimalOnPath(AID_RHINO_M, "Path41", 0, ST_WPT_WALK, 0, 0, 0, 1.5);
	Animal.EnableFear(a, false);
	Entity.SetName(a, "Rhino1");
	
	Script.WaitSec(4);
	Run("Rhino2");
	Script.WaitSec(1);
	Run("Rhino1");
	Script.WaitSec(4);
	
    end;
-----------------------------------------------------------------------------
function Part4()

	--for debug
	--Camera.JumpToWaypoint(entCamera, "CamWptOO");

	Camera.SetSpeed(entCamera, 0.0, 0.5);

	--Jeep Ignition off	
    Sound.Play(smpJeepOff, 1, DS2_VOLMAX, DS2_CENTER);
    
	Script.WaitSec(2);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path20", 1, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path20", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 2, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 4, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 3, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 0, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path20", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);

	end;

-----------------------------------------------------------------------------------------------------
function Part5()

	--ZOOM IN
	--Camera.SetFov(entCamera, 20, 0.5);

	Script.WaitSec(4);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 2, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 1, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 2, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(2);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 3, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 0, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 2, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 1, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 2, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 4, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 3, ST_POPUP, 3, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);

	end;
----------------------------------------------------------------------------------------------------
function Part6()

	--ZOOM OUT & PAN RIGHT
	Camera.SetPanOffset(entCamera, 5, 1.0);
	--Camera.SetFov(entCamera, 15, 1.0);

	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 4, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 4, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.25);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(2);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 0, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 1, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(2);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 4, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.25);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path24", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);

	end;
-------------------------------------------------------------------------------------------------------
function Part7()

	--PAN CENTER
	Camera.SetPanOffset(entCamera, 0, 1.0);
	--Camera.SetFov(entCamera, 60, 1.0);
	Camera.SetSpeed(entCamera, 10, 0.1);

	--Start Engine
	Sound.Play(smpJeepAcceleration, 1, DS2_VOLMAX, DS2_CENTER);
	
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path22", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path21", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(1.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path42", 0, ST_WPT_RUN, 0, 0, 0, 1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 0, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 1, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path42", 0, ST_WPT_RUN, 0, 0, 0, 1.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 2, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
	entMeerkat=EntGame.SpawnAnimalOnPath( AID_MEERKAT_M, "Path25", 3, ST_POPUP, 2, 0, 0, G_MAX_SPEED );
	Animal.FaceEntity(entMeerkat, entCamera);
	Animal.SetElvOffset(entMeerkat, -.1);
	Script.WaitSec(0.5);
		
	end;
-----------------------------------------------------------------------------
function Part8()

	Script.WaitSec(1.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path42", 0, ST_WPT_RUN, 0, 0, 0, 1.5);
	Script.WaitSec(.5);
	CreateFlock(AID_SPURWINGGOOSE_M, 7, "Path42", 0.0, 6.0, "V", 1.5);
	Script.WaitSec(3);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path4", 0, ST_WPT_RUN, 0, 0, 0, 0.8 * G_MAX_SPEED );
	Script.WaitSec(0.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path4", 0, ST_WPT_RUN, 0, 0, 0, 0.8 * G_MAX_SPEED );
	Script.WaitSec(0.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path4", 0, ST_WPT_RUN, 0, 0, 0, 0.8 * G_MAX_SPEED );
	Script.WaitSec(5);
	
	--ACCELERATE
	Camera.SetSpeed(entCamera, 5.0, 0.1);
	Script.WaitSec(2);
	Camera.SetSpeed(entCamera, 8.0, 0.1);
	
	Script.WaitSec(1);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path43", 0, ST_WPT_WALK, 0, 0, 0, 1.1);
	Animal.EnableFear(a, false);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path43", 1, ST_WPT_WALK, 0, 0, 0, 1.3);
	Animal.EnableFear(a, false);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path43", 2, ST_WPT_WALK, 0, 0, 0, 1.5);
	Animal.EnableFear(a, false);
	
	Script.WaitSec(3);
	EntGame.SpawnAnimalOnPath(AID_RHINO_M, "Path44", 0, ST_WPT_WALK, 15, 0, 0, 1.2);
		
	Script.WaitSec(1);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_F, "Path45", 0, ST_WPT_RUN, 0, 0, 0, .6);
	Animal.EnableFear(a, false);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path30a", 0, ST_WPT_RUN, 0, 0, 0, G_MAX_SPEED );
	Script.WaitSec(1);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path45", 2, ST_WPT_RUN, 0, 0, 0, .6);
	Animal.EnableFear(a, false);
	a = EntGame.SpawnAnimalOnPath(AID_KUDU_M, "Path45", 1, ST_WPT_RUN, 0, 0, 0, .6);
	Animal.EnableFear(a, false);
	EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path30a", 0, ST_WPT_RUN, 0, 2, 0, G_MAX_SPEED );
	Script.WaitSec(1.5);
	EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path30a", 0, ST_WPT_RUN, 0, 0, 0, G_MAX_SPEED );
	Script.WaitSec(9.5);
	
	entKudu0=EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path37", 0, ST_WPT_RUN, 0,  0,  0, G_MAX_SPEED );
	entKudu1=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path37", 0, ST_WPT_RUN, 0, -4,  0, G_MAX_SPEED );
	entKudu2=EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path37", 0, ST_WPT_RUN, 0, -8,  0, G_MAX_SPEED );
	entKudu3=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path37", 0, ST_WPT_RUN, 0,  0, -4, G_MAX_SPEED );
	entKudu4=EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path37", 0, ST_WPT_RUN, 0, -4,  4, G_MAX_SPEED );
	
	Script.WaitSec(4);
	
	end;
-----------------------------------------------------------------------------
function Part9()

	--debug
	--Camera.JumpToWaypoint(entCamera, "CamWptYY");

	Camera.SetSpeed(entCamera, 0.0, .5);

	--Jeep Ignition off	
    Sound.Play(smpJeepOff, 1, DS2_VOLMAX, DS2_CENTER);

	Script.WaitSec(2);
	CreateFlock(AID_SPURWINGGOOSE_M, 7, "Path38", 13.0, 17.0, "V", G_MAX_SPEED );
	Script.WaitSec(3);

	entRhino=EntGame.SpawnAnimalOnPath( AID_RHINO_M, "Path30", 0, ST_WPT_CHARGE, 0, 0, 0, G_MAX_SPEED);
	Animal.FaceEntity(entRhino, entCamera);
	Animal.SetAttackType(entRhino, ATK_STRAFE);
	Animal.SetStrafeAttackDist(entRhino, 6);
	Animal.SetPostAttackRand(entRhino, false);
	Animal.SetPostAttackDir(entRhino, -90);

	Script.WaitSec(2);
	CreateFlock(AID_SPURWINGGOOSE_M, 6, "Path38", 13.0, 17.0, "V", G_MAX_SPEED );
	Script.WaitSec(2);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path34", 0, ST_WPT_RUN, 0, 0, 1, G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(1.25);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path33", 1, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(1.5);

	--LOOK BEHIND JEEP
	Camera.SetPanOffset(entCamera, -180, .5);
	Camera.SetTiltOffset(entCamera, 0, 1.0);
	
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path33", 1, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path34", 0, ST_WPT_RUN, 0, 0, 1, G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path37", 0, ST_WPT_RUN, 0, 1, 0, G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);

	--Start Engine
	Sound.Play(smpJeepAcceleration, 1, DS2_VOLMAX, DS2_CENTER);
	
	--JEEP BEGINS TO MOVE
	--ACCELERATION
	Camera.SetSpeed(entCamera, 1, 0.1);
	Script.WaitSec(.50);
	Camera.SetSpeed(entCamera, 2, 0.1);
	Script.WaitSec(.25);
	
	Voice.PlayVox(VOX_STAMPEDE_B, DS2_VOLMAX);
		
	Camera.SetSpeed(entCamera, 3, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 4, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 5, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 6, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 7, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 8, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 9, 0.1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 10, 0.1);
	
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path34", 0, ST_WPT_RUN, 0, 0, 1, G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(1);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path33", 1, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(5);

	--DECELERATES SLIGHTLY
	Camera.SetPanOffset(entCamera, -360, 8.0);
	Camera.SetSpeed(entCamera, 9, .1);
	Script.WaitSec(.25);
	Camera.SetSpeed(entCamera, 8, .1);
	Script.WaitSec(.25);	
	Camera.SetSpeed(entCamera, 7, .1);
	
	Script.WaitSec(5.25);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path30", 3, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(0.25);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_F, "Path37", 1, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(2.5);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path52", 0, ST_WPT_RUN, 0, 1.5, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(5);
	entKudu=EntGame.SpawnAnimalOnPath( AID_KUDU_M, "Path54", 0, ST_WPT_RUN, 0, 1.5, 1, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);
	Script.WaitSec(0.5);
	entKudu=EntGame.SpawnAnimalOnPath( AID_RHINO_M, "Path54", 2, ST_WPT_RUN, 0, 1, 0, 0.7*G_MAX_SPEED);
	Animal.FaceEntity(entKudu, entCamera);

	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 0, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, -1.5, 1.5, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 0, -2, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 1.5, 1.5, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, -2, -2, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, .5, -1.5, 1.0);
	Script.WaitSec(.5);	
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 0, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, -1.5, 1.5, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 0, -2, 1.0);
	Script.WaitSec(5.0);
		
	--DECELERATION
	Camera.SetSpeed(entCamera, 9, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 8, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 7, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 6, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 5, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 4, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 3, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 2, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 1, 0.1);
	Script.WaitSec(.1);
	Camera.SetSpeed(entCamera, 0, 0.1);
	--STOP VEHICLE

	--Jeep Ignition off	
    Sound.Play(smpJeepOff, 1, DS2_VOLMAX, DS2_CENTER);
    
    EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, 1.5, 1.5, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, -2, -2, 0, 1.0);
	Script.WaitSec(.5);
	EntGame.SpawnBirdOnPath(AID_SPURWINGGOOSE_M, "Path40", 0, 0, .5, -1.5, 1.0);
	
	end;
------------------------------------------------------------------------------
-- Main entry point

Setup();

Part1();
Part2();
Part3();
Part4();
Part5();
Part6();
Part7();
Part8();
Part9();
