//==========================================
// Intro Map Script
// Tom Mustaine - Ritual Entertainment
//==========================================
// This map is not deathmatchable
//parm.deathmatch getcvar deathmatch
//parm.deathmatch ifnotequal 0 goto maps/intro_dm.scr::start
//parm.deathmatch ifnotequal 0 goto end_singleplayer_script
//goto single_player_script_start
//end

*83 model thug_shtg.def
*87 model thug_shtg.def
*83 health 700
*87 health 700

level.land_roof_dialogue1_done = 0

//end_singleplayer_script:
//end

//==========================================
// Intro Dialog
single_player_script_start:

	setdialogscript dialog/dialog_intro.scr

//
//==========================================

//==========================================
// Jump to Intro Cinematic
//==========================================

	$skip_trigger hide
	thread banktimecon
	goto cinematic
     end

//------------------------------------------
//******************************************
//==========================================
// Main thread and Script init
//==========================================
//******************************************
//------------------------------------------
mainthread:
// Flag so that player can't end level when dead
	level.PlayerKilled = 0
	level.CinematicStarted = 0

	thread helicopter_damage_thread		// Heli Damage sound thread
	thread rotors_spin_down_thread		// Rotor spindown for end
	thread billboard_thread			// Billboard setup and wait
	thread ammo1_thread			// Ammobox1 wait
	thread ammo2_thread			// Ammobox2 wait
	thread bank_entrance_thread		// Awning collapse and wait thread
	thread t1000_secret			// Easter egg

// Initial Level variable setup

	level.count_bad_guys = 0
	level.count_good_guys = 0
	level.PObjective1 = 0
	level.PObjective2 = 0
	level.PObjective3 = 0
	level.SObjective1 = 0
	level.found_secrets = 0
	level.total_secrets = 1
	level.tree_death_toll = 0
	game.intro_start = 1
	$door1	notsolid			// Fix guys getting caught on doors
	$door2	notsolid			// Fix guys getting caught on doors
	$door3	notsolid			// Fix guys getting caught on doors

	thread turret_death_wait		// Turret death counter
	thread turret1_deathreport		// Object waiting for turret death
	thread turret2_deathreport		// Object waiting for turret death
	thread turret3_deathreport		// Object waiting for turret death
	thread MissionComputer			// Mission Computer
	thread SkillLevelSettings		// Skill level settings
	thread pillar				// Awning trigger thread
	thread heli_damage_dialog		// Helicopter damage dialog thread
	thread random_sounds			// Random sounds near player head
                                                                                                                                                                                                                                                                                                                                                                                                                                               	thread shootsign			// Smart ass remark sign
     end
//==========================================
//------------------------------------------
//==========================================


//------------------------------------------
//******************************************
//==========================================
// All cinematic stuff
//==========================================
//******************************************
//------------------------------------------
cinematic:

	cinematic			// start up as a cinematic
	skipthread skip_sequence	// setup our skip thread
	waitforplayer			// wait till the player is spawned
	freezeplayer			// freeze the player
	fadeout 0.5 0 0 0		// fade out

	thread initialize_thread	// Setup level and actors
	local.waitforthread = parm.previousthread
	waitForThread local.waitforthread

	thread PoliceCar1_Movie			// Start Car1
	thread PoliceCar2_Movie			// Start Car2

	thread camera_thread			// Start Camera
	level.camerathread = parm.previousthread
	thread pigeon_thread			// Start Pigeon
	level.pigeonthread = parm.previousthread
	$roofblade thread ignore_thread		// Actors ignore everything
	$groundblade thread ignore_thread	// Actors ignore everything
	$cinematic_thug1 thread ignore_thread	// Actors ignore everything
	$cinematic_thug2 thread ignore_thread	// Actors ignore everything
     end

//==========================================
// Main Cinematic Skip Sequence
//==========================================
skip_sequence:
	fadeout 0.1 0 0 0
	noncinematic			// no longer a cinematic
	wait 0.1			// wait for fade out
	cueplayer			// go back to the player

	level.camera2started ifequal 1 terminate level.camera2thread	// kill any threads we have going
	terminate level.camerathread
	terminate level.pigeonthread

	$pigeon remove			// remove that darn pigeon

	thread helicopter_setup_thread	// setup helicopter
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	//waitForThread parm.previousthread

	$helicopter jumpto $hover_path
	thread mainthread		// Skip to action!
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	thread start_action_thread
     end

//==========================================
// Cinematic/Level Initilize thread
//==========================================
initialize_thread:
	hud 0				// Kill hud for Cinematic
	music none			// No music
	$sun1 remove
	freezeplayer
	$cinematic_thug1 model thug_shtg.def
	$cinematic_thug2 model thug_shtg.def
	$camera2 moveto $cam2start
	$node hide
	$node notsolid
	$lookatme hide
	$lookatme notsolid
	$roofblade hide
	$groundblade hide
	$groundblade notsolid
	$roofblade notsolid
	$node time .1
	$node rotateYup 180
	waitFor $node
	music aux5 none
	$cinematic_thug1 anim talk1
	$cinematic_thug2 anim talk1
     end

//==========================================
// Police Car #1 go
//==========================================
PoliceCar1_Movie:
	local.Movie = 1
	local.WaitTime = 0
	$policecar1_movie jumpto $police1_movie_start
	$policetruck1_movie jumpto $police1_movie_start
	$policetruck1_movie hide
	local.VehicleName string "$policecar1_movie"
	$policecar1_siren_movie bind local.VehicleName
	wait 0.1
     goto PoliceCar1_Movie_Loop

PoliceCar1_Movie_Loop:
	local.VehicleName show
	$policecar1_siren_movie playsound "environment/alarm/police/siren2.wav" 4
	local.VehicleName followpath $police1_movie_start normalangles
	waitFor local.VehicleName
	wait local.WaitTime
	$policecar1_siren_movie stopsound

level.piller ifequal 2 goto movieend1

	$police1_movie_launcher launch rocket
	wait 0.3
	parm.VehicleName string local.VehicleName
	thread Police1_Movie_CarExplode
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	local.VehicleName jumpto $police1_movie_start
	local.Vehicle randomint 100
	local.Vehicle ifgreater 50 local.VehicleName string "$policetruck1_movie"
	local.Vehicle iflessequal 50 local.VehicleName string "$policecar1_movie"
	$policecar1_siren_movie bind local.VehicleName
	local.WaitTime randomint 10
	local.WaitTime += 1
	wait local.WaitTime
	local.Movie ifequal 1 wait 15
	local.Movie = 0
      goto PoliceCar1_Movie_Loop
     end

movieend1:		// Stop Car from moving
end

