-----------------------------------------------------------------------------
-- Site 19 - Night Cabin Stage
-----------------------------------------------------------------------------
-- PostStage

function PostStage()
    -- do this stuff first, tells the game that the round is over
    EntGame.EnablePlayerControl(false);
    EntGame.ClearFlag(GF_READYTOSTART);
    EntGame.BindCameraToEntity("IntroCamera");
    
    Sound.Release(sfxHowl);
    Sound.Release(sfxCaveGrowl);
    Sound.Release(sfxWoodBreak);
    Sound.Release(sfxRoar);
	
    end;

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

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

    -- load world
    SetupWorld("Maps\\Site19\\Site19.ini", "","","");
    EntGame.CreatePlayerEntities();
    
    -- do any setup that is specifically for testing.
    if (EntGame.TestingLevels()) then
        Testing();
        end;

    -- set stagel parameters
    sfxHowl= Sound.Load("Sound\\Animals\\CoyoteHowl.wav");
    sfxCaveGrowl= Sound.Load("Sound\\Animals\\BearGrowlInCave2.wav");
    sfxWoodBreak= Sound.Load("Sound\\Environment\\WoodBreak1.wav");
    sfxRoar= Sound.Load("Sound\\Animals\\BearRoarLong2.wav");
    
    EntGame.SetGlobalDustColorInitial(0.15, 1.0, 1.0, 1.0);
    EntGame.SetGlobalDustColorFinal  (0.0, 1.0, 1.0, 1.0);
    
    EntGame.SetStageTimer(170);
 
    -- cache animals
    EntGame.LoadAnimal(AID_COYOTE); 
    EntGame.LoadAnimal(AID_WOLVERINE);
    EntGame.LoadAnimal(AID_GROUSE);
    EntGame.LoadAnimal(AID_GRIZZLY_BEAR);
    EntGame.LoadAnimal(AID_SALMON);
	
    -- setup tournament logic    
    EntGame.StagePrepare();

    -- show the scene from the intro camera
    EntGame.BindCameraToEntity("IntroCamera");
    
	-- tell the game the world has loaded
    Entity.GameEventPre(Game.GetRootEntity(), GE_WORLDLOADED, 0);	

    -- wait until the intro dialog is dispatched
    while (EntGame.GetFlag(GF_READYTOSTART) == false) do
        Script.WaitFrame(1);
        end;

    -- do a fade out        
    FadeOut();
    Script.WaitSec(0.5);    
    end;

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

function Intro()

    EntGame.PlaySong("Music\\KickinTrash.ogg");

	entRoot = Game.GetRootEntity();
    entAniObj = Entity.FindName(entRoot, "AniObjTest");
    entFishLauncher1 = Entity.FindName(entRoot, "FishLauncher1");   
    FishLauncher.Disable(entFishLauncher1);
    
    LookatPoint1 = Entity.FindName(entRoot, "AnimalWpt101");
    a=EntGame.SpawnAnimalStaggerCtl(AID_WOLVERINE, "IntroPath01", 0, ST_GRAZING, 15, 0, 0, 1, false);    
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);
    Animal.FaceEntity(a,LookatPoint1);
    Animal.SetElvOffset(a,0.47);
    Animal.SetCoinMode(a, CM_SPAWNREL);

    LookatPoint2 = Entity.FindName(entRoot, "AnimalWpt103");
    a=EntGame.SpawnAnimalStaggerCtl(AID_COYOTE, "IntroPath02", WPT_0, ST_GRAZING, 4+3, 0, 0, 1, false);  
    Animal.FaceEntity(a,LookatPoint2);
    
    LookatPoint3 = Entity.FindName(entRoot, "AnimalWpt105");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "IntroPath03", 0, ST_WPT_WALK, 3+4, 0, 0, .5);    
    Animal.FaceEntity(a,LookatPoint3);
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "IntroPath03", 0, ST_GRAZING, 3+6,-1.5, 3, .5);    
    Animal.FaceEntity(a,LookatPoint3);
            
    -- set the camera to a cool spot, then fade in
    EntGame.BindCameraToEntity("CountdownCamera3");
    FadeIn();    
    Script.WaitSec(1.0); 
    
    -- "3"
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_3, 0);   
    Script.WaitSec(1.0);
    
    -- "2"
    EntGame.BindCameraToEntity("CountdownCamera2");
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_2, 0);   
    Script.WaitSec(1.0);
    
    -- "1"
    EntGame.BindCameraToEntity("CountdownCamera1");
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_1, 0);   
    Script.WaitSec(1.0);
  
    -- "HUNT!"
    entCamera = Entity.FindName(entRoot, "MainCamera");
    Camera.JumpToWaypoint(entCamera, "CamWptAA");
    Camera.SetSpeed(entCamera, 0.0, 0.01);    
    EntGame.BindCameraToEntity(entCamera);
    EntGame.BindInputToEntity("Player1");  
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_HUNT, 0);     
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_START, 0);    
    end;

