#include "..\Shared\SPMission.h"

class isdfttn : public SPMission 
{
public:
	isdfttn(void)
	{
		b_count = &b_last - &b_first - 1;
		b_array = &b_first + 1;

		f_count = &f_last - &f_first - 1;
		f_array = &f_first + 1;

		h_count = &h_last - &h_first - 1;
		h_array = &h_first + 1;

		i_count = &i_last - &i_first - 1;
		i_array = &i_first + 1;
	}

	void Setup(void);
	void AddObject(Handle h);
	void Execute(void);

	// bools
	bool
		b_first,
		start_done,move_out,pilot1_to_ship,pilot2_to_ship,pilot3_to_ship,
		pilot1_in_ship,pilot2_in_ship,pilot3_in_ship,ship2_to_base,ship3_to_base,
		ship2_wait,ship3_wait,ships_removed,remove2,remove3,to_firing,rosas_there,
		player_at_rosas,start_fight,fight_over,out_of_ship,set_tunnel_check,in_tunnel,
		set_chicken,taunt1,taunt2,taunt3,at_recycler,free_recy_pilot,recycler_free,
		at_base,game_over,ON_HOLD,movie1,movie2,set_movie1_times, firstFrame,

		spawn_actor1,spawn_power1,cons2_move,apc_move,spawn_power2,repair_tug,
		stasis_move,tug_move,dialoge1,dialoge2,dialoge3,dialoge4,swap,
		in_ship1,in_ship2,in_ship3,all_in,rosas_challenge,to_combat,dodger_stop1,
		remove_ship3,remove_ship2,at_firing_range,ship1_to_base,rosas_ready,
		fire_first1,fire_first2,in_new_unit,rosas_home,rosas_leave_fight,rosas_to_base,
		recy_startup,
		b_last;

	// floats
	float
		f_first,
		move_time,remove_ships_time,rosas_check,fight_time,taunt_time,tunnel_check,
		chicken_check,play_check,recall_message_time,base_check,end_time,
		action1_time,action2_time,action3_time,action4_time,action5_time,dialouge1_time,
		action6_time,action7_time,action8_time,pilots_time,fight_check,fair_check,
		rosas_home_check,startup_wait,recy_pilot_safe,


		f_last;

	// handles
	Handle
		h_first,
		player,rosas,
		pilot1,pilot2,pilot3,recy_pilot,
		ship1,ship2,ship3,player_ship,
		recycler,dum_recy1,dum_recy2,dum_recy3,
		scav,dum_scav1,dum_scav2,dum_scav3,dum_scav4,
		dum_scav5,dum_scav6,dum_scav7,
		contruct,dum_con1,dum_con2,dum_con3,
		talk,
		new_pilot1,new_pilot2,new_pilot3,
		new_recy_pilot,
		base,
		actor1,actor2,movie_cons1,movie_cons2,movie_cons3,
		fix_serv,fix_tug,tug1,stasis1,crate,
		apc1,dead_crate,
		nav,
		h_last;


	// integers
	int
		i_first,
		i_last;
};
DLLBase * BuildMission(void)
{
	return new isdfttn();
}