//==========================================
// Police Car #1 explode
//==========================================
Police1_Movie_CarExplode:
	local.VehicleName string parm.VehicleName
	local.VehicleName time 0.6
	local.VehicleName moveUp    128
	local.VehicleName moveWest  24
	local.VehicleName rotateXup  -60
	trigger $police1_movie_boom
	//local.VehicleName shatter "1 1 1" 20 10 40 .05 0
	$policecar1_siren_movie playsound "environment/alarm/police/siren2down.wav" 3
      waitFor local.VehicleName

	local.VehicleName time 0.3
	local.VehicleName moveUp    64
	local.VehicleName moveWest   12
	local.VehicleName rotateXup  -30
      waitFor local.VehicleName

	local.VehicleName time 0.9
	local.VehicleName moveDown  128
	local.VehicleName moveWest    36
	local.VehicleName rotateXup  -90
	trigger $police1_movie_boom
	local.VehicleName shatter "1 1 1" 40 20 40 .05 0
      waitFor local.VehicleName

	local.VehicleName hide
	local.VehicleName time 0.1
	local.VehicleName rotateXup  180
	trigger $police1_movie_boom
      waitFor local.VehicleName
     end

//==========================================
// Police Car #2 go
//==========================================
PoliceCar2_Movie:
	local.Movie = 1
	local.WaitTime = 4
	$policecar2_movie jumpto $police2_movie_start
	$policetruck2_movie jumpto $police2_movie_start
	$policetruck2_movie hide
	local.VehicleName string "$policecar2_movie"
	$policecar2_siren_movie bind local.VehicleName
	wait 4
      goto PoliceCar2_Movie_Loop

PoliceCar2_Movie_Loop:
	local.VehicleName show
	$policecar2_siren_movie playsound "environment/alarm/police/siren2.wav" 4
	local.VehicleName followpath $police2_movie_start normalangles
	waitFor local.VehicleName
	wait local.WaitTime
	$policecar2_siren_movie stopsound

	level.piller ifequal 2 goto movieend2

	$police2_movie_launcher launch rocket
	wait 0.3
	parm.VehicleName string local.VehicleName
	thread Police2_Movie_CarExplode
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	local.VehicleName jumpto $police2_movie_start
	local.Vehicle randomint 100
	local.Vehicle ifgreater 50 local.VehicleName string "$policetruck2_movie"
	local.Vehicle iflessequal 50 local.VehicleName string "$policecar2_movie"
	$policecar2_siren_movie bind local.VehicleName
	local.WaitTime randomint 10
	local.WaitTime += 1
	wait local.WaitTime
	local.Movie ifequal 1 wait 15
	local.Movie = 0

      goto PoliceCar2_Movie_Loop
     end

movieend2:		// Car2 stop going
end

//==========================================
// Police Car #2 explode
//==========================================
Police2_Movie_CarExplode:
	local.VehicleName string parm.VehicleName
	local.VehicleName time 0.6
	local.VehicleName moveUp    128
	local.VehicleName moveNorth  24
	local.VehicleName rotateZup  -60
	trigger $police2_movie_boom
	//local.VehicleName shatter "1 1 1" 20 10 40 .05 0
	$policecar2_siren_movie playsound "environment/alarm/police/siren2down.wav" 3
      waitFor local.VehicleName

	local.VehicleName time 0.3
	local.VehicleName moveUp    64
	local.VehicleName moveNorth   12
	local.VehicleName rotateZup  -30
      waitFor local.VehicleName

	local.VehicleName time 0.9
	local.VehicleName moveDown  128
	local.VehicleName moveNorth    36
	local.VehicleName rotateZup  -90
	trigger $police2_movie_boom
	local.VehicleName shatter "1 1 1" 40 20 40 .05 0
      waitFor local.VehicleName

	local.VehicleName hide
	local.VehicleName time 0.1
	local.VehicleName rotateZup  180
	trigger $police2_movie_boom
      waitFor local.VehicleName
     end

//==========================================
// First Camera Thread - MAIN CINEMATIC
//==========================================
camera_thread:
	$pigeon speed 10
	$pigeon moveto $pigeonstart
	$camera moveto $pigeonstart
	$camera follow $pigeon
	$pigeon followpath $pigeonstart
	cueplayer
	$camera jumpcut
	cuecamera $camera
	fadein 2 0 0 0
     end

//==========================================
// Pigeon Thread - MAIN CINEMATIC
//==========================================
pigeon_thread:
	$skip_trigger notrigger
	$pigeon nextanim pigeon_fly
	wait 1.5
	$skip_trigger notrigger
	$pigeon nextanim coast
	wait 2.3
	$pigeon nextanim pigeon_fly
	wait 4
	$pigeon nextanim coast
	$pigeon nextanim coast
	wait 4.5
	$pigeon nextanim pigeon_fly
	wait 1.5
	$cinematic_thug1 anim attack
	$pigeon nextanim coast
	wait .8
	music aux6 none
	wait .2
	trigger $cinematic_sound1
	$pigeon gib 1 30 1 organic	// Piegon Dies
	$pigeon gib 20 30 1 feather
	wait .5
	skipthread ""			// no longer a cinematic
	thread camera2_thread
	level.camera2thread = parm.previousthread
     end

//==========================================
// Cinematic actors ignore thread
//==========================================
ignore_thread:
	local.self ignoreall
	pause
	goto ignore_thread
     end

//==========================================
// 2nd and 3rd Cinematic Camera Setup - MAIN CINEMATIC
//==========================================
camera2_thread:
	level.camera2started = 1
	$camera follow $node $lookatme
	wait 2
	thread camera3_thread
	$camera follow $cam2start $lookatme
	wait 2
	$camera pause
	wait 13.5 //was 12
	$camera continue
	thread move_lookatme_thread
	wait 8
	fadeout 1 0 0 0
	noncinematic		// we are no longer a cinematic
	cueplayer
	thread mainthread
	thread start_action_thread
     end

camera3_thread:
	music aux7
	parm.thug1 string $cinematic_thug1
	parm.thug2 string $cinematic_thug2
	thread dialog::thug_too_easy
	thread helicopter_ride_thread
	wait 1
	$cinematic_thug1 anim talk2
	wait 2
	$cinematic_thug1 anim talk1
	wait 1.5
	$cinematic_thug1 anim talk2
	wait 2.5
	$cinematic_thug1 anim laugh1
	wait .5
	$cinematic_thug2 anim laugh1
	wait 1
	$cinematic_thug1 anim talk1
	wait .5
	$cinematic_thug2 anim talk1
	wait 4.5
	parm.thug1 string $cinematic_thug1
	parm.thug2 string $cinematic_thug2
	wait 8.5
	thread dialog::blade_suprise
     end

move_lookatme_thread:
	$lookatme time 5
	$lookatme moveUp 128
	waitFor $lookatme
	$lookatme time 3.5
	$lookatme moveUp 148
	$lookatme moveEast 384
	$lookatme moveSouth 96
	waitFor $lookatme
     end