---------------------------------------------------------------------------------------------------------------------
-- Use this function for overriding various game parameters (i.e. weapon availability, etc.)
function Testing()
    EntGame.SetPlayerWeapon(0, WS_PISTOL, 	    WID_PISTOL_4);
    EntGame.SetPlayerWeapon(0, WS_SINGLE_RIFLE, WID_SINGLE_RIFLE_5);
    EntGame.SetPlayerWeapon(0, WS_SHOTGUN,	    WID_SHOTGUN_4);	
    EntGame.SetPlayerWeapon(0, WS_AUTO_RIFLE, 	WID_AUTO_RIFLE_4);	
    EntGame.SetPlayerWeapon(0, WS_BOW, 		    WID_BOW_3);
    EntGame.ResetWeaponIcons();
    end;

---------------------------------------------------------------------------------------------------------------------
function Part1()
        
    Script.WaitSec(0.5);
    --Sound.Play(sfxHowl, 1, 1, DS2_CENTER);

    Script.WaitSec(6);
    
    Camera.SetSpeed(entCamera, 1.50, 0.5); 
 
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt118");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath01", 0, ST_GRAZING, 45, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetElvOffset(a,1.6);
    Animal.SetCoinMode(a, CM_SPAWNREL);
 
    --Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt116");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "CoyoteRunPath01", 0, ST_WPT_WALK, 6, 0, 0, 1);   
    Animal.FaceEntity(a,LookatPoint);
    Script.WaitSec(2.2);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt116");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath01", 0, ST_WPT_RUN, 3, 0, 0, 1);   
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(1);
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath01", 0, ST_WPT_RUN, 3, 2, 0, .05);   
    Animal.FaceEntity(a,LookatPoint);
 
    Script.WaitSec(5);
    Camera.SetSpeed(entCamera, 1.30, 01.0); 
	
	--POWERUP
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt120");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath02", 0, ST_WPT_RUN, 5, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
	EntGame.CreateAnimalPowerUp(a, PID_WILEY_VISION_100);
         
    Script.WaitSec(2);
         
    Camera.StopAtWaypoint(entCamera, "CamWptEE");
         
    Script.WaitSec(2);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt107");
	
	--PREDATOR #1
    Predator1 = EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path1", 0, ST_WPT_RUN, 5, 0, 0, .8);    
    Animal.FaceEntity(Predator1, LookatPoint);
	Animal.SetAutoChargeDist(Predator1, 6);
	Animal.SetAttackType(Predator1, ATK_STRAFE);
	Animal.SetStrafeAttackDist(Predator1, 4);
	Animal.SetStrafeAttackDelay(Predator1, 0.50);
 	Entity.SetName(Predator1, "Predator1");
	
    Script.WaitSec(3);
            
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt120");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath02", 0, ST_WPT_RUN, 5, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(4);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt110");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path2", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(a,LookatPoint);
       
    Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt107");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path1", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(a,LookatPoint);

    Script.WaitSec(2);
                
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt113");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path3", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(a,LookatPoint);
    
    Camera.SetSpeed(entCamera, .50, 01.0); 
 
    Script.WaitSec(3);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt107");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path1", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(a,LookatPoint);
                
	--POWERUP			
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt107");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path2", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(a,LookatPoint);
	EntGame.CreateAnimalPowerUp(a, PID_3X_RELOAD_RATE);

    Script.WaitSec(2);
                
	--PREDATOR #2
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt113");
    Predator2 = EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse1Path3", 0, ST_WPT_RUN, 5, 0, 0, .05);    
    Animal.FaceEntity(Predator2,LookatPoint); 
	Animal.SetAutoChargeDist(Predator2, 6);
	Animal.SetAttackType(Predator2, ATK_STRAFE);
	Animal.SetStrafeAttackDist(Predator2, 4);
	Animal.SetStrafeAttackDelay(Predator2, 0.50);
 	Entity.SetName(Predator2, "Predator2");
	
    end;    
    
