-----------------------------------------------------------------------------
-- Site 12
-----------------------------------------------------------------------------
-- PostStage

function PostStage()
    EntGame.EnablePlayerControl(false);
    EntGame.ClearFlag(GF_READYTOSTART);
    EntGame.BindCameraToEntity("IntroCamera");
    
    Sound.Release(smpWaterFall);   
    end;    
    
-----------------------------------------------------------------------------    
-- Setup

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

    -- load world
    SetupWorld("Maps\\Site12\\Site12.ini", "","","");
    EntGame.CreatePlayerEntities();

	-- find a few key entities we may need later  
    -- we search from entRoot, which was already saved off in SetupWorld  
    entRoot = Game.GetRootEntity(); 
    entFishLauncher1 = Entity.FindName(entRoot, "FishLauncher1"); 
	entFishLauncher2 = Entity.FindName(entRoot, "FishLauncher2");
	entFishLauncher3 = Entity.FindName(entRoot, "FishLauncher3");
	entFishLauncher4 = Entity.FindName(entRoot, "FishLauncher4");	
	entFishLauncher5 = Entity.FindName(entRoot, "FishLauncher5");
	
    -- Do any setup that is specifically for testing.
	if (EntGame.TestingLevels()) then
		Testing();
		end;    
		
    -- find a few key entities we may need later
    -- we search from entRoot, which was already saved off in SetupWorld
    entRoot = Game.GetRootEntity();
    entFishLauncher1 = Entity.FindName(entRoot, "FishLauncher1");    
		
    EntGame.SetGlobalDustColorInitial(.3, 0.51, .61, .45);
    EntGame.SetGlobalDustColorFinal  (0.0, 0.61, .58, .45);

    EntGame.SetStageTimer(120);
	-- cache animals
	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);	

    -- load sounds
    smpWaterFall  = Sound.Load("Sound\\Environment\\Waterfall.wav");  
	
    -- 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\\SilverSurfer.ogg");
	    

	
	Bear = EntGame.SpawnAnimalOnPath(AID_GRIZZLY_BEAR, "FishingGrizzlyPath01", WPT_0, ST_BEAR_FEED, 12000, 0, 0, 1);
	Animal.SetInvincible(Bear, true);
	CaughtFish = EntGame.SpawnAnimalOnPath(AID_SALMON, "FishingGrizzlyPath01", WPT_0, ST_BEAR_FEED, 12000, 0, 0, 1);
	Animal.FaceEntity(CaughtFish, "MainCamera");
	Animal.FaceEntity(Bear, "MainCamera");
	--	Animal.SetState(Bear, ST_GRAZING);
	--	Animal.SetState(CaughtFish, ST_GRAZING);
	
	-- 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"
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_2, 0);   
    EntGame.BindCameraToEntity("CountdownCamera2");
    Script.WaitSec(1.0);
    
    -- "1"
    Entity.GameEventPre(Game.GetRootEntity(), SSK1_COUNTDOWN_1, 0);   
    EntGame.BindCameraToEntity("CountdownCamera1");
    Script.WaitSec(1.0);
    
    -- "HUNT!"  
    entCamera = Entity.FindName(entRoot, "MainCamera");
    EntGame.BindCameraToEntity(entCamera);    
    Camera.JumpToWaypoint(entCamera, "CamWptAA");
    Camera.SetSpeed(entCamera, 0.0, 0.01);    
    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_3);
	EntGame.SetPlayerWeapon(0, WS_SINGLE_RIFLE, WID_SINGLE_RIFLE_3);
    EntGame.SetPlayerWeapon(0, WS_SHOTGUN,	    WID_SHOTGUN_2);	
	EntGame.SetPlayerWeapon(0, WS_AUTO_RIFLE, 	WID_AUTO_RIFLE_3);	
	EntGame.SetPlayerWeapon(0, WS_BOW, 		    WID_BOW_2);
	EntGame.ResetWeaponIcons();
	end; 
	
-----------------------------------------------------------------------------

function Part1()

	Camera.JumpToWaypoint(entCamera, "CamWptAA");
    Camera.SetSpeed(entCamera, 0, 0.1); 

	Camera.StopAtWaypoint(entCamera, "CamWptCC");
	Camera.SetSpeed(entCamera, .1, 0.1); 
	
    --Bear = EntGame.SpawnAnimalOnPath(AID_GRIZZLY_BEAR, "ShortPath01", WPT_0, ST_GRAZING, 90, 0, 0, 1);
	--	Animal.SetElvOffset(Bear, -.45);
	--	Entity.FindName(entRoot, "entFishLauncher3");
	--	Animal.FaceEntity(Bear, entFishLauncher3); 
		
	Script.WaitSec(15);
	
	if (entFishLauncher3) then  
        entFish = FishLauncher.Launch(entFishLauncher3); 
        EntGame.CreateAnimalPowerUp(entFish, PID_3X_RELOAD_RATE); 
        end;    

	Script.WaitSec(15);
		
	if (entFishLauncher5) then  
        entFish = FishLauncher.Launch(entFishLauncher5); 
        EntGame.CreateAnimalPowerUp(entFish, PID_WILEY_VISION_100); 
        end;    		
 
    Script.WaitSec(15);
	
    if (entFishLauncher3) then
        entFish = FishLauncher.Launch(entFishLauncher3);
        EntGame.CreateAnimalPowerUp(entFish, PID_2X_SCORE);
        end;    
    
	Script.WaitSec(15);
	
	if (entFishLauncher3) then
        entFish = FishLauncher.Launch(entFishLauncher3);
        EntGame.CreateAnimalPowerUp(entFish, PID_2X_FIRE_RATE);
        end;    

	Script.WaitSec(15);
	
	if (entFishLauncher3) then
        entFish = FishLauncher.Launch(entFishLauncher3);
        EntGame.CreateAnimalPowerUp(entFish, PID_WILEY_VISION_100);
        end;  

	Script.WaitSec(15);
	
	if (entFishLauncher5) then
        entFish = FishLauncher.Launch(entFishLauncher5);
        EntGame.CreateAnimalPowerUp(entFish, PID_2X_SCORE);
        end;  
		
	Script.WaitSec(15);

	if (entFishLauncher3) then
        entFish = FishLauncher.Launch(entFishLauncher3);
        EntGame.CreateAnimalPowerUp(entFish, PID_WILEY_VISION_100);
        end;  
		
    end;    

-----------------------------------------------------------------------------
-- Main entry point
   
Setup();   
Intro();
Part1();