//==========================================
// Roof Cinematic - ROOF CINMEATIC
//==========================================
roofcam_thread:
	// if the player's dead, don't play cinematic
	level.PlayerKilled ifnotequal 0 end
	level.CinematicStarted = 1

	cinematic
	skipthread "roofcam_skip"
	trigger $glass2
	$helicopter time .1
	$helicopter notsolid
	$helicopter moveto $roofhelistart
	*1 hide
	$heligun show
	$roofblade show
	fadein 1 0 0 0
	hud 0
	freezeplayer
	thread roofheli_thread
	$roofcam jumpcut
	$roofcam moveto $roofcamstart
	$roofcam lookat $roofblade
	freezeplayer
	cuecamera $roofcam
	$roofblade thread roofblade_thread
	$roofcam follow $roofcamstart $roofblade
	wait 6
	$roofcam follow $roofblade
	waitFor $roofcam
	game.intro_start = 1		// Telling bank what exit player took
	//thread exit_level_thread
     end

roofblade_thread:
	thread exit_anyhow_roof
	$roofblade anim 1hand_idle3
	wait 3.5
	local.self walkto $roofpath1
	waitFor $roofblade
	local.self walkto $roofpath2
	wait 1
	fadeout 1 0 0 0
	waitFor $roofblade
	*1 take heligun
	level.intermissiontype = 1
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start1
     end

exit_anyhow_roof:
	wait 8
	*1 take heligun
	level.intermissiontype = 1
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start1
     end

roofcam_skip:
	noncinematic
	fadeout	1 0 0 0
	wait 1
	*1 take heligun
	level.intermissiontype = 1
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start1
     end

//==========================================
// Ground Cinematic - GROUND CINEMATIC
//==========================================
groundcam_thread:
	// if the player's dead, don't play cinematic
	level.PlayerKilled ifnotequal 0 end
	level.CinematicStarted = 1

	cinematic
	skipthread groundcam_skip
	*1 hide
	$heligun show
	$helicopter notsolid
	$groundblade show
	$groundblade thread groundblade_thread
	$groundcam follow $groundcam_start $groundblade
	$groundcam jumpcut
	freezeplayer
	cuecamera $groundcam
	fadein 1 0 0 0
	wait 4
	$groundcam follow $groundblade
	game.intro_start = 2		// Telling bank what exit player took
	//thread exit_level_thread
	wait 10
     end

groundblade_thread:
	thread end_level2_nomatterwhat
	$groundblade anim 1hand_idle3
	wait 3.5
	local.self walkto $groundpath1
	waitFor $groundblade
	local.self runto $groundpath2
	waitFor $groundblade
	$groundblade runto $groundpath7
	waitFor $groundblade
	thread end_level2
	$groundblade runto $groundpath8
	waitFor $groundblade
     end

end_level2:
	fadeout 1 0 0 0
	wait 1.5
	*1 take heligun
	level.intermissiontype = 2
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start2
     end

end_level2_nomatterwhat:	// Exit level anyhow if blade dosen't reach pathnodes.
	wait 10
	fadeout 1 0 0 0
	wait 1
	*1 take heligun
	level.intermissiontype = 2
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start2
     end

groundcam_skip:
	noncinematic
	fadeout 1 0 0 0
	wait 1
	*1 take heligun
	level.intermissiontype = 2
	thread LevelComplete	
	local.WaitingForThread = parm.previousthread
	waitForThread local.WaitingForThread
	map bank$start2
     end

//******************************************
//==========================================
// End of Cinematic section
//==========================================
//******************************************


//******************************************
//==========================================
// Other level threads
//==========================================
//******************************************

//==========================================
// Banktime Console
//==========================================
banktimecon:
	$banktime	time	10
	$banktime	rotateY	10
	level.hour = 3
	level.tens = 1
	level.mins = 2

banktimeconprint:
	level.digit1 = level.tens
	level.digit2 = level.mins

	local.PrintString string "xl 0 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 1  local.PrintString append " 1:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 2  local.PrintString append " 2:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 3  local.PrintString append " 3:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 4  local.PrintString append " 4:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 5  local.PrintString append " 5:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 6  local.PrintString append " 6:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 7  local.PrintString append " 7:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 8  local.PrintString append " 8:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 9  local.PrintString append " 9:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 10 local.PrintString append "10:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 11 local.PrintString append "11:\" xl 60 jcy fc 1 1 1 1.0 string \""
	level.hour ifequal 12 local.PrintString append "12:\" xl 60 jcy fc 1 1 1 1.0 string \""

	level.digit1 ifequal 0 local.PrintString append "0\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 1 local.PrintString append "1\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 2 local.PrintString append "2\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 3 local.PrintString append "3\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 4 local.PrintString append "4\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 5 local.PrintString append "5\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 6 local.PrintString append "6\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 7 local.PrintString append "7\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 8 local.PrintString append "8\" xl 80 jcy fc 1 1 1 1.0 string \""
	level.digit1 ifequal 9 local.PrintString append "9\" xl 80 jcy fc 1 1 1 1.0 string \""

	level.digit2 ifequal 0 local.PrintString append "0\""
	level.digit2 ifequal 1 local.PrintString append "1\""
	level.digit2 ifequal 2 local.PrintString append "2\""
	level.digit2 ifequal 3 local.PrintString append "3\""
	level.digit2 ifequal 4 local.PrintString append "4\""
	level.digit2 ifequal 5 local.PrintString append "5\""
	level.digit2 ifequal 6 local.PrintString append "6\""
	level.digit2 ifequal 7 local.PrintString append "7\""
	level.digit2 ifequal 8 local.PrintString append "8\""
	level.digit2 ifequal 9 local.PrintString append "9\""

	%introcon	conlayout	local.PrintString

	wait 60		// Wait time

	level.mins += 1
	level.mins ifequal 10 goto uptens
	goto banktimeconprint

uptens:
	level.mins *= 0
	level.tens += 1
	level.tens ifequal 6 goto uphour
	goto banktimeconprint

uphour:
	level.tens *= 0
	level.hour += 1
	level.hour ifequal 13 goto switch
	goto banktimeconprint

switch:
	level.hour = 1
	goto banktimeconprint
     end

//==========================================
// Neat stuff
//==========================================
t1000_secret:
	$t1000origin	notsolid
	$t1000origin	hide
	$t1000 bind $t1000origin
	wait .1
	$t1000origin jumpto $t1000way1
	$t1000 ignoreall
	$t1000 anim sitting
	//	$motorcycle	time	.2
	//	$motorcycle	rotateYdown	180
	//	waitFor $motorcycle
	wait .1
	$t1000 bind $motorcycle
	wait .1
	$t1000 group all +envmapped
	$motorcycle	jumpto	$motoway2
	$motorcycle	ontrigger start_t1000_secret
	pause