---------------------------------------------------------------------------------------------------------------------
function Part2()    	  

    --Camera.JumpToWaypoint(entCamera, "CamWptEE");	
    --Camera.SetSpeed(entCamera, 0.0, 0.007); 
  
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt123");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath02", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt125");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath03", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt127");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath04", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
	
    Script.WaitSec(7);
    Sound.Play(sfxCaveGrowl, 1, 100, DS2_CENTER);
    
    Script.WaitSec(1);
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CaveEmergePath02", 0, ST_WPT_RUN, 5, 0, 0, .5);
	Animal.FaceEntity(a, entCamera);

    Script.WaitSec(1);
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CaveEmergePath03", 0, ST_WPT_RUN, 5, 0, 0, .5);
	Animal.FaceEntity(a, entCamera);
    Script.WaitSec(2);
	
	--PREDATOR #3
    Predator3 = EntGame.SpawnAnimalOnPath(AID_GRIZZLY_BEAR, "CaveEmergePath01", 0, ST_WPT_RUN, 0, 0, 0, .1);
    Animal.FaceEntity(Predator3, entCamera);
    Animal.SetAutoChargeDist(Predator3, 4.0);
	Animal.SetAttackType(Predator3, ATK_STATIC);
	Animal.SetStaticAttackDist(Predator3, 3.75);
	Animal.SetStaticAttackDelay(Predator3, 1.75);	
	Animal.SetPostAttackRand(Predator3, false);
	Animal.SetPostAttackDir(Predator3, -90);	
	
    Script.WaitSec(3);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt137");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "LogEmergePath01", 0, ST_WPT_RUN, 5, 0, 0, .50);
    Animal.FaceEntity(a,LookatPoint);
    Script.WaitSec(2);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt137");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath01", 0, ST_WPT_RUN, 5, 0, 0, .50);
    Animal.FaceEntity(a,LookatPoint);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt139");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath03", 0, ST_WPT_RUN, 5, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
	
	--POWERUP
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt139");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath03", 0, ST_WPT_RUN, 5,2, 2, 1.0);
    Animal.FaceEntity(a,LookatPoint);	
	EntGame.CreateAnimalPowerUp(a, PID_2X_SCORE);
	
    Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt139");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath03", 0, ST_WPT_RUN, 5, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
        
    Script.WaitSec(5);
	
	--PREDATOR #4
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt137");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath01a", 0, ST_WPT_RUN, 5, 0, 0, .50);
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetAutoChargeDist(a, 6.0);
	Animal.SetStrafeAttackDist(a, 6.0);
	Animal.SetStrafeAttackDelay(a, 1.0);
	Animal.SetAttackType(a, ATK_STRAFE);
	Entity.SetName(a, "Attack1");
            
    Script.WaitSec(2);	
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt131");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "CaveEmergePath02", 0, ST_WPT_RUN, 5, 0, 0, 1);
    Animal.FaceEntity(a,LookatPoint);
	
    Script.WaitSec(3);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt137");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath01", 0, ST_WPT_RUN, 5, 0, 0, .50);
    Animal.FaceEntity(a,LookatPoint);

    Camera.SetSpeed(entCamera, 0.80, 01.50); 
    Camera.StopAtWaypoint(entCamera, "CamWptGG");
    
    Script.WaitSec(3);
    
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CaveEmergePath04", 0, ST_WPT_RUN, 6, 0, 0, .8);   
    Animal.FaceEntity(a,LookatPoint);
 
    Script.WaitSec(2);
        
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CaveEmergePath04", 0, ST_WPT_RUN, 6, 0, 0, .8);   
    Animal.FaceEntity(a,LookatPoint);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt142");
    
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath04", 0, ST_WPT_WALK, 3, 0, 0, 0.80);
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(2);
    
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CoyoteRunPath04", 0, ST_WPT_WALK, 3, 2, 2, 0.80);
    Animal.FaceEntity(a,LookatPoint);
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "CoyoteRunPath04", 0, ST_WPT_WALK, 4, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
    
    EntGame.SpawnAnimalOnPath(AID_GRIZZLY_BEAR, "BearWalkPath01", 0, ST_WPT_WALK, 10, 0, 0, .50);
    
    Script.WaitSec(2);
   
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "CoyoteRunPath04", 0, ST_WPT_WALK, 4, 0, 3, 1.0);
    Animal.FaceEntity(a,LookatPoint);
   
    Camera.SetSpeed(entCamera, 1.10, 01.30); 
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt153");
	
    a=EntGame.SpawnAnimalStaggerCtl(AID_COYOTE, "CoyoteIdlePath01", WPT_0, ST_GRAZING, 30, 0, 0, 1, false);  
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);
    Animal.SetElvOffset(a,.95); 
    Animal.FaceEntity(a,LookatPoint);			
    Animal.SetCoinMode(a, CM_SPAWNREL);	
    Animal.EnableFear(a, false);					

	LookatPoint = Entity.FindName(entRoot, "AnimalWpt157");
    a=EntGame.SpawnAnimalStaggerCtl(AID_WOLVERINE, "WolverineIdlePath01", WPT_0, ST_GRAZING, 30, 0, 0, 1, false);  
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);
    Animal.SetElvOffset(a,01.2); 
    Animal.FaceEntity(a,LookatPoint);			
    Animal.SetCoinMode(a, CM_SPAWNREL);
    Animal.EnableFear(a, false);
   
    end;    
     ---------------------------------------------------------------------------------------------------------------------

