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

function SpawnIntroAnimals()

    a =  EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "IntroCamAnimalsPath1", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
    b =  EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "IntroCamAnimalsPath2", 0, ST_WPT_RUN, 0, 0, 0, 1);
    
    end;

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

function PostStage()

    EntGame.EnablePlayerControl(false);
    EntGame.ClearFlag(GF_READYTOSTART);
    EntGame.BindCameraToEntity("OutroCamera");
	
	Sound.Release(smpLeopardRoar);

    end;     
    
-----------------------------------------------------------------------------    
-- Setup

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

    -- load world
    SetupWorld("Maps\\WorldRiverValley\\RiverValleyCommon.ini", "Maps\\Stage4-3\\Stage4-3.ini","","");
    EntGame.CreatePlayerEntities();
    
	EntGame.SetGlobalDustColorInitial(1.0, 0.72, .58, .26);
    EntGame.SetGlobalDustColorFinal  (0.0, 0.72, .58, .26);
    
    EntGame.SetStageTimer(150);
    
    -- load sounds
    smpLeopardRoar = Sound.Load("Sound\\Animals\\LeopardRoar.wav");

    EntGame.LoadAnimal(AID_BUFFALO_M);
	EntGame.LoadAnimal(AID_LEOPARD_M);	
	EntGame.LoadAnimal(AID_ELAND_M);
	EntGame.LoadAnimal(AID_ELAND_F);
	EntGame.LoadAnimal(AID_GEMSBOK_M);
	EntGame.LoadAnimal(AID_GEMSBOK_F);
        
    SpawnIntroAnimals();	

    StartupSequence("Music\\Afterlife.ogg");
    
    EntGame.DestroyAllAnimals();
      
    end;
    
-----------------------------------------------------------------------------

function Part1()

	Camera.JumpToWaypoint(entCamera, "CamWptAA");
	Camera.SetSpeed(entCamera, 0.0, 0.1);	
	
	EntGame.ShowCaption(STR_LVL_4_3_A, 0, 4.0);
	
	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha1", 0, ST_WPT_RUN, 0, 0, 0, .7);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha2", 0, ST_WPT_RUN, 0, 0, 0, .8);
    Script.WaitSec(2); 
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha1", 0, ST_WPT_RUN, 0, 0, 0, .7);   
    	
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha6", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha5", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	
  	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha6", 0, ST_WPT_RUN, 0, 0, 0, .6);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha5", 0, ST_WPT_RUN, 0, 0, 0, .6);
  	Script.WaitSec(2);
  	
  		
  	a = EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha23", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.SetAutoChargeDist(a, 20);	
	Animal.SetAttackType(a, ATK_STATIC);
	Animal.SetAttackRepeat(a, 2); 
	Animal.SetPostAttackRand(a, false);
	Animal.SetPostAttackDir(a, 90);	  	
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha24", 0, ST_WPT_RUN, 0, 0, 0, 1.0);
	
	Script.WaitSec(1);
	
	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha1", 0, ST_WPT_RUN, 0, 0, 0, .2);
	
	EntGame.ShowCaption(STR_LVL_4_3_B, 0, 3.0);
	
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha3", 0, ST_WPT_RUN, 0, 0, 0, .85);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha4", 0, ST_WPT_RUN, 0, 0, 0, 1.0);  
   
    Script.WaitSec(1.5);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha4", 0, ST_WPT_RUN, 0, 0, 0, .9);
    Script.WaitSec(1.5);   
    	
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha6", 0, ST_WPT_RUN, 0, 0, 0, .7);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha5", 0, ST_WPT_RUN, 0, 0, 0, 1.0);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha7", 0, ST_WPT_RUN, 0, 0, 0, .7)
    
    Script.WaitSec(3.0); 
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha3", 0, ST_WPT_RUN, 0, 0, 0, .2);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha4", 0, ST_WPT_RUN, 0, 0, 0, .4); 
    Script.WaitSec(3.5);
    
    EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha8", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha9", 0, ST_WPT_RUN, 0, 0, 0, .8);
	
	Script.WaitSec(3);
		
	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha8", 0, ST_WPT_RUN, 0, 0, 0, .6);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha9", 0, ST_WPT_RUN, 0, 0, 0, .5);
  	Script.WaitSec(1.5);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha8", 0, ST_WPT_RUN, 0, 0, 0, .6);
  	Script.WaitSec(1.5);
  	
	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha1", 0, ST_WPT_RUN, 0, 0, 0, .7);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha2", 0, ST_WPT_RUN, 0, 0, 0, 1.0);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha4", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha3", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	
  	Script.WaitSec(7);
  		
    end;
    
-----------------------------------------------------------------------------