start_t1000_secret:
	$motoremove1 remove
	$motoportal open
	thread dialog::blade_what_the
	trigger	$motobigexpl1
	$motobreak1 shatter "0 180 0" 150 10 40 .4 0
	$motobreak1 playsound	impact/comp_explode/cmpmx3.wav 4 8 -1
	$motobreak1 remove
	wait 2
	$motorcycle	playsound	vehicle/atv/strt.wav 4 8 -1
	wait 2
	$motorcycle	playsound	vehicle/humvee/skid.wav 4 8 -1
	$motorcycle followpath $motospline
	waitFor $motorcycle
	$motorcycle shatter "1 1 1" 20 10 40 .1 0
	$motorcycle remove
	$t1000 remove
	trigger $motoexploder
	level.found_secrets += 1
	thread global/universal_script.scr::secret
     end

tree_counter:
	level.tree_death_toll += 1
	//	print level.tree_death_toll
	level.tree_death_toll ifequal 3 trigger $motorcycle
     end

//==========================================
// Goofy Alley sign getting shot thread
//==========================================
shootsign:
	$shootsign1 ondamage sign_message
	pause

sign_message:
	$shootsign1 nodamage
	thread dialog::jc_what_are_you_shooting_at1
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	thread dialog::blade_can_it_jc
     end

//==========================================
// Turret Skill level settings
//==========================================
SkillLevelSettings:
	local.skilllevel getcvar skill
	//easy
	local.skilllevel ifequal 0 $turret1 rocketrate 7
	local.skilllevel ifequal 0 $turret2 rocketrate 6
	local.skilllevel ifequal 0 $turret3 rocketrate 7
	local.skilllevel ifequal 0 $turret1 health 1300
	local.skilllevel ifequal 0 $turret2 health 1400
	local.skilllevel ifequal 0 $turret3 health 1300
	//medium
	local.skilllevel ifequal 1 $turret1 rocketrate 5
	local.skilllevel ifequal 1 $turret2 rocketrate 5
	local.skilllevel ifequal 1 $turret3 rocketrate 5
	local.skilllevel ifequal 1 $turret1 health 2000
	local.skilllevel ifequal 1 $turret2 health 2000
	local.skilllevel ifequal 1 $turret3 health 2000
	//hard
	local.skilllevel ifequal 2 $turret1 rocketrate 4
	local.skilllevel ifequal 2 $turret2 rocketrate 4
	local.skilllevel ifequal 2 $turret3 rocketrate 4
	local.skilllevel ifequal 2 $turret1 health 2100
	local.skilllevel ifequal 2 $turret2 health 2400
	local.skilllevel ifequal 2 $turret3 health 2100
	$turret1	lagtime	1
	$turret2	lagtime	1
	$turret3	lagtime	1
     end

//==========================================
// Mission Status
//==========================================
MissionComputer:
//0 nd 1 succeed 2 fail
// level.PObjective1 --> Destroy rocket turrets
// level.PObjective2 --> Eliminate all enemy forces
// level.PObjective3 --> Gain entry into the Bank
// level.SObjective1 --> Minimize Civilian Casualties
%missioncon conlayout "xv -92 yv 76 fc 0.6 0.6 1 1 string \"Over Freeport city bank\""
%missioncon conapplayout "xv -120 yv 60 fc 0.4 0.4 0.8 1 string \"Primary Objective(s):\""
level.PObjective1 ifequal 0 %missioncon conapplayout "xv -118 yv 48 spicn b_blank 0.5 0.5 xv -116 yv 48 fc 0.7 0.7 0.7 1 string \" Destroy rocket turrets\""
level.PObjective2 ifequal 0 %missioncon conapplayout "xv -118 yv 36 spicn b_blank 0.5 0.5 xv -116 yv 36 fc 0.7 0.7 0.7 1 string \" Eliminate all enemy forces\""
level.PObjective3 ifequal 0 %missioncon conapplayout "xv -118 yv 24 spicn b_blank 0.5 0.5 xv -116 yv 24 fc 0.7 0.7 0.7 1 string \" Gain entry into the Bank\""

level.PObjective1 ifequal 1 %missioncon conapplayout "xv -118 yv 48 spicn b_checked 0.5 0.5 xv -116 yv 48 fc 0.3 0.3 0.3 1 string \" Destroy rocket turrets\""
level.PObjective2 ifequal 1 %missioncon conapplayout "xv -118 yv 36 spicn b_checked 0.5 0.5 xv -116 yv 36 fc 0.3 0.3 0.3 1 string \" Eliminate all enemy forces\""
level.PObjective3 ifequal 1 %missioncon conapplayout "xv -118 yv 24 spicn b_checked 0.5 0.5 xv -116 yv 24 fc 0.3 0.3 0.3 1 string \" Gain entry into the Bank\""

level.PObjective1 ifequal 2 %missioncon conapplayout "xv -118 yv 48 spicn b_notchecked 0.5 0.5 xv -116 yv 48 fc 0.3 0.3 0.3 1 string \" Destroy rocket turrets\""
level.PObjective2 ifequal 2 %missioncon conapplayout "xv -118 yv 36 spicn b_notchecked 0.5 0.5 xv -116 yv 36 fc 0.3 0.3 0.3 1 string \" Eliminate all enemy forces\""
level.PObjective3 ifequal 2 %missioncon conapplayout "xv -118 yv 24 spicn b_notchecked 0.5 0.5 xv -116 yv 24 fc 0.3 0.3 0.3 1 string \" Gain entry into the Bank\""

%missioncon conapplayout "xv -120 yv 0 fc 0.4 0.4 0.8 1 string \"Secondary Objective(s):\""
level.SObjective1 ifequal 0 %missioncon conapplayout "xv -118 yv -12 spicn b_blank 0.5 0.5 xv -116 yv -12 fc 0.7 0.7 0.7 1 string \" Minimize Hardcorp casualties\""
level.SObjective1 ifequal 1 %missioncon conapplayout "xv -118 yv -12 spicn b_checked 0.5 0.5 xv -116 yv -12 fc 0.3 0.3 0.3 1 string \" Minimize Hardcorp casualties\""
level.SObjective1 ifequal 2 %missioncon conapplayout "xv -118 yv -12 spicn b_notchecked 0.5 0.5 xv -116 yv -12 fc 0.3 0.3 0.3 1 string \" Minimize Hardcorp casualties\""
end

//==========================================
// Billboard destroyed thread1
//==========================================
billboard_thread:
	$billboard hide
	$billboard2 bind $billboard
	$fountain_flood time .1
	$fountain_flood moveDown 10
	waitFor $fountain_flood
	game.intro_billboard_fall ifequal 0 game.intro_billboard_fall = 1
	$billboard_left ondamage billboard_fall_sequence_left
	$billboard_right ondamage billboard_fall_sequence_right
	pause

