#include maps\_utility;
#include common_scripts\utility;
#include maps\_utility_code;
#include maps\_anim;

#using_animtree( "generic_human" );



/*#################################
###################################
#### ANIMATIONS TESTMAP By SPi ####
###################################
#################################*/



main()
{

	maps\_load::main();
	
	maps\test_animez_anim::main(); // calls the main function of test_animez_anim so our animations can be loaded.
	
	level.player takeallweapons(); //removes the default given mp5 from player so we can give other guns like:
	level.player giveWeapon( "m4_silencer" ); //gives m4sd to player
	level.player givemaxammo( "m4_silencer" ); //gives max ammo for m4sd to player
	level.player giveWeapon( "beretta" ); //gives m9 to player
	level.player givemaxammo( "beretta" ); //gives max ammo for m9 to player
	level.player setviewmodel( "viewhands_sas_woodland" ); //sets player viewhands to sas woodland
	level.player switchtoweapon( "m4_silencer" ); //sets player viewhands to sas woodland

	
	thread sas1_anim(); //calls the function that makes sas1 play his animation
	thread sas2_anim(); //calls the function that makes sas2 play his animation
}



sas1_anim()
{
	sas1_trigg = getent( "sas1_trigg" , "targetname" ); //gets the Trigger from targetname 
	sas1_trigg waittill("trigger"); //Script waits untill player activates the trigger

	sas1 = getent( "sas1" , "targetname" ); //gets the AI from targetname 
	animnode1 = getnode( "animnode1" , "targetname" ); //gets the node from targetname
	
	sas1.animname = "price"; //sets an animname for the AI so it can work with animations that are loaded in the specific animname

	sas1 setgoalnode(animnode1); //makes AI go to node
	sas1 waittill( "goal" ); //waits untill AI is to goalnode

	animnode1 anim_reach_solo(sas1, "sas1_anim"); //makes the Ai go to the proper position to start the animation relative with the node.
	//May cause some Errors, idle animations dont need this.
	
	animnode1 thread anim_single_solo(sas1, "sas1_anim"); 
	//makes the Node order the AI to play the animation one SINGLE time.
}



sas2_anim()
{
	sas2_trigg = getent( "sas2_trigg" , "targetname" ); 
	sas2_trigg waittill("trigger"); 

	sas2 = getent( "sas2" , "targetname" ); 
	animnode2 = getnode( "animnode2" , "targetname" );
	
	sas2.animname = "gaz"; 
	
	sas2 setgoalnode(animnode2); 
	sas2 waittill( "goal" );
	
	animnode2 thread anim_loop_solo(sas2, "sas2_anim", undefined, "stop_anim"); 
	//makes the Node order the AI to play the animation LOOP 
	//which means it will play the animation forever 
	//untill you order it to stop as shown below.
	
	wait 12; //script waits 12 seconds
	
	animnode2 notify("stop_anim"); //tells the node to stop animation as defined above.
	
}