function Part2()

	Camera.SetSpeed(entCamera, 2.0, 0.1);
	Camera.StopAtWaypoint(entCamera, "CamWptEE");
	
	Script.WaitSec(5);
  	
	EntGame.ShowCaption(STR_LVL_4_3_C, 0, 3.0);
	
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha6", 0, ST_WPT_RUN, 0, 0, 0, .85);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha5", 0, ST_WPT_RUN, 0, 0, 0, 1.1);
    Script.WaitSec(3);   
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha10", 0, ST_WPT_RUN, 0, 0, 0, .7);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha11", 0, ST_WPT_RUN, 0, 0, 0, 1.0);
    Script.WaitSec(.5); 
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha10", 0, ST_WPT_RUN, 0, 0, 0, .7)
    Script.WaitSec(2); 
	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha10", 0, ST_WPT_RUN, 0, 0, 0, .8)
	a = EntGame.SpawnAnimalOnPath(AID_LEOPARD_M, "FollowPathAlpha11",0, ST_WPT_RUN, 1,0,0,1.2);
	Animal.FaceEntity(a, entCamera );
	Script.WaitSec(2);
	EntGame.SpawnAnimalOnPath(AID_LEOPARD_M, "FollowPathAlpha11",0, ST_WPT_RUN, 0,-3,-3,1.2);
  	Sound.Play(smpLeopardRoar, 1, DS2_VOLMAX, DS2_CENTER);
  	Script.WaitSec(1.5);
  	
  	EntGame.SpawnAnimalOnPath(AID_LEOPARD_M, "FollowPathAlpha11",0, ST_WPT_RUN, 0,-2.5,-2.5,1.2);
  	  
	Script.WaitSec(5.5);
	 
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha13", 0, ST_WPT_RUN, 0, 0, 0, .85);
    Animal.FaceEntity(a, entCamera);
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha12", 0, ST_WPT_RUN, 0, 0, 0, 1.1);
    Animal.FaceEntity(a, entCamera);
    Script.WaitSec(1);
  	a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha13", 0, ST_WPT_RUN, 0, 2, 2, .5);
  	Animal.FaceEntity(a, entCamera);
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha12", 0, ST_WPT_RUN, 0, -2.5, 3, .6);
    Animal.FaceEntity(a, entCamera);
    Script.WaitSec(2);
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha13", 0, ST_WPT_RUN, 0, 3, -3, .5);
    Animal.FaceEntity(a, entCamera);
    Script.WaitSec(2);
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha13", 0, ST_WPT_RUN, 0, 0, 0, .4);
    Animal.FaceEntity(a, entCamera);
    a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha12", 0, ST_WPT_RUN, 0, 0, 0, .3);
    Animal.FaceEntity(a, entCamera);
    Script.WaitSec(3);
    EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha15", 0, ST_WPT_RUN, 0, 0, 0, .8);
    Script.WaitSec(3);	
   	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha15", 0, ST_WPT_RUN, 0, 0, 0, .8);
   	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha14", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	a = EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha16", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	Animal.FaceEntity(a, entCamera);
  	Script.WaitSec(3);
	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha15", 0, ST_WPT_RUN, 0, 0, 0, 1);
    Script.WaitSec(3);	
   	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha15", 0, ST_WPT_RUN, 0, 0, 0, .8);
   	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha14", 0, ST_WPT_RUN, 0, 0, 0, .7);
  	a = EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha16", 0, ST_WPT_RUN, 0, 0, 0, .6);
  	Animal.FaceEntity(a, entCamera);
  	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha14", 0, ST_WPT_RUN, 0, 0, 0, .4);
  	a = EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha16", 0, ST_WPT_RUN, 0, 0, 0, .3);
  	Animal.FaceEntity(a, entCamera);
  	
    end;
        
-----------------------------------------------------------------------------

function Part3()

	entBuffalo=EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha18", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.FaceEntity(entBuffalo, entCamera);
	Animal.SetAutoChargeDist(entBuffalo, 20.0);
	Animal.SetAttackType(entBuffalo, ATK_STATIC);
	Animal.SetStaticAttackDist(entBuffalo, 4.5);
	Animal.SetAttackRepeat(entBuffalo, 3);
	Animal.SetPostAttackRand(entBuffalo, false);
	Animal.SetPostAttackDir(entBuffalo, 90);
	
	entBuffalo=EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha19", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.FaceEntity(entBuffalo, entCamera);
	Animal.SetAutoChargeDist(entBuffalo, 20.0);
	Animal.SetAttackType(entBuffalo, ATK_STRAFE);
	Animal.SetStrafeAttackDist(entBuffalo, 5.7);
	Animal.SetPostAttackRand(entBuffalo, false);
	Animal.SetPostAttackDir(entBuffalo, -90);
	
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha20", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha18", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha26", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Script.WaitSec(1);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha20", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Script.WaitSec(9);
	
	EntGame.ShowCaption(STR_LVL_4_3_D, 0, 4.0);
	
	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha25", 0, ST_WPT_RUN, 0, 0, 0, .8);
	Script.WaitSec(1);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha25", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	Script.WaitSec(3);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha25", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	EntGame.ShowCaption(STR_LVL_4_3_E, 0, 3.0);
  	Script.WaitSec(.5);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha25", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	Script.WaitSec(1);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha25", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	Script.WaitSec(5.5);
  	
    end;
       