billboard_fall_sequence_left:
	$billboard_left nodamage
	$billboard_right nodamage
	game.intro_billboard_fall = 2
	wait .3
	$billboard time .4
	$billboard rotateXdown 56
	$billboard moveWest 64
	$billboard moveDown 30
	waitFor $billboard
	$billboard time .7
	$billboard rotateXdown 98
	$billboard rotateZup 5
	$billboard moveDown 495
	$billboard moveSouth 16
	$billboard moveWest 128
	waitFor $billboard
	$billboard time .5
	$billboard rotateXdown 85
	$billboard rotateZup 5
	$billboard moveDown 495
	$billboard moveSouth 16
	$billboard moveWest 128
	waitFor $billboard
	$billboard time .4
	$billboard rotateXdown 71
	$billboard rotateZup 5
	$billboard moveDown 490
	$billboard moveSouth 16
	$billboard moveWest 107
	waitFor $billboard
	$billboard playsound impact/crates/crate3.wav 3.0
	$glass1 remove
	$glass2 shatter "0 0 0" 25 10 75 .5 0
	$glass3 remove
	$glass2 remove
	$window_bar1 time .5
	$window_bar1 moveDown 368
	$window_bar1 rotateXup 22
	$window_bar1 rotateYup 30
	$window_bar1 moveWest 16
	waitFor $window_bar1
     goto bottom1


//==========================================
// Billboard destroyed thread2
//==========================================
billboard_fall_sequence_right:
	$billboard_left nodamage
	$billboard_right nodamage
	game.intro_billboard_fall = 3
	wait .3
	$billboard time .4
	$billboard rotateXdown 56
	$billboard moveWest 64
	$billboard moveDown 30
	waitFor $billboard
	$billboard time .7
	$billboard rotateXdown 98
	$billboard rotateZup 5
	$billboard moveDown 495
	$billboard moveSouth 16
	$billboard moveWest 128
	waitFor $billboard
	$billboard time .5
	$billboard rotateXdown 85
	$billboard rotateZup 5
	$billboard moveDown 495
	$billboard moveSouth 16
	$billboard moveWest 128
	waitFor $billboard
	$billboard time .4
	$billboard rotateXdown 71
	$billboard rotateZup 5
	$billboard moveDown 490
	$billboard moveSouth 16
	$billboard moveWest 107
	waitFor $billboard
	$billboard playsound impact/crates/crate3.wav 3.0
	$glass2 shatter "0 0 0" 25 10 75 .5 0
	$glass1 remove
	$glass2 remove
	$glass3 remove
	wait .2
	$billboard time .7
	$window_bar1 time .7
	$window_bar2 time .7
	$window_bar1 moveDown 368
	$window_bar1 rotateXup 22
	$window_bar1 rotateYdown 15
	$window_bar1 moveWest 16
	$window_bar2 moveDown 368
	$window_bar2 rotateXup 22
	$window_bar2 rotateYup 30
	$window_bar2 moveWest 16
	$billboard moveDown 356
	$billboard rotateXup 20
	$billboard rotateZdown 20
	waitFor $billboard
	$fountain_flood time 15
	$fountain_flood moveUp 15
	thread bottom2
	waitFor $fountain_flood
     end

bottom1:
      thread dialog::jc_dead_billboard1
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
     end

bottom2:
	thread dialog::jc_dead_billboard1
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
     end


//==========================================
// Awning at entrance setup thread
//==========================================
bank_entrance_thread:
	$pillar time .6
	$awning1 time .6
	$awning2 time .6
	$awning3 time .6
	$pillar ontrigger bank_entrance_collapse
	pause

bank_entrance_collapse:
	$pillar notrigger
	$awning2 shatter "0 0 0" 25 10 75 .10 0
	$pillar rotateZdown 45
	waitFor $pillar
	$pillar rotateZdown 45
	$awning1 rotateZup 45
	$awning2 moveDown 128
	waitFor $awning2
	$awning3 moveDown 100
	$awning1 moveDown 128
	$awning2 moveDown 128
	$awning1 moveSouth 32
	$awning2 rotateZdown 15
	waitFor $awning2
     end

pillar:
	$awning2	ondamage start_pillar
	$awning1	ondamage start_pillar
	$pillar ondamage start_pillar
	pause

start_pillar:
	$pillar	nodamage
	$awning2	nodamage
	$awning1	nodamage
	trigger $pillar
		level.piller = 2
	level.SObjective1 = 1
	thread MissionComputer
	thread global/universal_script.scr::SObjectiveComplete
     end

//==========================================
// Ammo box #1
//==========================================
ammo1_thread:
	$ammo1_roof time 1
	$ammo1 ondamage ammo1_sequence
	pause

ammo1_sequence:
	$ammo1 nodamage
	trigger $ammo1_explode
	$ammo1 shatter "0 0 0" 75 10 75 .2 0
	wait .2
	$ammo1 notsolid
	$ammo1 hide
	$ammo1_roof rotateXdown 15
	$ammo1_roof rotateZdown 15
	waitFor $ammo1_roof
	$ammo1_roof moveDown	128
	waitFor $ammo1_roof
     end

//==========================================
// Ammo box #2
//==========================================
ammo2_thread:
	game.intro_roof_break1 ifequal 0 game.intro_roof_break1 = 1
	$ammo2_roof time .5
	$ammo2_wall1 time 1.2
	$ammo2_wall2 time 1.2
	$ammo2 ondamage ammo2_sequence
	pause

ammo2_sequence:
	$ammo2 nodamage
	game.intro_roof_break1 = 2
	trigger $ammo2_explode
	$ammo2 shatter "0 0 0" 75 10 75 .2 0
	wait .2
	$ammo2 notsolid
	$ammo2 hide
	$ammo2_roof rotateXdown 15
	$ammo2_roof rotateZdown 15
	waitFor $ammo2_roof
	$ammo2_roof moveDown	128
	waitFor $ammo2_roof
     end

//------------------------------------------
//******************************************
//==========================================
// ALL HELICOPTER STUFF
//==========================================
//******************************************
//------------------------------------------

//==========================================
// Helicopter setup thread
//==========================================
helicopter_setup_thread:
	$rotors_brush notsolid			// Rotor origin
	$rotors_brush hide			// Rotor origin
	$rotors_brush bind $helicopter
	$heligun_origin bind $helicopter
	$blade2 bind $heligun_origin
	$heligun bind $heligun_origin
	$heli_fuckshitup bind $helicopter	// Random sound emitter
	wait .1
	$rotors bind $rotors_brush
	wait .1
	$rotors_brush time 1			// Start rotors spinning
	$rotors_brush rotateY 720
     end

//==========================================
// Random sounds played from heli
//==========================================
random_sounds:
	wait 10

random_sound_loop:
	wait 10
	local.rndsnd randomint 5
	local.rndsnd ifequal 1 goto combat_one
	local.rndsnd ifequal 2 goto combat_two
	local.rndsnd ifequal 3 goto combat_five
	local.rndsnd ifequal 4 goto combat_six
	local.rndsnd ifequal 5 goto combat_seven
     end

combat_one:
	parm.actor1	string	"$heli_fuckshitup"
	thread dialog::combat_one
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	goto random_sound_loop
     end

combat_two:
	parm.actor1	string	"$heli_fuckshitup"
	thread dialog::combat_two
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	goto random_sound_loop
     end