function Part3()  
	--Camera.JumpToWaypoint(entCamera, "CamWptGG");	
   --Camera.SetSpeed(entCamera, 0.0, 0.007);
    
    Script.WaitSec(10);
    
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "LogEmergePath02", 0, ST_WPT_WALK, 2, 0, 0, .50);
    Animal.FaceEntity(a,entCamera);	
    
    Script.WaitSec(.5);
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "LogEmergePath03", 0, ST_WPT_WALK, 2, 0, 0, .50);
    Animal.FaceEntity(a,entCamera);
    
    Script.WaitSec(1);
	
	--POWERUP
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath03", 0, ST_WPT_RUN, 2, 0, 0, .50);
    Animal.FaceEntity(a,entCamera);
	EntGame.CreateAnimalPowerUp(a, PID_4X_FIRE_RATE);
    
    Script.WaitSec(3);
    
    EntGame.SpawnAnimalOnPath(AID_GRIZZLY_BEAR, "BearWalkPath01", 0, ST_WPT_RUN, 0, 0, 0, 1.0);
    
    Script.WaitSec(3);
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath02", 0, ST_WPT_WALK, 2, 0, 0, 1.0);
    Animal.FaceEntity(a,entCamera);
    
    Script.WaitSec(3);
	
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "LogEmergePath03", 0, ST_WPT_WALK, 2, 0, 0, 1.0);
    Animal.FaceEntity(a,entCamera);

    Camera.SetSpeed(entCamera, 1.30, 01.20); 
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt181");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath06", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
        
    Script.WaitSec(.5);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt161");
    
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "FieldRunPath02", 0, ST_WPT_WALK, 6, 3, -3, 1.0);
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(3);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt159");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "FieldRunPath01", 0, ST_WPT_WALK, 3, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(3);
    
    Camera.SetSpeed(entCamera, 1.0, 01.20); 
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt163");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "FieldWeavePath01", 0, ST_WPT_RUN, 3, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);

    Script.WaitSec(3);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt167");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "FieldRunPath03", 0, ST_WPT_RUN, 3, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(2);
    
	--POWERUP
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt169");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "FieldRunPath04", 0, ST_WPT_RUN, 3, 0, 0, 1.0);
    Animal.FaceEntity(a,LookatPoint);
	EntGame.CreateAnimalPowerUp(a, PID_WILEY_VISION_50);
    
    Camera.SetSpeed(entCamera, 1.70, 01.00); 
    
    Script.WaitSec(2);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt171");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrousePerchedPath05", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
        
    Script.WaitSec(3);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt179");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseRunPath02", 0, ST_WPT_WALK, 5, 0, 0, .5);    
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(5);
	
	--PREDATOR #5
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt173");
    Predator5 = EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse2Path1", 0, ST_WPT_WALK, 2, 0, 0, .5);    
    Animal.FaceEntity(Predator5,LookatPoint);
    Animal.SetAutoChargeDist(Predator5, 6.0);
	Animal.SetAttackType(Predator5, ATK_STRAFE);
	Animal.SetStrafeAttackDist(Predator5, 5);
	Animal.SetStrafeAttackDelay(Predator5, 0.5);
 	Entity.SetName(Predator5, "Predator5");
    
    Script.WaitSec(3);
	
	--PREDATOR #6
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt173");
    Predator6 = EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse2Path2", 0, ST_WPT_WALK, 2, 0, 0, .05);    
    Animal.FaceEntity(Predator6,LookatPoint);
    Animal.SetAutoChargeDist(Predator6, 8.0);
	Animal.SetAttackType(Predator6, ATK_STRAFE);
	Animal.SetStrafeAttackDist(Predator6, 5);
	Animal.SetStrafeAttackDelay(Predator6, 0.5);
 	Entity.SetName(Predator6, "Predator6");	
	
    Script.WaitSec(1);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt186");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineRunPath01", 0, ST_WPT_RUN, 2, 0, 0, .40);    
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt173");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineHouse2Path1", 0, ST_WPT_WALK, 4, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Script.WaitSec(1);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt186");
    a=EntGame.SpawnAnimalOnPath(AID_WOLVERINE, "WolverineRunPath01", 0, ST_WPT_RUN, 2, 0, 0, .50);    
    Animal.FaceEntity(a,LookatPoint);
    
    Script.WaitSec(2);
	
    --Start launching fish
    FishLauncher.Enable(entFishLauncher1);
	FishLauncher.SetCoinMode(entFishLauncher1, CM_SPAWNREL);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt190");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "DeepFieldPath01", 0, ST_WPT_WALK, 2, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
	
    Script.WaitSec(4);
   
    Camera.SetSpeed(entCamera, 2.50, 01.00); 
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt190");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "DeepFieldPath01", 0, ST_WPT_RUN, 2, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);

	Script.WaitSec(3);
	
	if (entFishLauncher1) then  
        entFish = FishLauncher.Launch(entFishLauncher1); 
        EntGame.CreateAnimalPowerUp(entFish, PID_WILEY_VISION_50); 
        end;    
	
    Script.WaitSec(5);

	if (entFishLauncher1) then  
        entFish = FishLauncher.Launch(entFishLauncher1); 
        EntGame.CreateAnimalPowerUp(entFish, PID_10X_MAGAZINE); 
        end;   
		
    Camera.SetSpeed(entCamera, 1.0, 01.00); 
    Script.WaitSec(2);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt193");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "BridgeRunPath01", 0, ST_WPT_RUN, 1, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetSnapToTerrain(a,False);
    Animal.SetCoinMode (a, CM_SPAWNREL);
    
    Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt193");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "BridgeRunPath02", 0, ST_WPT_RUN, 1, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetSnapToTerrain(a,False);
    Animal.SetCoinMode (a, CM_SPAWNREL);
    Script.WaitSec(1);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt193");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "BridgeRunPath01", 0, ST_WPT_RUN, 1, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetSnapToTerrain(a,False);
    Animal.SetCoinMode (a, CM_SPAWNREL);
    
    Script.WaitSec(1);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt193");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "BridgeRunPath02", 0, ST_WPT_RUN, 1, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetSnapToTerrain(a,False);
    Animal.SetCoinMode (a, CM_SPAWNREL);
    
        end;    