-----------------------------------------------------------------------------

function Part4()

	Camera.SetSpeed(entCamera, 2.0, 0.1);
	Camera.StopAtWaypoint(entCamera, "CamWptII");
	
	Script.WaitSec(8);

    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha28", 0, ST_WPT_RUN, 0, 0, 0, .4);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha27", 0, ST_WPT_RUN, 0, 0, 0, .3);
	Script.WaitSec(2);
	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha29", 0, ST_WPT_RUN, 0, 0, 0, .85);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha28", 0, ST_WPT_RUN, 0, 0, 0, .9);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha27", 0, ST_WPT_RUN, 0, 0, 0, .9);
    Script.WaitSec(3);
    EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha101", 0, ST_WPT_RUN, 0, 0, 0, .9);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha102", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha103", 0, ST_WPT_RUN, 0, 0, 0, 1);
  	Script.WaitSec(2);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha103", 0, ST_WPT_RUN, 0, 0, 0, 1);
	Script.WaitSec(3);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha101", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Script.WaitSec(.55);
		
	entBuffalo=EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha101", 0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.FaceEntity(entBuffalo, entCamera);
	Animal.SetChargeWhenShot(entBuffalo, true);
	Animal.SetAttackType(entBuffalo, ATK_STRAFE);
	Animal.SetStrafeAttackDist(entBuffalo, 6);
	Animal.SetPostAttackRand(entBuffalo, false);
	Animal.SetPostAttackDir(entBuffalo, -90);

	
	Script.WaitSec(1);	
	
	entBuffalo=EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha102",0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.FaceEntity(entBuffalo, entCamera);
	Animal.SetChargeWhenShot(entBuffalo, true);
	Animal.SetAttackType(entBuffalo, ATK_STRAFE);
	Animal.SetStrafeAttackDist(entBuffalo, 6);
	Animal.SetPostAttackRand(entBuffalo, false);
	Animal.SetPostAttackDir(entBuffalo, -90);	

	
	Script.WaitSec(.5);
	EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha102",0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Script.WaitSec(1);
	
	entBuffalo=EntGame.SpawnAnimalOnPath(AID_BUFFALO_M, "FollowPathAlpha102",0, ST_WPT_RUN, 0, 0, 0, 1.2);
	Animal.FaceEntity(entBuffalo, entCamera);
	Animal.SetChargeWhenShot(entBuffalo, true);
	Animal.SetAttackType(entBuffalo, ATK_STRAFE);
	Animal.SetStrafeAttackDist(entBuffalo, 6);
	Animal.SetPostAttackRand(entBuffalo, false);
	Animal.SetPostAttackDir(entBuffalo, -90);
	
	Script.WaitSec(3);
	
	a = EntGame.SpawnAnimalOnPath(AID_LEOPARD_M, "FollowPathAlpha102",0, ST_WPT_RUN, 0,0,0,1.2);
	Animal.FaceEntity(a, entCamera );
	Script.WaitSec(2);
	a = EntGame.SpawnAnimalOnPath(AID_LEOPARD_M, "FollowPathAlpha102",0, ST_WPT_RUN, 0,0,0,1.2);
	Animal.FaceEntity(a, entCamera );
	
	Sound.Play(smpLeopardRoar, 1, DS2_VOLMAX, DS2_RIGHT);
	
	Script.WaitSec(6);
	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha103", 0, ST_WPT_RUN, 0, 0, 0, .9);
	Script.WaitSec(2);
		
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha103", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	
  	EntGame.SpawnAnimalOnPath(AID_ELAND_M, "FollowPathAlpha104", 0, ST_WPT_RUN, 0, 0, 0, .9);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha105", 0, ST_WPT_RUN, 0, 0, 0, .8);
  	EntGame.SpawnAnimalOnPath(AID_ELAND_F, "FollowPathAlpha106", 0, ST_WPT_RUN, 0, 0, 0, .7);
  	Script.WaitSec(5);
  	EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha107", 0, ST_WPT_RUN, 0, 0, 0, .85);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha108", 0, ST_WPT_RUN, 0, 0, 0, .9);
    Script.WaitSec(1);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha109", 0, ST_WPT_RUN, 0, 0, 0, .9);
    Script.WaitSec(1);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_M, "FollowPathAlpha107", 0, ST_WPT_RUN, 0, 0, 0, .85);
    EntGame.SpawnAnimalOnPath(AID_GEMSBOK_F, "FollowPathAlpha108", 0, ST_WPT_RUN, 0, 0, 0, .9);
    
    end;
       
-----------------------------------------------------------------------------
-- Main entry point
   
Setup();   
Part1();   
Part2();   
Part3();   
Part4(); 