combat_five:
	parm.actor1	string	"$heli_fuckshitup"
	thread dialog::combat_five
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	goto random_sound_loop
     end

combat_six:
	parm.actor1	string	"$heli_fuckshitup"
	thread dialog::combat_six
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	goto random_sound_loop
     end

combat_seven:
	parm.actor1	string	"$heli_fuckshitup"
	thread dialog::combat_seven
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	goto random_sound_loop
     end

//==========================================
// Helicopter damage dialog thread
//==========================================
heli_damage_dialog:
	level.helidamage ifgreater 300 goto nextmessage1
	wait 1
    goto heli_damage_dialog

nextmessage1:
	thread dialog::pilot_hit2
        wait 3
	thread dialog::blade_hold_still
nextmessage1a:
	level.helidamage ifgreater 650 goto nextmessage2
	wait 1
    goto nextmessage1a

nextmessage2:
	thread dialog::pilot_hit1

nextmessage2a:
	level.helidamage ifgreater 1000 goto nextmessage3
	wait 1
    goto nextmessage2a

nextmessage3:
	thread dialog::pilot_hit3

nextmessage3a:
	level.helidamage ifgreater 1350 goto nextmessage4
	wait 1
    goto nextmessage3a

nextmessage4:
	thread dialog::pilot_sec_airsupport

nextmessage4a:
	level.helidamage ifgreater 1500 goto nextmessage5
	wait 1
    goto nextmessage4a

nextmessage5:
	thread dialog::jc_chopper_repair
	wait 4
	thread dialog::blade_shutup_jc
nextmessage5a:
	level.helidamage ifgreater 1800 goto nextmessage6
	wait 1
    goto nextmessage5a

nextmessage6:
	thread dialog::pilot_going_down

nextmessage6a:
	level.helidamage ifgreater 2000 goto fucked
	wait 1
    goto nextmessage6a

fucked:
	// don't kill the player during a cinematic
	level.CinematicStarted ifnotequal 0 end
	level.PlayerKilled = 1
	level.PObjective1 = 2
	level.PObjective2 = 2
	level.PObjective3 = 2
	level.SObjective1 = 2
	thread MissionComputer
	thread global/universal_script.scr::PObjectiveFailed
	cueplayer
	*1 playerkill
	wait 2.5
	*1 respawn	// brings up the load game menu
     end

//==========================================
// Helicopter Damage sounds
//==========================================
heli_hit:
	level.hitme_hit ifequal 1 goto heli_already_hit
	level.hitme_hit = 1
	$rotors playsound misc/null.wav 1 7
	wait .1
	$rotors playsound vehicle/helicopt/hit1.wav 2 7
	wait 3.8
	$rotors playsound vehicle/helicopt/flyloop.wav 2 7
	level.hitme_hit = 0
     end

heli_already_hit:
    end

//==========================================
// Helicopter Start moving
//==========================================
helicopter_ride_thread:			// This is called by thugs talking
	thread helicopter_setup_thread
	waitForThread parm.previousthread

start_copter:				// Copter coming from around the corner
	wait 10.5 //was 9
	$helicopter followpath $path1_startintro
	wait 2 //was 4
	$rotors playsound vehicle/helicopt/flyloop.wav 2 7
	waitFor $helicopter
     end

start_action_thread:
	hud 1
	//releaseplayer
	$helicopter lock
	$helicopter doUse *1
	$blade2	remove
	$heligun hide
	$cinematic_thug1	remove
	$cinematic_thug2	remove
	$cinematic_thug1	health 500
	$cinematic_thug2	health 500
	thread move_dudes_up
	releaseplayer
	fadein 1 0 0 0
	wait 1
	music normal
	thread thugs_attacked_dialog1
	//thread thugs_attacked_dialog2
	thread blade_talksmack1

//==========================================
// Kill both thugs setup thread
// This is where the game should jump to
// if the cinematic is killed
//==========================================
kill_cinematic_thugs:
	thread hover_path
	local.deathindex = 0
	level.hoverpathover = 0

kill_cinematic_thugs_loop:
	$thug_death_counter ontrigger counterup
	pause

counterup:
	local.deathindex += 1
	local.deathindex ifequal 2 goto start_level_loop
	goto kill_cinematic_thugs_loop
     end

move_dudes_up:			// Lift real thugs up quake1 style :]
	$remove_me_for_guys	remove
	$move_guys_up	time	.1
	$move_guys_up	moveUp	112
	waitFor $move_guys_up
     end

//==========================================
// Helicopter Hover loop
//==========================================
hover_path:
	$helicopter followpath $hover_path
	waitFor $helicopter

	level.hoverpathover ifequal 1 goto start_heli_loop
	level.hoverpathover ifequal 0 goto hover_path
     end

	start_level_loop:
	level.hoverpathover = 1
     end

heli_loop_dialog_start:
	thread global/universal_script.scr::StatusUpdated
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	thread dialog::jc_remember_boss
	
     end

//==========================================
// Start helicopter main loop
//==========================================
start_heli_loop:
	thread heli_loop_dialog_start
	thread main_level_spawn_loop	// Start up main level bad guy spawn loop
	$helicopter followpath $down_path
	waitFor $helicopter

//==========================================
// Loop copter, check damage, etc.
//==========================================
helicopter_loop_sequence:
	$helicopter followpath $loop_path
	waitFor $helicopter

	level.turretsdead ifequal 5 goto helicopter_land_roof
	level.complete ifgreaterequal 2 goto helicopter_land_roof
	level.helidamage iflessequal 2000 goto helicopter_loop_sequence

//==========================================
// Helicopter Crashing on ground start
//==========================================
$helicopter followpath $road_path

	thread copter_goin_down

	waitFor $helicopter
	$rotors playsound misc/null.wav 1 7
	wait .1
	$rotors playsound vehicle/helicopt/hidown.wav 1.0 7

	thread dialog::pilot_were_down_whew_close
	$helicopter unlock
	hud 0
	trigger $rotors_brush
	fadeout 1 0 0 0
	wait 1
	//thread dialog2		// Dialog not available
	thread groundcam_thread		// Start end ground cinematic
	goto heli_end

//==========================================
// Helicopter lands on roof
//==========================================
helicopter_land_roof:
	//$helicopter followpath $loop_path
	//waitFor $helicopter
	//thread land_roof_dialogue1_thread
	//local.waitforthread = parm.previousthread
	level.land_roof_dialogue1_done ifequal 1 goto continue_thread
	level.land_roof_dialogue1_done ifequal 0 $helicopter followpath $loop_path
	waitFor $helicopter
	continue_thread:
	level.PObjective3 = 1
	thread global/universal_script.scr::PObjectiveComplete
	thread MissionComputer
	//thread land_roof_dialogue1_thread
	//wait 4

      $helicopter followpath $roof_path
	waitFor $helicopter

	thread land_roof_dialogue2_thread

	$helicopter stopsound
	$helicopter playsound vehicle/helicopt/hidown.wav 1.0 7
	thread roofcam_thread	// Start end roof cinematic
	trigger $rotors_brush