void isdfttn::Setup(void)
{
/*
	Here's where you set the values at the start.  
*/

//  bools
	ON_HOLD = true;
	
	start_done = false;
	move_out = false;
	pilot1_to_ship = false;
	pilot2_to_ship = false;
	pilot3_to_ship = false;
	pilot1_in_ship = false;
	pilot2_in_ship = false;
	pilot3_in_ship = false;
	ship2_to_base = false;
	ship3_to_base = false;
	ship2_wait = false;
	ship3_wait = false;
	ships_removed = false;
	remove2 = false;
	remove3 = false;
	to_firing = false;
	rosas_there = false;
	player_at_rosas = false;
	start_fight = false;
	fight_over = false;
	out_of_ship = true;;
	set_tunnel_check = false;
	in_tunnel = false;
	set_chicken = false;
	taunt1 = false; taunt2 = false; taunt3 = false;
	at_recycler = false;
	free_recy_pilot = false;
	recycler_free = false;
	at_base = false;
	game_over = false;
	movie1 = true; movie2 = false;
	set_movie1_times = false;
	firstFrame = true;
	spawn_actor1 = false;
	spawn_power1 = false;
	cons2_move = false;
	apc_move = false;
	spawn_power2 = false;
	repair_tug = false;
	stasis_move = false;
	tug_move = false;
	dialoge1 = false;
	dialoge2 = false;
	dialoge3 = false;
	dialoge4 = false;
	swap = false;
	in_ship1 = false; in_ship2 = false; in_ship3 = false; all_in = false;
	rosas_challenge = false;
	to_combat = false;
	dodger_stop1 = false;
	remove_ship3 = false;
	remove_ship2 = false;
	at_firing_range = false;
	ship1_to_base = false;
	rosas_ready = false;
	fire_first1 = false;
	fire_first2 = false;
	in_new_unit = false;
	rosas_home = false;
	rosas_leave_fight = false;
	rosas_to_base = false;
	recy_startup = false;


	
//  floats
	move_time = 999999.9f;
	remove_ships_time = 999999.9f;
	rosas_check = 999999.9f;
	fight_time = 999999.9f;
	taunt_time = 999999.9f;
	tunnel_check = 999999.9f;
	chicken_check = 999999.9f;
	play_check = 999999.9f;
	recall_message_time = 999999.9f;
	base_check = 999999.9f;
	end_time = 999999.9f;
	action1_time = 999999.9f;
	action2_time = 999999.9f;
	action3_time = 999999.9f;
	action4_time = 999999.9f;
	action5_time = 999999.9f;
	action6_time = 999999.9f;
	action7_time = 999999.9f;
	action8_time = 999999.9f;
	dialouge1_time = 999999.9f;
	pilots_time = 999999.9f;
	fight_check = 999999.9f;
	fair_check = 999999.9f;
	rosas_home_check = 999999.9f;
	startup_wait = 999999.9f;
	recy_pilot_safe = 999999.9f;
	
	
//  handles
	rosas = NULL;
	pilot1 = GetHandle("pilot1");
	pilot2 = GetHandle("pilot2");
	pilot3 = GetHandle("pilot3");
	recy_pilot = GetHandle("recy_pilot");
	ship1 = GetHandle("ship1");
	ship2 = GetHandle("ship2");
	ship3 = GetHandle("ship3");
	player_ship = GetHandle("player_ship");
	recycler = GetHandle("recycler");
	dum_recy1 = GetHandle("dum_recy1");
	dum_recy2 = GetHandle("dum_recy2");
	dum_recy3 = GetHandle("dum_recy3");
	scav = GetHandle("scav");
	dum_scav1 = GetHandle("dum_scav1");
	dum_scav2 = GetHandle("dum_scav2");
	dum_scav3 = GetHandle("dum_scav3");
	dum_scav4 = GetHandle("dum_scav4");
	dum_scav5 = GetHandle("dum_scav5");
	dum_scav6 = GetHandle("dum_scav6");
	dum_scav7 = GetHandle("dum_scav7");
	contruct = NULL;
	dum_con1 = GetHandle("dum_con1");
	dum_con2 = GetHandle("dum_con2");
	dum_con3 = GetHandle("dum_con3");
	movie_cons1 = GetHandle("movie_cons1");
	movie_cons2 = GetHandle("movie_cons2");
	movie_cons3 = GetHandle("movie_cons3");
	apc1 = GetHandle("apc1");
	fix_serv = GetHandle("fix_serv");
	fix_tug = GetHandle("fix_tug");
	tug1 = GetHandle("tug1");
	stasis1 = GetHandle("stasis1");
	crate = GetHandle("crate");
	base = GetHandle("base");
	nav = GetHandle("nav");
	talk = NULL;
	new_pilot1 = NULL;
	new_pilot2 = NULL;
	new_pilot3 = NULL;
	new_recy_pilot = NULL;
	actor1 = NULL; actor2 = NULL;



//  integers



}

void isdfttn::AddObject(Handle h)
{
}

