sr2lua/em01.lua

  1. -- em01.lua 
  2. -- SR2 mission script 
  3. -- 04/25/08 
  4.  
  5. -- Global Variables -- 
  6. Em01_assault_smoke				= {"em01_$n073", "em01_$n074", "em01_$n075", "em01_$n076"} 
  7. Em01_smoke_effect					= "smoke_grenade" 
  8. Em01_smoke_1					=	INVALID_THREAD_HANDLE 
  9. Em01_smoke_2					=	INVALID_THREAD_HANDLE 
  10. Em01_smoke_3					=	INVALID_THREAD_HANDLE 
  11. Em01_smoke_4					=	INVALID_THREAD_HANDLE 
  12.  
  13. Em01_ultor_assault_01			= {"em01_$c000", "em01_$c001"} 
  14. Num_em01_ultor_assault_01		= sizeof_table(Em01_ultor_assault_01) 
  15.  
  16. Em01_ultor_assault_02			= {"em01_$c002", "em01_$c003", "em01_$c004"} 
  17. Num_em01_ultor_assault_02		= sizeof_table(Em01_ultor_assault_02) 
  18.  
  19. Num_em01_assault_masako			= Num_em01_ultor_assault_01 + Num_em01_ultor_assault_02 
  20. Assault_masako_kill_count		= 0 
  21.  
  22. Em01_ultor_defend_01				= {"em01_$c005", "em01_$c006", "em01_$c007", "em01_$c008"} 
  23. Num_em01_ultor_defend_01		= sizeof_table(Em01_ultor_defend_01) 
  24. Defend_1_masako_kill_count		= 0 
  25.  
  26. Em01_ultor_defend_02_a			= {"em01_$c009", "em01_$c010", "em01_$c011"} 
  27. Num_em01_ultor_defend_02_a		= sizeof_table(Em01_ultor_defend_02_a) 
  28.  
  29. Em01_ultor_defend_02_b			= "em01_$c012" 
  30. Em01_ultor_defend_02_c			= "em01_$c013" 
  31.  
  32. Num_em01_defend_masako			= Num_em01_ultor_defend_02_a + 2 
  33. Defend_masako_kill_count		= 0 
  34.  
  35. Em01_ultor_west_a					= {"em01_$c014", "em01_$c015", "em01_$c016", "em01_$c017"} 
  36. Num_em01_ultor_west_a			= sizeof_table(Em01_ultor_west_a) 
  37.  
  38. Em01_ultor_west_b					= {"em01_$c018", "em01_$c019", "em01_$c020", "em01_$c021"} 
  39. Num_em01_ultor_west_b			= sizeof_table(Em01_ultor_west_b) 
  40.  
  41. Num_em01_west_masako				= Num_em01_ultor_west_a + Num_em01_ultor_west_b 
  42. West_masako_kill_count			= 0 
  43.  
  44. Em01_ultor_east					= {"em01_$c022", "em01_$c023", "em01_$c024", "em01_$c025"} 
  45. Num_em01_ultor_east				= sizeof_table(Em01_ultor_east) 
  46.  
  47. East_masako_kill_count			= 0 
  48.  
  49. Em01_ultor_south_a				= {"em01_$c026", "em01_$c027", "em01_$c028", "em01_$c029"} 
  50. Num_em01_ultor_south_a			= sizeof_table(Em01_ultor_south_a) 
  51.  
  52. Em01_ultor_south_b				= {"em01_$c030", "em01_$c031", "em01_$c032", "em01_$c033"} 
  53. Num_em01_ultor_south_b			= sizeof_table(Em01_ultor_south_b) 
  54.  
  55. Num_em01_south_masako			= Num_em01_ultor_south_a + Num_em01_ultor_south_b 
  56. South_masako_kill_count			= 0 
  57.  
  58. Em01_ultor_heli					= {"em01_$c034", "em01_$c035"} 
  59. Heli_masako_killed				= false 
  60.  
  61. Em01_heli_path						= {"em01_$n040", "em01_$n039", "em01_$n040", "em01_$n041"} 
  62. Num_em01_heli_path				= sizeof_table(Em01_heli_path) 
  63. Em01_heli_can_jump				= {false, true, false, true} 
  64. Em01_heli_jump_church			= {["em01_$n039"] = {{"em01_$n131", "em01_$n130", "em01_$n129", "em01_$n041"}, 4}, 
  65. 											["em01_$n041"] = {{"em01_$n129", "em01_$n130", "em01_$n131", "em01_$n039"}, 2}} 
  66. HELI_JUMP_PATTERN					= 1 
  67. HELI_JUMP_INDEX					= 2 
  68.  
  69. Num_em01_required_kills			= Num_em01_assault_masako + Num_em01_ultor_defend_01 + Num_em01_defend_masako + Num_em01_west_masako + Num_em01_ultor_east + Num_em01_south_masako 
  70. Num_em01_required_count			= 0 
  71.  
  72. Em01_siren_lights					= {"em01_$v010", "em01_$v011", "em01_$v012", "em01_$v013", "em01_$v014", "em01_$v017", "em01_$v018"} 
  73. Num_em01_siren_lights			= sizeof_table(Em01_siren_lights) 
  74.  
  75. Em01_weak_sauce_heli				= {"em01_$c040", "em01_$c041"} 
  76. Em01_lamb_apc_a					= {"em01_$c042", "em01_$c043"} 
  77. Em01_lamb_apc_b					= {"em01_$c044", "em01_$c045"} 
  78.  
  79. Em01_oh_shit_heli_a				= {"em01_$c036", "em01_$c037"} 
  80. Em01_oh_shit_heli_b				= {"em01_$c038", "em01_$c039"} 
  81. Em01_oh_shit_fire_now			= false 
  82.  
  83. Em01_last_stand_heli_a			= {"em01_$c047", "em01_$c048"} 
  84. Em01_last_stand_heli_b			= {"em01_$c049", "em01_$c050"} 
  85. Em01_last_stand_heli_killed	= 0 
  86.  
  87. Em01_ls_table_a_ccw				= {{"em01_$ccw100_107", "em01_$ccw100_102"},  
  88. 											{"em01_$ccw102_100", "em01_$ccw102_107"},  
  89. 											{"em01_$ccw107_102", "em01_$ccw107_100"}} 
  90. Em01_ls_table_a_ccw_idx			= {{["em01_$ccw100_107"] = 3, ["em01_$ccw100_102"] = 2},  
  91. 											{["em01_$ccw102_100"] = 1, ["em01_$ccw102_107"] = 3},  
  92. 											{["em01_$ccw107_102"] = 2, ["em01_$ccw107_100"] = 1}} 
  93. Em01_ls_table_a_cw				= {{"em01_$cw100_102", "em01_$cw100_107"},  
  94. 											{"em01_$cw102_107", "em01_$cw102_100"},  
  95. 											{"em01_$cw107_100", "em01_$cw107_102"}} 
  96. Em01_ls_table_a_cw_idx			= {{["em01_$cw100_102"] = 2, ["em01_$cw100_107"] = 3},  
  97. 											{["em01_$cw102_107"] = 3, ["em01_$cw102_100"] = 1},  
  98. 											{["em01_$cw107_100"] = 1, ["em01_$cw107_102"] = 2}} 
  99. Em01_ls_table_a					= {Em01_ls_table_a_ccw, Em01_ls_table_a_cw} 
  100. Em01_ls_table_a_idx				= {Em01_ls_table_a_ccw_idx, Em01_ls_table_a_cw_idx} 
  101.  
  102. Em01_ls_table_b_ccw				= {{"em01_$ccw110_116", "em01_$ccw110_114"},  
  103. 											{"em01_$ccw114_110", "em01_$ccw114_116"},  
  104. 											{"em01_$ccw116_114", "em01_$ccw116_110"}} 
  105. Em01_ls_table_b_ccw_idx			= {{["em01_$ccw110_116"] = 3, ["em01_$ccw110_114"] = 2},  
  106. 											{["em01_$ccw114_110"] = 1, ["em01_$ccw114_116"] = 3},  
  107. 											{["em01_$ccw116_114"] = 2, ["em01_$ccw116_110"] = 1}} 
  108. Em01_ls_table_b_cw				= {{"em01_$cw110_114", "em01_$cw110_116"},  
  109. 											{"em01_$cw114_116", "em01_$cw114_110"},  
  110. 											{"em01_$cw116_110", "em01_$cw116_114"}} 
  111. Em01_ls_table_b_cw_idx			= {{["em01_$cw110_114"] = 2, ["em01_$cw110_116"] = 3},  
  112. 											{["em01_$cw114_116"] = 3, ["em01_$cw114_110"] = 1},  
  113. 											{["em01_$cw116_110"] = 1, ["em01_$cw116_114"] = 2}} 
  114. Em01_ls_table_b					= {Em01_ls_table_b_ccw, Em01_ls_table_b_cw} 
  115. Em01_ls_table_b_idx				= {Em01_ls_table_b_ccw_idx, Em01_ls_table_b_cw_idx} 
  116.  
  117. Em01_ls_table_julius				= {"em01_$n123", "em01_$n124", "em01_$n140", "em01_$n125",  
  118. 											"em01_$n126", "em01_$n127", "em01_$n139", "em01_$n128"} 
  119. Num_em01_ls_table_julius		= sizeof_table(Em01_ls_table_julius) 
  120.  
  121. Em01_church_doors					= {"em01_SRCh_dr01MeshMoverA010", "em01_SRCh_dr01MeshMoverA020", 
  122. 											"em01_SRCh_dr01MeshMoverA030", "em01_SRCh_dr01MeshMoverA040"} 
  123. Num_em01_church_doors			= sizeof_table(Em01_church_doors) 
  124.  
  125. --a table to create a random set of numbers for a helicopter firing sequence.  Each time the sequence is called it picks from one set of lines, fires a rocket then waits the rand time, then fires the next rocket until the end of the sequence.  The final value is how long the heli waits at the location after firing the last rocket before moving to the next location. 
  126. --Changing this table will increase/decrease the randomness of the firing sequence 
  127.  
  128. Em01_missile_sequence			= {{0.0}, 
  129. 											{rand_float(2.0, 3.0), 10.0}, 
  130. 											{rand_float(2.0, 2.5), 10.0}, 
  131. 											{rand_float(1.5, 2.5), rand_float(1.0, 2.0), 10.0}, 
  132. 											{rand_float(2.0, 2.5), rand_float(1.0, 2.0), 10.0}, 
  133. 											{rand_float(1.5, 2.0), rand_float(2.0, 2.5), 10.0}, 
  134. 								} 
  135. 								 
  136. Num_em01_missile_sequence		= sizeof_table(Em01_missile_sequence) 
  137.  
  138. HELI_FIRE_MULTIPLIER 			= 3.0		--multiplier for helicopter missle accuracy.  If multiplier is set to 1 then missle will hit within 1 meter of the target 
  139. -- Current number of the path chase vehicles that are chasing the player 
  140. Num_path_chase_vehicles_chasing = 0 
  141.  
  142. CHURCH_IS_BEING_ABANDONED		= false 
  143. CHURCH_ABANDON_DIST_WARN		= 80.0 
  144. CHURCH_ABANDON_TIME				= 15000 
  145.  
  146. -- Max number of path chase vehicles that should chase the player 
  147. MAX_NUM_PATH_CHASERS          = 3 
  148.  
  149. CHURCH_SCRIPT_PAUSED				= false 
  150.  
  151. SMOKE_DEFEND_ACTIVE				= true 
  152. SMOKE_ASSAULT_ACTIVE				= true 
  153.  
  154. IN_COOP								= false 
  155.  
  156. LAST_STAND_SHOW_PERFORMED		= false 
  157. LAST_STAND_ATTACK_STARTED     = false 
  158. Controls_disabled = false 
  159. Players_have_temp_weapons		= false 
  160.  
  161. LOCATION_START_LOCAL				= "em01_$local_player_start" 
  162. LOCATION_START_REMOTE			= "em01_$remote_player_start" 
  163.  
  164. GROUP_START							= "em01_$start" 
  165. GROUP_ASSAULT_1					= "em01_$assault_1" 
  166. GROUP_ASSAULT_2					= "em01_$assault_2" 
  167. GROUP_DEFEND_1						= "em01_$defend_1" 
  168. GROUP_DEFEND_2_A					= "em01_$defend_2_a" 
  169. GROUP_DEFEND_2_B					= "em01_$defend_2_b" 
  170. GROUP_DEFEND_2_C					= "em01_$defend_2_c" 
  171. GROUP_WEST_VEHICLES				= "em01_$west_vehicles" 
  172. GROUP_WEST_A						= "em01_$west_a" 
  173. GROUP_WEST_B						= "em01_$west_b" 
  174. GROUP_EAST_VEHICLE				= "em01_$east_vehicle" 
  175. GROUP_EAST							= "em01_$east" 
  176. GROUP_SOUTH_VEHICLES				= "em01_$south_vehicles" 
  177. GROUP_SOUTH_A						= "em01_$south_a" 
  178. GROUP_SOUTH_B						= "em01_$south_b" 
  179. GROUP_HELI_VEHICLE				= "em01_$heli_vehicle" 
  180. GROUP_HELI							= "em01_$heli" 
  181. GROUP_JULIUS_VEHICLE				= "em01_$julius_vehicle" 
  182. GROUP_WEAK_VEHICLE				= "em01_$weak_vehicle" 
  183. GROUP_WEAK							= "em01_$weak" 
  184. GROUP_LAMB							= "em01_$lamb" 
  185. GROUP_LAMB_A						= "em01_$lamb_a" 
  186. GROUP_LAMB_B						= "em01_$lamb_b" 
  187. GROUP_OH_SHIT_VEH_A				= "em01_$oh_shit_vehicle_a" 
  188. GROUP_OH_SHIT_VEH_B				= "em01_$oh_shit_vehicle_b" 
  189. GROUP_OH_SHIT_A					= "em01_$oh_shit_a" 
  190. GROUP_OH_SHIT_B					= "em01_$oh_shit_b" 
  191. GROUP_ROADBLOCK					= "em01_$roadblock" 
  192. GROUP_STAND_VEH_A					= "em01_$last_stand_veh_a" 
  193. GROUP_STAND_VEH_B					= "em01_$last_stand_veh_b" 
  194. GROUP_STAND_A						= "em01_$last_stand_a" 
  195. GROUP_STAND_B						= "em01_$last_stand_b" 
  196.  
  197. PATH_CHASE_GROUPS             = { "em01_$Path_Chase_V1", "em01_$Path_Chase_V2", 
  198.                                   "em01_$Path_Chase_V3", "em01_$Path_Chase_V4", 
  199.                                   "em01_$Path_Chase_V5", "em01_$Path_Chase_V6" } 
  200.  
  201. PATH_CHASE_PASSENGERS         = { { "em01_$Path_Chase_V1_M01", "em01_$Path_Chase_V1_M02" }, 
  202.                                   { "em01_$Path_Chase_V2_M01", "em01_$Path_Chase_V2_M02" }, 
  203.                                   { "em01_$Path_Chase_V3_M01", "em01_$Path_Chase_V3_M02" }, 
  204.                                   { "em01_$Path_Chase_V4_M01", "em01_$Path_Chase_V4_M02" }, 
  205.                                   { "em01_$Path_Chase_V5_M01", "em01_$Path_Chase_V5_M02" }, 
  206.                                   { "em01_$Path_Chase_V6_M01", "em01_$Path_Chase_V6_M02" } } 
  207.  
  208. CHARACTER_JULIUS					= "em01_$julius" 
  209.  
  210. CHURCH_LEASH_INSIDE				= "em01_$inside" 
  211. CHURCH_LEASH_EAST					= "em01_$east" 
  212. CHURCH_LEASH_WEST					= "em01_$west" 
  213. CHURCH_LEASH_SOUTH				= "em01_$south" 
  214.  
  215. HELI_ATTACK_POINT_1				= "em01_$n044" 
  216. HELI_ATTACK_POINT_2				= "em01_$n045" 
  217.  
  218. LAST_STAND_POINT_A				= "em01_$n083" 
  219. LAST_STAND_POINT_B				= "em01_$n091" 
  220. LAST_STAND_CHECK_A				= "em01_$n100" 
  221. LAST_STAND_CHECK_B				= "em01_$n110" 
  222.  
  223. DEFEND_CHURCH_TRIGGER			= "em01_$defend_trigger" 
  224. APC_RAM1_TRIGGER					= "em01_$ram1" 
  225. APC_RAM2_TRIGGER					= "em01_$ram2" 
  226. PEEL_OFF_TRIGGER					= "em01_$call_off" 
  227. GOTCHA_TRIGGER						= "em01_$gotcha" 
  228. LAST_STAND_SHOW_TRIGGER			= "em01_$last_stand_show" 
  229. LAST_STAND_EXECUTE_TRIGGER		= "em01_$last_stand_execute" 
  230.  
  231. TRIGGER_BLAST_CHURCH				= "em01_$blast_church" 
  232. TRIGGER_FALL_BACK					= "em01_$fall_back" 
  233. TRIGGER_BLAST_OH_SHIT			= "em01_$blast_oh_shit" 
  234. TRIGGER_BLAST_VEHICLE			= "em01_$blast_vehice" 
  235. TRIGGER_BLAST_CANCEL				= "em01_$blast_cancel" 
  236.  
  237. PATH_CHASE_TRIGGERS           =  { "em01_$Path_Chase_V1_T", "em01_$Path_Chase_V2_T", 
  238.                                    "em01_$Path_Chase_V3_T", "em01_$Path_Chase_V4_T", 
  239.                                    "em01_$Path_Chase_V5_T", "em01_$Path_Chase_V6_T" } 
  240.  
  241. WEST_SIDE_VEHICLE_1				= "em01_$v000" 
  242. WEST_SIDE_VEHICLE_2				= "em01_$v001" 
  243. EAST_SIDE_VEHICLE					= "em01_$v002" 
  244. SOUTH_SIDE_VEHICLE_1				= "em01_$v003" 
  245. SOUTH_SIDE_VEHICLE_2				= "em01_$v004" 
  246. HELI_ATTACK_VEHICLE				= "em01_$v005" 
  247. JULIUS_VEHICLE						= "em01_$v006" 
  248. OH_SHIT_HELI_A						= "em01_$v007" 
  249. OH_SHIT_HELI_B						= "em01_$v008" 
  250. WEAK_HELI_VEHICLE					= "em01_$v009" 
  251. LAMB_A_VEHICLE						= "em01_$v015" 
  252. LAMB_B_VEHICLE						= "em01_$v016" 
  253. LAST_STAND_HELI_A					= "em01_$v019" 
  254. LAST_STAND_HELI_B					= "em01_$v020" 
  255.  
  256. PATH_CHASE_VEHICLES           = { "em01_$Path_Chase_V1", "em01_$Path_Chase_V2", 
  257.                                   "em01_$Path_Chase_V3", "em01_$Path_Chase_V4", 
  258.                                   "em01_$Path_Chase_V5", "em01_$Path_Chase_V6" } 
  259.  
  260. WEST_SIDE_ARRIVE_1				= "em01_$path000" 
  261. WEST_SIDE_ARRIVE_2				= "em01_$path001" 
  262. EAST_SIDE_ARRIVE					= "em01_$path002" 
  263. SOUTH_SIDE_ARRIVE_1				= "em01_$path003" 
  264. SOUTH_SIDE_ARRIVE_2				= "em01_$path004" 
  265. HELI_ATTACK_ARRIVE				= "em01_$path005" 
  266. ESCAPE_ROUTE_PATH_A				= "em01_$path006a" 
  267. ESCAPE_ROUTE_PATH_B				= "em01_$path006b" 
  268. CRASH_ROUTE_PATH					= "em01_$path007" 
  269. OH_SHIT_PATH_A						= "em01_$path008" 
  270. OH_SHIT_PATH_B						= "em01_$path009" 
  271. APC_RAM_PATH_A						= "em01_$path010" 
  272. APC_RAM_PATH_B						= "em01_$path011" 
  273. LAST_STAND_PATH_A					= "em01_$path012" 
  274. LAST_STAND_PATH_B					= "em01_$path013" 
  275.  
  276. CHURCH_ABANDON_INTERIOR_THREAD	= INVALID_THREAD_HANDLE 
  277. CHURCH_ABANDON_PERIMETER_THREAD	= INVALID_THREAD_HANDLE 
  278. LAMB_TO_THE_SLAUGHTER_THREAD		= INVALID_THREAD_HANDLE 
  279. JULIUS_MOVE_TO_POINT_THREAD		= INVALID_THREAD_HANDLE 
  280. JULIUS_VEHICLE_HEALTH_WATCH		= INVALID_THREAD_HANDLE 
  281.  
  282. CT_INTRO = "BON01" 
  283. CT_OUTRO = "BON02" 
  284.  
  285. -- This needs to come after Julius being defined... 
  286. Em01_heliwave1_exchange = {{"JULIUS_BONUS_HELICOPTER_01",	CHARACTER_JULIUS,	0.0}, 
  287. 									{"PLAYER_BONUS_HELICOPTER_01",	LOCAL_PLAYER,		rand_float(0.25, 0.5)}} 
  288.  
  289. Em01_helideath_exchange = {{"JULIUS_BONUS_HELIDEATH_01",		CHARACTER_JULIUS,	0.0}, 
  290. 									{"PLAYER_BONUS_HELIDEATH_01",		LOCAL_PLAYER,		rand_float(0.25, 0.5)}} 
  291.  
  292. Em01_vehicle_exchange	= {{"JULIUS_BONUS_CARCHAT_01",		CHARACTER_JULIUS,	0.0}, 
  293. 									{"PLAYER_BONUS_CARCHAT_01",		LOCAL_PLAYER,		rand_float(0.25, 0.5)}, 
  294. 									{"JULIUS_BONUS_CARCHAT_02",		CHARACTER_JULIUS,	rand_float(0.25, 0.5)}} 
  295.  
  296. Em01_heliwave2_exchange = {{"JULIUS_BONUS_HELIWAVE2_01",		CHARACTER_JULIUS,	0.0}, 
  297. 									{"PLAYER_BONUS_HELIWAVE2_01",		LOCAL_PLAYER,		rand_float(0.25, 0.5)}} 
  298.  
  299.  
  300. function em01_start(checkpoint, is_restart) 
  301. 	-- Start trigger is hit...the activate button was hit 
  302. 	set_mission_author("Ryan Spencer") 
  303.  
  304. 	-- Check for coop being active 
  305. 	if (coop_is_active()) then 
  306. 		IN_COOP	= true 
  307. 	end 
  308.  
  309. 	-- Fade out of free roam... 
  310. 	mission_start_fade_out() 
  311.  
  312.    --[[ TEMP 
  313.    checkpoint = "perimeter" 
  314.    group_create(GROUP_START, true) 
  315.    -- Teleport the player(s) to where they will need to be 
  316.    teleport_coop(LOCATION_START_LOCAL, LOCATION_START_REMOTE) 
  317.    -- END TEMP]] 
  318.  
  319. 	-- Check to see if we are starting from the beginning 
  320. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  321. 		-- No checkpoint 
  322. 	if (not is_restart) then 
  323.       cutscene_play( CT_INTRO ) 
  324. 	end 
  325.       fade_out( 0 ) 
  326.  
  327. 		-- Have smoke bombs go off!!! 
  328. 		thread_new("em01_smoke_it_up") 
  329.  
  330. 		-- Create the starting group 
  331. 		group_create(GROUP_START, true) 
  332.  
  333. 		-- Teleport the player(s) to where they will need to be 
  334. 		teleport_coop(LOCATION_START_LOCAL, LOCATION_START_REMOTE) 
  335.  
  336. 		group_create_hidden(GROUP_ASSAULT_1) 
  337. 		group_create_hidden(GROUP_ASSAULT_2) 
  338.  
  339. 		-- Julius just received a beating so he needs half health 
  340. 		set_current_hit_points(CHARACTER_JULIUS, get_max_hit_points(CHARACTER_JULIUS) * 0.5) 
  341. 		-- Give Julius a handgun 
  342. 		inv_item_remove_all(CHARACTER_JULIUS) 
  343. 		inv_item_add("desert eagle", 1, CHARACTER_JULIUS) 
  344.  
  345. 		-- Spawn off a thread to make sure the church is not abandoned 
  346. 		CHURCH_ABANDON_INTERIOR_THREAD = thread_new("em01_church_abandonment_interior") 
  347.  
  348. 		-- Proceed with the assault 
  349. 		thread_new("em01_church_assault") 
  350. 	elseif (checkpoint == "perimeter") then 
  351. 		-- Perimeter checkpoint 
  352.  
  353. 		-- Setup all the needed data 
  354. 		group_create(GROUP_JULIUS_VEHICLE, true) 
  355.  
  356. 		-- Load our ultor strike scenario 
  357. 		group_create_hidden(GROUP_WEAK_VEHICLE) 
  358. 		group_create_hidden(GROUP_WEAK) 
  359. 		group_create_hidden(GROUP_LAMB) 
  360. 		group_create_hidden(GROUP_LAMB_A) 
  361. 		group_create_hidden(GROUP_LAMB_B) 
  362.  
  363. 		thread_new("em01_make_a_run_for_it") 
  364. 	else--if(checkpoint == "last stand" ) then 
  365. 		-- Last stand checkpoint 
  366.       -- Give the player(s) the rocket launcher 
  367.       inv_weapon_add_temporary(LOCAL_PLAYER, "rpg_annihilator", 1, true) 
  368.       inv_weapon_add_temporary(LOCAL_PLAYER, "AR50_launcher", 1 ,true ) 
  369.       inv_weapon_add_temporary(LOCAL_PLAYER, "grenade", 1, true ) 
  370.       if (IN_COOP) then 
  371.          inv_weapon_add_temporary(REMOTE_PLAYER, "rpg_annihilator", 1, true) 
  372.          inv_weapon_add_temporary(REMOTE_PLAYER, "AR50_launcher", 1 ,true ) 
  373.          inv_weapon_add_temporary(REMOTE_PLAYER, "grenade", 1, true ) 
  374.       end 
  375. 		Players_have_temp_weapons = true 
  376.  
  377. 		-- Create our groups for the final stand off 
  378. 		group_create_hidden(GROUP_STAND_VEH_A, true) 
  379. 		group_create_hidden(GROUP_STAND_VEH_B, true) 
  380. 		group_create(GROUP_STAND_A, true) 
  381. 		group_create(GROUP_STAND_B, true) 
  382. 		group_create(GROUP_ROADBLOCK, true) 
  383.  
  384. 		thread_new("em01_last_stand_show") 
  385. 		thread_new("em01_last_stand_attack") 
  386. 	end 
  387.  
  388. 	--Turn off museum kiosk triggers for duration of mission 
  389. 	trigger_enable("julius_kiosk_$01", false) 
  390. 	trigger_enable("julius_kiosk_$02", false) 
  391. 	trigger_enable("julius_kiosk_$03", false) 
  392. 	trigger_enable("julius_kiosk_$04", false) 
  393. 	trigger_enable("julius_kiosk_$05", false) 
  394. 	trigger_enable("julius_kiosk_$06", false) 
  395. 	trigger_enable("julius_kiosk_$07", false) 
  396. 	 
  397. 	-- Open up the Church doors 
  398. 	for i = 1, Num_em01_church_doors, 1 do 
  399.       mesh_mover_reset(Em01_church_doors[i]) 
  400. 		door_open(Em01_church_doors[i]) 
  401. 	end 
  402.  
  403. 	-- Add Julius to the party 
  404. 	party_add(CHARACTER_JULIUS, LOCAL_PLAYER) 
  405. 	-- He can not be abandoned 
  406. 	on_dismiss("em01_julius_abondoned", CHARACTER_JULIUS) 
  407. 	-- He cannot die during this mission 
  408. 	on_death("em01_julius_died", CHARACTER_JULIUS) 
  409. 	-- Have Julius attack enemies 
  410. 	set_attack_enemies_flag(CHARACTER_JULIUS, true) 
  411.  
  412. 	-- Lets do some persona override here... 
  413. 	persona_override_character_stop_all(CHARACTER_JULIUS) 
  414. 	persona_override_character_start(CHARACTER_JULIUS, POT_SITUATIONS[POT_ATTACK], "JULIUS_BONUS_ATTACK") 
  415. 	persona_override_character_start(CHARACTER_JULIUS, POT_SITUATIONS[POT_TAKE_DAMAGE], "JULIUS_BONUS_TAKEDAM") 
  416.  
  417. 	-- We don't want any ultor to spawn unless we say so... 
  418. 	notoriety_force_no_spawn("ultor", true) 
  419. 	notoriety_force_no_spawn("police", true) 
  420. 	notoriety_set_min("police", 4) 
  421. 	roadblocks_enable(false) 
  422.  
  423. 	-- Fade in from the mission setup 
  424. 	mission_start_fade_in() 
  425. end 
  426.  
  427. function em01_cleanup() 
  428. 	-- Cleanup mission here 
  429.  
  430. 	-- Kill any running threads 
  431. 	thread_kill(CHURCH_ABANDON_INTERIOR_THREAD) 
  432. 	thread_kill(CHURCH_ABANDON_PERIMETER_THREAD) 
  433. 	thread_kill(LAMB_TO_THE_SLAUGHTER_THREAD) 
  434. 	thread_kill(JULIUS_MOVE_TO_POINT_THREAD) 
  435. 	thread_kill(JULIUS_VEHICLE_HEALTH_WATCH) 
  436. 	 
  437. 	--stop the smoke effect 
  438. 	effect_stop(Em01_smoke_1) 
  439. 	effect_stop(Em01_smoke_2) 
  440. 	effect_stop(Em01_smoke_3) 
  441. 	effect_stop(Em01_smoke_4) 
  442. 	 
  443. 	--Turn on museum kiosk triggers after mission is over 
  444. 	trigger_enable("julius_kiosk_$01", true) 
  445. 	trigger_enable("julius_kiosk_$02", true) 
  446. 	trigger_enable("julius_kiosk_$03", true) 
  447. 	trigger_enable("julius_kiosk_$04", true) 
  448. 	trigger_enable("julius_kiosk_$05", true) 
  449. 	trigger_enable("julius_kiosk_$06", true) 
  450. 	trigger_enable("julius_kiosk_$07", true) 
  451.  
  452. 	-- Just reset all of the persona overrides... 
  453. 	if (character_exists(CHARACTER_JULIUS)) then 
  454. 		persona_override_character_stop_all(CHARACTER_JULIUS) 
  455. 	end 
  456.  
  457. 	-- Turn the damage indicator 
  458. 	damage_indicator_off(0) 
  459.  
  460. 	-- Turn off the objective text 
  461. 	objective_text_clear(0) 
  462.  
  463. 	-- Reset notoriety 
  464. 	notoriety_force_no_spawn("police", false) 
  465. 	notoriety_force_no_spawn("ultor", false) 
  466. 	notoriety_reset("police") 
  467. 	roadblocks_enable() 
  468.  
  469. 	-- Remove callbacks 
  470. 	on_vehicle_enter("", JULIUS_VEHICLE) 
  471. 	on_vehicle_exit("", JULIUS_VEHICLE) 
  472. 	on_vehicle_destroyed("", JULIUS_VEHICLE) 
  473. 	on_vehicle_destroyed("", WEAK_HELI_VEHICLE) 
  474. 	on_trigger_exit("", DEFEND_CHURCH_TRIGGER) 
  475.  
  476. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  477. 	if ( coop_is_active() ) then 
  478. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  479. 	end 
  480.  
  481. 	if ( Players_have_temp_weapons ) then 
  482. 		inv_weapon_remove_temporary(LOCAL_PLAYER, "rpg_annihilator") 
  483. 		inv_weapon_remove_temporary(LOCAL_PLAYER, "AR50_launcher") 
  484. 		inv_weapon_remove_temporary(LOCAL_PLAYER, "grenade") 
  485. 		if ( coop_is_active() ) then 
  486. 			inv_weapon_remove_temporary(REMOTE_PLAYER, "rpg_annihilator") 
  487. 			inv_weapon_remove_temporary(REMOTE_PLAYER, "AR50_launcher") 
  488. 			inv_weapon_remove_temporary(REMOTE_PLAYER, "grenade") 
  489. 		end 
  490. 	end 
  491.  
  492. 	-- Remove the markers 
  493. 	marker_remove_group(GROUP_ASSAULT_1, SYNC_ALL) 
  494. 	marker_remove_group(GROUP_ASSAULT_2, SYNC_ALL) 
  495. 	 
  496. 	marker_remove_group(GROUP_DEFEND_1, SYNC_ALL) 
  497. 	marker_remove_group(GROUP_DEFEND_2_A, SYNC_ALL) 
  498. 	marker_remove_group(GROUP_DEFEND_2_B, SYNC_ALL) 
  499. 	marker_remove_group(GROUP_DEFEND_2_C, SYNC_ALL) 
  500.  
  501. 	marker_remove_group(GROUP_WEST_A, SYNC_ALL) 
  502. 	marker_remove_group(GROUP_WEST_B, SYNC_ALL) 
  503.  
  504. 	marker_remove_group(GROUP_EAST, SYNC_ALL) 
  505.  
  506. 	marker_remove_group(GROUP_SOUTH_A, SYNC_ALL) 
  507. 	marker_remove_group(GROUP_SOUTH_B, SYNC_ALL) 
  508.  
  509. 	marker_remove_group(GROUP_HELI_VEHICLE, SYNC_ALL) 
  510.  
  511. 	marker_remove_group(GROUP_JULIUS_VEHICLE, SYNC_ALL) 
  512.  
  513. 	-- Release these groups to the world 
  514. 	release_to_world(GROUP_ASSAULT_1) 
  515. 	release_to_world(GROUP_ASSAULT_2) 
  516. 	 
  517. 	release_to_world(GROUP_DEFEND_1) 
  518. 	release_to_world(GROUP_DEFEND_2_A) 
  519. 	release_to_world(GROUP_DEFEND_2_B) 
  520. 	release_to_world(GROUP_DEFEND_2_C) 
  521.  
  522. 	release_to_world(GROUP_WEST_VEHICLES) 
  523. 	release_to_world(GROUP_WEST_A) 
  524. 	release_to_world(GROUP_WEST_B) 
  525.  
  526. 	release_to_world(GROUP_EAST_VEHICLE) 
  527. 	release_to_world(GROUP_EAST) 
  528.  
  529. 	release_to_world(GROUP_SOUTH_VEHICLES) 
  530. 	release_to_world(GROUP_SOUTH_A) 
  531. 	release_to_world(GROUP_SOUTH_B) 
  532.  
  533. 	release_to_world(GROUP_HELI_VEHICLE) 
  534. 	release_to_world(GROUP_HELI) 
  535.  
  536. 	release_to_world(GROUP_WEAK_VEHICLE) 
  537. 	release_to_world(GROUP_WEAK) 
  538. 	release_to_world(GROUP_LAMB) 
  539. 	release_to_world(GROUP_LAMB_A) 
  540. 	release_to_world(GROUP_LAMB_B) 
  541.  
  542. 	release_to_world(GROUP_OH_SHIT_VEH_A) 
  543. 	release_to_world(GROUP_OH_SHIT_VEH_B) 
  544. 	release_to_world(GROUP_OH_SHIT_A) 
  545. 	release_to_world(GROUP_OH_SHIT_B) 
  546. --[[ 
  547. 	release_to_world(GROUP_STAND_VEH_A) 
  548. 	release_to_world(GROUP_STAND_VEH_B) 
  549. --]] 
  550. 	release_to_world(GROUP_STAND_A) 
  551. 	release_to_world(GROUP_STAND_B) 
  552. 	 
  553. 	-- Destroy these groups 
  554. 	group_destroy(GROUP_ROADBLOCK) 
  555. 	group_destroy(GROUP_START) 
  556. 	group_destroy(GROUP_JULIUS_VEHICLE) 
  557.  
  558. 	-- Close the Church doors, so that things are back the way they were before 
  559. 	for i = 1, Num_em01_church_doors, 1 do 
  560. 		door_close(Em01_church_doors[i]) 
  561. 	end 
  562.  
  563. 	if ( Controls_disabled ) then 
  564. 		player_controls_enable( LOCAL_PLAYER ) 
  565. 		if ( coop_is_active() ) then 
  566. 			player_controls_enable( REMOTE_PLAYER ) 
  567. 		end 
  568. 	end 
  569. end 
  570.  
  571. function em01_success() 
  572. 	-- Called when the mission has ended with success 
  573. 	-- Unlock Julius' Car 
  574.  
  575. 	-- Post the news event 
  576. 	radio_post_event("JANE_NEWS_BONUS", true) 
  577.  
  578. end 
  579.  
  580. function em01_complete() 
  581. 	-- Mission is complete with success 
  582. 	mission_end_success("em01", CT_OUTRO) 
  583. end 
  584.  
  585. function em01_church_abandoned() 
  586. 	-- Mission is complete with failure 
  587. 	mission_end_failure("em01", "em01_church_abandoned") 
  588. end 
  589.  
  590. function em01_julius_died() 
  591. 	-- Mission is complete with failure 
  592. 	mission_end_failure("em01", "em01_julius_died") 
  593. end 
  594.  
  595. function em01_julius_abondoned() 
  596. 	-- Mission is complete with failure 
  597. 	mission_end_failure("em01", "em01_julius_abandoned") 
  598. end 
  599.  
  600. function em01_vehicle_destroyed() 
  601. 	-- Mission is complete with failure 
  602. 	mission_end_failure("em01", "em01_vehicle_destroyed") 
  603. end 
  604.  
  605. function em01_smoke_it_up() 
  606. 	while (SMOKE_DEFEND_ACTIVE) do 
  607. 		if (SMOKE_ASSAULT_ACTIVE) then 
  608. 			-- Play the two effects near the front 
  609. 			Em01_smoke_1 = effect_play(Em01_smoke_effect, Em01_assault_smoke[1], false) 
  610. 			delay(1) 
  611. 			Em01_smoke_2 = effect_play(Em01_smoke_effect, Em01_assault_smoke[2], false) 
  612. 			 
  613. 			-- Delay so there is smoke in the church for an extended period of time 
  614. 			delay(4) 
  615. 		end 
  616.  
  617. 		-- Play the two effects near the sides 
  618. 		Em01_smoke_3 = effect_play(Em01_smoke_effect, Em01_assault_smoke[3], false) 
  619. 		delay(1) 
  620. 		Em01_smoke_4 = effect_play(Em01_smoke_effect, Em01_assault_smoke[4], false) 
  621.  
  622. 		-- Delay a significant amount of time and do it agian...smoke effects lasts about 30 seconds 
  623. 		delay(26) 
  624. 	end 
  625. end 
  626.  
  627. -- For the interior we just need to check failure...the notoriety and pausing of church script 
  628. --		is handled by the trigger that detects when the player has left protecting the church 
  629. function em01_church_abandonment_interior() 
  630. 	-- Do this until the thread is killed 
  631. 	while(1) do 
  632. 		thread_yield() 
  633.  
  634. 		local local_player = get_dist_char_to_nav(LOCAL_PLAYER, CHURCH_LEASH_INSIDE) 
  635. 		local remote_player = 0.0 
  636.  
  637. 		if (IN_COOP) then 
  638. 			remote_player = get_dist_char_to_nav(REMOTE_PLAYER, CHURCH_LEASH_INSIDE) 
  639. 		end 
  640.  
  641. 		local		local_abandoning = (local_player > CHURCH_ABANDON_DIST_WARN) 
  642. 		local		remote_abandoning = (remote_player > CHURCH_ABANDON_DIST_WARN) 
  643.  
  644. 		if (local_abandoning or remote_abandoning) then 
  645. 			if (CHURCH_IS_BEING_ABANDONED == false) then 
  646. 				-- Show the abandon message 
  647. 				mission_help_table_nag("em01_abandoning_church") 
  648.  
  649. 				-- Put 15 seconds on the clock 
  650. 				hud_timer_set(0, CHURCH_ABANDON_TIME, "em01_church_abandoned") 
  651. 				-- Add the radius the player(s) must be in 
  652. 				minimap_icon_add_radius(CHURCH_LEASH_INSIDE, CHURCH_ABANDON_DIST_WARN, SYNC_ALL) 
  653. 			end 
  654. 			 
  655. 			CHURCH_IS_BEING_ABANDONED = true 
  656. 		else 
  657. 			CHURCH_IS_BEING_ABANDONED = false 
  658.  
  659. 			-- Remove the timer 
  660. 			hud_timer_stop(0) 
  661. 			-- Remove the radius the player(s) must be in 
  662. 			minimap_icon_remove_radius(CHURCH_LEASH_INSIDE, SYNC_ALL) 
  663. 		end 
  664. 	end 
  665. end 
  666.  
  667. function em01_church_assault() 
  668. 	-- Setup the defense trigger 
  669. 	trigger_enable(DEFEND_CHURCH_TRIGGER, true) 
  670. 	on_trigger_exit("em01_exited_church", DEFEND_CHURCH_TRIGGER) 
  671.  
  672. 	-- Delay a couple of seconds before Julius speaks and the objective is given 
  673. 	delay(2.0) 
  674.  
  675. 	-- Play audio line for Julius 
  676. 	audio_play_for_character("JULIUS_BONUS_MISSIONSTART", CHARACTER_JULIUS, "voice", false, true) 
  677.  
  678. 	-- Instruct the player to defend the church 
  679. 	mission_help_table("em01_defend_church") 
  680.  
  681. 	-- Delay a couple of seconds before the church assault begins 
  682. 	delay(2.0) 
  683.  
  684. 	-- Add the objective 
  685. 	objective_text(0, "em01_defend_objective", Assault_masako_kill_count, Num_em01_assault_masako) 
  686.  
  687. 	-- Assault the church...wave one attack 
  688. 	group_show(GROUP_ASSAULT_1) 
  689. 	marker_add_group(GROUP_ASSAULT_1, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  690. 	for i = 1, Num_em01_ultor_assault_01, 1 do 
  691. 		on_death("em01_assault_killed", Em01_ultor_assault_01[i]) 
  692. 		attack(Em01_ultor_assault_01[i]) 
  693. 	end 
  694.  
  695. 	-- Assault the church...wave two prepare 
  696. 	group_show(GROUP_ASSAULT_2) 
  697. 	marker_add_group(GROUP_ASSAULT_2, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  698. 	for i = 1, Num_em01_ultor_assault_02, 1 do 
  699. 		on_death("em01_assault_killed", Em01_ultor_assault_02[i]) 
  700. 	end 
  701.  
  702. 	-- Wait a little while before sending in ground troops 
  703. 	 
  704. 	delay(3.0) 
  705.  
  706. 	-- Assault the church...wave two attack 
  707. 	for i = 1, Num_em01_ultor_assault_02, 1 do 
  708. 		attack(Em01_ultor_assault_02[i]) 
  709. 	end 
  710.  
  711. 	-- Create the attackers in the defend church phase 
  712. 	group_create_hidden(GROUP_DEFEND_1) 
  713. 	group_create_hidden(GROUP_DEFEND_2_A) 
  714. 	group_create_hidden(GROUP_DEFEND_2_B) 
  715. 	group_create_hidden(GROUP_DEFEND_2_C) 
  716. end 
  717.  
  718. function em01_exited_church(human, trigger) 
  719. 	-- Swap the enter/exit functionality 
  720. 	on_trigger_exit("", trigger) 
  721. 	on_trigger("em01_entered_church", trigger) 
  722.  
  723. 	-- The player is defending the church so punish him for not doing so 
  724. 	notoriety_force_no_spawn("ultor", false) 
  725. 	notoriety_force_no_spawn("police", false) 
  726.  
  727. 	CHURCH_SCRIPT_PAUSED = true 
  728. end 
  729.  
  730. function em01_entered_church(human, trigger) 
  731. 	-- Swap the enter/exit functionality 
  732. 	on_trigger("", trigger) 
  733. 	on_trigger_exit("em01_exited_church", trigger) 
  734.  
  735. 	-- The player has temporarily learned his lesson so disable notoriety spawning 
  736. 	notoriety_force_no_spawn("ultor", true) 
  737. 	notoriety_force_no_spawn("police", true) 
  738.  
  739. 	CHURCH_SCRIPT_PAUSED = false 
  740. end 
  741.  
  742. function em01_clear_objective(show_help_text) 
  743. 	-- Delay a second so that the objective can be seen updated 
  744. 	delay(1) 
  745. 	-- Clear the objective 
  746. 	objective_text_clear(0) 
  747. 	--show help text for when first sets of masako are killed 
  748. 	if show_help_text then 
  749. 		delay(3) 
  750. 		mission_help_table("em01_more_masako") 
  751. 	end 
  752. 	 
  753. 	-- Delay a couple of seconds so the objective is seen as cleared 
  754. 	delay(2) 
  755. end 
  756.  
  757. function em01_assault_killed(human) 
  758. 	-- Remove the marker 
  759. 	marker_remove_npc(human, SYNC_ALL) 
  760.  
  761. 	-- Add to the count 
  762. 	Assault_masako_kill_count = Assault_masako_kill_count + 1 
  763.  
  764. 	-- Keep track of the total kills 
  765. 	Num_em01_required_count = Num_em01_required_count + 1 
  766.  
  767. 	-- Update the objective 
  768. 	objective_text(0, "em01_defend_objective", Assault_masako_kill_count, Num_em01_assault_masako) 
  769.  
  770. 	-- Once the objective has been met, we can start the side attacks 
  771. 	if (Assault_masako_kill_count == Num_em01_assault_masako) then 
  772. 		em01_clear_objective(true) 
  773. 		em01_defend_church_part1() 
  774. 	end 
  775. end 
  776.  
  777. function em01_defend_church_part1() 
  778. 	-- Wait until we can actually execute the script 
  779. 	while (CHURCH_SCRIPT_PAUSED) do 
  780. 		thread_yield() 
  781. 	end 
  782.  
  783. 	-- The smoke assault is finished 
  784. 	SMOKE_ASSAULT_ACTIVE = false 
  785.  
  786. 	-- Show the group 
  787. 	group_show(GROUP_DEFEND_1) 
  788. 	-- Have the group attack from the west side 
  789. 	marker_add_group(GROUP_DEFEND_1, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  790. 	for i = 1, Num_em01_ultor_defend_01, 1 do 
  791. 		on_death("em01_defend_1_killed", Em01_ultor_defend_01[i]) 
  792. 		attack(Em01_ultor_defend_01[i]) 
  793. 	end 
  794.  
  795. 	-- Add the objective 
  796. 	objective_text(0, "em01_defend_objective", Defend_1_masako_kill_count, Num_em01_ultor_defend_01) 
  797. end 
  798.  
  799. function em01_defend_1_killed(human) 
  800. 	-- Remove the marker 
  801. 	marker_remove_npc(human, SYNC_ALL) 
  802.  
  803. 	-- Add to the count 
  804. 	Defend_1_masako_kill_count = Defend_1_masako_kill_count + 1 
  805.  
  806. 	-- Keep track of the total kills 
  807. 	Num_em01_required_count = Num_em01_required_count + 1 
  808.  
  809. 	-- Update the objective 
  810. 	objective_text(0, "em01_defend_objective", Defend_1_masako_kill_count, Num_em01_ultor_defend_01) 
  811.  
  812. 	-- One assault human left so start the perimeter attack 
  813. 	if (Defend_1_masako_kill_count == Num_em01_ultor_defend_01) then 
  814. 		em01_clear_objective(true) 
  815. 		em01_defend_church_part2() 
  816. 	end 
  817. end 
  818.  
  819. function em01_defend_church_part2() 
  820. 	-- Wait until we can actually execute the script 
  821. 	while (CHURCH_SCRIPT_PAUSED) do 
  822. 		thread_yield() 
  823. 	end 
  824.  
  825. 	-- Show the group 
  826. 	group_show(GROUP_DEFEND_2_A) 
  827. 	-- Have the group attack from the west side 
  828. 	marker_add_group(GROUP_DEFEND_2_A, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  829. 	for i = 1, Num_em01_ultor_defend_02_a, 1 do 
  830. 		on_death("em01_defend_2_killed", Em01_ultor_defend_02_a[i]) 
  831. 		attack(Em01_ultor_defend_02_a[i]) 
  832. 	end 
  833.  
  834. 	-- Wait until we can show both the masako from upstairs... 
  835. 	em01_defend_church_part2_reveal_human(GROUP_DEFEND_2_B, Em01_ultor_defend_02_b) 
  836. 	em01_defend_church_part2_reveal_human(GROUP_DEFEND_2_C, Em01_ultor_defend_02_c) 
  837.  
  838. 	-- Create the perimeter west group 
  839. 	group_create_hidden(GROUP_WEST_VEHICLES) 
  840. 	group_create_hidden(GROUP_WEST_A) 
  841. 	group_create_hidden(GROUP_WEST_B) 
  842.  
  843. 	-- The smoke defend church sequence if finished 
  844. 	SMOKE_DEFEND_ACTIVE = false 
  845.  
  846. 	-- Add the objective 
  847. 	objective_text(0, "em01_defend_objective", Defend_masako_kill_count, Num_em01_defend_masako) 
  848. end 
  849.  
  850. function em01_defend_church_part2_reveal_human(group, human) 
  851. 	-- Wait until group is shown 
  852. 	while (1) do 
  853. 		thread_yield() 
  854.  
  855. 		-- Only attempted if the script is not paused 
  856. 		if (not CHURCH_SCRIPT_PAUSED) then 
  857. 			local local_can_show		= not npc_in_player_fov(human, LOCAL_PLAYER) 
  858. 			local remote_can_show	= true 
  859.  
  860. 			if (IN_COOP) then 
  861. 				local	remote_can_show = not npc_in_player_fov(human, REMOTE_PLAYER) 
  862. 			end 
  863.  
  864. 			if (local_can_show and remote_can_show) then 
  865. 				-- Show the human 
  866. 				group_show(group) 
  867. 				-- Have the human attack 
  868. 				marker_add_group(group, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  869. 				on_death("em01_defend_2_killed", human) 
  870. 				attack(human) 
  871. 				return 
  872. 			end 
  873. 		end 
  874. 	end 
  875. end 
  876.  
  877. function em01_defend_2_killed(human) 
  878. 	-- Remove the marker 
  879. 	marker_remove_npc(human, SYNC_ALL) 
  880.  
  881. 	-- Add to the count 
  882. 	Defend_masako_kill_count = Defend_masako_kill_count + 1 
  883.  
  884. 	-- Keep track of the total kills 
  885. 	Num_em01_required_count = Num_em01_required_count + 1 
  886.  
  887. 	-- Update the objective 
  888. 	objective_text(0, "em01_defend_objective", Defend_masako_kill_count, Num_em01_defend_masako) 
  889.  
  890. 	-- One assault human left so start the perimeter attack 
  891. 	if (Defend_masako_kill_count == Num_em01_defend_masako) then 
  892. 		em01_clear_objective(false) 
  893. 		em01_perimeter_west() 
  894. 	end 
  895. end 
  896.  
  897. function em01_church_abandon_perimeter_cleanup() 
  898.    CHURCH_IS_BEING_ABANDONED = false 
  899.  
  900.    -- The player has temporarily learned his lesson so disable notoriety spawning 
  901.    notoriety_force_no_spawn("ultor", true) 
  902.    notoriety_force_no_spawn("police", true) 
  903.  
  904.    CHURCH_SCRIPT_PAUSED = false 
  905.  
  906.    -- Remove the timer 
  907.    hud_timer_stop(0) 
  908.    -- Remove the radius the player(s) must be in 
  909.    minimap_icon_remove_radius(CHURCH_LEASH_INSIDE, SYNC_ALL) 
  910. end 
  911.  
  912. -- When we abandon the defending the perimeter of the church we need to check for failure and raise 
  913. -- notoriety and pause the script. There is not trigger for this part 
  914. function em01_church_abandonment_perimeter() 
  915. 	-- Do this until the thread is killed 
  916. 	while(1) do 
  917. 		thread_yield() 
  918.  
  919. 		local local_player = get_dist_char_to_nav(LOCAL_PLAYER, CHURCH_LEASH_INSIDE) 
  920. 		local remote_player = 0.0 
  921.  
  922. 		if (IN_COOP) then 
  923. 			remote_player = get_dist_char_to_nav(REMOTE_PLAYER, CHURCH_LEASH_INSIDE) 
  924. 		end 
  925.  
  926. 		local		local_abandoning = (local_player > CHURCH_ABANDON_DIST_WARN) 
  927. 		local		remote_abandoning = (remote_player > CHURCH_ABANDON_DIST_WARN) 
  928.  
  929. 		if (local_abandoning or remote_abandoning) then 
  930. 			if (CHURCH_IS_BEING_ABANDONED == false) then 
  931. 				-- Show the abandon message 
  932. 				mission_help_table_nag("em01_abandoning_church") 
  933.  
  934. 				-- The player is defending the church so punish him for not doing so 
  935. 				notoriety_force_no_spawn("ultor", false) 
  936. 				notoriety_force_no_spawn("police", false) 
  937.  
  938. 				CHURCH_SCRIPT_PAUSED = true 
  939.  
  940. 				-- Put 15 seconds on the clock 
  941. 				hud_timer_set(0, CHURCH_ABANDON_TIME, "em01_church_abandoned") 
  942. 				-- Add the radius the player(s) must be in 
  943. 				minimap_icon_add_radius(CHURCH_LEASH_INSIDE, CHURCH_ABANDON_DIST_WARN, SYNC_ALL) 
  944. 			end 
  945. 			 
  946. 			CHURCH_IS_BEING_ABANDONED = true 
  947. 		else 
  948. 			CHURCH_IS_BEING_ABANDONED = false 
  949.  
  950. 			-- The player has temporarily learned his lesson so disable notoriety spawning 
  951. 			notoriety_force_no_spawn("ultor", true) 
  952. 			notoriety_force_no_spawn("police", true) 
  953.  
  954. 			CHURCH_SCRIPT_PAUSED = false 
  955.  
  956. 			-- Remove the timer 
  957. 			hud_timer_stop(0) 
  958. 			-- Remove the radius the player(s) must be in 
  959. 			minimap_icon_remove_radius(CHURCH_LEASH_INSIDE, SYNC_ALL) 
  960. 		end 
  961. 	end 
  962. end 
  963.  
  964. function em01_west_perimeter_vehicle_pathfind() 
  965. 	-- Do the pathfind...this function yields 
  966. 	vehicle_pathfind_to(WEST_SIDE_VEHICLE_2, WEST_SIDE_ARRIVE_2, true, false) 
  967. 	vehicle_stop(WEST_SIDE_VEHICLE_2) 
  968.  
  969. 	-- One the vehicle has reached its destination then have the humans exit... 
  970. 	for i = 1, Num_em01_ultor_west_b, 1 do 
  971. 		vehicle_exit(Em01_ultor_west_b[i]) 
  972. 		attack(Em01_ultor_west_b[i], CHARACTER_JULIUS) 
  973. 	end 
  974. 	 
  975. 	-- Do the pathfind...this function yields 
  976. 	vehicle_pathfind_to(WEST_SIDE_VEHICLE_1, WEST_SIDE_ARRIVE_1, true, false) 
  977. 	vehicle_stop(WEST_SIDE_VEHICLE_1) 
  978.  
  979. 	-- One the vehicle has reached its destination then have the humans exit... 
  980. 	for i = 1, Num_em01_ultor_west_a, 1 do 
  981. 		vehicle_exit(Em01_ultor_west_a[i]) 
  982. 		attack(Em01_ultor_west_a[i], CHARACTER_JULIUS) 
  983. 	end 
  984. end 
  985.  
  986. function em01_move_julius_to_point(navpoint) 
  987. 	-- Change Julius's state to idle before pathfinding 
  988. 	npc_go_idle(CHARACTER_JULIUS) 
  989. 	-- Move the human to this location 
  990. 	move_to_safe(CHARACTER_JULIUS, navpoint, 3, true, true) 
  991. 	-- Make sure Julius isn't killed during the first move to 
  992. 	if (follower_is_unconscious(CHARACTER_JULIUS)) then 
  993. 		thread_yield() 
  994. 		 
  995. 		-- We need to pause the script from proceeding until Julius is revived 
  996. 		while (follower_is_unconscious(CHARACTER_JULIUS)) do 
  997. 			thread_yield() 
  998. 		end 
  999.  
  1000. 		-- Change Julius's state to idle before pathfinding 
  1001. 		npc_go_idle(CHARACTER_JULIUS) 
  1002. 		-- Move Julius to this location 
  1003. 		move_to_safe(CHARACTER_JULIUS, navpoint, 3, true, true) 
  1004. 	end 
  1005. end 
  1006.  
  1007. function em01_church_abandon_interior_cleanup() 
  1008.    CHURCH_IS_BEING_ABANDONED = false 
  1009.  
  1010.       -- Remove the timer 
  1011.    hud_timer_stop(0) 
  1012.    -- Remove the radius the player(s) must be in 
  1013.    minimap_icon_remove_radius(CHURCH_LEASH_INSIDE, SYNC_ALL) 
  1014. end 
  1015.  
  1016. function em01_perimeter_west() 
  1017. 	-- Just to be safe, make sure notoriety spawning isn't happening...do this before the thread is spawned 
  1018. 	notoriety_force_no_spawn("ultor", true) 
  1019. 	notoriety_force_no_spawn("police", true) 
  1020.  
  1021. 	-- No longer need the interior church abandonment thread 
  1022. 	thread_kill(CHURCH_ABANDON_INTERIOR_THREAD) 
  1023.  
  1024.    -- Remove any failure timers that were possibly running 
  1025.    em01_church_abandon_interior_cleanup() 
  1026.  
  1027.    -- Spawn off a thread to make sure the church is not abandoned 
  1028. 	CHURCH_ABANDON_PERIMETER_THREAD = thread_new("em01_church_abandonment_perimeter") 
  1029.  
  1030. 	-- Disable the defense trigger since we are defending at the perimeter 
  1031. 	trigger_enable(DEFEND_CHURCH_TRIGGER, false) 
  1032.  
  1033. 	-- Make Julius independent 
  1034. 	follower_make_independent(CHARACTER_JULIUS, true) 
  1035.  
  1036. 	-- Wait until we can actually execute the script 
  1037. 	while (CHURCH_SCRIPT_PAUSED) do 
  1038. 		thread_yield() 
  1039. 	end 
  1040.  
  1041. 	-- We need to pause the script from proceeding until Julius is revived 
  1042. 	while (follower_is_unconscious(CHARACTER_JULIUS)) do 
  1043. 		thread_yield() 
  1044. 	end 
  1045.  
  1046. 	-- Show the groups 
  1047. 	group_show(GROUP_WEST_VEHICLES) 
  1048. 	group_show(GROUP_WEST_A) 
  1049. 	group_show(GROUP_WEST_B) 
  1050.  
  1051. 	-- Setup the callbacks 
  1052. 	for i = 1, Num_em01_ultor_west_a, 1 do 
  1053. 		on_death("em01_west_killed", Em01_ultor_west_a[i]) 
  1054. 	end 
  1055.  
  1056. 	for i = 1, Num_em01_ultor_west_b, 1 do 
  1057. 		on_death("em01_west_killed", Em01_ultor_west_b[i]) 
  1058. 	end 
  1059.  
  1060. 	-- Add the markers 
  1061. 	marker_add_group(GROUP_WEST_A, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1062. 	marker_add_group(GROUP_WEST_B, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1063.  
  1064. 	-- Teleport the humans into the vehicles 
  1065. 	vehicle_enter_group_teleport(Em01_ultor_west_a, WEST_SIDE_VEHICLE_1) 
  1066. 	vehicle_enter_group_teleport(Em01_ultor_west_b, WEST_SIDE_VEHICLE_2) 
  1067.  
  1068. 	-- Pathfind to their locations 
  1069. 	thread_new("em01_west_perimeter_vehicle_pathfind") 
  1070.  
  1071. 	-- Create the perimeter east group 
  1072. 	group_create_hidden(GROUP_EAST_VEHICLE) 
  1073. 	group_create_hidden(GROUP_EAST) 
  1074.  
  1075. 	-- Spawn the thread to move Julius to his destination 
  1076. 	thread_kill(JULIUS_MOVE_TO_POINT_THREAD) 
  1077. 	JULIUS_MOVE_TO_POINT_THREAD = thread_new("em01_move_julius_to_point", CHURCH_LEASH_WEST) 
  1078.  
  1079. 	-- Play Julius' help line 
  1080. 	audio_play_for_character("JULIUS_BONUS_REINFORCE", CHARACTER_JULIUS, "voice", false, true, 1, 2) 
  1081.  
  1082. 	-- Julius call out for the player 
  1083. 	mission_help_table("em01_defend_west") 
  1084.  
  1085. 	-- Add the objective 
  1086. 	objective_text(0, "em01_defend_objective", West_masako_kill_count, Num_em01_west_masako) 
  1087. end 
  1088.  
  1089. function em01_west_killed(human) 
  1090. 	-- Remove the marker 
  1091. 	marker_remove_npc(human, SYNC_ALL) 
  1092.  
  1093. 	-- Add to the count 
  1094. 	West_masako_kill_count = West_masako_kill_count + 1 
  1095.  
  1096. 	-- Keep track of the total kills 
  1097. 	Num_em01_required_count = Num_em01_required_count + 1 
  1098.  
  1099. 	-- Update the objective 
  1100. 	objective_text(0, "em01_defend_objective", West_masako_kill_count, Num_em01_west_masako) 
  1101.  
  1102. 	-- One assault human left so start the perimeter attack 
  1103. 	if (West_masako_kill_count == Num_em01_west_masako) then 
  1104. 		em01_clear_objective(false) 
  1105. 		em01_perimeter_east() 
  1106. 	end 
  1107. end 
  1108.  
  1109. function em01_east_perimeter_vehicle_pathfind() 
  1110. 	-- Do the pathfind...this function yields 
  1111. 	vehicle_pathfind_to(EAST_SIDE_VEHICLE, EAST_SIDE_ARRIVE, true, false) 
  1112. 	vehicle_stop(EAST_SIDE_VEHICLE) 
  1113.  
  1114. 	-- One the vehicle has reached its destination then have the humans exit... 
  1115. 	for i = 1, Num_em01_ultor_east, 1 do 
  1116. 		vehicle_exit(Em01_ultor_east[i]) 
  1117. 		attack(Em01_ultor_east[i], CHARACTER_JULIUS) 
  1118. 	end 
  1119. end 
  1120.  
  1121. function em01_perimeter_east() 
  1122. 	-- Wait until we can actually execute the script 
  1123. 	while (CHURCH_SCRIPT_PAUSED) do 
  1124. 		thread_yield() 
  1125. 	end 
  1126.  
  1127. 	-- We need to pause the script from proceeding until Julius is revived 
  1128. 	while (follower_is_unconscious(CHARACTER_JULIUS)) do 
  1129. 		thread_yield() 
  1130. 	end 
  1131.  
  1132. 	-- Show the groups 
  1133. 	group_show(GROUP_EAST_VEHICLE) 
  1134. 	group_show(GROUP_EAST) 
  1135.  
  1136. 	-- Setup the callbacks 
  1137. 	for i = 1, Num_em01_ultor_east, 1 do 
  1138. 		on_death("em01_east_killed", Em01_ultor_east[i]) 
  1139. 	end 
  1140.  
  1141. 	-- Add the markers 
  1142. 	marker_add_group(GROUP_EAST, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1143.  
  1144. 	-- Teleport the humans into the vehicles 
  1145. 	vehicle_enter_group_teleport(Em01_ultor_east, EAST_SIDE_VEHICLE) 
  1146.  
  1147. 	-- Pathfind to their locations 
  1148. 	thread_new("em01_east_perimeter_vehicle_pathfind") 
  1149.  
  1150. 	-- Create the perimeter west group 
  1151. 	group_create_hidden(GROUP_SOUTH_VEHICLES) 
  1152. 	group_create_hidden(GROUP_SOUTH_A) 
  1153. 	group_create_hidden(GROUP_SOUTH_B) 
  1154.  
  1155. 	-- Spawn the thread to move Julius to his destination 
  1156. 	thread_kill(JULIUS_MOVE_TO_POINT_THREAD) 
  1157. 	JULIUS_MOVE_TO_POINT_THREAD = thread_new("em01_move_julius_to_point", CHURCH_LEASH_EAST) 
  1158.  
  1159. 	-- Play Julius' help line 
  1160. 	audio_play_for_character("JULIUS_BONUS_REINFORCE", CHARACTER_JULIUS, "voice", false, true, 0, 2) 
  1161.  
  1162. 	-- Julius call out for the player 
  1163. 	mission_help_table("em01_defend_east") 
  1164.  
  1165. 	-- Add the objective 
  1166. 	objective_text(0, "em01_defend_objective", East_masako_kill_count, Num_em01_ultor_east) 
  1167. end 
  1168.  
  1169. function em01_east_killed(human) 
  1170. 	-- Remove the marker 
  1171. 	marker_remove_npc(human, SYNC_ALL) 
  1172.  
  1173. 	-- Add to the count 
  1174. 	East_masako_kill_count = East_masako_kill_count + 1 
  1175.  
  1176. 	-- Keep track of the total kills 
  1177. 	Num_em01_required_count = Num_em01_required_count + 1 
  1178.  
  1179. 	-- Update the objective 
  1180. 	objective_text(0, "em01_defend_objective", East_masako_kill_count, Num_em01_ultor_east) 
  1181.  
  1182. 	-- One assault human left so start the perimeter attack 
  1183. 	if (East_masako_kill_count == Num_em01_ultor_east) then 
  1184. 		em01_clear_objective(false) 
  1185. 		em01_perimeter_south() 
  1186. 	end 
  1187. end 
  1188.  
  1189. function em01_south_perimeter_vehicle_pathfind() 
  1190. 	-- Do the pathfind...this function yields 
  1191. 	vehicle_pathfind_to(SOUTH_SIDE_VEHICLE_2, SOUTH_SIDE_ARRIVE_2, true, false) 
  1192. 	vehicle_stop(SOUTH_SIDE_VEHICLE_2) 
  1193.  
  1194. 	-- One the vehicle has reached its destination then have the humans exit... 
  1195. 	for i = 1, Num_em01_ultor_south_b, 1 do 
  1196. 		vehicle_exit(Em01_ultor_south_b[i]) 
  1197. 		attack(Em01_ultor_south_b[i], CHARACTER_JULIUS) 
  1198. 	end 
  1199. 	 
  1200. 	-- Do the pathfind...this function yields 
  1201. 	vehicle_pathfind_to(SOUTH_SIDE_VEHICLE_1, SOUTH_SIDE_ARRIVE_1, true, false) 
  1202. 	vehicle_stop(SOUTH_SIDE_VEHICLE_1) 
  1203.  
  1204. 	-- One the vehicle has reached its destination then have the humans exit... 
  1205. 	for i = 1, Num_em01_ultor_south_a, 1 do 
  1206. 		vehicle_exit(Em01_ultor_south_a[i]) 
  1207. 		attack(Em01_ultor_south_a[i], CHARACTER_JULIUS) 
  1208. 	end 
  1209. end 
  1210.  
  1211. function em01_perimeter_south() 
  1212. 	-- Wait until we can actually execute the script 
  1213. 	while (CHURCH_SCRIPT_PAUSED) do 
  1214. 		thread_yield() 
  1215. 	end 
  1216.  
  1217. 	-- We need to pause the script from proceeding until Julius is revived 
  1218. 	while (follower_is_unconscious(CHARACTER_JULIUS)) do 
  1219. 		thread_yield() 
  1220. 	end 
  1221.  
  1222. 	-- Show the groups 
  1223. 	group_show(GROUP_SOUTH_VEHICLES) 
  1224. 	group_show(GROUP_SOUTH_A) 
  1225. 	group_show(GROUP_SOUTH_B) 
  1226.  
  1227. 	-- Setup the callbacks 
  1228. 	for i = 1, Num_em01_ultor_south_a, 1 do 
  1229. 		on_death("em01_south_killed", Em01_ultor_south_a[i]) 
  1230. 	end 
  1231.  
  1232. 	for i = 1, Num_em01_ultor_south_b, 1 do 
  1233. 		on_death("em01_south_killed", Em01_ultor_south_b[i]) 
  1234. 	end 
  1235.  
  1236. 	-- Add the markers 
  1237. 	marker_add_group(GROUP_SOUTH_A, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1238. 	marker_add_group(GROUP_SOUTH_B, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1239.  
  1240. 	-- Teleport the humans into the vehicles 
  1241. 	vehicle_enter_group_teleport(Em01_ultor_south_a, SOUTH_SIDE_VEHICLE_1) 
  1242. 	vehicle_enter_group_teleport(Em01_ultor_south_b, SOUTH_SIDE_VEHICLE_2) 
  1243.  
  1244. 	-- Pathfind to their locations 
  1245. 	thread_new("em01_south_perimeter_vehicle_pathfind") 
  1246.  
  1247. 	-- Create the perimeter east group 
  1248. 	group_create_hidden(GROUP_HELI_VEHICLE) 
  1249. 	group_create_hidden(GROUP_HELI) 
  1250.  
  1251. 	-- Spawn the thread to move Julius to his destination 
  1252. 	thread_kill(JULIUS_MOVE_TO_POINT_THREAD) 
  1253. 	JULIUS_MOVE_TO_POINT_THREAD = thread_new("em01_move_julius_to_point", CHURCH_LEASH_SOUTH) 
  1254.  
  1255. 	-- Play Julius' help line 
  1256. 	audio_play_for_character("JULIUS_BONUS_REINFORCE", CHARACTER_JULIUS, "voice", false, true, 2, 2) 
  1257.  
  1258. 	-- Julius call out for the player 
  1259. 	mission_help_table("em01_defend_south") 
  1260.  
  1261. 	-- Add the objective 
  1262. 	objective_text(0, "em01_defend_objective", South_masako_kill_count, Num_em01_south_masako) 
  1263. end 
  1264.  
  1265. function em01_south_killed(human) 
  1266. 	-- Remove the marker 
  1267. 	marker_remove_npc(human, SYNC_ALL) 
  1268.  
  1269. 	-- Add to the count 
  1270. 	South_masako_kill_count = South_masako_kill_count + 1 
  1271.  
  1272. 	-- Keep track of the total kills 
  1273. 	Num_em01_required_count = Num_em01_required_count + 1 
  1274.  
  1275. 	-- Update the objective 
  1276. 	objective_text(0, "em01_defend_objective", South_masako_kill_count, Num_em01_south_masako) 
  1277.  
  1278. 	-- One assault human left so start the perimeter attack 
  1279. 	if (South_masako_kill_count == Num_em01_south_masako) then 
  1280. 		em01_perimeter_attack_heli() 
  1281. 		-- Do this after and not before since we want the helicopter to arrive ASAP 
  1282. 		em01_clear_objective(false) 
  1283. 	end 
  1284. end 
  1285.  
  1286. function em01_they_have_helicopters() 
  1287. 	-- Disable the trigger 
  1288. 	trigger_enable(TRIGGER_FALL_BACK, false) 
  1289.  
  1290. 	-- Play the helicopter exchange 
  1291. 	audio_play_conversation(Em01_heliwave1_exchange) 
  1292.  
  1293. 	-- Julius call out for the player to fall back 
  1294. 	mission_help_table_nag("em01_fall_back") 
  1295.  
  1296. 	delay(6.0) 
  1297.  
  1298. 	-- Give the objective 
  1299. 	mission_help_table("em01_heli") 
  1300. end 
  1301.  
  1302. function em01_fire_missile_at_church() 
  1303. 	-- Get the driver of the heli 
  1304. 	local	driver = vehicle_get_driver(HELI_ATTACK_VEHICLE) 
  1305.  
  1306.    -- If the driver can't be found, the helicopter's not going to be 
  1307.    -- doing much attacking 
  1308.    if ( driver == nil ) then 
  1309.       return 
  1310.    end 
  1311.  
  1312. 	-- We want this guy to have perfect aim 
  1313. 	if (not character_is_dead(driver)) then 
  1314. 		set_perfect_aim(driver, true) 
  1315. 	end 
  1316. 	 
  1317. 	-- Shoot at a designated spot 
  1318. 	helicopter_shoot_navpoint(HELI_ATTACK_VEHICLE, "em01_$n141") 
  1319. 	 
  1320. 	delay(0.25) 
  1321.  
  1322. 	-- Shoot at a designated spot 
  1323. 	helicopter_shoot_navpoint(HELI_ATTACK_VEHICLE, "em01_$n142") 
  1324.  
  1325. 	delay(0.25) 
  1326. 	 
  1327. 	-- Shoot at a designated spot 
  1328. 	helicopter_shoot_navpoint(HELI_ATTACK_VEHICLE, "em01_$n143") 
  1329. 	 
  1330. 	-- We want this guy to not have perfect aim 
  1331. 	if (not character_is_dead(driver)) then 
  1332. 		set_perfect_aim(driver, false) 
  1333. 	end 
  1334. end 
  1335.  
  1336. function em01_missile_attack_sequence(heli, target_humans, missile_sequence) 
  1337. 	-- Find the closest human... 
  1338. 	local		human_table = sizeof_table(target_humans) 
  1339. 	local		target_human = target_humans[1] 
  1340. 	local		human_dist = get_dist(target_human, heli) 
  1341.  
  1342. 	for i = 2, human_table, 1 do 
  1343. 		local		dist = get_dist(target_humans[i], heli) 
  1344.  
  1345. 		if (dist < human_dist) then 
  1346. 			target_human = target_humans[i] 
  1347. 			human_dist = dist 
  1348. 		end 
  1349. 	end 
  1350.  
  1351. 	-- Set the target and let the helicopter fire at them 
  1352. 	helicopter_go_to_set_target(heli, target_human) 
  1353.  
  1354. 	-- Wait for the heli to be facing the target human 
  1355. 	while (vehicle_exists(heli) and character_exists(target_human) and not fov_check_xz_plane(heli, target_human, 10.0)) do 
  1356. 		thread_yield() 
  1357. 	end 
  1358.  
  1359. 	-- Peform the missile sequence 
  1360. 	local		seq_table = sizeof_table(missile_sequence) 
  1361. 	-- Get the driver of the heli 
  1362. 	local		driver = vehicle_get_driver(heli) 
  1363.  
  1364.    -- If the driver can't be found, the helicopter's not going to be 
  1365.    -- doing much attacking 
  1366.    if ( driver == nil ) then 
  1367.       return 
  1368.    end 
  1369.  
  1370. 	for i = 1, seq_table, 1 do 
  1371. 		-- If the heli is not destroyed and the driver is not dead then perform a missile fire 
  1372. 		if (not vehicle_is_destroyed(heli) and not character_is_dead(driver)) then 
  1373. 			-- We want this guy to have perfect aim 
  1374. 			set_perfect_aim(driver, true) 
  1375. 			-- Fire a missile at the human now 
  1376. 			helicopter_shoot_human(heli, target_human, true, HELI_FIRE_MULTIPLIER) 
  1377. 			-- We want this guy to not have perfect aim 
  1378. 			set_perfect_aim(driver, false) 
  1379. 		end 
  1380.  
  1381. 		-- Delay before firing again 
  1382. 		delay(missile_sequence[i]) 
  1383. 	end 
  1384. end 
  1385.  
  1386. function em01_heli_perimeter_vehicle_pathfind() 
  1387. 	-- Change the amount of damage the vehicle can take 
  1388. 	if (not IN_COOP) then 
  1389. 		set_max_hit_points(HELI_ATTACK_VEHICLE, get_max_hit_points(HELI_ATTACK_VEHICLE) * 4, true) 
  1390. 	else 
  1391. 		set_max_hit_points(HELI_ATTACK_VEHICLE, get_max_hit_points(HELI_ATTACK_VEHICLE) * 8, true) 
  1392. 	end 
  1393.  
  1394. 	-- Setup the fallback trigger 
  1395. 	trigger_enable(TRIGGER_FALL_BACK, true) 
  1396. 	on_trigger("em01_they_have_helicopters", TRIGGER_FALL_BACK) 
  1397.  
  1398. 	-- Setup the shoot navpoint trigger 
  1399. 	trigger_enable(TRIGGER_BLAST_CHURCH, true) 
  1400. 	on_trigger("em01_fire_missile_at_church", TRIGGER_BLAST_CHURCH) 
  1401.  
  1402. 	-- Teleport the heli to the start path point 
  1403. 	teleport_vehicle(HELI_ATTACK_VEHICLE, "em01_$n003") 
  1404.  
  1405. 	-- Do the pathfind...this function yields 
  1406. 	helicopter_fly_to_direct(HELI_ATTACK_VEHICLE, 40.0, HELI_ATTACK_ARRIVE) 
  1407.  
  1408. 	-- We want this helicopter to just shoot gun fire...rockets are scripted 
  1409. 	helicopter_set_missile_chance(HELI_ATTACK_VEHICLE, 0.01) 
  1410.  
  1411. 	-- The helicopter needs to maintain a pattern and attack a various points 
  1412. 	em01_execute_pattern() 
  1413. end 
  1414.  
  1415. function em01_execute_pattern() 
  1416. 	-- We need to keep track of what index we are at...init to starting value 
  1417. 	local		pattern_idx = 1 
  1418. 	local		use_jump_path = false 
  1419.  
  1420. 	-- Do this until the thread is killed 
  1421. 	while (1) do 
  1422. 		-- Exit if the vehicle is destroyed 
  1423. 		if (vehicle_is_destroyed(HELI_ATTACK_VEHICLE)) then 
  1424. 			return 
  1425. 		end 
  1426.  
  1427. 		local		smoke, fire = vehicle_get_smoke_and_fire_state(HELI_ATTACK_VEHICLE) 
  1428.  
  1429. 		-- If the helicopter is on fire then just exit 
  1430. 		if (fire) then 
  1431. 			return 
  1432. 		end 
  1433.  
  1434. 		-- Have the helicopter fly to the next point in the list 
  1435. 		if (not use_jump_path) then 
  1436. 			helicopter_fly_to_direct(HELI_ATTACK_VEHICLE, 50.0, Em01_heli_path[pattern_idx]) 
  1437. 		else 
  1438. 			helicopter_fly_to_direct(HELI_ATTACK_VEHICLE, 35.0, Em01_heli_jump_church[Em01_heli_path[pattern_idx]][HELI_JUMP_PATTERN]) 
  1439. 			-- Update the pattern idx to the correct position 
  1440. 			pattern_idx = Em01_heli_jump_church[Em01_heli_path[pattern_idx]][HELI_JUMP_INDEX] 
  1441. 		end 
  1442.  
  1443. 		smoke, fire = vehicle_get_smoke_and_fire_state(HELI_ATTACK_VEHICLE) 
  1444.  
  1445. 		-- If the helicopter is on fire then just exit 
  1446. 		if (fire) then 
  1447. 			return 
  1448. 		else 
  1449. 			-- Fire a sequence of missiles 
  1450. 			if (not IN_COOP) then 
  1451. 				em01_missile_attack_sequence(HELI_ATTACK_VEHICLE, {LOCAL_PLAYER, CHARACTER_JULIUS}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  1452. 			else 
  1453. 				em01_missile_attack_sequence(HELI_ATTACK_VEHICLE, {LOCAL_PLAYER, CHARACTER_JULIUS, REMOTE_PLAYER}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  1454. 			end 
  1455. 		end 
  1456.  
  1457. 		local		heli_can_jump_church = Em01_heli_can_jump[pattern_idx] 
  1458. 		local		heli_should_jump_church = ((rand_int(0, 2) == 0) and not use_jump_path) 
  1459.  
  1460. 		if (heli_can_jump_church and heli_should_jump_church) then 
  1461. 			-- We want to use the alternate path... 
  1462. 			use_jump_path = true 
  1463. 		else 
  1464. 			-- We want the pattern to circle around 
  1465. 			pattern_idx = pattern_idx + 1 
  1466. 			if (pattern_idx > Num_em01_heli_path) then 
  1467. 				pattern_idx = 1 
  1468. 			end 
  1469.  
  1470. 			use_jump_path = false 
  1471. 		end 
  1472. 	end 
  1473. end 
  1474.  
  1475. function em01_perimeter_attack_heli() 
  1476. 	-- Julius is no longer independent 
  1477. 	follower_make_independent(CHARACTER_JULIUS, false) 
  1478.  
  1479. 	-- Wait until we can actually execute the script 
  1480. 	while (CHURCH_SCRIPT_PAUSED) do 
  1481. 		thread_yield() 
  1482. 	end 
  1483.  
  1484. 	-- Show the groups 
  1485. 	group_show(GROUP_HELI_VEHICLE) 
  1486. 	group_show(GROUP_HELI) 
  1487.  
  1488. 	-- Setup the callbacks 
  1489. 	on_vehicle_destroyed("em01_heli_killed", HELI_ATTACK_VEHICLE) 
  1490.  
  1491. 	-- Add the marker 
  1492. 	marker_add_group(GROUP_HELI_VEHICLE, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  1493.  
  1494. 	-- Teleport the humans into the vehicle 
  1495. 	vehicle_enter_group_teleport(Em01_ultor_heli, HELI_ATTACK_VEHICLE) 
  1496.  
  1497. 	-- Pathfind to their locations 
  1498. 	thread_new("em01_heli_perimeter_vehicle_pathfind") 
  1499.  
  1500. 	-- Create the next group 
  1501. 	group_create_hidden(GROUP_JULIUS_VEHICLE) 
  1502.  
  1503. 	-- Spawn off a thread to check if the player and Julius can make a run for it 
  1504. 	thread_new("em01_can_run_for_it") 
  1505.  
  1506. 	-- Load our ultor strike scenario 
  1507. 	group_create_hidden(GROUP_WEAK_VEHICLE) 
  1508. 	group_create_hidden(GROUP_WEAK) 
  1509. 	group_create_hidden(GROUP_LAMB) 
  1510. 	group_create_hidden(GROUP_LAMB_A) 
  1511. 	group_create_hidden(GROUP_LAMB_B) 
  1512. end 
  1513.  
  1514. function em01_heli_killed(vehicle) 
  1515. 	-- Remove the marker 
  1516. 	marker_remove_vehicle(vehicle, SYNC_ALL) 
  1517.  
  1518. 	Heli_masako_killed = true 
  1519. end 
  1520.  
  1521. function em01_can_run_for_it() 
  1522. 	-- Loop until the conditions are met 
  1523. 	while (1) do 
  1524. 		thread_yield() 
  1525. 		-- The heli has to be destroyed 
  1526. 		if (Heli_masako_killed) then 
  1527. 			-- All of the masako required kills need to be dead 
  1528. 			if (Num_em01_required_count == Num_em01_required_kills) then 
  1529. 				-- Spawn off a thread to release the previous groups...they are not needed anymore 
  1530. 				thread_new("em01_defend_release_to_world") 
  1531.  
  1532. 				-- Checkpoint here... 
  1533. 				mission_set_checkpoint("perimeter") 
  1534.  
  1535. 				-- We no longer need to protect the church so kill the thread 
  1536. 				thread_kill(CHURCH_ABANDON_PERIMETER_THREAD) 
  1537.  
  1538.             em01_church_abandon_perimeter_cleanup() 
  1539.  
  1540. 				-- Delay for a couple of seconds 
  1541. 				delay(2.0) 
  1542.  
  1543. 				em01_make_a_run_for_it() 
  1544. 				return 
  1545. 			end 
  1546. 		end 
  1547. 	end 
  1548. end 
  1549.  
  1550. function em01_defend_release_to_world() 
  1551. 	-- Release these groups to the world now... 
  1552. 	release_to_world(GROUP_HELI_VEHICLE) 
  1553. 	release_to_world(GROUP_WEST_VEHICLES) 
  1554. 	release_to_world(GROUP_EAST_VEHICLE) 
  1555. 	release_to_world(GROUP_SOUTH_VEHICLES) 
  1556.  
  1557. 	-- Wait a frame 
  1558. 	thread_yield() 
  1559.  
  1560. 	-- Release these groups to the world now... 
  1561. 	release_to_world(GROUP_ASSAULT_1) 
  1562. 	release_to_world(GROUP_ASSAULT_2) 
  1563.  
  1564. 	-- Wait a frame 
  1565. 	thread_yield() 
  1566.  
  1567. 	-- Release these groups to the world now... 
  1568. 	release_to_world(GROUP_DEFEND_1) 
  1569. 	release_to_world(GROUP_DEFEND_2_A) 
  1570. 	release_to_world(GROUP_DEFEND_2_B) 
  1571. 	release_to_world(GROUP_DEFEND_2_C) 
  1572.  
  1573. 	-- Wait a frame 
  1574. 	thread_yield() 
  1575.  
  1576. 	-- Release these groups to the world now... 
  1577. 	release_to_world(GROUP_WEST_A) 
  1578. 	release_to_world(GROUP_WEST_B) 
  1579. 	release_to_world(GROUP_EAST) 
  1580.  
  1581. 	-- Wait a frame 
  1582. 	thread_yield() 
  1583.  
  1584. 	-- Release these groups to the world now... 
  1585. 	release_to_world(GROUP_SOUTH_A) 
  1586. 	release_to_world(GROUP_SOUTH_B) 
  1587. 	release_to_world(GROUP_HELI) 
  1588. end 
  1589.  
  1590. function em01_make_a_run_for_it() 
  1591. 	-- Play the helicopter death exchange 
  1592. 	audio_play_conversation(Em01_helideath_exchange) 
  1593.  
  1594. 	-- Julius says lets make a run for it 
  1595. 	mission_help_table("em01_run_for_it") 
  1596.  
  1597. 	-- Add waypoint to Julius' car 
  1598. 	waypoint_add(JULIUS_VEHICLE, SYNC_ALL) 
  1599. 	-- Show Julius' car 
  1600. 	group_show(GROUP_JULIUS_VEHICLE) 
  1601. 	-- Add a marker 
  1602. 	marker_add_vehicle(JULIUS_VEHICLE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, SYNC_ALL) 
  1603.  
  1604. 	-- Setup the enter/exit callback 
  1605. 	on_vehicle_enter("em01_vehicle_entered", JULIUS_VEHICLE) 
  1606. 	on_vehicle_exit("em01_vehicle_exited", JULIUS_VEHICLE) 
  1607.  
  1608. 	-- The vehicle cannot be destroyed 
  1609. 	on_vehicle_destroyed("em01_vehicle_destroyed", JULIUS_VEHICLE) 
  1610.  
  1611.    em01_setup_julius_vehicle() 
  1612.  
  1613. 	-- Spawn off a thread to watch when Julius can start to drive 
  1614. 	thread_new("em01_wait_for_car_load") 
  1615.  
  1616. 	-- Don't let npcs exit until we say so 
  1617. 	vehicle_suppress_npc_exit(JULIUS_VEHICLE, true)  
  1618. 	-- Don't let the vehicle move until we say so 
  1619. 	vehicle_speed_override(JULIUS_VEHICLE, 0.1) 
  1620. 	 
  1621. 	-- Delay for a little while to allow the player some time to make the run for it 
  1622. 	delay(20.0) 
  1623.  
  1624. 	if (LAMB_TO_THE_SLAUGHTER_THREAD == INVALID_THREAD_HANDLE) then 
  1625. 		thread_new("em01_exploring_is_weak_sauce") 
  1626. 	end 
  1627. end 
  1628.  
  1629. function em01_setup_julius_vehicle() 
  1630. 	-- Make sure the vehicle is not entered...we just want to teleport everyone 
  1631. 	set_unjackable_flag(JULIUS_VEHICLE, true) 
  1632.    vehicle_prevent_explosion_fling( JULIUS_VEHICLE, true ) 
  1633. 	-- Give Julius' car infinite mass 
  1634. 	vehicle_infinite_mass(JULIUS_VEHICLE, true) 
  1635. 	-- Don't let weapon fire flatten the tires 
  1636. 	vehicle_never_flatten_tires(JULIUS_VEHICLE, true) 
  1637. end 
  1638.  
  1639. function em01_wait_for_car_load() 
  1640. 	-- Wait to force a driver until the player is fairly close...must be greater than 12 or so meters 
  1641. 	local		local_close_enough = false 
  1642. 	local		remote_close_enough = false 
  1643.    local    julius_alive = character_is_dead( CHARACTER_JULIUS ) 
  1644.  
  1645.    repeat 
  1646.       thread_yield() 
  1647. 		-- Check to see if we are close enough to Julius' vehicle to continue 
  1648. 		local_close_enough = (get_dist_char_to_vehicle(LOCAL_PLAYER, JULIUS_VEHICLE) <= 10.0) 
  1649. 		if (IN_COOP) then 
  1650. 			remote_close_enough = (get_dist_char_to_vehicle(REMOTE_PLAYER, JULIUS_VEHICLE) <= 10.0) 
  1651. 		end 
  1652.       -- Check to see if Julius is alive 
  1653.       julius_alive = not character_is_dead( CHARACTER_JULIUS ) 
  1654.    until ( julius_alive and local_close_enough and ( coop_is_active() == false or remote_close_enough ) ) 
  1655.  
  1656. 	-- Make Julius independent 
  1657. 	follower_make_independent(CHARACTER_JULIUS, true) 
  1658.    -- Make sure Julius doesn't die between now and when he's teleported into the vehicle 
  1659.    turn_invulnerable( CHARACTER_JULIUS ) 
  1660.  
  1661. --[[		SAVE THIS...JUST BECAUSE 
  1662. 	-- Tell Julius to enter his vehicle as the driver 
  1663. 	vehicle_enter(CHARACTER_JULIUS, JULIUS_VEHICLE, 0, false, true) 
  1664. 	-- Spawn off a thread to make sure Julius get in as the driver 
  1665. 	thread_new("em01_ensure_julius_is_driver") 
  1666.  
  1667. 	-- Check to see if the car has everyone that is needed in it 
  1668. 	local		julius = (character_is_in_vehicle(CHARACTER_JULIUS, JULIUS_VEHICLE) and character_is_in_a_driver_seat(CHARACTER_JULIUS)) 
  1669. 	local		local_player = character_is_in_vehicle(LOCAL_PLAYER, JULIUS_VEHICLE) 
  1670. 	local		remote_player = true 
  1671.  
  1672. 	if (IN_COOP) then 
  1673. 		remote_player = character_is_in_vehicle(REMOTE_PLAYER, JULIUS_VEHICLE) 
  1674. 	end 
  1675.  
  1676. 	-- Wait for the necessary people to be in the vehicle 
  1677. 	while (not julius or not local_player or not remote_player) do 
  1678. 		thread_yield() 
  1679.  
  1680. 		julius = (character_is_in_vehicle(CHARACTER_JULIUS, JULIUS_VEHICLE) and character_is_in_a_driver_seat(CHARACTER_JULIUS)) 
  1681. 		local_player = character_is_in_vehicle(LOCAL_PLAYER, JULIUS_VEHICLE) 
  1682.  
  1683. 		if (IN_COOP) then 
  1684. 			remote_player = character_is_in_vehicle(REMOTE_PLAYER, JULIUS_VEHICLE) 
  1685. 		end 
  1686. 	end 
  1687. ]]-- 
  1688.  
  1689.  
  1690. 	-- Fade out and wait for the fade to complete 
  1691. 	fade_out(1.0) 
  1692. 	while (fade_get_percent() < 1.0) do 
  1693. 		thread_yield() 
  1694. 	end 
  1695.  
  1696.    -- No waypoint necessary anymore 
  1697.    waypoint_remove( SYNC_ALL) 
  1698.  
  1699.    -- Players should not be messing around with stuff when the 
  1700.    -- screen is faded out 
  1701.    player_controls_disable( LOCAL_PLAYER ) 
  1702.    if ( coop_is_active() ) then 
  1703.       player_controls_disable( REMOTE_PLAYER ) 
  1704.    end 
  1705. 	Controls_disabled = true 
  1706.  
  1707. 	repeat 
  1708. 		thread_yield() 
  1709. 	until ( character_is_ready( LOCAL_PLAYER ) and ( coop_is_active() == false or character_is_ready( REMOTE_PLAYER ) ) ) 
  1710.  
  1711. 	delay( 2.0 ) 
  1712.  
  1713. 	-- Okay, now that the fade is complete the vehicle can be entered 
  1714. 	set_unjackable_flag(JULIUS_VEHICLE, false) 
  1715.  
  1716. 	-- If any of the necessary guys are in a vehicle, remove them 
  1717. 	if (character_is_in_vehicle(CHARACTER_JULIUS)) then 
  1718. 		vehicle_exit_teleport(CHARACTER_JULIUS) 
  1719. 	end 
  1720.  
  1721. 	if (character_is_in_vehicle(LOCAL_PLAYER)) then 
  1722. 		vehicle_exit_teleport(LOCAL_PLAYER) 
  1723. 	end 
  1724.  
  1725. 	if (IN_COOP) then 
  1726. 		if (character_is_in_vehicle(REMOTE_PLAYER)) then 
  1727. 			vehicle_exit_teleport(REMOTE_PLAYER) 
  1728. 		end 
  1729. 	end 
  1730.  
  1731. 	-- Teleport everyone where they need to be 
  1732. 	vehicle_enter_teleport(CHARACTER_JULIUS, JULIUS_VEHICLE, 0) 
  1733. 	vehicle_enter_teleport(LOCAL_PLAYER, JULIUS_VEHICLE, 1) 
  1734. 	if (IN_COOP) then 
  1735. 		vehicle_enter_teleport(REMOTE_PLAYER, JULIUS_VEHICLE, 2) 
  1736. 	end 
  1737.  
  1738. 	repeat 
  1739. 		thread_yield() 
  1740. 	until ( character_is_in_vehicle( LOCAL_PLAYER ) and ( coop_is_active() == false or character_is_in_vehicle( REMOTE_PLAYER ) ) ) 
  1741.  
  1742. 	-- Don't allow the player(s) to exit 
  1743. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  1744. 	if (IN_COOP) then 
  1745. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  1746. 	end 
  1747.  
  1748.    -- Re-enable controls now that the players are safely in the vehicle 
  1749.    player_controls_enable( LOCAL_PLAYER ) 
  1750.    if ( coop_is_active() ) then 
  1751.       player_controls_enable( REMOTE_PLAYER ) 
  1752.    end 
  1753. 	Controls_disabled = false 
  1754.  
  1755. 	-- Fade in and wait for the fade to complete roughly 50% 
  1756. 	fade_in(1.0) 
  1757. 	fade_in_block() 
  1758.  
  1759.    -- Now that Julius is in the car, make him vulnerable again 
  1760.    turn_vulnerable( CHARACTER_JULIUS ) 
  1761.  
  1762. 	-- Proceed to the next phase 
  1763. 	em01_protect_julius_car() 
  1764. end 
  1765.  
  1766. --[[		SAVE THIS...JUST BECAUSE 
  1767. function em01_ensure_julius_is_driver() 
  1768. 	-- Keep checking until it happens 
  1769. 	while (not character_is_in_vehicle(CHARACTER_JULIUS, JULIUS_VEHICLE) and not character_is_in_a_driver_seat(CHARACTER_JULIUS)) do 
  1770. 		-- Tell Julius to enter his vehicle as the driver 
  1771. 		vehicle_enter(CHARACTER_JULIUS, JULIUS_VEHICLE, 0, false, true) 
  1772.  
  1773. 		thread_yield() 
  1774. 	end 
  1775. end 
  1776. ]]-- 
  1777.  
  1778. function em01_vehicle_entered(human) 
  1779. 	-- Need to know who we are dealing with 
  1780. 	local		sync = SYNC_LOCAL 
  1781.  
  1782. 	if (human == REMOTE_PLAYER) then 
  1783. 		sync = SYNC_REMOTE 
  1784. 	end 
  1785.  
  1786. 	-- Remove the vehicle 
  1787. 	marker_remove_vehicle(JULIUS_VEHICLE, sync) 
  1788. end 
  1789.  
  1790. function em01_vehicle_exited(human) 
  1791. 	-- Need to know who we are dealing with 
  1792. 	local		sync = SYNC_LOCAL 
  1793.  
  1794. 	if (human == REMOTE_PLAYER) then 
  1795. 		sync = SYNC_REMOTE 
  1796. 	end 
  1797.  
  1798. 	-- Add a marker 
  1799. 	marker_add_vehicle(JULIUS_VEHICLE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, sync) 
  1800. end 
  1801.  
  1802. function em01_exploring_is_weak_sauce() 
  1803. 	-- Show our groups 
  1804. 	group_show(GROUP_WEAK_VEHICLE) 
  1805. 	group_show(GROUP_WEAK) 
  1806.  
  1807. 	-- Teleport the humans into the vehicle 
  1808. 	vehicle_enter_group_teleport(Em01_weak_sauce_heli, WEAK_HELI_VEHICLE) 
  1809.  
  1810. 	-- Setup a callback for death 
  1811. 	on_vehicle_destroyed("em01_weak_destroyed", WEAK_HELI_VEHICLE) 
  1812.  
  1813. 	-- Go into chase mode 
  1814. 	vehicle_chase(WEAK_HELI_VEHICLE, LOCAL_PLAYER) 
  1815. end 
  1816.  
  1817. function em01_weak_destroyed() 
  1818. 	-- Release to the world 
  1819. 	release_to_world(GROUP_WEAK_VEHICLE) 
  1820. 	release_to_world(GROUP_WEAK) 
  1821.  
  1822. 	-- Invalidate the destroyed callback 
  1823. 	on_vehicle_destroyed("", WEAK_HELI_VEHICLE) 
  1824.  
  1825. 	-- Re-create the groups 
  1826. 	group_create_hidden(GROUP_WEAK_VEHICLE) 
  1827. 	group_create_hidden(GROUP_WEAK) 
  1828. end 
  1829.  
  1830. function em01_lamb_to_the_slaughter() 
  1831. 	-- Show our groups 
  1832. 	group_show(GROUP_LAMB) 
  1833. 	group_show(GROUP_LAMB_A) 
  1834. 	group_show(GROUP_LAMB_B) 
  1835.  
  1836. 	-- Turn on the siren lights for all the road blocks... 
  1837. 	for i = 1, Num_em01_siren_lights, 1 do 
  1838. 		vehicle_set_sirenlights(Em01_siren_lights[i], true) 
  1839. 	end 
  1840.  
  1841. 	-- Teleport the humans into the vehicle 
  1842. 	vehicle_enter_group_teleport(Em01_lamb_apc_a, LAMB_A_VEHICLE) 
  1843. 	vehicle_enter_group_teleport(Em01_lamb_apc_b, LAMB_B_VEHICLE) 
  1844.  
  1845. 	-- Setup the ram scenario 
  1846. 	trigger_enable(APC_RAM1_TRIGGER, true) 
  1847. 	trigger_enable(APC_RAM2_TRIGGER, true) 
  1848. 	on_trigger("em01_apc_ram1", APC_RAM1_TRIGGER) 
  1849. 	on_trigger("em01_apc_ram2", APC_RAM2_TRIGGER) 
  1850.  
  1851. 	-- Remove the callback for the helicopter 
  1852. 	on_vehicle_destroyed("", WEAK_HELI_VEHICLE) 
  1853. --[[ 
  1854. 	-- If the first character is hidden then we want to show this group too...otherwise, it is already attacking the player 
  1855. 	if (character_hidden(Em01_weak_sauce_heli[1])) then 
  1856. 		-- Show our groups 
  1857. 		group_show(GROUP_WEAK_VEHICLE) 
  1858. 		group_show(GROUP_WEAK) 
  1859.  
  1860. 		-- Teleport the humans into the vehicle 
  1861. 		vehicle_enter_group_teleport(Em01_weak_sauce_heli, WEAK_HELI_VEHICLE) 
  1862.  
  1863. 		-- Go into chase mode 
  1864. 		vehicle_chase(WEAK_HELI_VEHICLE, LOCAL_PLAYER) 
  1865. 	end 
  1866. ]] 
  1867. end 
  1868.  
  1869. function em01_apc_ram1() 
  1870. 	-- Disable the trigger 
  1871. 	trigger_enable(APC_RAM1_TRIGGER, false) 
  1872. 	-- Change to navmesh pathfinding 
  1873. 	vehicle_pathfind_to(LAMB_A_VEHICLE, APC_RAM_PATH_A, true, false) 
  1874. 	-- Go into chase mode 
  1875. 	vehicle_chase(LAMB_A_VEHICLE, LOCAL_PLAYER, false, true, false, true) 
  1876. end 
  1877.  
  1878. function em01_apc_ram2() 
  1879. 	-- Disable the trigger 
  1880. 	trigger_enable(APC_RAM2_TRIGGER, false) 
  1881. 	-- Change to navmesh pathfinding 
  1882. 	vehicle_pathfind_to(LAMB_B_VEHICLE, APC_RAM_PATH_B, true, false) 
  1883. 	-- Go into chase mode 
  1884. 	vehicle_chase(LAMB_B_VEHICLE, LOCAL_PLAYER, false, true, false, true) 
  1885. end 
  1886.  
  1887. function em01_julius_car_health_watch() 
  1888. 	local		last_percentage = get_current_hit_points(JULIUS_VEHICLE) / get_max_hit_points(JULIUS_VEHICLE) 
  1889. 	local		percentage 
  1890.  
  1891. 	-- Only watch the vehicle while it is not destroyed 
  1892. 	while (not vehicle_is_destroyed(JULIUS_VEHICLE)) do 
  1893. 		thread_yield() 
  1894.  
  1895. 		percentage = get_current_hit_points(JULIUS_VEHICLE) / get_max_hit_points(JULIUS_VEHICLE) 
  1896.  
  1897. 		if ((percentage <= 0.75) and (last_percentage > 0.75)) then 
  1898. 			-- Play audio line for Julius 
  1899. 			audio_play_for_character("JULIUS_BONUS_CAR75_01", CHARACTER_JULIUS, "voice") 
  1900. 		elseif ((percentage <= 0.25) and (last_percentage > 0.25)) then 
  1901. 			-- Play audio line for Julius 
  1902. 			audio_play_for_character("JULIUS_BONUS_CAR25_01", CHARACTER_JULIUS, "voice") 
  1903. 			-- This thread is no longer needed... 
  1904. 			return 
  1905. 		end 
  1906.  
  1907. 		-- Update the last_percentage variable 
  1908. 		last_percentage = percentage 
  1909. 	end 
  1910. end 
  1911.  
  1912. function em01_protect_vehicle_exchange() 
  1913. 	-- Play the vehicle exchange 
  1914. 	audio_play_conversation(Em01_vehicle_exchange) 
  1915.  
  1916. 	-- Instruct player to protect the car 
  1917. 	mission_help_table("em01_protect_car") 
  1918. end 
  1919.  
  1920. function em01_path_chase_setup() 
  1921.    for index, group_name in pairs( PATH_CHASE_GROUPS ) do 
  1922.       group_create_hidden( group_name ) 
  1923.    end 
  1924.  
  1925.    for index, trigger_name in pairs( PATH_CHASE_TRIGGERS ) do 
  1926.       trigger_enable( trigger_name, true ) 
  1927.       on_trigger( "em01_hit_path_chase_trigger", trigger_name ) 
  1928.    end 
  1929. end 
  1930.  
  1931. function em01_index_from_trigger_name( trigger_name_to_match ) 
  1932.    for index, trigger_name in pairs( PATH_CHASE_TRIGGERS ) do 
  1933.       if ( trigger_name == trigger_name_to_match ) then 
  1934.          return index 
  1935.       end 
  1936.    end 
  1937.    return -1 
  1938. end 
  1939.  
  1940. function em01_hit_path_chase_trigger( triggerer_name, trigger_name ) 
  1941.    trigger_enable( trigger_name, false ) 
  1942.    if ( Num_path_chase_vehicles_chasing < MAX_NUM_PATH_CHASERS ) then 
  1943.       local trigger_index = em01_index_from_trigger_name( trigger_name ) 
  1944.  
  1945.       script_assert( trigger_index ~= -1, "failed to find trigger's index" ) 
  1946.  
  1947.       if ( trigger_index ~= nil ) then 
  1948.          mission_debug( "trigger index = "..trigger_index.."." ) 
  1949.       else 
  1950.          mission_debug( "trigger index = nil." ) 
  1951.       end 
  1952.  
  1953.       group_show( PATH_CHASE_GROUPS[trigger_index] ) 
  1954.  
  1955.       thread_new( "em01_path_chase_vehicle_chase", trigger_index ) 
  1956.    end 
  1957. end 
  1958.  
  1959. function em01_path_chase_vehicle_chase( path_chase_index ) 
  1960.    Num_path_chase_vehicles_chasing = Num_path_chase_vehicles_chasing + 1 
  1961.  
  1962.    local path_chase_vehicle = PATH_CHASE_VEHICLES[path_chase_index] 
  1963.    local path_chase_passengers = PATH_CHASE_PASSENGERS[path_chase_index] 
  1964.  
  1965.    mission_debug( "group teleport for group index "..path_chase_index ) 
  1966.    vehicle_enter_group_teleport( path_chase_passengers, path_chase_vehicle ) 
  1967.  
  1968.    vehicle_chase( path_chase_vehicle, LOCAL_PLAYER, false, true, false, true) 
  1969.  
  1970.    -- Keep checking this vehicle for destruction 
  1971.    local driver = "none" 
  1972.    local vehicle_destroyed = false 
  1973.    repeat 
  1974.       driver = vehicle_get_driver( path_chase_vehicle ) 
  1975.       vehicle_destroyed = vehicle_is_destroyed( path_chase_vehicle ) 
  1976.       thread_yield() 
  1977.    until ( driver == nil or vehicle_destroyed ) 
  1978.  
  1979.    Num_path_chase_vehicles_chasing = Num_path_chase_vehicles_chasing - 1 
  1980. end 
  1981.  
  1982. function em01_protect_julius_car() 
  1983. 	-- Spawn off a thread to do the audio exchange and show the message 
  1984. 	thread_new("em01_protect_vehicle_exchange") 
  1985.  
  1986. 	-- Create our groups for when we are almost across the bridge 
  1987. 	group_create_hidden(GROUP_OH_SHIT_VEH_A) 
  1988. 	group_create_hidden(GROUP_OH_SHIT_VEH_B) 
  1989. 	group_create_hidden(GROUP_OH_SHIT_A) 
  1990. 	group_create_hidden(GROUP_OH_SHIT_B) 
  1991.  
  1992. 	-- Give the player the rocket launcher 
  1993. 	inv_weapon_add_temporary(LOCAL_PLAYER, "rpg_annihilator", 1, true) 
  1994.    inv_weapon_add_temporary(LOCAL_PLAYER, "AR50_launcher", 1 ,true ) 
  1995.    inv_weapon_add_temporary(LOCAL_PLAYER, "grenade", 1, true ) 
  1996. 	inv_item_equip("AR50_launcher", LOCAL_PLAYER) 
  1997. 	if (IN_COOP) then 
  1998. 		inv_weapon_add_temporary(REMOTE_PLAYER, "rpg_annihilator", 1, true) 
  1999.       inv_weapon_add_temporary(REMOTE_PLAYER, "AR50_launcher", 1 ,true ) 
  2000.       inv_weapon_add_temporary(REMOTE_PLAYER, "grenade", 1, true ) 
  2001. 		inv_item_equip("AR50_launcher", REMOTE_PLAYER) 
  2002. 	end 
  2003. 	Players_have_temp_weapons = true 
  2004.  
  2005. 	-- Enable the trigger to disable notoriety spawning 
  2006. 	trigger_enable(PEEL_OFF_TRIGGER, true) 
  2007. 	on_trigger("em01_peel_off", PEEL_OFF_TRIGGER) 
  2008.  
  2009. 	-- Enable the trigger to re-enable notoriety behaviors 
  2010. 	trigger_enable(GOTCHA_TRIGGER, true) 
  2011. 	on_trigger("em01_gotcha_heli", GOTCHA_TRIGGER) 
  2012.  
  2013.    em01_path_chase_setup() 
  2014.  
  2015. 	-- Spawn off the thread to script the massive ultor strike 
  2016. 	LAMB_TO_THE_SLAUGHTER_THREAD = thread_new("em01_lamb_to_the_slaughter") 
  2017.  
  2018. 	-- Spawn off a thread to play Julius lines about this car health 
  2019. 	JULIUS_VEHICLE_HEALTH_WATCH = thread_new("em01_julius_car_health_watch") 
  2020.  
  2021. 	-- We want Julius to drive like a mad man 
  2022. 	vehicle_speed_override(JULIUS_VEHICLE, 40.0 ) 
  2023. 	-- Change the amount of damage the vehicle can take 
  2024. 	set_max_hit_points(JULIUS_VEHICLE, get_max_hit_points(JULIUS_VEHICLE) * 3, true) 
  2025.  
  2026. 	-- Show the damage bar of the vehicle... 
  2027. 	damage_indicator_on(0, JULIUS_VEHICLE, 0.0, "em01_bar_label", get_max_hit_points(JULIUS_VEHICLE), SYNC_ALL) 
  2028.  
  2029. 	-- Julius will now drive to the museum 
  2030. 	vehicle_turret_base_to(JULIUS_VEHICLE, ESCAPE_ROUTE_PATH_A, false) 
  2031. 	vehicle_turret_base_to(JULIUS_VEHICLE, ESCAPE_ROUTE_PATH_B, false) 
  2032. 	-- No longer need the speed override for following rails 
  2033. 	vehicle_speed_cancel(JULIUS_VEHICLE) 
  2034. 	-- Change to navmesh pathfinding 
  2035. 	vehicle_pathfind_to(JULIUS_VEHICLE, CRASH_ROUTE_PATH, true, false) 
  2036.  
  2037. 	-- Turn the damage bar off 
  2038. 	damage_indicator_off(0) 
  2039.  
  2040. 	-- Remove callbacks on Julius' car 
  2041. 	on_vehicle_enter("", JULIUS_VEHICLE) 
  2042. 	on_vehicle_exit("", JULIUS_VEHICLE) 
  2043. 	on_vehicle_destroyed("", JULIUS_VEHICLE) 
  2044.  
  2045. 	-- Julius can now exit the vehicle 
  2046. 	vehicle_suppress_npc_exit(JULIUS_VEHICLE, false)  
  2047.  
  2048. 	-- Let the player(s) exit 
  2049. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  2050. 	if (IN_COOP) then 
  2051. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  2052. 	end 
  2053. --[[ 
  2054. 	-- Wait until the vehicle has left the ground 
  2055. 	while (not vehicle_in_air(JULIUS_VEHICLE)) do 
  2056. 		thread_yield() 
  2057. 	end 
  2058.  
  2059. 	-- Wait until the vehicle is on the ground again 
  2060. 	while (vehicle_in_air(JULIUS_VEHICLE)) do 
  2061. 		thread_yield() 
  2062. 	end 
  2063. ]] 
  2064. 	-- Wait until the vehicle is not moving very fast 
  2065. 	while (get_vehicle_speed(JULIUS_VEHICLE) > 5.0) do 
  2066. 		thread_yield() 
  2067. 	end 
  2068.  
  2069. 	-- Make Julius exit the car 
  2070. 	vehicle_exit(CHARACTER_JULIUS) 
  2071.  
  2072. 	-- Kill the health watch thread for Julius's car 
  2073. 	thread_kill(JULIUS_VEHICLE_HEALTH_WATCH) 
  2074.  
  2075. 	-- Checkpoint here... 
  2076. 	mission_set_checkpoint("last stand") 
  2077.  
  2078. 	-- Show the objective to the player 
  2079. 	em01_last_stand_objective() 
  2080. end 
  2081.  
  2082. function em01_blast_oh_shit() 
  2083. 	-- Disable this trigger as it is no longer needed 
  2084. 	trigger_enable(TRIGGER_BLAST_OH_SHIT, false) 
  2085.  
  2086. 	Em01_oh_shit_fire_now = true 
  2087. end 
  2088.  
  2089. function em01_peel_off() 
  2090. 	-- Disable this trigger 
  2091. 	trigger_enable(PEEL_OFF_TRIGGER, false) 
  2092.  
  2093. 	-- Peel off the scripted attacks 
  2094. 	vehicle_flee(LAMB_A_VEHICLE, LOCAL_PLAYER) 
  2095. 	vehicle_flee(LAMB_B_VEHICLE, LOCAL_PLAYER) 
  2096.  
  2097. 	local		smoke, fire = vehicle_get_smoke_and_fire_state(WEAK_HELI_VEHICLE) 
  2098.  
  2099. 	if (not fire and not vehicle_is_destroyed(WEAK_HELI_VEHICLE)) then 
  2100. 		-- Can't make a helicopter flee like this...so just have him chase a fleeing apc 
  2101. 		vehicle_chase(WEAK_HELI_VEHICLE, Em01_lamb_apc_a[1], false, true, false, true) 
  2102. 	end 
  2103.  
  2104. 	-- Show our groups for the "Oh Shit" moment 
  2105. 	group_show(GROUP_OH_SHIT_VEH_A) 
  2106. 	group_show(GROUP_OH_SHIT_VEH_B) 
  2107. 	group_show(GROUP_OH_SHIT_A) 
  2108. 	group_show(GROUP_OH_SHIT_B) 
  2109.  
  2110. 	-- Teleport the humans into the vehicle 
  2111. 	vehicle_enter_group_teleport(Em01_oh_shit_heli_a, OH_SHIT_HELI_A) 
  2112. 	vehicle_enter_group_teleport(Em01_oh_shit_heli_b, OH_SHIT_HELI_B) 
  2113.  
  2114. 	trigger_enable(TRIGGER_BLAST_OH_SHIT, true) 
  2115. 	on_trigger("em01_blast_oh_shit", TRIGGER_BLAST_OH_SHIT) 
  2116.  
  2117. 	-- Spawn off threads to run the pathfinding 
  2118. 	thread_new("em01_oh_shit_a_execute") 
  2119. 	thread_new("em01_oh_shit_b_execute") 
  2120.  
  2121. 	-- Delay for a short period of time 
  2122. 	delay(1.0) 
  2123.  
  2124. 	-- Play a line for the local player 
  2125. 	audio_play_for_character("PLAYER_BONUS_GOONS_01", LOCAL_PLAYER, "voice") 
  2126. end 
  2127.  
  2128. function em01_gotcha_heli() 
  2129. 	-- Disable this trigger 
  2130. 	trigger_enable(GOTCHA_TRIGGER, false) 
  2131.  
  2132. 	-- Once we have gotten to this point, flattening of the tires is acceptable 
  2133. 	vehicle_never_flatten_tires(JULIUS_VEHICLE, false)  
  2134.  
  2135. 	-- Release these groups to the world now... 
  2136. 	release_to_world(GROUP_WEAK_VEHICLE) 
  2137. 	release_to_world(GROUP_WEAK) 
  2138. 	release_to_world(GROUP_LAMB) 
  2139. 	release_to_world(GROUP_LAMB_A) 
  2140. 	release_to_world(GROUP_LAMB_B) 
  2141.  
  2142. 	-- Create our groups for the final showdown 
  2143. 	group_create_hidden(GROUP_STAND_VEH_A) 
  2144. 	group_create_hidden(GROUP_STAND_VEH_B) 
  2145. 	group_create_hidden(GROUP_STAND_A) 
  2146. 	group_create_hidden(GROUP_STAND_B) 
  2147. 	group_create_hidden(GROUP_ROADBLOCK) 
  2148.  
  2149. 	-- Enable the last stand trigger 
  2150. 	trigger_enable(LAST_STAND_SHOW_TRIGGER, true) 
  2151. 	on_trigger("em01_last_stand_show", LAST_STAND_SHOW_TRIGGER) 
  2152.  
  2153. 	trigger_enable(LAST_STAND_EXECUTE_TRIGGER, true) 
  2154. 	on_trigger("em01_last_stand_attack", LAST_STAND_EXECUTE_TRIGGER) 
  2155. end 
  2156.  
  2157. function em01_oh_shit_a_execute() 
  2158. 	-- Setup a callback for death 
  2159. 	on_vehicle_destroyed("em01_heli_destroyed", OH_SHIT_HELI_A) 
  2160.  
  2161. 	-- Teleport the helicopter to the starting location 
  2162. 	teleport_vehicle(OH_SHIT_HELI_A, HELI_ATTACK_POINT_1) 
  2163.  
  2164. 	-- Pathfind above the heightmap 
  2165. 	helicopter_fly_to_direct(OH_SHIT_HELI_A, 30.0, OH_SHIT_PATH_A) 
  2166.  
  2167. 	-- Wait until the player is where we want them to be 
  2168. 	while (not Em01_oh_shit_fire_now) do 
  2169. 		thread_yield() 
  2170. 	end 
  2171.  
  2172. 	local driver = vehicle_get_driver(OH_SHIT_HELI_A) 
  2173.  
  2174.    -- If the driver can't be found, the helicopter's not going to be 
  2175.    -- doing much attacking 
  2176.    if ( driver == nil ) then 
  2177.       return 
  2178.    end 
  2179.  
  2180. 	if (not vehicle_is_destroyed(OH_SHIT_HELI_A) and not character_is_dead(driver)) then 
  2181. 		-- We want this guy to have perfect aim 
  2182. 		set_perfect_aim(driver, true) 
  2183. 		-- Fire a rocket at the player(s) 
  2184. 		helicopter_shoot_navpoint(OH_SHIT_HELI_A, "em01_$n137") 
  2185. 		-- We want this guy to not have perfect aim 
  2186. 		set_perfect_aim(driver, false) 
  2187.  
  2188. 		-- Go into chase mode 
  2189. 		vehicle_chase(OH_SHIT_HELI_A, LOCAL_PLAYER) 
  2190. 	end 
  2191. end 
  2192.  
  2193. function em01_oh_shit_b_execute() 
  2194. 	-- Setup a callback for death 
  2195. 	on_vehicle_destroyed("em01_heli_destroyed", OH_SHIT_HELI_B) 
  2196.  
  2197. 	-- Teleport the helicopter to the starting location 
  2198. 	teleport_vehicle(OH_SHIT_HELI_B, HELI_ATTACK_POINT_2) 
  2199.  
  2200. 	-- Pathfind above the heightmap 
  2201. 	helicopter_fly_to_direct(OH_SHIT_HELI_B, 15.0, OH_SHIT_PATH_B) 
  2202.  
  2203. 	-- Wait until the player is where we want them to be 
  2204. 	while (not Em01_oh_shit_fire_now) do 
  2205. 		thread_yield() 
  2206. 	end 
  2207.  
  2208. 	local driver = vehicle_get_driver(OH_SHIT_HELI_B) 
  2209.  
  2210.    -- If the driver can't be found, the helicopter's not going to be 
  2211.    -- doing much attacking 
  2212.    if ( driver == nil ) then 
  2213.       return 
  2214.    end 
  2215.  
  2216. 	if (not vehicle_is_destroyed(OH_SHIT_HELI_B) and not character_is_dead(driver)) then 
  2217. 		-- We want this guy to have perfect aim 
  2218. 		set_perfect_aim(driver, true) 
  2219. 		-- Fire a rocket at the player(s) 
  2220. 		helicopter_shoot_navpoint(OH_SHIT_HELI_B, "em01_$n138") 
  2221. 		-- We want this guy to not have perfect aim 
  2222. 		set_perfect_aim(driver, false) 
  2223.  
  2224. 		-- Go into chase mode 
  2225. 		vehicle_chase(OH_SHIT_HELI_B, LOCAL_PLAYER) 
  2226. 	end 
  2227. end 
  2228.  
  2229. function em01_heli_destroyed(heli) 
  2230. 	-- Need to know who we are dealing with 
  2231. 	if (heli == OH_SHIT_HELI_A) then 
  2232. 		-- Release to the world 
  2233. 		release_to_world(GROUP_OH_SHIT_A) 
  2234. 		release_to_world(GROUP_OH_SHIT_VEH_A) 
  2235.  
  2236. 		-- TODO: Respawn this helicopter... 
  2237. 	else 
  2238. 		-- Release to the world 
  2239. 		release_to_world(GROUP_OH_SHIT_B) 
  2240. 		release_to_world(GROUP_OH_SHIT_VEH_B) 
  2241.  
  2242. 		-- TODO: Respawn this helicopter... 
  2243. 	end 
  2244. end 
  2245.  
  2246. function em01_last_stand_show(human) 
  2247. 	-- Disable the trigger...it is no longer needed 
  2248. 	trigger_enable(LAST_STAND_SHOW_TRIGGER, false) 
  2249.  
  2250. 	-- Make Julius independent...he might be already but do this for safety 
  2251. 	follower_make_independent(CHARACTER_JULIUS, true) 
  2252.  
  2253. 	-- Teleport the vehicles first... 
  2254.    teleport_vehicle(LAST_STAND_HELI_A, LAST_STAND_POINT_A) 
  2255.    teleport_vehicle(LAST_STAND_HELI_B, LAST_STAND_POINT_B) 
  2256.  
  2257.    -- Show the groups 
  2258.    group_show(GROUP_STAND_VEH_A) 
  2259.    group_show(GROUP_STAND_VEH_B) 
  2260.  
  2261.    if ( human ~= nil ) then 
  2262.       group_show(GROUP_STAND_A) 
  2263.       group_show(GROUP_STAND_B) 
  2264.       group_show(GROUP_ROADBLOCK) 
  2265.    end 
  2266.  
  2267. 	-- Teleport the humans into the vehicle 
  2268. 	vehicle_enter_group_teleport(Em01_last_stand_heli_a, LAST_STAND_HELI_A) 
  2269. 	vehicle_enter_group_teleport(Em01_last_stand_heli_b, LAST_STAND_HELI_B) 
  2270.  
  2271. 	-- Setup the death callbacks 
  2272. 	on_vehicle_destroyed("em01_last_stand_heli_destroyed", LAST_STAND_HELI_A) 
  2273. 	on_vehicle_destroyed("em01_last_stand_heli_destroyed", LAST_STAND_HELI_B) 
  2274.  
  2275. 	-- Change the amount of damage the vehicles can take 
  2276. 	if (not IN_COOP) then 
  2277. 		set_max_hit_points(LAST_STAND_HELI_A, get_max_hit_points(LAST_STAND_HELI_A) * 4, true) 
  2278. 		set_max_hit_points(LAST_STAND_HELI_B, get_max_hit_points(LAST_STAND_HELI_B) * 4, true) 
  2279. 	else 
  2280. 		set_max_hit_points(LAST_STAND_HELI_A, get_max_hit_points(LAST_STAND_HELI_A) * 8, true) 
  2281. 		set_max_hit_points(LAST_STAND_HELI_B, get_max_hit_points(LAST_STAND_HELI_B) * 8, true) 
  2282. 	end 
  2283.  
  2284.    -- Set the show variable 
  2285. 	LAST_STAND_SHOW_PERFORMED = true 
  2286.     
  2287.    if ( human == nil ) then 
  2288.       mission_debug( "objective!" ) 
  2289.       -- We are continuing from a checkpoint, show the objective to the player 
  2290.       em01_last_stand_objective() 
  2291.    end 
  2292. end 
  2293.  
  2294. function em01_last_stand_attack(human) 
  2295. 	-- Disable the trigger...it is no longer needed 
  2296. 	trigger_enable(LAST_STAND_EXECUTE_TRIGGER, false) 
  2297.  
  2298. 	-- Wait until the show has been performed... 
  2299. 	while (not LAST_STAND_SHOW_PERFORMED) do 
  2300. 		thread_yield() 
  2301. 	end 
  2302. 	-- If the "oh shit" helicopters still exist then have them flee 
  2303. 	if (vehicle_exists(OH_SHIT_HELI_A)) then 
  2304. 		vehicle_flee(OH_SHIT_HELI_A) 
  2305. 	end 
  2306.  
  2307. 	if (vehicle_exists(OH_SHIT_HELI_B)) then 
  2308. 		vehicle_flee(OH_SHIT_HELI_B) 
  2309. 	end 
  2310.  
  2311.    -- Allow some time for the players to find cover before attacking with the helicopters 
  2312.    if ( human ~= nil ) then 
  2313.       delay( 15.0 ) 
  2314.    end 
  2315.  
  2316. 	-- Add the marker 
  2317. 	marker_add_vehicle(LAST_STAND_HELI_A, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  2318. 	marker_add_vehicle(LAST_STAND_HELI_B, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  2319.  
  2320. 	-- Fire off the threads to execute the helicopter patterns 
  2321. 	thread_new("em01_last_stand_a", human) 
  2322. 	thread_new("em01_last_stand_b", human) 
  2323.  
  2324.    -- Mark the last stand attack as started 
  2325.    LAST_STAND_ATTACK_STARTED = true 
  2326. end 
  2327.  
  2328. function em01_last_stand_objective() 
  2329.    -- Wait until the attack has started before giving the objective 
  2330.    repeat 
  2331.       thread_yield() 
  2332.    until ( LAST_STAND_ATTACK_STARTED ) 
  2333.    mission_debug( "objective done delaying" ) 
  2334.  
  2335. 	-- Play the helicopter wave2 exchange 
  2336. 	audio_play_conversation(Em01_heliwave2_exchange) 
  2337.  
  2338. 	-- Give the directive and show the objective 
  2339. 	mission_help_table("em01_last_stand") 
  2340. 	objective_text(0, "em01_ls_objective", Em01_last_stand_heli_killed, 2, SYNC_ALL) 
  2341.  
  2342. 	-- Spawn off a thread to move Julius around 
  2343. 	thread_new("em01_last_stand_julius") 
  2344. end 
  2345.  
  2346. function em01_last_stand_heli_destroyed(vehicle) 
  2347. 	-- Remove the marker 
  2348. 	marker_remove_vehicle(vehicle, SYNC_ALL) 
  2349.  
  2350. 	-- Increment the number of helicopters killed 
  2351. 	Em01_last_stand_heli_killed = Em01_last_stand_heli_killed + 1 
  2352.  
  2353. 	-- Update the objective 
  2354. 	objective_text(0, "em01_ls_objective", Em01_last_stand_heli_killed, 2, SYNC_ALL) 
  2355.  
  2356. 	if (Em01_last_stand_heli_killed == 2) then 
  2357. 		-- Mission can end with success 
  2358. 		em01_complete() 
  2359. 	end 
  2360. end 
  2361.  
  2362. function em01_fire_missiles_at_vehicle() 
  2363. 	-- Disable the trigger 
  2364. 	trigger_enable(TRIGGER_BLAST_VEHICLE, false) 
  2365. 	-- Disable the cancel trigger too 
  2366. 	trigger_enable(TRIGGER_BLAST_CANCEL, false) 
  2367.  
  2368. 	-- Play Julius' audio line 
  2369. 	audio_play_for_character("JULIUS_BONUS_CRASHCAR_01", CHARACTER_JULIUS, "voice") 
  2370.  
  2371. 	-- Get the driver of this heli 
  2372. 	local driver = vehicle_get_driver(LAST_STAND_HELI_A) 
  2373.  
  2374.    -- If the driver can't be found, the helicopter's not going to be 
  2375.    -- doing much attacking 
  2376.    if ( driver == nil ) then 
  2377.       return 
  2378.    end 
  2379. 	 
  2380. 	-- We want this guy to have perfect aim 
  2381. 	if (not character_is_dead(driver)) then 
  2382. 		set_perfect_aim(driver, true) 
  2383. 	end 
  2384.  
  2385. 	-- Shoot at a designated spot 
  2386. 	helicopter_shoot_navpoint(LAST_STAND_HELI_A, "em01_$n132") 
  2387.  
  2388. 	delay(0.1) 
  2389. 	 
  2390. 	-- Shoot at a designated spot 
  2391. 	helicopter_shoot_navpoint(LAST_STAND_HELI_A, "em01_$n133") 
  2392.  
  2393. 	delay(0.1) 
  2394. 	 
  2395. 	-- Shoot at a designated spot 
  2396. 	helicopter_shoot_navpoint(LAST_STAND_HELI_A, "em01_$n134") 
  2397.  
  2398. 	-- We want this guy to not have perfect aim 
  2399. 	if (not character_is_dead(driver)) then 
  2400. 		set_perfect_aim(driver, false) 
  2401. 	end 
  2402. end 
  2403.  
  2404. function em01_fire_rpg_at_vehicle() 
  2405. 	-- Disable the trigger 
  2406. 	trigger_enable(TRIGGER_BLAST_VEHICLE, false) 
  2407. 	-- Disable the cancel trigger too 
  2408. 	trigger_enable(TRIGGER_BLAST_CANCEL, false) 
  2409.  
  2410. 	-- Play Julius' audio line 
  2411. 	audio_play_for_character("JULIUS_BONUS_CRASHCAR_01", CHARACTER_JULIUS, "voice") 
  2412.  
  2413. 	-- We want this guys to have perfect aim 
  2414. 	if (not character_is_dead("em01_$c054")) then 
  2415. 		set_perfect_aim("em01_$c054", true) 
  2416. 	end 
  2417.  
  2418. 	if (not character_is_dead("em01_$c055")) then 
  2419. 		set_perfect_aim("em01_$c055", true) 
  2420. 	end 
  2421.  
  2422. 	if (not character_is_dead("em01_$c056")) then 
  2423. 		set_perfect_aim("em01_$c056", true) 
  2424. 	end 
  2425.  
  2426. 	-- Shoot at a designated spot 
  2427. 	force_fire("em01_$c054", "em01_$n132", true) 
  2428.  
  2429. 	delay(0.1) 
  2430. 	 
  2431. 	-- Shoot at a designated spot 
  2432. 	force_fire("em01_$c055", "em01_$n133", true) 
  2433.  
  2434. 	delay(0.1) 
  2435. 	 
  2436. 	-- Shoot at a designated spot 
  2437. 	force_fire("em01_$c056", "em01_$n134", true) 
  2438.  
  2439. 	-- We want this guys to not have perfect aim 
  2440. 	if (not character_is_dead("em01_$c054")) then 
  2441. 		set_perfect_aim("em01_$c054", false) 
  2442. 	end 
  2443.  
  2444. 	if (not character_is_dead("em01_$c055")) then 
  2445. 		set_perfect_aim("em01_$c055", false) 
  2446. 	end 
  2447.  
  2448. 	if (not character_is_dead("em01_$c056")) then 
  2449. 		set_perfect_aim("em01_$c056", false) 
  2450. 	end 
  2451.  
  2452. 	-- Delay and then remove the rpg from these guys inventory 
  2453. 	delay(0.1) 
  2454. 	inv_item_remove("rpg_launcher", 1, "em01_$c054") 
  2455. 	inv_item_remove("rpg_launcher", 1, "em01_$c055") 
  2456. 	inv_item_remove("rpg_launcher", 1, "em01_$c056") 
  2457. end 
  2458.  
  2459. function em01_fire_missile_at_vehicle_cancel() 
  2460. 	-- Disable the trigger 
  2461. 	trigger_enable(TRIGGER_BLAST_CANCEL, false) 
  2462. 	-- Setup the shoot navpoint trigger 
  2463. 	trigger_enable(TRIGGER_BLAST_VEHICLE, true) 
  2464. 	on_trigger("em01_fire_rpg_at_vehicle", TRIGGER_BLAST_VEHICLE) 
  2465.  
  2466. 	-- Give a couple of guys rpgs since the heli won't be firing missiles 
  2467. 	inv_item_add("rpg_launcher", 1, "em01_$c054", true) 
  2468. 	inv_item_add("rpg_launcher", 1, "em01_$c055", true) 
  2469. 	inv_item_add("rpg_launcher", 1, "em01_$c056", true) 
  2470. end 
  2471.  
  2472. function em01_last_stand_a(human) 
  2473. 	-- Only pathfind to the desired area if we are not restarting from a checkpoint 
  2474. 	--if (not (human == nil)) then 
  2475. 		-- Setup the shoot navpoint trigger 
  2476. 		trigger_enable(TRIGGER_BLAST_VEHICLE, true) 
  2477. 		on_trigger("em01_fire_missiles_at_vehicle", TRIGGER_BLAST_VEHICLE) 
  2478.  
  2479. 		trigger_enable(TRIGGER_BLAST_CANCEL, true) 
  2480. 		on_trigger("em01_fire_missile_at_vehicle_cancel", TRIGGER_BLAST_CANCEL) 
  2481.  
  2482. 		-- Pathfind to the location 
  2483. 		helicopter_fly_to_direct(LAST_STAND_HELI_A, 45.0, LAST_STAND_PATH_A) 
  2484. 	--end 
  2485.  
  2486. 	-- Variables to store the current direction and pattern being executed 
  2487. 	local		direction = 1		-- Start this heli going ccw 
  2488. 	local		pattern_idx = 1 
  2489. 	local		dir_executed = 0 
  2490. 	local		new_pattern = "" 
  2491.  
  2492. 	-- We want this helicopter to just machine gun fire 
  2493. 	helicopter_set_missile_chance(LAST_STAND_HELI_A, 0.01) 
  2494.  
  2495. 	-- Fly the pattern... 
  2496. 	while (1) do 
  2497. 		-- Delay for a couple of seconds 
  2498. 		delay(1.0) 
  2499.  
  2500. 		-- Exit if the vehicle is destroyed 
  2501. 		if (vehicle_is_destroyed(LAST_STAND_HELI_A)) then 
  2502. 			return 
  2503. 		end 
  2504.  
  2505. 		-- Randomly choose the new pattern that can be used 
  2506. 		new_pattern = Em01_ls_table_a[direction][pattern_idx][rand_int(1, 2)] 
  2507.  
  2508. 		-- Have the helicopter fly to the next point in the list 
  2509. 		helicopter_fly_to_direct(LAST_STAND_HELI_A, 40.0, new_pattern) 
  2510. 		 
  2511. 		-- Fire a sequence of missiles 
  2512. 		if (not IN_COOP) then 
  2513. 			em01_missile_attack_sequence(LAST_STAND_HELI_A, {LOCAL_PLAYER, CHARACTER_JULIUS}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  2514. 		else 
  2515. 			em01_missile_attack_sequence(LAST_STAND_HELI_A, {LOCAL_PLAYER, CHARACTER_JULIUS, REMOTE_PLAYER}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  2516. 		end 
  2517.  
  2518. 		-- Set the pattern idx to use for the next choice 
  2519. 		pattern_idx = Em01_ls_table_a_idx[direction][pattern_idx][new_pattern] 
  2520.  
  2521. 		-- Increment the number of times a pattern has been executed in the current direction (cw, or ccw) 
  2522. 		dir_executed = dir_executed + 1 
  2523. 		if (dir_executed == 2) then 
  2524. 			-- Reset the number of times this direction has been executed 
  2525. 			dir_executed = 0 
  2526. 			-- Switch the pattern direction 
  2527. 			if (direction == 1) then 
  2528. 				direction = 2 
  2529. 			else 
  2530. 				direction = 1 
  2531. 			end 
  2532. 		end 
  2533. 	end 
  2534. end 
  2535.  
  2536. function em01_last_stand_b(human) 
  2537. 	-- Only pathfind to the desired area if we are not restarting from a checkpoint 
  2538. 	--if (not (human == nil)) then 
  2539. 		-- Pathfind to the location 
  2540. 		helicopter_fly_to_direct(LAST_STAND_HELI_B, 40.0, LAST_STAND_PATH_B) 
  2541. 	--end 
  2542.  
  2543. 	-- Variables to store the current direction and pattern being executed 
  2544. 	local		direction = 2		-- Start this heli going cw 
  2545. 	local		pattern_idx = 1 
  2546. 	local		dir_executed = 0 
  2547. 	local		new_pattern = "" 
  2548.  
  2549. 	-- We want this helicopter to just machine gun fire 
  2550. 	helicopter_set_missile_chance(LAST_STAND_HELI_B, 0.01) 
  2551.  
  2552. 	-- Fly the pattern... 
  2553. 	while (1) do 
  2554. 		-- Delay for a couple of seconds 
  2555. 		delay(1.0) 
  2556.  
  2557. 		-- Exit if the vehicle is destroyed 
  2558. 		if (vehicle_is_destroyed(LAST_STAND_HELI_B)) then 
  2559. 			return 
  2560. 		end 
  2561.  
  2562. 		-- Randomly choose the new pattern that can be used 
  2563. 		new_pattern = Em01_ls_table_b[direction][pattern_idx][rand_int(1, 2)] 
  2564.  
  2565. 		-- Have the helicopter fly to the next point in the list 
  2566. 		helicopter_fly_to_direct(LAST_STAND_HELI_B, 40.0, new_pattern) 
  2567. 		 
  2568. 		-- Fire a sequence of missiles 
  2569. 		if (not IN_COOP) then 
  2570. 			em01_missile_attack_sequence(LAST_STAND_HELI_B, {LOCAL_PLAYER, CHARACTER_JULIUS}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  2571. 		else 
  2572. 			em01_missile_attack_sequence(LAST_STAND_HELI_B, {LOCAL_PLAYER, CHARACTER_JULIUS, REMOTE_PLAYER}, Em01_missile_sequence[rand_int(1, Num_em01_missile_sequence)]) 
  2573. 		end 
  2574.  
  2575. 		-- Set the pattern idx to use for the next choice 
  2576. 		pattern_idx = Em01_ls_table_b_idx[direction][pattern_idx][new_pattern] 
  2577.  
  2578. 		-- Increment the number of times a pattern has been executed in the current direction (cw, or ccw) 
  2579. 		dir_executed = dir_executed + 1 
  2580. 		if (dir_executed == 2) then 
  2581. 			-- Reset the number of times this direction has been executed 
  2582. 			dir_executed = 0 
  2583. 			-- Switch the pattern direction 
  2584. 			if (direction == 1) then 
  2585. 				direction = 2 
  2586. 			else 
  2587. 				direction = 1 
  2588. 			end 
  2589. 		end 
  2590. 	end 
  2591. end 
  2592.  
  2593. function em01_last_stand_julius() 
  2594. 	-- Store our current location 
  2595. 	local		current_location = 0 
  2596.  
  2597. 	-- Do this until the mission fails or succeeds 
  2598. 	while (1) do 
  2599. 		-- Find a new location 
  2600. 		local		location = rand_int(1, Num_em01_ls_table_julius) 
  2601.  
  2602. 		while (location == current_location) do 
  2603. 			location = rand_int(1, Num_em01_ls_table_julius) 
  2604. 		end 
  2605.  
  2606. 		current_location = location 
  2607.  
  2608. 		-- Move to a navpoint...attack...repeat 
  2609. 		move_to_safe(CHARACTER_JULIUS, Em01_ls_table_julius[current_location], 3, true, true) 
  2610.  
  2611. 		-- Leash Julius to this navpoint 
  2612. 		npc_leash_to_nav(CHARACTER_JULIUS, Em01_ls_table_julius[current_location], 2.0) 
  2613.  
  2614. 		-- Have Julius attack enemies 
  2615. 		set_attack_enemies_flag(CHARACTER_JULIUS, true) 
  2616.  
  2617. 		-- Delay a random amount for this location 
  2618. 		delay(rand_float(2.0, 6.0)) 
  2619.  
  2620. 		-- Remove the leash 
  2621. 		npc_leash_remove(CHARACTER_JULIUS) 
  2622. 	end 
  2623. end 
  2624.