heli_end:
     end

//==========================================
// Helicopter monitor damage thread
//==========================================
helicopter_damage_thread:

helicopter_damage_start:
	$helicopter ondamage heli_damage_sequence
	$rotors ondamage heli_damage_sequence
	pause

heli_damage_sequence:
	$helicopter nodamage
	$rotors nodamage
	thread heli_hit		// Helicopter damage sounds
	level.helidamage += local.damage
	goto helicopter_damage_start
     end

//==========================================
// Helicopter Rotor Spindown
//==========================================
rotors_spin_down_thread:
	level.rotors_speed = 720
	$rotors_brush ontrigger rotors_spin_down_loop_begin
	pause

rotors_spin_down_loop_begin:
	$rotors_brush notrigger
	rotors_spin_down_loop:
	level.rotors_speed -= 5
	$rotors_brush rotateY level.rotors_speed
	wait .1
	level.rotors_speed ifgreater 0 goto rotors_spin_down_loop
     end

//==========================================
// Helicopter Goto Roof
//==========================================
roofheli_thread:
	wait 1
	$helicopter followpath $roofhelistart
	waitFor $helicopter
     end
//******************************************
//==========================================
// End of Helicopter section
//==========================================
//******************************************



//------------------------------------------
//******************************************
//==========================================
// LEVEL DIALOG THREADS
//==========================================
//******************************************
//------------------------------------------

//==========================================
// Thugs Talking at start of action
//==========================================
thugs_attacked_dialog1:
	parm.thug1	string	"$dialog_airattack"
	thread dialog::thug_air_attack
     end

thugs_attacked_dialog2:
	parm.thug2	string	"$dialog_runforcover"
	thread dialog::thug_get_to_launchers1
end

blade_talksmack1:
	wait 4
	thread dialog::blade_not_so_fast
     end

//==========================================
// Pilot says "copter goin down!"
//==========================================
copter_goin_down:
	thread dialog::pilot_controls_arent_responding
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
	thread dialog::blade_uh_oh
	wait 2
	thread dialog::pilot_hang_on1
     end

dialog2:
	wait 3
	thread dialog::jc_get_in_there
     end

land_roof_dialogue1_thread:
	wait 1 //was 2
	thread dialog::jc_rooftop_landin
	local.waitforthread = parm.previousthread
	waitForThread parm.previousthread
     end

land_roof_dialogue2_thread:
	thread dialog::pilot_drop_and_dust
     end

//------------------------------------------
//******************************************
//==========================================
// LEVEL GAMEPLAY AND LOGIC
//==========================================
//******************************************
//------------------------------------------

//==========================================
// Temp scriptobject for turret death level variables
//==========================================
turret1_deathreport:
	$turret1_dead	ontrigger	1change
	pause

1change:
	$turret1_dead	remove
	level.turret1_nuked = 1
     end

turret2_deathreport:
	$turret2_dead	ontrigger	2change
	pause

2change:
	$turret2_dead	remove
	level.turret2_nuked = 1
     end

turret3_deathreport:
	$turret3_dead	ontrigger	3change
	pause

3change:
	$turret3_dead	remove
	level.turret3_nuked = 1
     end

//==========================================
// Main level Loop (for spawning characters.
// and randomly choosing stuff to happen in
// the streets)
//==========================================
main_level_spawn_loop:
	level.complete ifgreater 0 thread spawn_levelisdone
	level.complete ifgreater 0 goto end_main
	thread spawn_check_bad_guys
	wait 3
	goto main_level_spawn_loop

end_main:
     end

//==========================================
// Psyco spawn BAD GUY checking thread
//==========================================
spawn_check_bad_guys:
	level.count_bad_guys ifequal 3 goto spawn_check_end
	goto spawn_roof_check
     end

	//Spawn guys on roof randomness
spawn_roof_check:
	local.rndroof randomint 100
	local.rndroof iflessequal 33 goto turret1_startspawn
	local.rndroof ifgreater 33 goto more_roof_rnd

more_roof_rnd:
	local.rndroof iflessequal 66 goto turret2_startspawn
	local.rndroof ifgreater 66 goto turret3_startspawn
     end

turret1_startspawn:
	level.turret1_active ifequal 1 goto spawn_guythere
	level.turret1_nuked ifequal 1 goto spawn_guythere
	level.turret1_active ifequal 0 thread spawn_guy_at_turret1
     end

turret2_startspawn:
	level.turret2_active ifequal 1 goto spawn_guythere
	level.turret2_nuked ifequal 1 goto spawn_guythere
	level.turret2_active ifequal 0 thread spawn_guy_at_turret2
     end

turret3_startspawn:
	level.turret3_active ifequal 1 goto spawn_guythere
	level.turret3_nuked ifequal 1 goto spawn_guythere
	level.turret3_active ifequal 0 thread spawn_guy_at_turret3
     end

spawn_levelisdone:
	level.count_bad_guys ifequal 0 goto obj2_done
	wait 1
	goto spawn_levelisdone

obj2_done:
	level.complete += 1
	level.PObjective2 = 1
	thread MissionComputer
	thread global/universal_script.scr::PObjectiveComplete
	wait 1
	thread land_roof_dialogue1_thread	// Turrets dead, no more baddies
	local.waitforthread = parm.previousthread
	waitForThread local.waitforthread
	wait 6
	level.land_roof_dialogue1_done = 1
     end

spawn_check_end:	// Enough Bad guys
     end

spawn_guythere:		// Bad guy already there
     end

//==========================================
//==========================================
// Turret counter and level.complete state.
//==========================================
turret_death_wait:
	local.turret_death_index = 0

turret_death_loop:
	$turret_death_counter	ontrigger	count_turret
	pause

count_turret:
	$turret_death_counter	notrigger
	local.turret_death_index += 1
	local.turret_death_index ifequal 3 goto turrets_dead
	local.turret_death_index ifequal 1 thread dialog::pilot_nice_shooting
	local.turret_death_index ifequal 2 thread dialog::jc_way_to_hit
	goto turret_death_loop

turrets_dead:
	level.turretsdead = 5
	level.PObjective1 = 1
	thread MissionComputer
	thread global/universal_script.scr::PObjectiveComplete
	level.complete += 1
     end

//==========================================
// Spawn People in to turrets
//==========================================
// Removed window guys Spawn code 9/29
//==========================================
spawn_guy_at_turret1:		// Thug1 dude
	trigger $spawner1
	level.count_bad_guys += 1
	level.turret1_active = 1
	wait .1
	$thug1	thread thug1_setstates
	wait 2
	trigger $thug1
     end

thug1_setstates:
	local.self	ignore	runtoarea
	local.self	ignore	doorsound mutantsound voicesound machinesound radiosound
	local.self	ignore	weaponsound movementsound painsound deathsound breakingsound
	local.self	ignore	attackentity use sightenemy

	local.self	definestate	activate	thug1_activated
	local.self	definestate	killed	thug1_killed
	local.self	definestate	idle	thug1_idle

	local.self	state	idle

	pause

