sr2lua/bh07.lua

  1. -- bh07.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- Groups -- 
  6. 	GROUP_FIREBOMBERS =			"bh07_$firebombers" 
  7. 	GROUP_FIREBOMBERS_COOP =	"bh07_$firebombers_coop" 
  8. 	GROUP_THE_STORE =				"bh07_$the_store" 
  9. 	GROUP_THE_STORE_COOP =		"bh07_$the_store_coop" 
  10. 	GROUP_PRISONERS =				"bh07_$prisoners" 
  11. 	GROUP_PRISONERS_COOP =		"bh07_$prisoners_coop" 
  12. 	GROUP_COORDINATOR =			"bh07_$coordinator" 
  13. 	GROUP_COORDINATOR_COOP =	"bh07_$coordinator_coop" 
  14. 	GROUP_COURTESY_CAR =			"bh07_$courtesy_car" 
  15. 	GROUP_COURTESY_CAR_COOP =	"bh07_$courtesy_car_coop" 
  16.  
  17. -- Navpoints -- 
  18. 	NAV_LOCAL_START =				"bh07_$n078" 
  19. 	NAV_REMOTE_START =			"bh07_$n079" 
  20. 	NAV_OBJ_FIREBOMBERS =		"bh07_$obj_firebombers" 
  21. 	NAV_OBJ_STORE =				"bh07_$obj_store" 
  22. 	NAV_OBJ_PRISONERS =			"bh07_$obj_prisoners" 
  23. 	NAV_OBJ_COORD =				"bh07_$obj_coord" 
  24.  
  25. 	--NAV_COORD_FLEE_PATH =		{"bh07_$n081", "bh07_$n082", "bh07_$n083", "bh07_$n084", "bh07_$n085", "bh07_$n086", "bh07_$n087"} 
  26. 	NAV_COORD_FLEE_PATH =		{"bh07_$n086", "bh07_$n087"} 
  27. 	NAV_COORD_FLEE_GROUND =		{"bh07_$n088", "bh07_$n089", "bh07_$n090"} 
  28. 	NAV_SWAT_HELI_INITIAL_PATH = "bh07_$n072" 
  29. 	NAV_SWAT_HELI_APPROACH =   {"bh07_$n073", "bh07_$n074", "bh07_$n076", "bh07_$n077", "bh07_$n080", "bh07_$n071"} 
  30. 	NAV_FIREBOMBER_PATHS =		{{"bh07_$n000", "bh07_$n001", "bh07_$n002", "bh07_$n003"}, 
  31. 										{"bh07_$n004", "bh07_$n005"}, 
  32. 										{"bh07_$n006", "bh07_$n007", "bh07_$n008"}, 
  33. 										{"bh07_$n009", "bh07_$n010", "bh07_$n011"}, 
  34. 										{"bh07_$n012", "bh07_$n013", "bh07_$n014", "bh07_$n015", "bh07_$n016"}, 
  35. 										{"bh07_$n017", "bh07_$n018", "bh07_$n019", "bh07_$n020", "bh07_$n021", "bh07_$n022"}, 
  36. 										{"bh07_$n023", "bh07_$n024", "bh07_$n025"}, 
  37. 										{"bh07_$n094", "bh07_$n095", "bh07_$n096", "bh07_$n097", "bh07_$n098", "bh07_$n016"}, 
  38. 										{"bh07_$n099", "bh07_$n100", "bh07_$n101", "bh07_$n102", "bh07_$n110", "bh07_$n097", "bh07_$n098", "bh07_$n016"}, 
  39. 										{"bh07_$n103", "bh07_$n104", "bh07_$n105", "bh07_$n106", "bh07_$n107", "bh07_$n108", "bh07_$n109", "bh07_$n022"}} 
  40. 	FIREBOMBER_PATH_MAP =		{{2,4}, 
  41. 										{3,8}, 
  42. 										{5,9}, 
  43. 										{5,9}, 
  44. 										{6,10}, 
  45. 										{1,7}, 
  46. 										{3,8}, 
  47. 										{6,10}, 
  48. 										{6,10}, 
  49. 										{1,7}} 
  50.  
  51. --[[ 
  52. 	NAV_STORE =						{"bh07_$n028", "bh07_$n029", "bh07_$n030", "bh07_$n031",  
  53. 										"bh07_$n032", "bh07_$n033", "bh07_$n034", "bh07_$n035",  
  54. 										"bh07_$n036", "bh07_$n037", "bh07_$n038", "bh07_$n039",  
  55. 										"bh07_$n040", "bh07_$n041", "bh07_$n042", "bh07_$n043", 
  56. 										"bh07_$n044", "bh07_$n045", "bh07_$n046", "bh07_$n047", 
  57. 										"bh07_$n048", "bh07_$n049", "bh07_$n050", "bh07_$n051", 
  58. 										"bh07_$n052", "bh07_$n053", "bh07_$n054", "bh07_$n055", 
  59. 										"bh07_$n056", "bh07_$n057", "bh07_$n058", "bh07_$n059", 
  60. 										"bh07_$n060", "bh07_$n061", "bh07_$n062", "bh07_$n063", 
  61. 										"bh07_$n064", "bh07_$n065", "bh07_$n066", "bh07_$n067", 
  62. 										"bh07_$n068", "bh07_$n069", "bh07_$n070", "bh07_$n075"} 
  63. ]]-- 
  64. 	NAV_STORE =						{{"bh07_$n065", "bh07_$n064", "bh07_$n063", "bh07_$n029", "bh07_$n062", "bh07_$n061", "bh07_$n060"}, 
  65. 										{"bh07_$n054", "bh07_$n055", "bh07_$n039", "bh07_$n056", "bh07_$n057", "bh07_$n037", "bh07_$n058", "bh07_$n059"}, 
  66. 										{"bh07_$n048", "bh07_$n049", "bh07_$n034", "bh07_$n050", "bh07_$n051", "bh07_$n052", "bh07_$n033", "bh07_$n053"}, 
  67. 										{"bh07_$n044", "bh07_$n032", "bh07_$n043", "bh07_$n036", "bh07_$n045", "bh07_$n035", "bh07_$n046"}, 
  68. 										{"bh07_$n066", "bh07_$n040", "bh07_$n038", "bh07_$n042", "bh07_$n041"}, 
  69. 										{"bh07_$n067", "bh07_$n030", "bh07_$n068", "bh07_$n031", "bh07_$n069", "bh07_$n069"}} 
  70.  
  71. 	NUM_STORE_NAVS =				sizeof_table(NAV_STORE) 
  72.  
  73. -- Triggers 
  74. 	TRIGGER_STORE_ENTRANCES	=	{"bh07_$Tstore_entrance_1", "bh07_$Tstore_entrance_2"} 
  75.  
  76. -- Vehicles -- 
  77. 	VEH_FIREBOMBER =				"bh07_$v000" 
  78. 	VEH_COORD =						"bh07_$v001" 
  79. 	VEH_SWAT =						"bh07_$v002" 
  80. 	VEH_FIREBOMBER_COOP =		"bh07_$v004" 
  81. 	VEH_SWAT_HELI =				"bh07_$v005" 
  82.  
  83. -- Characters -- 
  84. 	CHAR_LT_FIREBOMBER =			"bh07_$c000" 
  85. 	CHAR_FIREBOMBERS =			{"bh07_$c000", "bh07_$c001", "bh07_$c002"} 
  86. 	CHAR_FIREBOMBERS_COOP =		{"bh07_$c023", "bh07_$c024", "bh07_$c025", "bh07_$c026"} 
  87.  
  88. 	CHAR_SWAT =						{"bh07_$c014", "bh07_$c015", "bh07_$c005", "bh07_$c021", "bh07_$c022"} 
  89. 	CHAR_SWAT_COOP =				{"bh07_$c033", "bh07_$c034"} 
  90. 	CHAR_LT_SWAT =					"bh07_$c018" 
  91. 	CHAR_SD_TRIBAL_SWAT =		{"bh07_$c016", "bh07_$c017", "bh07_$c040", "bh07_$c041"} 
  92. 	CHAR_SD_SAINTS_SWAT =		{"bh07_$c019", "bh07_$c020", "bh07_$c038", "bh07_$c039"} 
  93. 	CHAR_ALL_SWAT_PRISONERS =	{"bh07_$c016", "bh07_$c017", "bh07_$c018", "bh07_$c019", "bh07_$c020", "bh07_$c038", "bh07_$c039", "bh07_$c040", "bh07_$c041"} 
  94. 	CHAR_TRIBAL_SWAT =			{"bh07_$c016", "bh07_$c017", "bh07_$c018", "bh07_$c040", "bh07_$c041"} 
  95. 	CHAR_SWAT_HELI =				{"bh07_$c003", "bh07_$c004", "bh07_$c042", "bh07_$c043", "bh07_$c044"} 
  96.  
  97. 	CHAR_LT_STORE =				"bh07_$c006" 
  98. 	CHAR_ALL_STORE =				{"bh07_$c007", "bh07_$c008", "bh07_$c037"} 
  99. 	CHAR_STORE_COOP =				{"bh07_$c031", "bh07_$c032"} 
  100. 	CHAR_CLERKBEATERS_STORE =	{"bh07_$c036", "bh07_$c006"} 
  101. 	CHAR_CLERK_STORE =			"bh07_$c035" 
  102. 	CHAR_BROWNBAGGERS_CLERK =	"shops_sr2_city_$TY_liq_clerk" 
  103.  
  104. 	CHAR_LT_COORD =				"bh07_$c009" 
  105. 	CHAR_SD_COORD =				{"bh07_$c010", "bh07_$c011", "bh07_$c012", "bh07_$c013"} 
  106. 	CHAR_ALL_COORD =				{"bh07_$c009", "bh07_$c010", "bh07_$c011", "bh07_$c012", "bh07_$c013"} 
  107. 	CHAR_ALL_COORD_COOP =		{"bh07_$c027", "bh07_$c028", "bh07_$c029", "bh07_$c030"} 
  108.  
  109. -- Text -- 
  110. 	TEXT_LTS_KILLED =				"bh07_lts_killed" 
  111. 	TEXT_ELIMINATE_LTS =			"bh07_eliminate_lts" 
  112. 	TEXT_KILL_REMAINING_LTS =	"bh07_kill_remaining_lts" 
  113. 	TEXT_SAVE_SHOP_OWNER =		"bh07_save_shop_owner" 
  114. 	TEXT_SHOP_OWNER_HEALTH =	"bh07_shop_owner_health" 
  115. 	TEXT_PREVENT_DAMAGE =		"bh07_prevent_damage" 
  116. 	TEXT_STORE_DAMAGE_METER =	"bh07_store_damage_meter" 
  117. 	TEXT_SHOP_OWNER_DIED =		"bh07_shop_owner_died" 
  118. 	TEXT_TOO_MUCH_DAMAGE =		"bh07_too_much_damage" 
  119. 	TEXT_KILL_FLEEING_LT =		"bh07_kill_fleeing_lieutenant" 
  120.  
  121. 	TEXT_MEETING_LT =				"bh07_meeting_lieutenant" 
  122. 	TEXT_TORCHING_DOCKS =		"bh07_torching_docks" 
  123. 	TEXT_ARRESTED_LT =			"bh07_arrested_lieutenant" 
  124. 	TEXT_DESTROYING_STORE =		"bh07_destroying_store" 
  125. 	TEXT_REMAINING_LT	=			"bh07_remaining_lieutenant" 
  126.  
  127. -- Threads -- 
  128. 	THREAD_STORE_MAYHEM =		{-1, -1, -1} 
  129. 	THREAD_COORD_FLEE =			-1 
  130. 	THREAD_HELI_PATH =			-1 
  131. 	THREAD_INITIAL_GPS =			-1 
  132. 	THREAD_FIREBOMBERS =			-1 
  133. 	THREAD_STORE =					-1 
  134. 	THREAD_PRISONERS =			-1 
  135. 	THREAD_COORD =					-1 
  136. 	THREAD_FIREBOMBER_ESCORT = -1 
  137. 	THREAD_MOLOTOVS =				-1 
  138. 	THREAD_SWAT_HELI =			-1 
  139. 	THREAD_HELI_EXIT =			{-1, -1, -1, -1, -1, -1} 
  140. 	THREAD_SHOP_OWNER =			-1 
  141. 	THREAD_NOTORIETY =			-1 
  142. 	ALL_THREADS =					{THREAD_STORE_MAYHEM[1], THREAD_STORE_MAYHEM[2], THREAD_STORE_MAYHEM[3], THREAD_COORD_FLEE, THREAD_HELI_PATH, 
  143. 										 THREAD_INITIAL_GPS, THREAD_FIREBOMBERS, THREAD_STORE, THREAD_PRISONERS, THREAD_COORD, THREAD_FIREBOMBER_ESCORT, 
  144. 										 THREAD_MOLOTOVS, THREAD_SWAT_HELI, THREAD_HELI_EXIT[1], THREAD_HELI_EXIT[2], THREAD_HELI_EXIT[3], THREAD_HELI_EXIT[4], 
  145. 										 THREAD_HELI_EXIT[5], THREAD_HELI_EXIT[6], THREAD_SHOP_OWNER, THREAD_NOTORIETY} 
  146.  
  147. -- Checkpoints -- 
  148. 	CHECKPOINT_SWAT =				"bh07_checkpoint_swat" 
  149. 	CHECKPOINT_FIREBOMBERS =	"bh07_checkpoint_firebombers" 
  150. 	CHECKPOINT_COORDINATOR =	"bh07_checkpoint_coordinator" 
  151. 	CHECKPOINT_STORE =			"bh07_checkpoint_store" 
  152.  
  153. -- Cutscenes -- 
  154. 	CUTSCENE_IN =						"br07-1.bik" 
  155. 	CUTSCENE_OUT =						"br07-2.bik" 
  156.  
  157. -- Other -- 
  158. 	Lieutenants_killed =			0 
  159. 	Store_total_damage =			0 
  160. 	Store_mayhem_choice =		{["bh07_$c006"] = -1, ["bh07_$c007"] = -1, ["bh07_$c008"] = -1} 
  161. 	IN_COOP =						false 
  162. 	INITIAL_NUM_LIEUTENANTS =	4 
  163. 	STORE_COOP_DISTANCE =		20 
  164. 	SWAT_HELI_LAUNCH_DISTANCE = 100 
  165. 	FIREBOMBER_DISTANCE =		200 
  166. 	STORE_DAMAGE_LIMIT =			1000 
  167. 	STORE_DAMAGE_AMOUNT =		25 
  168. 	ANIM_STATE_KNEEL =			"surrender" 
  169. 	ANIM_STATE_SWAT =				"combat stand" 
  170. 	ANIM_ACTION_DRINK =			"powerup liquor" 
  171. 	MOLOTOV_INTERVAL =			1 
  172. 	COORD_SPAWN_RADIUS =			200 
  173. 	FIREBOMBER_SPAWN_RADIUS =	250 
  174. 	STORE_SPAWN_RADIUS =			200 
  175. 	PRISONERS_SPAWN_RADIUS =	600 
  176.  
  177. 	PLAYER_SYNC = {[LOCAL_PLAYER] = SYNC_LOCAL, [REMOTE_PLAYER] = SYNC_REMOTE} 
  178. 	OTHER_PLAYER = {[LOCAL_PLAYER] = REMOTE_PLAYER, [REMOTE_PLAYER] = LOCAL_PLAYER}	 
  179.  
  180. BH07_SAINTS_ATTACK_PERSONAS = { 
  181. 	["AM_TSS2"]	=	"AMTSS2", 
  182. 	["AM_TSS3"]	=	"AMTSS3", 
  183.  
  184. 	["BM_TSS1"]	=	"BMTSS1", 
  185. 	["BM_TSS2"]	=	"BMTSS2", 
  186.  
  187. 	["BF_TSS1"]	=	"BFTSS1", 
  188. 	["BF_TSS2"]	=	"BFTSS2", 
  189.  
  190. 	["HM_TSS1"]	=	"HMTSS1", 
  191. 	["HM_TSS2"]	=	"HMTSS2", 
  192. 	["HM_TSS3"]	=	"HMTSS3", 
  193.  
  194. 	["HF_TSS3"]	=	"HFTSS3", 
  195.  
  196. 	["WM_TSS2"]	=	"WMTSS2", 
  197. 	["WM_TSS3"]	=	"WMTSS3", 
  198.  
  199. 	["WF_TSS1"]	=	"WFTSS1", 
  200. 	["WF_TSS2"]	=	"WFTSS2", 
  201. 	["WF_TSS3"]	=	"WFTSS3", 
  202. } 
  203.  
  204. BH07_BH_ATTACK_PERSONAS = { 
  205. 	["HM_Bro1"]	=	"HMBRO1", 
  206. 	["HM_Bro2"]	=	"HMBRO2", 
  207. 	["HM_Bro3"]	=	"HMBRO3", 
  208.  
  209. 	["HF_Bro1"]	=	"HFBRO1", 
  210. 	["HF_Bro2"]	=	"HFBRO2", 
  211.  
  212. 	["WM_Bro1"]	=	"WMBRO1", 
  213. 	["WM_Bro2"]	=	"WMBRO2", 
  214. 	["WM_Bro3"]	=	"WMBRO3", 
  215.  
  216. 	["WF_Bro1"]	=	"WFBRO1", 
  217. 	["WF_Bro2"]	=	"WFBRO2", 
  218. } 
  219.  
  220. BH07_TAUNT_PERSONAS = { 
  221. 	["HM_Bro1"]	=	"HMBRO1", 
  222. 	["HM_Bro2"]	=	"HMBRO2", 
  223. 	["HM_Bro3"]	=	"HMBRO3", 
  224.  
  225. 	["HF_Bro2"]	=	"HFBRO2", 
  226.  
  227. 	["WM_Bro3"]	=	"WMBRO3", 
  228.  
  229. 	["WF_Bro1"]	=	"WFBRO1", 
  230. 	["WF_Bro2"]	=	"WFBRO2", 
  231. } 
  232.  
  233. BH07_SHOP_PERSONAS = { 
  234. 	["HM_Bro1"]	=	"HMBRO1", 
  235. 	["HM_Bro2"]	=	"HMBRO2", 
  236. 	["HM_Bro3"]	=	"HMBRO3", 
  237.  
  238. 	["HF_Bro2"]	=	"HFBRO2", 
  239.  
  240. 	["WM_Bro3"]	=	"WMBRO3", 
  241.  
  242. 	["WF_Bro1"]	=	"WFBRO1", 
  243. 	["WF_Bro2"]	=	"WFBRO2", 
  244. } 
  245.  
  246. BH07_MOLOTOV_PERSONAS = { 
  247. 	["HM_Bro1"]	=	"HMBRO1", 
  248. 	["HM_Bro2"]	=	"HMBRO2", 
  249. 	["HM_Bro3"]	=	"HMBRO3", 
  250.  
  251. 	["HF_Bro2"]	=	"HFBRO2", 
  252.  
  253. 	["WM_Bro3"]	=	"WMBRO3", 
  254.  
  255. 	["WF_Bro1"]	=	"WFBRO1", 
  256. 	["WF_Bro2"]	=	"WFBRO2", 
  257. } 
  258.  
  259. function bh07_start(bh07_checkpoint, is_restart) 
  260.  
  261. 	if bh07_checkpoint == MISSION_START_CHECKPOINT then 
  262. 		if (not is_restart) then 
  263. 			cutscene_play("br07-01") 
  264. 		end 
  265. 		fade_out(0) 
  266. 	end 
  267.  
  268. 	bh07_initialize(bh07_checkpoint) 
  269.  
  270. 	if not Bh07_checkpoint_firebombers_complete then 
  271. 		THREAD_FIREBOMBERS = thread_new("bh07_firebombers") 
  272. 	else 
  273. 		Lieutenants_killed = Lieutenants_killed + 1 
  274. 	end 
  275.  
  276. 	if not Bh07_checkpoint_store_complete then 
  277. 		THREAD_STORE = thread_new("bh07_the_store") 
  278. 	else 
  279. 		Lieutenants_killed = Lieutenants_killed + 1 
  280. 	end 
  281.  
  282. 	if not Bh07_checkpoint_swat_complete then 
  283. 		THREAD_PRISONERS = thread_new("bh07_no_prisoners") 
  284. 	else 
  285. 		Lieutenants_killed = Lieutenants_killed + 1 
  286. 	end 
  287.  
  288. 	if not Bh07_checkpoint_coordinator_complete then 
  289. 		THREAD_COORD = thread_new("bh07_the_coordinator") 
  290. 	else 
  291. 		Lieutenants_killed = Lieutenants_killed + 1 
  292. 	end 
  293.  
  294. 	--THREAD_NOTORIETY = thread_new("bh07_notoriety") 
  295.  
  296. 	if bh07_checkpoint == MISSION_START_CHECKPOINT then 
  297. 		THREAD_INITIAL_GPS = thread_new("bh07_firebomber_gps") 
  298. 		mission_help_table(TEXT_ELIMINATE_LTS) 
  299. 	elseif (Lieutenants_killed == INITIAL_NUM_LIEUTENANTS - 1) then 
  300. 		mission_help_table(TEXT_REMAINING_LT) 
  301. 	else 
  302. 		mission_help_table(TEXT_KILL_REMAINING_LTS) 
  303. 	end 
  304.  
  305. 	bh07_show_lieutenant_counter() 
  306. end 
  307.  
  308. function bh07_initialize(checkpoint) 
  309.  
  310. 	mission_start_fade_out(0.0) 
  311.  
  312. 	bh07_initialize_common() 
  313.  
  314. 	bh07_initialize_checkpoint(checkpoint) 
  315.  
  316. 	mission_start_fade_in() 
  317.  
  318. end 
  319.  
  320. -- Initialization code shared by all checkpoints. 
  321. function bh07_initialize_common() 
  322.  
  323. 	-- Start trigger is hit...the activate button was hit 
  324. 	set_mission_author("Phillip Alexander and Aaron Hanson (aka Father Zucosos)") 
  325.  
  326. 	if coop_is_active() then 
  327. 		IN_COOP = true 
  328. 	end 
  329.  
  330. 	notoriety_set_max("Police", 2)	 
  331.  
  332. 	bh07_start_persona_overrides() 
  333.  
  334. end 
  335.  
  336. -- Initialization code specific to the checkpoint. 
  337. function bh07_initialize_checkpoint(checkpoint) 
  338.  
  339. 	if checkpoint == MISSION_START_CHECKPOINT then 
  340. 		 
  341. 		Bh07_checkpoint_firebombers_complete = false 
  342. 		Bh07_checkpoint_swat_complete = false 
  343. 		Bh07_checkpoint_store_complete = false 
  344. 		Bh07_checkpoint_coordinator_complete = false 
  345.  
  346. 		group_create(GROUP_COURTESY_CAR, true) 
  347. 		if IN_COOP then 
  348. 			group_create(GROUP_COURTESY_CAR_COOP, true) 
  349. 		end 
  350.  
  351. 		teleport_coop(NAV_LOCAL_START, NAV_REMOTE_START) 
  352.  
  353. 	end 
  354.  
  355. end 
  356.  
  357. function bh07_start_persona_overrides() 
  358. --	persona_override_group_start(BH07_SAINTS_ATTACK_PERSONAS, POT_SITUATIONS[POT_ATTACK], "BR07_ATTACK") 
  359. --	persona_override_group_start(BH07_TAUNT_PERSONAS, POT_SITUATIONS[POT_TAUNT_NEGATIVE], "BR07_TAUNT") 
  360. 	persona_override_group_start(BH07_SHOP_PERSONAS, POT_SITUATIONS[POT_CUSTOM_1], "BR07_SHOP") 
  361. 	persona_override_group_start(BH07_MOLOTOV_PERSONAS, POT_SITUATIONS[POT_CUSTOM_2], "BR07_MOLOTOV") 
  362. end 
  363.  
  364. function bh07_stop_persona_overrides() 
  365. --	persona_override_group_stop(SAINTS_PERSONAS, POT_SITUATIONS[POT_ATTACK]) 
  366. --	persona_override_group_stop(BROTHERHOOD_PERSONAS, POT_SITUATIONS[POT_TAUNT_NEGATIVE]) 
  367. 	persona_override_group_stop(BROTHERHOOD_PERSONAS, POT_SITUATIONS[POT_CUSTOM_1]) 
  368. 	persona_override_group_stop(BROTHERHOOD_PERSONAS, POT_SITUATIONS[POT_CUSTOM_2]) 
  369. end 
  370.  
  371. function bh07_wait_to_spawn_objective(nav, radius) 
  372. 	local dist, closest_player = get_dist_closest_player_to_object(nav) 
  373. 	while (dist >= radius) do 
  374. 		dist, closest_player = get_dist_closest_player_to_object(nav) 
  375. 		thread_yield() 
  376. 	end 
  377. end 
  378.  
  379. function bh07_firebomber_gps() 
  380.  
  381. 	-- Add a waypoint to the truck's starting location 
  382. 	mission_waypoint_add(NAV_OBJ_FIREBOMBERS, SYNC_ALL) 
  383.  
  384. 	-- Returns true if the waypoint should no longer be displayed. 
  385. 	local function should_keep_waypoint() 
  386. 		if (	(Lieutenants_killed == 0)  
  387. 				and (get_dist_closest_player_to_object(CHAR_LT_COORD) > 25) 
  388. 				and (get_dist_closest_player_to_object(CHAR_LT_STORE) > 25)  
  389. 				and (get_dist_closest_player_to_object(CHAR_LT_SWAT) > 25) 
  390. 			) then 
  391. 			return true 
  392. 		end 
  393. 		return false 
  394. 	end 
  395.  
  396. 	local vehicle_waypoint = false	 
  397.  
  398. 	-- Remove the waypoint if the player is too close to any of the LTNTS, or any LTNT has been killed. 
  399. 	while (should_keep_waypoint()) do 
  400. 		if ( (not vehicle_waypoint) and (group_is_loaded(GROUP_FIREBOMBERS)) ) then 
  401. 			mission_waypoint_remove(SYNC_ALL) 
  402. 			mission_waypoint_add(VEH_FIREBOMBER) 
  403. 			vehicle_waypoint = true 
  404. 		end 
  405. 		thread_yield() 
  406. 	end 
  407.  
  408. 	mission_waypoint_remove(SYNC_ALL) 
  409. end 
  410.  
  411. function bh07_initial_gps() 
  412. 	mission_waypoint_add(NAV_OBJ_FIREBOMBERS, SYNC_ALL) 
  413.  
  414. 	local vehicle_waypoint = false 
  415.  
  416. 	while (Lieutenants_killed == 0) and 
  417. 	      (get_dist_char_to_nav(LOCAL_PLAYER, CHAR_LT_COORD) > 25) and 
  418. 			(get_dist_char_to_nav(LOCAL_PLAYER, CHAR_LT_STORE) > 25) and 
  419. 			(get_dist_char_to_nav(LOCAL_PLAYER, CHAR_LT_SWAT) > 25) do 
  420. 		if ( (not vehicle_waypoint) and (group_is_loaded(GROUP_FIREBOMBERS)) ) then 
  421. 			mission_waypoint_remove(SYNC_ALL) 
  422. 			mission_waypoint_add(VEH_FIREBOMBER) 
  423. 			vehicle_waypoint = true 
  424. 		end 
  425. 		thread_yield() 
  426. 	end 
  427.  
  428. 	mission_waypoint_remove(SYNC_ALL) 
  429. end 
  430.  
  431. function bh07_show_lieutenant_counter() 
  432. 	objective_text(0, TEXT_LTS_KILLED, Lieutenants_killed, INITIAL_NUM_LIEUTENANTS) 
  433. end 
  434.  
  435. function bh07_firebombers() 
  436. 	marker_add_navpoint(NAV_OBJ_FIREBOMBERS, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  437. 	bh07_wait_to_spawn_objective(NAV_OBJ_FIREBOMBERS, FIREBOMBER_SPAWN_RADIUS) 
  438.  
  439. 	group_create(GROUP_FIREBOMBERS, true) 
  440. 	if IN_COOP then 
  441. 		group_create(GROUP_FIREBOMBERS_COOP, true) 
  442. 	end 
  443.  
  444. 	delay(2.0) 
  445.  
  446. 	local closest_player, dist 
  447. 	repeat 
  448. 		thread_yield() 
  449. 		dist, closest_player = get_dist_closest_player_to_object(VEH_FIREBOMBER) 
  450. 	until dist <= FIREBOMBER_DISTANCE 
  451.  
  452. 	on_death("bh07_lieutenant_killed", CHAR_LT_FIREBOMBER) 
  453. 	marker_add_npc(CHAR_FIREBOMBERS[1], MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  454. 	marker_remove_navpoint(NAV_OBJ_FIREBOMBERS, SYNC_ALL) 
  455. 	thread_yield() 
  456. 	 
  457. 	set_ignore_ai_flag(CHAR_FIREBOMBERS[1], true) 
  458. 	set_ignore_ai_flag(CHAR_FIREBOMBERS[2], true) 
  459. 	set_ignore_ai_flag(CHAR_FIREBOMBERS[3], true) 
  460. 	vehicle_suppress_npc_exit(VEH_FIREBOMBER, true) 
  461. 	vehicle_enter_teleport(CHAR_FIREBOMBERS[1], VEH_FIREBOMBER, 0) 
  462. 	vehicle_enter_teleport(CHAR_FIREBOMBERS[2], VEH_FIREBOMBER, 2) 
  463. 	vehicle_enter_teleport(CHAR_FIREBOMBERS[3], VEH_FIREBOMBER, 3) 
  464. 	set_unjackable_flag(VEH_FIREBOMBER, true) 
  465.  
  466. 	if IN_COOP then 
  467. 		vehicle_enter_group_teleport(CHAR_FIREBOMBERS_COOP, VEH_FIREBOMBER_COOP) 
  468.  
  469. 		THREAD_FIREBOMBER_ESCORT = thread_new("bh07_firebomber_escort") 
  470. 	end 
  471. 	 
  472. 	vehicle_prevent_explosion_fling(VEH_FIREBOMBER, true) 
  473. 	vehicle_infinite_mass(VEH_FIREBOMBER, true) 
  474. 	vehicle_set_crazy(VEH_FIREBOMBER, true) 
  475. 	vehicle_max_speed(VEH_FIREBOMBER, 65) 
  476.  
  477. 	 
  478. 	THREAD_MOLOTOVS = thread_new("bh07_firebombers_molotovs") 
  479. 	local path_node = 6 
  480.  
  481. 	mission_help_table(TEXT_TORCHING_DOCKS) 
  482.  
  483. 	while(not character_is_dead(CHAR_LT_FIREBOMBER) and not vehicle_is_destroyed(VEH_FIREBOMBER)) do 
  484. 		thread_yield() 
  485. 		local num_choices = sizeof_table(FIREBOMBER_PATH_MAP[path_node]) 
  486. 		local choice_id = rand_int(1, num_choices) 
  487. 		path_node = FIREBOMBER_PATH_MAP[path_node][choice_id] 
  488. 		local path_navs =	NAV_FIREBOMBER_PATHS[path_node] 
  489. 		vehicle_pathfind_to(VEH_FIREBOMBER, path_navs, true, false) 
  490. 	end 
  491.  
  492. 	while(not character_is_dead(CHAR_LT_FIREBOMBER)) do 
  493. 		thread_yield() 
  494. 	end 
  495.  
  496. 	Bh07_checkpoint_firebombers_complete = true 
  497. 	if bh07_more_objectives_remain() then 
  498. 		mission_set_checkpoint(CHECKPOINT_FIREBOMBERS) 
  499.  
  500. 		if (Lieutenants_killed == INITIAL_NUM_LIEUTENANTS - 1) then 
  501. 			mission_help_table(TEXT_REMAINING_LT) 
  502. 		else 
  503. 			mission_help_table(TEXT_KILL_REMAINING_LTS) 
  504. 		end 
  505. 	end 
  506.  
  507. 	marker_remove_npc(CHAR_LT_FIREBOMBER, SYNC_ALL) 
  508. end 
  509.  
  510. function bh07_firebomber_escort() 
  511. 	vehicle_chase(VEH_FIREBOMBER_COOP, CHAR_FIREBOMBERS[1], false, false, true) 
  512. end 
  513.  
  514. function bh07_firebombers_molotovs() 
  515. 	while(1) do 
  516. 		thread_yield() 
  517. 		delay(MOLOTOV_INTERVAL) 
  518. 		inv_item_equip("molotov", CHAR_FIREBOMBERS[1]) 
  519. 		audio_play_persona_line(CHAR_FIREBOMBERS[1], POT_SITUATIONS[POT_CUSTOM_2][1]) 
  520. 		force_throw_from_vehicle(CHAR_FIREBOMBERS[1], true) 
  521. 		thread_yield() 
  522. 		delay(MOLOTOV_INTERVAL) 
  523. 		inv_item_equip("molotov", CHAR_FIREBOMBERS[2]) 
  524. 		audio_play_persona_line(CHAR_FIREBOMBERS[2], POT_SITUATIONS[POT_CUSTOM_2][1]) 
  525. 		force_throw_from_vehicle(CHAR_FIREBOMBERS[2], true) 
  526. 		thread_yield() 
  527. 		delay(MOLOTOV_INTERVAL) 
  528. 		inv_item_equip("molotov", CHAR_FIREBOMBERS[3]) 
  529. 		audio_play_persona_line(CHAR_FIREBOMBERS[3], POT_SITUATIONS[POT_CUSTOM_2][1]) 
  530. 		force_throw_from_vehicle(CHAR_FIREBOMBERS[3], true) 
  531. 	end 
  532. end 
  533.  
  534.  
  535. function bh07_no_prisoners() 
  536. 	marker_add_navpoint(NAV_OBJ_PRISONERS, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  537. 	bh07_wait_to_spawn_objective(NAV_OBJ_PRISONERS, PRISONERS_SPAWN_RADIUS) 
  538.  
  539. 	group_create(GROUP_PRISONERS, true) 
  540. 	-- Hide the swat group. we don't want the player to find them standing around 
  541. 	vehicle_hide(VEH_SWAT_HELI) 
  542. 	for i, npc in pairs(CHAR_SWAT_HELI) do 
  543. 		character_hide(npc) 
  544. 	end 
  545. 	if IN_COOP then 
  546. 		group_create(GROUP_PRISONERS_COOP, true) 
  547. 	end 
  548.  
  549. 	vehicle_set_sirenlights(VEH_SWAT, true) 
  550.  
  551. 	marker_add_npc(CHAR_LT_SWAT, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  552. 	marker_remove_navpoint(NAV_OBJ_PRISONERS, SYNC_ALL) 
  553. 	on_death("bh07_lieutenant_killed", CHAR_LT_SWAT) 
  554. 	thread_yield() 
  555.  
  556. 	for i, npc in pairs(CHAR_SWAT) do 
  557. 		inv_item_add("m16", 1, npc) 
  558. 		inv_item_equip("m16", npc) 
  559. 		on_death("bh07_swat_killed", npc) 
  560. 		on_damage("bh07_holdup_interrupted", npc, 0.99) 
  561. 		npc_unholster_best_weapon(npc) 
  562. 		set_animation_state(npc, ANIM_STATE_SWAT) 
  563. 	end 
  564.  
  565. 	if IN_COOP then 
  566. 		for i, npc in pairs(CHAR_SWAT_COOP) do 
  567. 			inv_item_add("m16", 1, npc) 
  568. 			inv_item_equip("m16", npc) 
  569. 			on_death("bh07_swat_killed", npc) 
  570. 			on_damage("bh07_holdup_interrupted", npc, 0.99) 
  571. 			npc_unholster_best_weapon(npc) 
  572. 			set_animation_state(npc, ANIM_STATE_SWAT) 
  573. 		end 
  574. 	end 
  575.  
  576. 	for i, npc in pairs(CHAR_ALL_SWAT_PRISONERS) do 
  577. 		inv_item_remove_all(npc) 
  578. 		on_damage("bh07_holdup_interrupted", npc, 0.99) 
  579. 		set_animation_state(npc, ANIM_STATE_KNEEL) 
  580. 	end 
  581.  
  582. 	for i, npc in pairs(CHAR_SD_SAINTS_SWAT) do 
  583. 		set_attack_player_flag(npc, false) 
  584. 	end 
  585.  
  586. 	local function bh07_npc_is_players_shield(npc) 
  587. 		if (not character_is_dead(npc) ) then 
  588. 			if (character_has_specific_human_shield(LOCAL_PLAYER,npc) ) then 
  589. 				return true				 
  590. 			elseif ( IN_COOP and character_has_specific_human_shield(REMOTE_PLAYER,npc) ) then 
  591. 				return true 
  592. 			end 
  593. 		end 
  594. 		return false 
  595. 	end 
  596.  
  597. 	local heli_launched = false 
  598. 	while not character_is_dead(CHAR_LT_SWAT) do 
  599. 		thread_yield() 
  600. 		if (not heli_launched) and (get_dist_closest_player_to_object(CHAR_LT_SWAT) <= SWAT_HELI_LAUNCH_DISTANCE) then 
  601. 			THREAD_SWAT_HELI = thread_new("bh07_launch_swat_heli") 
  602. 			heli_launched = true 
  603. 			mission_help_table(TEXT_ARRESTED_LT) 
  604. 		end 
  605.  
  606. 		if (not Bh07_holdup_triggered) then 
  607.  
  608. 			for i, npc in pairs(CHAR_SWAT) do 
  609. 				if(bh07_npc_is_players_shield(npc)) then 
  610. 					bh07_holdup_interrupted() 
  611. 				end 
  612. 			end 
  613.  
  614. 			if IN_COOP then 
  615. 				for i, npc in pairs(CHAR_SWAT_COOP) do 
  616. 					if(bh07_npc_is_players_shield(npc)) then 
  617. 						bh07_holdup_interrupted() 
  618. 					end 
  619. 				end 
  620. 			end 
  621.  
  622. 			for i, npc in pairs(CHAR_ALL_SWAT_PRISONERS) do 
  623. 				if(bh07_npc_is_players_shield(npc)) then 
  624. 					bh07_holdup_interrupted() 
  625. 				end 
  626. 			end 
  627. 			 
  628. 		end		 
  629.  
  630. 	end 
  631.  
  632. 	Bh07_checkpoint_swat_complete = true 
  633. 	if bh07_more_objectives_remain() then 
  634. 		mission_set_checkpoint(CHECKPOINT_SWAT) 
  635. 		if (Lieutenants_killed == INITIAL_NUM_LIEUTENANTS - 1) then 
  636. 			mission_help_table(TEXT_REMAINING_LT) 
  637. 		else 
  638. 			mission_help_table(TEXT_KILL_REMAINING_LTS) 
  639. 		end 
  640. 	end 
  641.  
  642. 	marker_remove_npc(CHAR_LT_SWAT, SYNC_ALL) 
  643. end 
  644.  
  645. function bh07_launch_swat_heli() 
  646.  
  647. 	local dist,player = get_dist_closest_player_to_object(VEH_SWAT_HELI) 
  648. 	-- If the player is close by, don't show the heli... don't want to pop it in on top of them. 
  649. 	if (dist < 100) then 
  650. 		return 
  651. 	end 
  652. 	 
  653. 	vehicle_show(VEH_SWAT_HELI) 
  654. 	for i, npc in pairs(CHAR_SWAT_HELI) do 
  655. 		character_show(npc) 
  656. 	end 
  657. 	 
  658. 	vehicle_enter_group_teleport(CHAR_SWAT_HELI, VEH_SWAT_HELI) 
  659. 	delay(2) 
  660.  
  661. 	helicopter_fly_to(VEH_SWAT_HELI, 35, NAV_SWAT_HELI_INITIAL_PATH) 
  662. 	delay() 
  663. 	--THREAD_HELI_PATH = thread_new("bh07_swat_path") 
  664. 	helicopter_fly_to_direct(VEH_SWAT_HELI, 35, NAV_SWAT_HELI_APPROACH) 
  665. 	--[[ 
  666. 	while(get_dist(VEH_SWAT_HELI, NAV_SWAT_HELI_APPROACH[6]) > 3.5) do 
  667. 		thread_yield() 
  668. 	end 
  669. 	]] 
  670. 	turn_invulnerable(VEH_SWAT_HELI) 
  671. 	delay(1) 
  672. 	if(THREAD_HELI_PATH ~= -1) then 
  673. 		thread_kill(THREAD_HELI_PATH) 
  674. 	end 
  675. 	delay() 
  676. 	for i, npc in pairs(CHAR_SWAT_HELI) do 
  677. 		if (i > 1) then 
  678. 			THREAD_HELI_EXIT[i] = thread_new("bh07_swat_heli_exit", npc) 
  679. 		end 
  680. 	end 
  681. 	turn_vulnerable(VEH_SWAT_HELI) 
  682. end 
  683.  
  684. function bh07_swat_path() 
  685. 	helicopter_fly_to_direct(VEH_SWAT_HELI, 35, NAV_SWAT_HELI_APPROACH) 
  686. end 
  687.  
  688. function bh07_swat_heli_exit(npc) 
  689. 	vehicle_exit(npc, false) 
  690. 	attack(npc, LOCAL_PLAYER) 
  691. end 
  692.  
  693. function bh07_swat_killed() 
  694. 	for i, npc in pairs(CHAR_SWAT) do 
  695. 		clear_animation_state(npc) 
  696. 		on_death("", npc) 
  697. 		on_damage("", npc, 0.99) 
  698. 		inv_item_add("m16", 1, npc) 
  699. 		inv_item_equip("m16", npc) 
  700. 		set_ignore_ai_flag(npc, false) 
  701. 		set_attack_player_flag(npc, true) 
  702. 		attack(npc, CLOSEST_PLAYER) 
  703. 	end 
  704.  
  705. 	if IN_COOP then 
  706. 		for i, npc in pairs(CHAR_SWAT_COOP) do 
  707. 			clear_animation_state(npc) 
  708. 			on_death("", npc) 
  709. 			on_damage("", npc, 0.99) 
  710. 			inv_item_add("m16", 1, npc) 
  711. 			inv_item_equip("m16", npc) 
  712. 			set_ignore_ai_flag(npc, false) 
  713. 			set_attack_player_flag(npc, true) 
  714. 			attack(npc, CLOSEST_PLAYER) 
  715. 		end 
  716. 	end 
  717.  
  718. 	for i, npc in pairs(CHAR_TRIBAL_SWAT) do 
  719. 		on_damage("", npc, 0.99) 
  720. 		set_ignore_ai_flag(npc, false) 
  721. 		clear_animation_state(npc) 
  722. 	end 
  723.  
  724. 	for i, npc in pairs(CHAR_SD_SAINTS_SWAT) do 
  725. 		set_attack_player_flag(npc, false) 
  726. 		set_ignore_ai_flag(npc, false) 
  727. 		attack(npc, CHAR_SD_TRIBAL_SWAT[i]) 
  728. 	end 
  729. end 
  730.  
  731. Bh07_holdup_triggered = false 
  732. function bh07_holdup_interrupted() 
  733.  
  734. 	if(Bh07_holdup_triggered) then 
  735. 		return 
  736. 	else 
  737. 		Bh07_holdup_triggered = true 
  738. 	end 
  739.  
  740. 	for i, npc in pairs(CHAR_ALL_SWAT_PRISONERS) do 
  741. 		on_damage("", npc, 0.99) 
  742. 	end 
  743.  
  744. 	for i, npc in pairs(CHAR_SWAT) do 
  745. 		clear_animation_state(npc) 
  746. 		on_damage("", npc, 0.99) 
  747. 		set_ignore_ai_flag(npc, false) 
  748. 		set_attack_player_flag(npc, true) 
  749. 		attack(npc, CLOSEST_PLAYER) 
  750. 	end 
  751.  
  752. 	if IN_COOP then 
  753. 		for i, npc in pairs(CHAR_SWAT_COOP) do 
  754. 			clear_animation_state(npc) 
  755. 			on_damage("", npc, 0.99) 
  756. 			set_ignore_ai_flag(npc, false) 
  757. 			set_attack_player_flag(npc, true) 
  758. 			attack(npc, CLOSEST_PLAYER) 
  759. 		end 
  760. 	end 
  761. end 
  762.  
  763. Store_approached = false 
  764. function bh07_the_store() 
  765. 	marker_add_navpoint(NAV_OBJ_STORE, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  766. 	bh07_wait_to_spawn_objective(NAV_OBJ_STORE, STORE_SPAWN_RADIUS) 
  767. 	trigger_type_enable("liquor store", false) 
  768.  
  769. 	-- setup triggers so that we know when the player has approached the store 
  770. 	for i,trigger in pairs (TRIGGER_STORE_ENTRANCES) do 
  771. 		on_trigger("bh07_the_store_approached", trigger) 
  772. 		trigger_enable(trigger, true) 
  773. 	end 
  774.  
  775. 	group_create(GROUP_THE_STORE, true) 
  776. 	if IN_COOP then 
  777. 		group_create(GROUP_THE_STORE_COOP, true) 
  778. 	end 
  779.  
  780. 	on_death("bh07_failure_shop_owner_died", CHAR_CLERK_STORE) 
  781.  
  782. 	marker_add_npc(CHAR_LT_STORE, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  783. 	marker_remove_navpoint(NAV_OBJ_STORE, SYNC_ALL) 
  784. 	on_death("bh07_lieutenant_killed", CHAR_LT_STORE) 
  785.  
  786. 	while (not Store_approached) do 
  787. 		thread_yield() 
  788. 	end 
  789.  
  790. 	local dist, closest_player = get_dist_closest_player_to_object(NAV_OBJ_STORE) 
  791. 	local sync = PLAYER_SYNC[closest_player] 
  792.  
  793. 	character_hide(CHAR_BROWNBAGGERS_CLERK) 
  794.  
  795. 	mission_help_table(TEXT_DESTROYING_STORE, "", "", sync) 
  796. 	--mission_help_table(TEXT_PREVENT_DAMAGE, "", "", sync) 
  797. 	objective_text(1, TEXT_STORE_DAMAGE_METER, Store_total_damage, STORE_DAMAGE_LIMIT, sync) 
  798.  
  799. 	THREAD_SHOP_OWNER = thread_new("bh07_shop_owner") 
  800.  
  801. 	for i, npc in pairs(CHAR_ALL_STORE) do 
  802. 		set_attack_player_flag(npc, false) 
  803. 		character_set_cannot_wield_havok_weapon(npc, true) 
  804. 		npc_weapon_pickup_override(npc, false) 
  805. 		THREAD_STORE_MAYHEM[i] = thread_new("bh07_store_mayhem", npc) 
  806. 		on_damage("bh07_store_fight", npc, 0.8) 
  807. 	end 
  808.  
  809. 	if IN_COOP then 
  810. 		for i, npc in pairs(CHAR_STORE_COOP) do 
  811. 			on_damage("bh07_store_fight", npc, 0.8) 
  812. 			npc_weapon_pickup_override(npc, false) 
  813. 			character_set_cannot_wield_havok_weapon(npc, true) 
  814. 		end 
  815. 	end 
  816.  
  817. 	while not character_is_dead(CHAR_LT_STORE) do 
  818. 		thread_yield() 
  819.  
  820. 		-- See if the Coop player should start getting the hud updates 
  821. 		if (IN_COOP and (sync ~= SYNC_ALL)) then 
  822. 			if (get_dist(OTHER_PLAYER[closest_player], NAV_OBJ_STORE) < STORE_COOP_DISTANCE) then 
  823. 				mission_help_table(TEXT_PREVENT_DAMAGE, "", "", OTHER_PLAYER[closest_player]) 
  824. 				sync = SYNC_ALL 
  825. 			end 
  826. 		end 
  827. 		objective_text(1, TEXT_STORE_DAMAGE_METER, Store_total_damage, STORE_DAMAGE_LIMIT, sync) 
  828.  
  829. 		if Store_total_damage >= STORE_DAMAGE_LIMIT then 
  830. 			bh07_failure_store_damage() 
  831. 		end 
  832.  
  833. 		-- If one of the brotherhood is taken as a human shield, then they should attack the player. 
  834. 		if (not Store_fight_triggered) then 
  835. 			for i, npc in pairs(CHAR_ALL_STORE) do 
  836. 				if (not character_is_dead(npc) ) then 
  837. 					if (character_has_specific_human_shield(LOCAL_PLAYER,npc) ) then 
  838. 						bh07_store_fight()					 
  839. 					elseif ( IN_COOP and character_has_specific_human_shield(REMOTE_PLAYER,npc) ) then 
  840. 						bh07_store_fight() 
  841. 					end 
  842. 				end 
  843. 			end 
  844.  
  845. 			if IN_COOP then 
  846. 				for i, npc in pairs(CHAR_STORE_COOP) do 
  847. 					if (not character_is_dead(npc) ) then 
  848. 						if (character_has_specific_human_shield(LOCAL_PLAYER,npc) ) then 
  849. 							bh07_store_fight()					 
  850. 						elseif ( IN_COOP and character_has_specific_human_shield(REMOTE_PLAYER,npc) ) then 
  851. 							bh07_store_fight() 
  852. 						end 
  853. 					end 
  854. 				end 
  855. 			end 
  856. 		end 
  857.  
  858. 	end 
  859.  
  860. 	if ( character_exists(CHAR_CLERK_STORE) and (not character_is_dead(CHAR_CLERK_STORE)) ) then 
  861. 		turn_invulnerable(CHAR_CLERK_STORE, false) 
  862. 	end 
  863.  
  864.  
  865. 	delay(2) 
  866. 	Bh07_checkpoint_store_complete = true 
  867. 	if bh07_more_objectives_remain() then 
  868. 		mission_set_checkpoint(CHECKPOINT_STORE) 
  869.  
  870. 		if (Lieutenants_killed == INITIAL_NUM_LIEUTENANTS - 1) then 
  871. 			mission_help_table(TEXT_REMAINING_LT) 
  872. 		else 
  873. 			mission_help_table(TEXT_KILL_REMAINING_LTS) 
  874. 		end 
  875. 	end 
  876.  
  877. 	objective_text_clear(1) 
  878. 	damage_indicator_off(0) 
  879. 	marker_remove_npc(CHAR_LT_STORE, SYNC_ALL) 
  880. end 
  881.  
  882. function bh07_the_store_approached(trigger) 
  883.  
  884. 	Store_approached = true 
  885.  
  886. 	for i,trigger in pairs (TRIGGER_STORE_ENTRANCES) do 
  887. 		on_trigger("", trigger) 
  888. 		trigger_enable(trigger, false) 
  889. 	end 
  890.  
  891. end 
  892.  
  893. Store_fight_triggered = false 
  894. function bh07_store_fight() 
  895. 	 
  896. 	if(Store_fight_triggered) then 
  897. 		return 
  898. 	else 
  899. 		Store_fight_triggered = true 
  900. 	end 
  901.  
  902. 	for i, npc in pairs(CHAR_ALL_STORE) do 
  903. 		thread_kill(THREAD_STORE_MAYHEM[i]) 
  904. 		on_damage("", npc, 0.8) 
  905. 		set_attack_player_flag(npc, true) 
  906. 		set_ignore_ai_flag(npc, false) 
  907. 		local dist, closest_player = get_dist_closest_player_to_object(npc) 
  908. 		attack(npc, closest_player) 
  909. 	end 
  910.  
  911. 	if IN_COOP then 
  912. 		for i, npc in pairs(CHAR_STORE_COOP) do 
  913. 			on_damage("", npc, 0.8) 
  914. 			set_attack_player_flag(npc, true) 
  915. 			set_ignore_ai_flag(npc, false) 
  916. 			local dist, closest_player = get_dist_closest_player_to_object(npc) 
  917. 			attack(npc, closest_player) 
  918. 		end 
  919. 	end 
  920. end 
  921.  
  922. function bh07_store_mayhem(npc) 
  923. 	set_attack_player_flag(npc, false) 
  924. 	set_ignore_ai_flag(npc, true) 
  925. 	npc_unholster_best_weapon(npc) 
  926. 	local path_choice = 0 
  927. 	local speak_delay = rand_int(4,10) 
  928. 	while(1) do 
  929. 		thread_yield() 
  930. 		local maybe_drink = rand_int(1, 6) 
  931. 		if maybe_drink == 1 then 
  932. 			npc_do_drugs(npc, "40oz") 
  933. 			delay(4) 
  934. 			speak_delay = speak_delay - 4 
  935. 		else 
  936. 			repeat  
  937. 				path_choice = rand_int(1, NUM_STORE_NAVS) 
  938. 			until not bh07_store_mayhem_choice_being_used(path_choice) 
  939. 			Store_mayhem_choice[npc] = path_choice 
  940. 			for i, nav in pairs(NAV_STORE[path_choice]) do 
  941. 				thread_yield() 
  942. 				move_to(npc, nav, 2, true, false) 
  943. 				turn_to(npc, nav, true) 
  944. 				if(speak_delay <= 0) then 
  945. 					audio_play_persona_line(npc, POT_SITUATIONS[POT_CUSTOM_1][1]) 
  946. 					speak_delay = rand_int(6,9) 
  947. 				end 
  948. 				force_melee(npc, 2) 
  949. 				delay(1) 
  950. 				if not character_is_dead(CHAR_LT_STORE) then 
  951. 					Store_total_damage = Store_total_damage + STORE_DAMAGE_AMOUNT 
  952. 				end 
  953. 				speak_delay = speak_delay - 2 
  954. 			end 
  955. 		end 
  956. 	end 
  957. end 
  958.  
  959. function bh07_store_mayhem_choice_being_used(choice) 
  960. 	for i, used_choice in pairs(Store_mayhem_choice) do 
  961. 		if used_choice == choice then 
  962. 			return true 
  963. 		end 
  964. 	end 
  965. 	return false 
  966. end 
  967.  
  968. function bh07_shop_owner() 
  969. 	--on_death("bh07_failure_shop_owner_died", CHAR_CLERK_STORE) 
  970.  
  971. 	local shop_owner_initial_health = get_current_hit_points(CHAR_CLERK_STORE) 
  972. 	local increased_health = shop_owner_initial_health * 3 
  973. 	set_max_hit_points(CHAR_CLERK_STORE, increased_health) 
  974. 	set_current_hit_points(CHAR_CLERK_STORE, increased_health) 
  975.  
  976. 	delay(3) 
  977. 	mission_help_table(TEXT_SAVE_SHOP_OWNER) 
  978. 	--damage_indicator_on(0, CHAR_CLERK_STORE, 0, TEXT_SHOP_OWNER_HEALTH) 
  979.  
  980. 	for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  981. 		inv_item_remove_all(npc) 
  982. 		set_attack_player_flag(npc, false) 
  983. 		npc_weapon_pickup_override(npc, false) 
  984. 		character_set_cannot_wield_havok_weapon(npc, true) 
  985. 		attack(npc, CHAR_CLERK_STORE) 
  986. 	end 
  987. 	set_attack_player_flag(CHAR_CLERK_STORE, false) 
  988.  
  989. 	local attacking_player = false 
  990. 	local unattacked_time = 0 
  991. 	local hit_points = {} 
  992. 	for j, lnpc in pairs(CHAR_CLERKBEATERS_STORE) do 
  993. 		hit_points[j] = get_current_hit_points(lnpc) 
  994. 	end 
  995.  
  996. 	while bh07_shop_owner_in_danger() do 
  997. 		thread_yield() 
  998.  
  999. 		if not attacking_player then 
  1000.  
  1001. 			bh07_shop_owner_attack_owner() 
  1002. 			for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1003. 				if not character_is_dead(npc) and (get_current_hit_points(npc) - hit_points[i]) < -50 then 
  1004. 					attacking_player = true 
  1005. 					bh07_shop_owner_attack_player() 
  1006. 					for j, lnpc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1007. 						hit_points[j] = get_current_hit_points(lnpc) 
  1008. 					end 
  1009. 					break 
  1010. 				end 
  1011. 			end 
  1012.  
  1013. 		else 
  1014.  
  1015. 			local unattacked = true 
  1016. 			for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1017. 				if (get_current_hit_points(npc) - hit_points[i]) < -50 then 
  1018. 					unattacked_time = 0 
  1019. 					unattacked = false 
  1020. 					for j, lnpc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1021. 						hit_points[j] = get_current_hit_points(lnpc) 
  1022. 					end 
  1023. 					break 
  1024. 				end 
  1025. 			end 
  1026.  
  1027. 			if unattacked then 
  1028. 				unattacked_time = unattacked_time + get_frame_time() 
  1029. 			end 
  1030.  
  1031. 			if unattacked_time >= 15 then 
  1032. 				bh07_shop_owner_attack_owner() 
  1033. 				attacking_player = false 
  1034. 				for j, lnpc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1035. 					hit_points[j] = get_current_hit_points(lnpc) 
  1036. 				end 
  1037. 			end 
  1038. 		end 
  1039. 	end 
  1040. 	--damage_indicator_off(0) 
  1041. end 
  1042.  
  1043. function bh07_shop_owner_in_danger() 
  1044. 	for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1045. 		if not character_is_dead(npc) then 
  1046. 			return true 
  1047. 		end 
  1048. 	end 
  1049. 	return false 
  1050. end 
  1051.  
  1052. function bh07_shop_owner_attack_player() 
  1053. 	for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1054. 		set_attack_player_flag(npc, true) 
  1055. 		local dist, closest_player = get_dist_closest_player_to_object(npc) 
  1056. 		attack(npc, closest_player) 
  1057. 	end 
  1058. end 
  1059.  
  1060. function bh07_shop_owner_attack_owner() 
  1061. 	for i, npc in pairs(CHAR_CLERKBEATERS_STORE) do 
  1062. 		set_attack_player_flag(npc, false) 
  1063. 		attack(npc, CHAR_CLERK_STORE) 
  1064. 	end 
  1065. end 
  1066.  
  1067. function bh07_the_coordinator() 
  1068. 	marker_add_navpoint(NAV_OBJ_COORD, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1069. 	bh07_wait_to_spawn_objective(NAV_OBJ_COORD, COORD_SPAWN_RADIUS) 
  1070.  
  1071. 	group_create(GROUP_COORDINATOR, true) 
  1072. 	if IN_COOP then 
  1073. 		group_create(GROUP_COORDINATOR_COOP, true) 
  1074. 	end 
  1075.  
  1076. 	marker_add_npc(CHAR_LT_COORD, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  1077. 	marker_remove_navpoint(NAV_OBJ_COORD, SYNC_ALL) 
  1078. 	on_death("bh07_lieutenant_killed", CHAR_LT_COORD) 
  1079. 	thread_yield() 
  1080.  
  1081. 	for i, npc in pairs(CHAR_ALL_COORD) do 
  1082. 		on_damage("bh07_coord_flee", npc, 0.90) 
  1083. 	end 
  1084.  
  1085. 	if IN_COOP then 
  1086. 		for i, npc in pairs(CHAR_ALL_COORD_COOP) do 
  1087. 			on_damage("bh07_coord_flee", npc, 0.90) 
  1088. 		end 
  1089. 	end 
  1090.  
  1091. 	mission_help_table(TEXT_MEETING_LT) 
  1092.  
  1093. 	while not character_is_dead(CHAR_LT_COORD) do 
  1094. 		thread_yield() 
  1095. 	end 
  1096.  
  1097. 	Bh07_checkpoint_coordinator_complete = true 
  1098. 	if bh07_more_objectives_remain() then 
  1099. 		mission_set_checkpoint(CHECKPOINT_COORDINATOR) 
  1100. 		if (Lieutenants_killed == INITIAL_NUM_LIEUTENANTS - 1) then 
  1101. 			mission_help_table(TEXT_REMAINING_LT) 
  1102. 		else 
  1103. 			mission_help_table(TEXT_KILL_REMAINING_LTS) 
  1104. 		end 
  1105. 	end 
  1106.  
  1107. 	marker_remove_npc(CHAR_LT_COORD, SYNC_ALL) 
  1108. end 
  1109.  
  1110. function bh07_coord_flee() 
  1111. 	for i, npc in pairs(CHAR_ALL_COORD) do 
  1112. 		on_damage("", npc, 0.90) 
  1113. 	end 
  1114.  
  1115. 	if IN_COOP then 
  1116. 		for i, npc in pairs(CHAR_ALL_COORD_COOP) do 
  1117. 			on_damage("", npc, 0.90) 
  1118. 		end 
  1119. 	end 
  1120.  
  1121. 	set_ignore_ai_flag(CHAR_LT_COORD, true) 
  1122. 	vehicle_enter(CHAR_LT_COORD, VEH_COORD) 
  1123. 	vehicle_disable_chase(VEH_COORD, true) 
  1124. 	while not character_is_in_vehicle(CHAR_LT_COORD, VEH_COORD) do 
  1125. 		thread_yield() 
  1126. 	end 
  1127.  
  1128. 	mission_help_table(TEXT_KILL_FLEEING_LT) 
  1129.  
  1130. 	set_unjackable_flag(VEH_COORD, true) 
  1131. 	vehicle_suppress_npc_exit(VEH_COORD, true) 
  1132. 	vehicle_set_crazy(VEH_COORD, true) 
  1133. 	on_vehicle_destroyed("bh07_kill_flee_thread", VEH_COORD) 
  1134. 	THREAD_COORD_FLEE = thread_new("bh07_coord_vehicle_flee") 
  1135. end 
  1136.  
  1137. function bh07_coord_vehicle_flee() 
  1138. 	vehicle_speed_override(VEH_COORD, 50) 
  1139. 	vehicle_pathfind_to(VEH_COORD, NAV_COORD_FLEE_PATH, true, false, false) 
  1140. 	delay(4) 
  1141. 	vehicle_pathfind_to(VEH_COORD, NAV_COORD_FLEE_GROUND, true, false, false) 
  1142. 	local dist, closest_player = get_dist_closest_player_to_object(VEH_COORD) 
  1143. 	vehicle_flee(VEH_COORD, closest_player) 
  1144. end 
  1145.  
  1146. function bh07_kill_flee_thread() 
  1147. 	if THREAD_COORD_FLEE ~= -1 then 
  1148. 		thread_kill(THREAD_COORD_FLEE) 
  1149. 	end 
  1150. end 
  1151.  
  1152. function bh07_more_objectives_remain() 
  1153. 	return not (Bh07_checkpoint_firebombers_complete and Bh07_checkpoint_swat_complete and	Bh07_checkpoint_store_complete and Bh07_checkpoint_coordinator_complete) 
  1154. end 
  1155.  
  1156. function bh07_lieutenant_killed() 
  1157. 	Lieutenants_killed = Lieutenants_killed + 1 
  1158. 	bh07_show_lieutenant_counter() 
  1159. 	if(Lieutenants_killed < INITIAL_NUM_LIEUTENANTS) then 
  1160. 		bh07_raise_notoriety() 
  1161. 	else 
  1162. 		delay(3) 
  1163. 		bh07_success_all_lieutenants_killed() 
  1164. 	end 
  1165. end 
  1166.  
  1167. function bh07_raise_notoriety() 
  1168. 	notoriety_set_max("Brotherhood", min(Lieutenants_killed + 1, 3)) 
  1169. 	notoriety_set("Brotherhood", min(Lieutenants_killed + 1, 3)) 
  1170. 	notoriety_set_min("Brotherhood", min(Lieutenants_killed + 1, 3)) 
  1171. end 
  1172.  
  1173. function bh07_notoriety() 
  1174. 	local phase_time = 0 
  1175. 	while(1) do 
  1176. 		thread_yield() 
  1177. 		phase_time = 0 
  1178. 		while (true) do 
  1179. 			thread_yield() 
  1180. 			local current_notoriety = notoriety_get_decimal("Brotherhood") 
  1181. 			local target_notoriety = Lieutenants_killed + 1.0 
  1182. 			phase_time = phase_time + get_frame_time() 
  1183. 			local pct = phase_time / 30 
  1184. 			local new_notoriety = pct * target_notoriety 
  1185. 			if new_notoriety > target_notoriety then 
  1186. 				new_notoriety = target_notoriety 
  1187. 			end 
  1188. 			if (new_notoriety > current_notoriety) then 
  1189. 				notoriety_set_min("Brotherhood", new_notoriety) 
  1190. 				notoriety_set("Brotherhood", new_notoriety) 
  1191. 			end 
  1192. 		end 
  1193. 	end 
  1194. end 
  1195.  
  1196. function bh07_success_all_lieutenants_killed() 
  1197. 	delay(3) 
  1198. 	mission_end_success("bh07", "br07-02") 
  1199. end 
  1200.  
  1201. function bh07_failure_shop_owner_died() 
  1202. 	mission_end_failure("bh07", TEXT_SHOP_OWNER_DIED) 
  1203. end 
  1204.  
  1205. function bh07_failure_store_damage() 
  1206. 	mission_end_failure("bh07", TEXT_TOO_MUCH_DAMAGE) 
  1207. end 
  1208.  
  1209. function bh07_cleanup() 
  1210.  
  1211. 	if ( vehicle_exists(VEH_FIREBOMBER) and not vehicle_is_destroyed(VEH_FIREBOMBER) ) then 
  1212. 		vehicle_prevent_explosion_fling(VEH_FIREBOMBER, false) 
  1213. 		vehicle_infinite_mass(VEH_FIREBOMBER, false) 
  1214. 			 
  1215. 	end 
  1216.  
  1217. 	-- Cleanup mission here 
  1218.  
  1219. 	marker_remove_navpoint(NAV_OBJ_FIREBOMBERS) 
  1220. 	marker_remove_navpoint(NAV_OBJ_PRISONERS) 
  1221. 	marker_remove_navpoint(NAV_OBJ_STORE) 
  1222. 	marker_remove_navpoint(NAV_OBJ_COORD) 
  1223. 	 
  1224. 	for i,trigger in pairs (TRIGGER_STORE_ENTRANCES) do 
  1225. 		on_trigger("", trigger) 
  1226. 		trigger_enable(trigger, false) 
  1227. 	end 
  1228.  
  1229. 	for i, thread in pairs(ALL_THREADS) do 
  1230. 		if thread ~= -1 then 
  1231. 			thread_kill(thread) 
  1232. 		end 
  1233. 	end 
  1234.  
  1235. 	objective_text_clear(1) 
  1236. 	damage_indicator_off(0) 
  1237.  
  1238. 	mission_waypoint_remove(SYNC_ALL) 
  1239.  
  1240. 	trigger_type_enable("liquor store", true) 
  1241.  
  1242. 	bh07_stop_persona_overrides() 
  1243.  
  1244. end 
  1245.  
  1246. function bh07_success() 
  1247. 	-- Called when the mission has ended with success 
  1248. --	bink_play_movie(CUTSCENE_OUT) 
  1249. end 
  1250.