---------------------------------------------------------------------------------------------------------------------
function Part4()
	--Camera.JumpToWaypoint(entCamera, "CamWptMM");	
  --Camera.SetSpeed(entCamera, 0.0, 0.007);



    Camera.StopAtWaypoint(entCamera, "CamWptMM");
    Script.WaitSec(13);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt199");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "CabinRailPerchPath01", 0, ST_PERCH, 35, 0, 0, 1);    
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt207");
    a=EntGame.SpawnAnimalOnPath(AID_COYOTE, "CabinRoofPath02", 0, ST_GRAZING, 35, 0, 0, 1);  
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);	
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);
    Animal.SetElvOffset(a,0.47);
    
    Script.WaitSec(.5);
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt200");
    a=EntGame.SpawnAnimalStaggerCtl(AID_COYOTE, "CabinRoofPath02", 0, ST_GRAZING, 25, 0, 0, 1, false); 
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);
    Animal.SetElvOffset(a,03.47);	
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetCoinMode(a, CM_SPAWNREL);	  

    LookatPoint = Entity.FindName(entRoot, "AnimalWpt201");
    a=EntGame.SpawnAnimalStaggerCtl(AID_COYOTE, "CabinRoofPath01", 0, ST_GRAZING, 25, 0, 0, 1, false);    
	Animal.SetRunWhenShot(a, false);
	Animal.SetNeverLimp(a, true);
    Animal.FaceEntity(a,LookatPoint);
    Animal.SetElvOffset(a,05.47);
    Animal.SetCoinMode(a, CM_SPAWNREL);
          
    FishLauncher.Disable(entFishLauncher1);
    
    --Play a roar, spawn a grizzly.	
	
	  
		
    Sound.Play(sfxRoar, 1, 10, DS2_CENTER);
        
    Script.WaitSec(.1);
    
	--PREDATOR
    b=EntGame.SpawnAnimalStaggerCtl(AID_GRIZZLY_BEAR, "CabinPorchPath01", WPT_0, ST_CHARGE_WARN, 3, 0, 0, 1, false);  
	
	--Animal.SetState(b, ST_CHARGE_WARN)
	Animal.SetInvincible(b, true);
    Entity.SetName(b, "AngryBear");
    Animal.FaceEntity(b,entCamera);
    Animal.SetAutoChargeDist(b, 4.50);
	Animal.SetAttackType(b, ATK_STATIC);
	Animal.SetStaticAttackDist(b, 3.75);
	Animal.SetStaticAttackDelay(b, 1.75);	
	Animal.SetPostAttackRand(b, false);
	Animal.SetPostAttackDir(b, -90);		
    Sound.Play(sfxRoar, 1, 10, DS2_CENTER);
    
    Camera.SetPanOffset(entCamera, -90.0, 0.3);

    --Slowly Fix camera pan skewing
    Camera.SetRollOffset(entCamera, -5.0, 3.0);	
    
   Script.WaitSec(2.4);
 
    --Make the beam break.
    AnimatedObject.SetState(entAniObj, AO_ST_ACTIVE);	
    Sound.Play(sfxWoodBreak, 1, 20, DS2_CENTER);

	Script.WaitSec(1.5);
	Animal.SetInvincible(b, false);

    Script.WaitSec(3.5);
    
    WalkSpeed = 2.5;
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt211");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseRoofPopPath01", 0, ST_WPT_FLY, 1, 0, 0, 1.0);     
    Animal.FaceEntity(a,LookatPoint); 
    Animal.SetSpeedWalk(a, WalkSpeed); 
    Animal.SetState(a, ST_WPT_FLY);
	EntGame.CreateAnimalPowerUp(a, PID_5X_SCORE);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt217");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseRoofPopPath03", 0, ST_WPT_FLY, 1, 0, 0, 1.0);     
    Animal.FaceEntity(a,LookatPoint); 
    Animal.SetSpeedWalk(a, WalkSpeed); 
    Animal.SetState(a, ST_WPT_FLY);
    
    Script.WaitSec(1);	
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt219");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseRoofPopPath02", 0, ST_WPT_FLY, 1, 0, 0, 1.0);     
    Animal.FaceEntity(a,LookatPoint); 
    Animal.SetSpeedWalk(a, WalkSpeed); 
    Animal.SetState(a, ST_WPT_FLY);
    
    Script.WaitSec(3);	
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt217");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseGroundPopPath01", 0, ST_WPT_WALK, 2, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt219");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseGroundPopPath02", 0, ST_WPT_WALK, 2, 0, 0, 1.0);    
    Animal.FaceEntity(a,LookatPoint);

	Script.WaitSec(2);
	
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt217");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseGroundPopPath01", 0, ST_WPT_WALK, 2, .5, -.5, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
    
    LookatPoint = Entity.FindName(entRoot, "AnimalWpt219");
    a=EntGame.SpawnAnimalOnPath(AID_GROUSE, "GrouseGroundPopPath02", 0, ST_WPT_WALK, 2, -.5, .5, 1.0);    
    Animal.FaceEntity(a,LookatPoint);
	
    end;

---------------------------------------------------------------------------------------------------------------------
-- Main entry point
   
Setup();
Intro();
Part1();
Part2();
Part3();
Part4();