void isdfttn::Execute(void)
{
/*
	Here is where you put what happens every frame.  
*/

	
	player = GetPlayerHandle();


	// this holds the dummy ships always

	if (IsAround(dum_recy1))
	{
		Stop(dum_recy1);
	}
	if (IsAround(dum_recy2))
	{
		Stop(dum_recy2);
	}
	if (IsAround(dum_recy3))
	{
		Stop(dum_recy3);
	}

	if (IsAround(dum_scav1))
	{
		Stop(dum_scav1);
	}
	if (IsAround(dum_scav2))
	{
		Stop(dum_scav2);
	}
	if (IsAround(dum_scav3))
	{
		Stop(dum_scav3);
	}
	if (IsAround(dum_scav4))
	{
		Stop(dum_scav4);
	}
	if (IsAround(dum_scav5))
	{
		Stop(dum_scav5);
	}
	if (IsAround(dum_scav6))
	{
		Stop(dum_scav6);
	}
	if (IsAround(dum_scav7))
	{
		Stop(dum_scav7);
	}

	if (IsAround(dum_con1))
	{
		Stop(dum_con1);
	}
	if (IsAround(dum_con2))
	{
		Stop(dum_con2);
	}
	if (IsAround(dum_con3))
	{
		Stop(dum_con3);
	}
	//////////////////////////////////////////


	// this holds the recycler and the scav until it is time
	
	if (!recycler_free)
	{
		//Stop(recycler);
		//Stop(scav);
	}
	//////////////////////////////////////////


	if (!start_done)
	{
		//SetTeamNum(recycler,0);
		SetTeamNum(scav,0);
		Stop(recycler);
		Stop(scav);
		//RemoveObject(recycler);
		//recycler = BuildObject("ivrecy",0,"recycler_spot");
		Ally(3,1);
		Ally(1,3);
		start_done = true;
	}
	


	// these are the movies
	
	if (movie1)
	{
		if (firstFrame) {
			CameraReady();
			firstFrame = false;
		}
		movie1 = PlayMovie("open");
		movie2 = true;
	}
	if ((!movie1) && (movie2))
	{
		movie2 = PlayMovie("group2");

		if (!movie2)
		{
			CameraFinish();
			firstFrame = true;
		}
	}


	if ((!set_movie1_times) && (movie2))
	{
		dialouge1_time = GetTime() + 1.0f;
		action1_time = GetTime() + 4.2f; // spawn + start tank
		action2_time = GetTime() + 14.0f; // build power
		action3_time = GetTime() + 7.0f; // move constructor2
		action4_time = GetTime() + 12.0f; // launch apc
		action5_time = GetTime() + 9.0f; // build far power
		action6_time = GetTime() + 27.5f; // repair tug
		action7_time = GetTime() + 26.6f; // move stasis
		action8_time = GetTime() + 20.0f; // move tug
		recall_message_time = GetTime() + 35.0f; // this is the first message to report in
		Pickup(tug1,crate);
		set_movie1_times = true;
	}


	// first tank

	if ((!spawn_actor1) && (action1_time < GetTime()))
	{
		actor1 = BuildObject("ivmovietank",0,"movie1_spawn1");
		Retreat(actor1,"movie1_path1");
		Build(movie_cons1,"ibpgn1");
		Build(movie_cons3,"ibpgn1");
		spawn_actor1 = true;
	}


	// building far power

	if ((!spawn_power2) && (action5_time < GetTime()))
	{
		Dropoff(movie_cons3,"movie1_build2",1);
		spawn_power2 = true;
	}


	// building close power

	if ((!spawn_power1) && (action2_time < GetTime()))
	{
		Dropoff(movie_cons1,"movie1_build1",1);
		RemoveObject(actor1);
		spawn_power1 = true;
	}


	// moving cons2

	if ((!cons2_move) && (action3_time < GetTime()))
	{
		SetAvoidType(movie_cons2,0);
		Goto(movie_cons2,"movie1_path2a");
		cons2_move = true;
	}

	
	// moving apc

	if ((!apc_move) && (action4_time < GetTime()))
	{
		SetAvoidType(apc1,0);
		Goto(apc1,"movie1_path3",1);
		apc_move = true;
	}


	// reparing tug

	if ((!repair_tug) && (action6_time < GetTime()))
	{
		SetAvoidType(fix_serv,0);
		SetAvoidType(fix_tug,0);
		SetCurHealth(fix_tug,1000);
		Service(fix_serv,fix_tug,1);
		repair_tug = true;
	}


	// moving stasis truck

	if ((!stasis_move) && (action7_time < GetTime()))
	{
		SetAvoidType(stasis1,0);
		Goto(stasis1,"movie1_path5",1);
		stasis_move = true;
	}
	

	// moving tug w/crate

	if ((!tug_move) && (action8_time < GetTime()))
	{
		SetAvoidType(tug1,0);
		Goto(tug1,"movie1_path4",1);
		tug_move = true;
	}


	// this is the first pilot talking

	if ((!dialoge1) && (!movie1) && (movie2))
	{
		talk = AudioMessage("cin0105.wav"); // (pilot1) we must be going somwhere?!
		SetAnimation(pilot3,"speak",1);
		dialoge1 = true;
	}


	// this is the second pilot talking

	if ((!dialoge2) && (dialoge1) && (IsAudioMessageDone(talk)))
	{
		talk = AudioMessage("cin0106.wav"); // (pilot2) must be a mine field or something!
		SetAnimation(pilot2,"speak",1);
		dialoge2 = true;
	}

	
	// this is the last pilot talking

	if ((!dialoge3) && (dialoge2) && (IsAudioMessageDone(talk)))
	{
		talk = AudioMessage("cin0106a.wav"); // (Rosas) wwhat lest finish this!
		SetAnimation(pilot1,"speak",1);
		dialoge3 = true;
	}


	if ((!dialoge4) && (dialoge3) && (IsAudioMessageDone(talk)))
	{
		talk = AudioMessage("cin0107.wav"); // (pilot2) You guys will have to finish this some other time.
		dialoge4 = true;
	}


	// this is swapping them out

	if ((!movie1) && (!movie2) && (!swap))
	{
		RemoveObject(pilot3);
		RemoveObject(pilot2);
		RemoveObject(pilot1);

		new_pilot3 = BuildObject("ispilo",1,"pilot3_point");
		new_pilot2 = BuildObject("ispilo",1,"pilot2_point");
		new_pilot1 = BuildObject("ispilo",1,"pilot1_point");
		
		Goto(new_pilot3,ship3,1);
		Goto(new_pilot2,ship2,1);
		Goto(new_pilot1,ship1,1);

		//GetIn(new_pilot3,ship3,1);
		//GetIn(new_pilot2,ship2,1);
		//GetIn(new_pilot1,ship1,1);

		swap = true;
	}
	//////////////////////////////////////////


	// this is checking to see when the player is in the tunnels

	if ((IsAround(player_ship)) && (!fight_over))
	{
		if ((!in_tunnel) && (InBuilding(player_ship)))
		{
			in_tunnel = true;
		}

		if ((in_tunnel) && (!InBuilding(player_ship)))
		{
			in_tunnel = false;
		}
	}
	//////////////////////////////////////////


	// this is checking to see when the three ships are alive

	if ((swap) && (!all_in))
	{
		if (IsAlive(new_pilot3))
		{
			SetCurHealth(new_pilot3,100);
		}
		else if (!in_ship3)
		{
			SetAvoidType(ship3,0);
			Goto(ship3,"base_path1a");
			in_ship3 = true;
		}


		if (IsAlive(new_pilot2))
		{
			SetCurHealth(new_pilot2,100);
		}
		else if (!in_ship2)
		{
			SetAvoidType(ship2,0);
			Goto(ship2,"base_path1");
			in_ship2 = true;
		}


		if (IsAlive(new_pilot1))
		{
			SetCurHealth(new_pilot1,100);
		}
		else if (!in_ship1)
		{
			SetAvoidType(ship1,0);
			LookAt(ship1,player);
			in_ship1 = true;
		}


		if ((in_ship1) && (in_ship2) && (in_ship3))
		{
			pilots_time = GetTime() + 1.0f;
			all_in = true;
		}
	}
	//////////////////////////////////////////


	// this is checking to see when the two other pilots are out of sight

	if (pilots_time < GetTime())
	{
		pilots_time = GetTime() + 1.0f;
	
		if ((in_ship3) && (!remove_ship3))
		{
			if (GetDistance(ship3,player) > 500.0f)
			{
				RemoveObject(ship3);
				remove_ship3 = true;
			}
			else if ((!ship3_to_base) && (GetDistance(ship3,"center_point") < 20.0f))
			{
				Goto(ship3,"base_path2a",1);
				ship3_to_base = true;
			}
		}

		if ((in_ship2) && (!remove_ship2))
		{
			if (GetDistance(ship2,player) > 500.0f)
			{
				RemoveObject(ship2);
				remove_ship2 = true;
			}
			else if ((!ship2_to_base) && (GetDistance(ship2,"center_point") < 20.0f))
			{
				Goto(ship2,"base_path2",1);
				ship2_to_base = true;
			}
		}

		if ((in_ship1) && (!at_firing_range))
		{
			if (GetDistance(ship1,"fire_point1") < 30.0f)
			{
				Goto(ship1,"fire_point2");
				at_firing_range = true;
			}
			else if ((!ship1_to_base) && (GetDistance(ship1,"center_point") < 20.0f))
			{
				Goto(ship1,"rosas_path",1);
				ship1_to_base = true;
			}
		}
	}
	/////////////////////////////////////////


	// this is when rosas gets to the fighting area

	if ((!rosas_ready) && (at_firing_range) && (GetDistance(ship1,"fire_point2") < 30.0f))
	{
		LookAt(ship1,player);
		SetSkill(ship1,3);
		fight_check = GetTime() + 2.0f;
		rosas_ready = true;
	}
	/////////////////////////////////////////


	// this is checking to see when the player is in his ship

	if (IsOdf(player,"ivtscou1"))
	{
		out_of_ship = false;
	}
	else
	{
		out_of_ship = true;
	}
	//////////////////////////////////////////	


	// this is triggering Rosas challange

	if ((!out_of_ship) && (!rosas_challenge))
	{
		SetObjectiveOn(ship1);
		SetObjectiveName(ship1,"Dodger");
		SetObjectiveOn(nav);
		SetObjectiveName(nav,"LSF");
		talk = AudioMessage("isdfttn01.wav"); // (Rosas) lets meet at the firing area
		Goto(ship1,"dodger_point");
		base_check = GetTime() + 2.0f;
		play_check = GetTime() + 10;
		rosas_challenge = true;
	}
	//////////////////////////////////////////	


	// dodger stops when he reaches the point

	if ((!dodger_stop1) && (rosas_challenge))
	{
		if (GetDistance(ship1,"dodger_point") < 20.0f)
		{
			LookAt(ship1,player);
			dodger_stop1 = true;
		}
	}
	//////////////////////////////////////////


	// this sends Rosas to the combat area

	if ((!to_combat) && (rosas_challenge) && (IsAudioMessageDone(talk)))
	{
		Goto(ship1,"base_path1");
		fair_check = GetTime() + 1.0f;
		to_combat = true;
	}
	//////////////////////////////////////////


	// this checks to see if the player shoot rosas on the way

	if ((!rosas_ready) && (to_combat) && (fair_check < GetTime()))
	{
		if ((!fire_first1) && (GetTime() - GetLastFriendShot(ship1) < .2f))
		{
			fair_check = GetTime() + 15.0f;
			AudioMessage("isdfttn20.wav"); // (rosas) That's fair - shoot a guy in the back
			fire_first1 = true;
		}

		if ((!fire_first2) && (fire_first1) && (GetTime() - GetLastFriendShot(ship1) < .2f))
		{
			AudioMessage("isdfttn21.wav"); // (rosas) save for the firing range Cowboy
			fire_first2 = true;
		}
	}
	//////////////////////////////////////////



	// this is the rosas fight code

	if ((!start_fight) && (rosas_ready))
	{
		// when the player reaches the firing range

		if ((!player_at_rosas) && (fight_check < GetTime()))
		{
			fight_check = GetTime() + 1.0f;

			if (GetDistance(player,"fire_point2") < 60.0f)
			{
				Follow(ship1,player);
				talk = AudioMessage("isdfttn03.wav");// isdfttn03 (rosas) alright - you know the rules
				player_at_rosas = true;
			}
		}
		//////////////////////////////////////////


		// this starts the fighting

		if ((!start_fight) && (player_at_rosas))
		{
			if (GetTime() - GetLastFriendShot(ship1) < .2f)
			{
				StopAudioMessage(talk);
				talk = AudioMessage("isdfttn02.wav"); // isdfttn02 (rosas) that's fair! Lets go!
				SetTeamNum(ship1,2);
				Attack(ship1,player);
				fight_time = GetTime() + 80.0f;
				taunt_time = GetTime() + 4.0f;
				start_fight = true;
			}

			if ((!start_fight) && (IsAudioMessageDone(talk)))
			{
				talk = AudioMessage("isdfttn04.wav"); // isdfttn04 (rosas)  Go!
				SetTeamNum(ship1,2);
				Attack(ship1,player);
				fight_time = GetTime() + 80.0f;
				taunt_time = GetTime() + 4.0f;
				start_fight = true;
			}
		}
		//////////////////////////////////////////
	}


	// this is the taunting dialouge

	if ((!fight_over) && (!in_tunnel) && (start_fight))
	{
		if ((!taunt1) && (taunt_time < GetTime()))
		{
			talk = AudioMessage("isdfttn05.wav"); // isdfttn05 (rosas) taunt1
			taunt_time = GetTime() + 20.0f;
			taunt1 = true;
		}

		if ((taunt1) && (!taunt2) && (taunt_time < GetTime()))
		{
			talk = AudioMessage("isdfttn06.wav"); // isdfttn06 (rosas) taunt2
			taunt_time = GetTime() + 20.0f;
			taunt2 = true;
		}

		if ((taunt2) && (!taunt3) && (taunt_time < GetTime()))
		{
			talk = AudioMessage("isdfttn07.wav"); // isdfttn07 (rosas) taunt3
			taunt_time = GetTime() + 20.0f;
			taunt3 = true;
		}
	}
	//////////////////////////////////////////


	// this is checking to see if the player gets into one of my new ships

	if (
		(IsOdf(player,"ivmbikettn")) ||
		(IsOdf(player,"ivmislttn")) ||
		(IsOdf(player,"ivtankttn")) ||
		(IsOdf(player,"ivrcktttn")) ||
		(IsOdf(player,"ivatankttn"))
		)
	{
		in_new_unit = true;
	}


	// this ends the fight

	if ((!fight_over) && (start_fight))
	{
		// this is if rosas gets tired

		if (fight_time < GetTime())
		{
			SetTeamNum(ship1,1);
			SetObjectiveOff(ship1);
			talk = AudioMessage("isdfttn09.wav"); // isdfttn09 (rosas) I'm getting sick of this - I'm outta here
			SetTeamNum(ship1,1);
			Goto(ship1,"fire_point2");
			rosas_home_check = GetTime() + 1.0f;
			fight_over = true;
		}


		// this is if the player gets into one of the other vehicles

		if (in_new_unit)
		{
			SetTeamNum(ship1,1);
			SetObjectiveOff(ship1);
			talk = AudioMessage("isdfttn23.wav"); //  (rosas) fuck around in vehicles
			Goto(ship1,"fire_point2");
			rosas_home_check = GetTime() + 1.0f;
			fight_over = true;
		}

		// this is if the player chickens out

		if (in_tunnel)
		{
			if (!set_chicken)
			{
				SetPerceivedTeam(player,2);
				LookAt(ship1,player);
				chicken_check = GetTime() + 2.0f;
				set_chicken = true;
			}

			if ((set_chicken) && (chicken_check < GetTime()))
			{
				SetPerceivedTeam(player,1);
				SetTeamNum(ship1,1);
				SetObjectiveOff(ship1);
				talk = AudioMessage("isdfttn08.wav"); // isdfttn08 (rosas) fine chicken - I'm outta here
				Goto(ship1,"over_path2");
				rosas_home_check = GetTime() + 1.0f;
				fight_over = true;
			}
		}
		else if (set_chicken)
		{
			SetPerceivedTeam(player,1);
			Attack(ship1,player);
			chicken_check = GetTime() + 999999.9f;
			set_chicken = false;
		}
	}


	// this is checking to make sure Rosas makes it home

	if (!rosas_home)
	{
		if (rosas_home_check < GetTime())
		{
			rosas_home_check = GetTime() + 1.0f;
	
			if (!rosas_leave_fight)
			{
				if (GetDistance(ship1,"fire_point2") < 20.0f)
				{
					Goto(ship1,"over_path1");
					rosas_leave_fight = true;
				}
			}

			if ((!rosas_to_base) && (rosas_leave_fight))
			{
				if (GetDistance(ship1,"center_point") < 30.0f)
				{
					Goto(ship1,"base_path2");
					rosas_to_base = true;
				}
			}
		}

		if (GetDistance(ship1,"base_point") < 30.0f)
		{
			rosas_home = true;
		}
	}
	/////////////////////////////////////////


	// this is the recall message that triggers at regular intervals

	if ((!at_base) && (recall_message_time < GetTime()))
	{
		if (IsAudioMessageDone(talk))
		{
			talk = AudioMessage("isdfttn22.wav"); // isdfttn22 (base) all pilots return to base
			SetObjectiveOn(nav);
			SetObjectiveName(nav,"LSF");
			recall_message_time = GetTime() + 60.0f;
		}
	}



// this is the playground code

	// this is when the player reaches the playground

	if ((!at_recycler) && (play_check < GetTime()))
	{
		play_check = GetTime() + 1.0f;

		if (GetDistance(player,recycler) < 60.0f)
		{
			SetAnimation(recy_pilot,"speak");
			talk = AudioMessage("isdfttn10.wav"); // isdfttn10 (recycler) I didn't kow you had training today
			at_recycler = true;
		}
	}
	//////////////////////////////////////////

	// this is the pilot getting into the recycler

	if ((at_recycler) && (!free_recy_pilot) && (IsAudioMessageDone(talk)))
	{
		RemoveObject(recy_pilot);
		recy_pilot = BuildObject("ispilo",1,"recy_pilot_spot");
		Goto(recy_pilot,"recycler_spot",1);
		recy_pilot_safe = GetTime() + 5.0f;
		free_recy_pilot = true;
	}
	//////////////////////////////////////////


	// this is when the recycler comes to life

	if ((free_recy_pilot) && (!recycler_free))
	{
		if ((GetDistance(recy_pilot,recycler) < 15.0f) || (recy_pilot_safe < GetTime()))
		{
			SetTeamNum(recycler,1);
			SetTeamNum(scav,1);
			RemoveObject(recy_pilot);
			//RemoveObject(recycler);
			//recycler = BuildObject("ivrecyttn",1,"recycler_spot");
			Stop(recycler,0);
			Stop(scav,0);
			startup_wait = GetTime() + 3.0f;
			recycler_free = true;
		}
	}
	//////////////////////////////////////////

	// this is the last message from the recy pilot

	if ((!recy_startup) && (startup_wait < GetTime()))
	{
		talk = AudioMessage("isdfttn24.wav"); // isdfttn24 (recycler) ready for orders
		Goto(scav,"play_point",0);
		recy_startup = true;
	}
	//////////////////////////////////////////


// this is when the player returns to base

	// this is when the player reaches the base

	if ((!at_base) && (base_check < GetTime()))
	{
		base_check = GetTime() + 2.0f;

		if (GetDistance(player,nav) < 60.0f)
		{
			StopAudioMessage(talk);
			talk = AudioMessage("isdfttn11.wav"); // isdfttn11 (base) glad you could join us
			//end_time = GetTime() + 20.0f;
			at_base = true;
		}
	}
	//////////////////////////////////////////


	// this is the end

	if ((!game_over) && (at_base))
	{
		if (IsAudioMessageDone(talk))
		{
			SucceedMission(GetTime() + 5.0f);
			game_over = true;
		}
	}
	//////////////////////////////////////////


}