thug1_idle:
	local.self	anim	idle
	waitFor local.self
	pause
	goto thug1_idle

thug1_activated:
	$door1	open $thug1
	local.self      ignore  activate
	local.self	runto	$turret1_path1
	waitFor local.self
	local.self	runto	$turret1_path2
	waitFor local.self
	$turret1	activate
	local.self	anim	manrocket1
	pause
     end

thug1_killed:
	$turret1	deactivate
	level.turret1_active = 0
	level.count_bad_guys -= 1
     end

spawn_guy_at_turret2:		// Thug2 dude
	trigger $spawner2
	level.count_bad_guys += 1
	level.turret2_active = 1
	wait .1
	$thug2	thread thug2_setstates
	wait 2
	trigger $thug2
     end

thug2_setstates:
	local.self	ignore	runtoarea
	local.self	ignore	doorsound mutantsound voicesound machinesound radiosound
	local.self	ignore	weaponsound movementsound painsound deathsound breakingsound
	local.self	ignore	attackentity use sightenemy

	local.self	definestate	activate	thug2_activated
	local.self	definestate	killed	thug2_killed
	local.self	definestate	idle	thug2_idle

	local.self	state	idle

	pause

thug2_idle:
	local.self	anim	idle
	waitFor local.self
	pause
	goto thug2_idle

thug2_activated:
	$door2	open $thug2
	local.self      ignore  activate
	local.self	runto	$turret2_path1
	waitFor local.self
	local.self	runto	$turret2_path2
	waitFor local.self
	$turret2	activate
	local.self	anim	manrocket1
	pause
     end

thug2_killed:
	$turret2	deactivate
	level.turret2_active = 0
	level.count_bad_guys -= 1
	//thread spawn_guy_at_turret2
	end

spawn_guy_at_turret3:		// Thug3 dude
	trigger $spawner3
	level.count_bad_guys += 1
	level.turret3_active = 1
	wait .1
	$thug3	thread thug3_setstates
	wait 2
	trigger $thug3
     end

thug3_setstates:
	local.self	ignore	runtoarea
	local.self	ignore	doorsound mutantsound voicesound machinesound radiosound
	local.self	ignore	weaponsound movementsound painsound deathsound breakingsound
	local.self	ignore	attackentity use sightenemy

	local.self	definestate	activate	thug3_activated
	local.self	definestate	killed	thug3_killed
	local.self	definestate	idle	thug3_idle

	local.self	state	idle

	pause

thug3_idle:
	local.self	anim	idle
	waitFor local.self
	pause
	goto thug3_idle

thug3_activated:
	$door3	open $thug3
	local.self      ignore  activate
	local.self	runto	$turret3_path1
	waitFor local.self
	local.self	runto	$turret3_path2
	waitFor local.self
	$turret3	activate
	local.self	anim	manrocket1
	pause
     end

thug3_killed:
	$turret3	deactivate
	level.turret3_active = 0
	level.count_bad_guys -= 1
	//thread spawn_guy_at_turret3
     end

precache:
  cachesound "environment/alarm/police/siren2.wav"
  cachesound "environment/alarm/police/siren2down.wav"
  cachesound "impact/comp_explode/cmpmx3.wav"
  cachesound "impact/crates/crate3.wav"
  cachesound "misc/null.wav"
  cachesound "vehicle/helicopt/hit1.wav"
  cachesound "vehicle/helicopt/flyloop.wav"
  cachesound "vehicle/helicopt/hidown.wav"
  cachesound "vehicle/atv/strt.wav"
  cachesound "vehicle/humvee/skid.wav"
end

LevelComplete:
// Clears any items in the player's inventory that need to be removed
thread global/universal_script.scr::ClearInventory

// Any objectives that haven't been set to Success or Fail should be set
// here. This usually is for things like "Eliminate All Hostile Forces"
// All Objectives need to be set to Success or Fail by the end of the
// map. This should be automatic for the most part but if you
// Find any that aren't, we need to figure out what to do with them.
level.SObjective1 ifnotequal 1 level.SObjective1 = 2
level.PObjective1 ifnotequal 1 level.PObjective1 = 2
level.PObjective2 ifnotequal 1 level.PObjective2 = 2
level.PObjective3 ifnotequal 1 level.PObjective3 = 1

// Set up the Primary Objectives
local.IMString string "oxl 2 oyt -32 fc 0.53 0.53 0.83 1 string \"Primary Objective(s):\""

level.PObjective1 ifequal 1 local.IMString append "oxl 6 oyt -42 spicn b_checked 0.5 0.5 oxl 18 oyt -42 fc 0.6 0.6 0.6 1 string \"Destroy rocket turrets\""
level.PObjective2 ifequal 1 local.IMString append "oxl 6 oyt -52 spicn b_checked 0.5 0.5 oxl 18 oyt -52 fc 0.6 0.6 0.6 1 string \"Eliminate all enemy forces\""
level.PObjective3 ifequal 1 local.IMString append "oxl 6 oyt -62 spicn b_checked 0.5 0.5 oxl 18 oyt -62 fc 0.6 0.6 0.6 1 string \"Gain entry into the Bank\""

level.PObjective1 ifequal 2 local.IMString append "oxl 6 oyt -42 spicn b_notchecked 0.5 0.5 oxl 18 oyt -42 fc 0.6 0.6 0.6 1 string \"Destroy rocket turrets\""
level.PObjective2 ifequal 2 local.IMString append "oxl 6 oyt -52 spicn b_notchecked 0.5 0.5 oxl 18 oyt -52 fc 0.6 0.6 0.6 1 string \"Eliminate all enemy forces\""
level.PObjective3 ifequal 2 local.IMString append "oxl 6 oyt -62 spicn b_notchecked 0.5 0.5 oxl 18 oyt -62 fc 0.6 0.6 0.6 1 string \"Gain entry into the Bank\""


// Set up the Secondary Objectives
local.IMString append "oxl 2 oyt -82 fc 0.53 0.53 0.83 1 string \"Secondary Objective(s):\""

level.SObjective1 ifequal 1 local.IMString append "oxl 6 oyt -92 spicn b_checked 0.5 0.5 oxl 18 oyt -92 fc 0.6 0.6 0.6 1 string \"Minimize Hardcorp casualties\""

level.SObjective1 ifequal 2 local.IMString append "oxl 6 oyt -92 spicn b_notchecked 0.5 0.5 oxl 18 oyt -92 fc 0.6 0.6 0.6 1 string \"Minimize Hardcorp casualties\""

// Send over the information that Scott needs to load the proper intermission
level.intermissiontype ifequal 1 loadintermission "layouts/im_layouts/intro_to_bank_B"
level.intermissiontype ifequal 2 loadintermission "layouts/im_layouts/intro_to_bank_A"
intermissionlayout local.IMString
end