./m04.lua

  1.  
  2. --[[ 
  3. 	m04.lua 
  4. 	SR3 Mission Script 
  5. 	DATE: 08/04/2010 
  6. 	AUTHOR:	Anne Chilldon 
  7. ]]-- 
  8.  
  9.  
  10. -- Debug flags -- 
  11.  
  12. -- Tweakable Parameters -- 
  13. 	--delay between calling the M04_Attack situation 
  14. 	M04_Attack_Line_Time = 5.0 
  15. 	 
  16. 	M04_mechanic_cash = 50	-- enough to buy a paint job 
  17. 	M04_clothes_cash = 50	-- enough to buy a hat 
  18. 	 
  19. -- Groups -- 
  20.  
  21. 	M04_group = { 
  22. 		--[[ = { 
  23. 			name = "name from editor", 
  24. 			members = { "optional", "list", "of", "members" }, 
  25. 		}, 
  26. 		 
  27. 		 = { 
  28. 			name = "next group name" 
  29. 		},]] 
  30. 		homies_001 = { 
  31. 			name = "Homies_grp", 
  32. 			members = { "Pierce" } 
  33. 		}, 
  34. 		goons_001 = { 
  35. 			name = "Morningstar_goons", 
  36. 			members = { "Morningstar_goon_001", "Morningstar_goon_002", "Morningstar_goon_003"} 
  37. 		}, 
  38. 		brute_001 = { 
  39. 			name = "Morningstar_brute", 
  40. 			vehicle = "Brute_Vehicle 001", 
  41. 			members = { "Morningstar Brute" } 
  42. 		}, 
  43. 		brute_002 = { 
  44. 			name = "Brute_Driver_Group", 
  45. 			members = { "Brute_Driver 001" } 
  46. 		}, 
  47. 		starting_vehicle = { 
  48. 			name = "Starting_Vehicles", 
  49. 			vehicle = "Helper_Vehicle 001" 
  50. 		}, 
  51. 		backup_vehicle = { 
  52. 			name = "Backup_Vehicles", 
  53. 			vehicle = "Helper_Vehicle 002" 
  54. 		}, 
  55. 		roadblock_001 = { 
  56. 			name = "RoadBlock 001", 
  57. 			vehicles = { "RoadBlock1_Vehicle 001", "RoadBlock1_Vehicle 002", }, 
  58. 						--"RoadBlock1_Vehicle 003" 
  59. 			members = { "RoadBlock1_NPC 002", "RoadBlock1_NPC 004", "RoadBlock1_NPC 005"} 
  60. 		}, 
  61. 		roadblock_002 = { 
  62. 			name = "RoadBlock 002", 
  63. 			vehicles = { "RoadBlock2_Vehicle 001", "RoadBlock2_Vehicle 002", }, 
  64. 					--	"RoadBlock2_Vehicle 003" 
  65. 			members = { "RoadBlock2_NPC 002", "RoadBlock2_NPC 004", "RoadBlock2_NPC 005"} 
  66. 		}, 
  67. 		notoriety_001 = { 
  68. 			name = "grp_Notoriety1", 
  69. 			vehicle = "veh_Notoriety_Vehicle 001", 
  70. 			members = { "npc_Notoriety1 001", "npc_Notoriety1 002" } 
  71. 		}, 
  72. 		notoriety_002 = { 
  73. 			name = "grp_Notoriety2", 
  74. 			vehicle = "veh_Notoriety_Vehicle 002", 
  75. 			members = { "npc_Notoriety2 001", "npc_Notoriety2 002" } 
  76. 		}, 
  77. 		notoriety_003 = { 
  78. 			name = "grp_Notoriety3", 
  79. 			vehicle = "veh_Notoriety_Vehicle 003", 
  80. 			members = { "npc_Notoriety3 001", "npc_Notoriety3 002" } 
  81. 		}, 
  82. 		notoriety_004 = { 
  83. 			name = "grp_Notoriety4", 
  84. 			vehicle = "veh_Notoriety_Vehicle 004", 
  85. 			members = { "npc_Notoriety4 001", "npc_Notoriety4 002" } 
  86. 		}, 
  87. 		CTE_01 =  { 
  88. 			name = "CTE_Pierce_car_01", 
  89. 			vehicle = "CTE_Vehicle 001" 
  90. 		} 
  91. 	} 
  92.  
  93. -- Navpoints -- 
  94. 	RETAIL_MARK = { "Goon_Navpoint 001", "Goon_Navpoint 002", "Goon_Navpoint 003" } 
  95. 	M04_P_TELEPORT_2 = { "Pierce_Teleport_2" } 
  96. 	M04_P_TELEPORT_3 = { "Pierce_Teleport_3" } 
  97. 	M04_P_TELEPORT_4 = { "Pierce_Teleport_4" } 
  98. 	M04_P_STORE = { "Pierce_store_nav" } 
  99. 	M04_PLAYER_START = { "m04_local_player_start" } 
  100. 	M04_COOP_START = { "m04_remote_player_start" } 
  101. 	M04_PLAYER_CHECKPOINT_2 = { "m04_local_checkpoint_2" } 
  102. 	M04_COOP_CHECKPOINT_2 = { "m04_remote_checkpoint_2" } 
  103. 	M04_PLAYER_CHECKPOINT_3 = { "m04_local_checkpoint_3" } 
  104. 	M04_COOP_CHECKPOINT_3 = { "m04_remote_checkpoint_3" } 
  105. 	M04_PLAYER_CHECKPOINT_4 = { "m04_local_checkpoint_4" } 
  106. 	M04_COOP_CHECKPOINT_4 = { "m04_remote_checkpoint_4" } 
  107. 	M04_PLAYER_STORE = { "m04_local_store_nav" } 
  108. 	M04_COOP_STORE = { "m04_remote_store_nav" } 
  109. 	M04_VEHICLE_CHECKPOINT_2 = { "m04_vehicle_checkpoint_2" } 
  110. 	M04_VEHICLE_CHECKPOINT_3 = { "m04_vehicle_checkpoint_3" } 
  111. 	 
  112. -- Paths -- 
  113. 	Brute_Path = "Brute_path" 
  114. 	 
  115. -- Triggers -- 
  116. 	-- Mechanic Trigger 
  117. 	MECHANIC_TRIGGER = "Mechanic_Trigger 001" 
  118. 	MECHANIC_TRIGGER2 = "Mechanic_Trigger 002" 
  119. 	-- Clothing Trigger 
  120. 	CLOTHES_TRIGGER = "Clothes_Trigger 001" 
  121. 	CLOTHES_TRIGGER2 = "Clothes_Trigger 002" 
  122. 	-- Safehouse Trigger 
  123. 	SAFEHOUSE_TRIGGER = "Safehouse_Trigger 001" 
  124. 	SAFEHOUSE_TRIGGER2 = "Safehouse_Trigger 002" 
  125. 	-- Notoriety Trigger 
  126. 	NOTORIETY_TRIGGER = "Notoriety_Trigger 001" 
  127. 	-- Traffic Trigger 
  128. 	TRAFFIC_TRIGGER = "trig_Traffic" 
  129. -- Characters -- 
  130.  
  131. -- Vehicles -- 
  132.  
  133. -- Mesh Movers -- 
  134.  
  135. -- Text -- 
  136. 	-- Help Text/Objective -- 
  137. 		-- Get in a car -- 
  138. 		M04_OBJ_GET_CAR = "m04_obj_get_car" 
  139. 		-- Drive to RimJobs -- 
  140. 		M04_OBJ_DRIVE_MECHANIC = "m04_obj_drive_mechanic" 
  141. 		-- Use the mechanic -- 
  142. 		M04_OBJ_USE_MECHANIC = "m04_obj_use_mechanic" 
  143. 		-- Drive to Planet Saints -- 
  144. 		M04_OBJ_DRIVE_PLANET_SAINTS = "m04_obj_drive_planet_saints" 
  145. 		-- Purchase clothing -- 
  146. 		M04_OBJ_BUY_CLOTHES = "m04_obj_buy_clothes" 
  147. 		-- Kill Goons -- 
  148. 		M04_OBJ_KILL_GOONS = "m04_obj_kill_goons" 
  149. 		-- Kill the Brute -- 
  150. 		M04_OBJ_KILL_BRUTE = "m04_obj_kill_brute" 
  151. 		-- Return to the safehouse to remove the notoriety -- 
  152. 		M04_OBJ_RETURN_HOME = "m04_obj_return_home" 
  153. 	-- Tutorial -- 
  154. 		-- Mechanics ar used to repair and upgrade vehicles -- 
  155. 		-- Clothing shops allow you to purchase clothing for your character.  You may always swap out clothing you have purchased at your crib or in the store -- 
  156. 		-- Whenever you have notoriety, it will reduce slowly over time or can be reduced immediately by visiting any building you own -- 
  157. 	-- Dialog -- 
  158. 		-- Pierce -- 
  159. 			-- We need to find a place we can use yto upgrade our rides.  We should take it to RimJobs to get it cleaned up 
  160. 			-- That place will work.  Now that we're rollin' in style, we'll need to dress the part.  Let's go to Planet Saints and get some fresh threads 
  161. 			-- Now we're stylin' 
  162. 			-- What the fuck is that thing 
  163. 			-- Amazing line, I'll call you when I have more info on those Morningstar 
  164. 		-- Player -- 
  165. 			-- It looks angry 
  166. 	-- Failure Text -- 
  167. 		-- Pierce Dies -- 
  168. 		M04_FAILURE_PIERCE_DIED = "m04_failure_pierce_died" 
  169. 		-- Pierce is abandoned -- 
  170. 		M04_FAILURE_ABANDON_PIERCE = "m04_failure_abandon_pierce" 
  171. 		-- Car destroyed -- 
  172. 		M04_FAILURE_CAR_DESTROYED = "m04_failure_car_destroyed" 
  173.  
  174. -- Threads -- 
  175. 	M04_thread_convo = INVALID_THREAD_HANDLE 
  176. 	M04_thread_attack_line_timer = INVALID_THREAD_HANDLE 
  177. -- Checkpoints -- 
  178. 	M04_CHECKPOINT_START = MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  179. 	M04_CHECKPOINT_CLOTHES_TUTORIAL = "m04_checkpoint_clothes_tutorial" 
  180. 	M04_CHECKPOINT_BRUTE_FIGHT = "m04_checkpoint_brute_fight" 
  181. 	M04_CHECKPOINT_NOTORIETY_REDUCTION = "m04_checkpoint_notoriety_reduction" 
  182. 	 
  183. -- Cutscenes -- 
  184. 	M04_CUTSCENE_MISSION_INTRO 	= "" 
  185. 	M04_CUTSCENE_CTE_INTRO		= "m04_cte_01" 
  186. 	M04_CUTSCENE_MISSION_OUTRO 	= "" 
  187.  
  188. -- Conversations -- 
  189. 	M04_convo = { 
  190. 		mission_start = { 
  191. 			name = "m04_mission_start", 
  192. 			handle = INVALID_CONVERSATION_HANDLE, 
  193. 		}, 
  194. 		drive_to_rj = { 
  195. 			name = "M04_Drive_To_RJ", 
  196. 			handle = INVALID_CONVERSATION_HANDLE, 
  197. 		}, 
  198. 		go_to_ps = { 
  199. 			name = "M04_Go_To_PS", 
  200. 			handle = INVALID_CONVERSATION_HANDLE, 
  201. 		}, 
  202. 		drive_to_ps = { 
  203. 			name = "M04_Drive_To_PS", 
  204. 			handle = INVALID_CONVERSATION_HANDLE, 
  205. 		}, 
  206. 		sing_intro = { 
  207. 			name = "M04_Sing_A_Long_Intro", 
  208. 			handle = INVALID_CONVERSATION_HANDLE, 
  209. 		}, 
  210. 		exit_ps = { 
  211. 			name = "M04_Exit_PS", 
  212. 			handle = INVALID_CONVERSATION_HANDLE, 
  213. 		}, 
  214. 		brute_combat = { 
  215. 			name = "M04_Brute_Combat", 
  216. 			handle = INVALID_CONVERSATION_HANDLE, 
  217. 		}, 
  218. 		escape = { 
  219. 			name = "M04_Escape", 
  220. 			handle = INVALID_CONVERSATION_HANDLE, 
  221. 		}, 
  222. 		wtf = { 
  223. 			name = "M04_What_Was_That_Guy", 
  224. 			handle = INVALID_CONVERSATION_HANDLE, 
  225. 		}, 
  226. 	} 
  227. 		 
  228. -- Other -- 
  229. -- Global Variables -- 
  230. 	In_coop = false 
  231. 	Player_car = "" 
  232. 	convo_1 = false 
  233. 	convo_2 = false 
  234. 	sing_along = false 
  235. 	Num_guys_to_kill = 0 
  236. 	convo_is_playing = false 
  237. 	 
  238. 	M04_given_mechanic_cash = false 
  239. 	M04_given_clothes_cash = false 
  240. 	 
  241. -- Trigger Flags -- 
  242. 	Driving_to_mechanic = false 
  243. 	Using_mechanic = false 
  244. 	Mechanic_breadcrumb_Reached = false 
  245. 	Mechanic_Reached = false 
  246. 	Mechanic_Purchase_Done = false 
  247. 	Mechanic_Tutorial_Done = false 
  248. 	Clothes_Store_Reached = false 
  249. 	Clothes_Purchase_Done = false 
  250. 	Clothes_Tutorial_Done = false 
  251. 	Safehouse_Reached = false 
  252. 	Notoriety_Reached = false 
  253. -- ************************* 
  254. -- 
  255. -- Standard functions 
  256. -- 
  257. -- ************************* 
  258.  
  259. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  260. -- at the specified checkpoint. 
  261. -- CALLED FROM CODE 
  262. -- 
  263. -- m04_checkpoint:	The checkpoint the mission should begin at 
  264. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  265. -- 
  266. function m04_start(m04_checkpoint, is_restart) 
  267. 	--m04_checkpoint = M04_CHECKPOINT_BRUTE_FIGHT 
  268. 	-- Check if this mission starting from the beginning 
  269. 	if (m04_checkpoint == M04_CHECKPOINT_START) then 
  270. 		if (is_restart == false) then 
  271. 			-- First time playing mission 
  272. 			local fade_in_after = false 
  273. 			local cte_navs = { "m04_local_player_start", "m04_remote_player_start" } 
  274. 			-- Play CTE before any code happens 
  275. 			group_create( M04_group.CTE_01.name, true ) 
  276. 			vehicle_ignore_repulsors(M04_group.CTE_01.vehicle, true) 
  277. 			cutscene_play( M04_CUTSCENE_CTE_INTRO, nil, cte_navs, fade_in_after ) 
  278. 			group_destroy( M04_group.CTE_01.name ) 
  279. 		else 
  280. 			--Teleport the players 
  281. 			teleport_coop(M04_PLAYER_START[1], M04_COOP_START[1], true) 
  282. 		end 
  283. 		fade_out(0) 
  284. 	end 
  285.  
  286. 	-- Handle mission initialization for the current checkpoint 
  287. 	m04_initialize(m04_checkpoint) 
  288.  
  289. 	-- Run the mission from the current checkpoint 
  290. 	m04_run(m04_checkpoint) 
  291. 	 
  292. end 
  293.  
  294. -- This is the primary function responsible for running the entire mission from start to finish. 
  295. -- 
  296. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  297. -- 
  298. function m04_run(first_checkpoint) 
  299. 	local current_checkpoint = first_checkpoint 
  300. 	--M04_convo.mission_start.handle = audio_conversation_load(M04_convo.mission_start.name) 
  301. 	--local current_checkpoint = M04_CHECKPOINT_BRUTE_FIGHT 
  302. 	--Player_car = M04_group.starting_vehicle.vehicle 
  303. 	-- Run the mission from the beginning 
  304. 	if current_checkpoint == M04_CHECKPOINT_START then	 
  305. 		-- Checkpoint 1 - Mechanic Tutorial 
  306. 	 
  307. 		M04_given_mechanic_cash = false 
  308.  
  309. 		-- Pierce talks 
  310. 		delay(1.0) 
  311. 		audio_play_persona_line(M04_group.homies_001.members[1], "M04_Mission_Start_01") 
  312. 	 
  313. 		m04_get_into_car()		 
  314. 		 
  315. 		Mechanic_Tutorial_Done = false 
  316. 		while not Mechanic_Tutorial_Done do 
  317. 			if not (character_is_in_vehicle(LOCAL_PLAYER) or character_is_in_vehicle(REMOTE_PLAYER)) and not Mechanic_Reached then 
  318. 				-- don't do anything until the player is in a car 
  319. 				m04_get_into_car() 
  320. 			else 
  321. 				-- If we are not at the mechanic, tell the player to go there 
  322. 				m04_go_to_mechanic() 
  323. 				if Mechanic_Reached then 
  324. 					-- if other conditions are true, tell player to use the mechanic 
  325. 					m04_use_mechanic() 
  326. 				end 
  327. 			end 
  328. 		end 
  329. 		 
  330. --[[ 
  331. 		if (character_is_in_vehicle(LOCAL_PLAYER)) then 
  332. 			m04_go_to_mechanic() 
  333. 			m04_use_mechanic() 
  334. 		else 
  335. 			m04_get_into_car() 
  336. 		end 
  337. ]]-- 
  338. 		-- Set to checkpoint 2 
  339. 		current_checkpoint = M04_CHECKPOINT_CLOTHES_TUTORIAL 
  340. 		mission_set_checkpoint(M04_CHECKPOINT_CLOTHES_TUTORIAL, false) 
  341. 	 
  342. 	end 
  343. 	 
  344. 	if current_checkpoint == M04_CHECKPOINT_CLOTHES_TUTORIAL then 
  345. 	--	M04_convo.go_to_ps.handle = audio_conversation_load(M04_convo.go_to_ps.name) 
  346. 		--Checkpoint 2 - Clothes Tutorial 
  347. 		--TODO: Replace this with real audio 
  348. 	--	delay(4.0) 
  349. 	--	message("Pierce: That place will work.", 4.0) 
  350. 	--	message("Pierce: Now that we're rolling in style, we'll need to dress the part.", 4.0) 
  351. 	--	message("Pierce: Let's go to Planet Saints and get some fresh threads.", 4.0) 
  352. 	--	audio_conversation_play(M04_convo.go_to_ps.handle) 
  353. 		 
  354. 	--	audio_conversation_wait_for_end(M04_convo.go_to_ps.handle) 
  355. 	--	M04_convo.go_to_ps.handle = INVALID_CONVERSATION_HANDLE 
  356. 		 
  357. 	--	m04_get_into_car() 
  358. 		m04_open_rj_door() 
  359. 		M04_given_clothes_cash = false 
  360. 		 
  361. 		m04_go_to_clothes_store() 
  362. 		m04_buy_clothes() 
  363.  
  364. 		-- Set to checkpoint 3 
  365. 		current_checkpoint = M04_CHECKPOINT_BRUTE_FIGHT 
  366. 		mission_set_checkpoint(M04_CHECKPOINT_BRUTE_FIGHT, true) 
  367. 	end 
  368. 	 
  369. 	if current_checkpoint == M04_CHECKPOINT_BRUTE_FIGHT then 
  370. 		-- Checkpoint 3 - Brute Fight 
  371. 		 
  372. 		m04_spawn_brute() 
  373. 		-- Setting this up as a thread to  
  374. 		thread_new("m04_force_notoriety") 
  375. 		 
  376. 		-- Set checkpoint 4 
  377. 		current_checkpoint = M04_CHECKPOINT_NOTORIETY_REDUCTION 
  378. 		mission_set_checkpoint(M04_CHECKPOINT_NOTORIETY_REDUCTION, true) 
  379. 	end 
  380. 	 
  381. 	if current_checkpoint == M04_CHECKPOINT_NOTORIETY_REDUCTION then 
  382. 		-- Checkpoint 4 - Notoriety Reduction 
  383. 		m04_return_to_safehouse() 
  384. 		 
  385. 	--	message("Pierce: Well that was fun!", 4.0) 
  386. 		--delay(4.0) 
  387. 	end 
  388. 	 
  389. 	 
  390. 	-- Call mission success?? 
  391. --	mission_end_success("m04", M04_CUTSCENE_MISSION_OUTRO) 
  392. 	mission_end_success("m04") 
  393. 	 
  394. end 
  395.  
  396. -- This is the primary function responsible for cleaning up the entire mission 
  397. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  398. -- 
  399. function m04_cleanup() 
  400. 	-- Kill conversation thread 
  401. 	thread_kill(M04_thread_convo) 
  402. 	 
  403. 	-- Cleanup groups 
  404. 	m04_cleanup_homies() 
  405. 	m04_cleanup_enemies() 
  406. 	 
  407. 	-- Cleanup triggers 
  408. 	m04_clear_trigger(MECHANIC_TRIGGER) 
  409. 	m04_clear_trigger(MECHANIC_TRIGGER2) 
  410. 	m04_clear_trigger(CLOTHES_TRIGGER) 
  411. 	m04_clear_trigger(SAFEHOUSE_TRIGGER) 
  412. 	m04_clear_trigger(NOTORIETY_TRIGGER) 
  413. 	 
  414. 	-- allow notoriety spawning again 
  415. 	notoriety_force_no_spawn("police", false)	 
  416. 	notoriety_force_no_spawn("morningstar", false) 
  417. 	notoriety_force_no_spawn("deckers", false) 
  418. 	 
  419. 	notoriety_set_can_decay(true) 
  420. 	notoriety_set("Morningstar", 0) 
  421. 	notoriety_set("deckers", 0) 
  422. 	notoriety_set("Police", 0) 
  423.  
  424. 	-- Make sure traffic splines are all turned back on 
  425. 	m04_traffic_on() 
  426. 	 
  427. 	on_vehicle_exit("", LOCAL_PLAYER)	 
  428. 	 
  429. 	cleanup_conversations(M04_convo) 
  430. 	 
  431. 	on_purchase( "" ) 
  432.  
  433. 	-- Cleanup singalong 
  434. 	radio_clear_sing_along_track("MIX_Sublime___What_I_Got") 
  435. 	radio_set_sing_along_allowed_during_missions(false) 
  436. 	vehicle_clear_all_radio_locks() 
  437.  
  438. --	tutorial_stop("notoriety_decreases") 
  439. end 
  440.  
  441. -- Called when the mission has ended with success 
  442. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  443. -- 
  444. function m04_success() 
  445. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  446. 	 
  447. end 
  448.  
  449.  
  450. -- ************************* 
  451. -- 
  452. -- Local functions 
  453. -- 
  454. -- ************************* 
  455.  
  456. -- Initialize the mission for the specified checkpoint 
  457. -- 
  458. -- checkpoint:		Checkpoint to initialize the mission to 
  459. -- 
  460. function m04_initialize(checkpoint) 
  461. 	-- Make sure the screen is completly faded out 
  462. 	mission_start_fade_out(0.0) 
  463.  
  464. 	-- Set the mission author 
  465. 	set_mission_author("Anne Chilldon") 
  466.  
  467. 	-- Common initialization 
  468. 	m04_initialize_common() 
  469.  
  470. 	notoriety_force_no_spawn("police", true) 
  471. 	notoriety_force_no_spawn("morningstar", true) 
  472. 	notoriety_force_no_spawn("deckers", true) 
  473. 	 
  474. 	-- Checkpoint specific initialization 
  475. 	m04_initialize_checkpoint(checkpoint)	 
  476. 	 
  477. 	-- Start fading in 
  478. 	 
  479. 	mission_start_fade_in() 
  480.  
  481. end 
  482.  
  483.  
  484. -- *************************************************** 
  485. -- m04_run Helper Functions 
  486. -- *************************************************** 
  487. -- Tell the player to get in a car and loop until he is in a vehicle 
  488. function m04_get_into_car() 
  489. 	-- Get into the car 
  490. 	-- Remove any waypoints and such 
  491. 	if (Mechanic_Tutorial_Done) then 
  492. 		m04_clear_trigger(CLOTHES_TRIGGER) 
  493. 	else 
  494. 		m04_clear_trigger(MECHANIC_TRIGGER) 
  495. 		m04_clear_trigger(MECHANIC_TRIGGER2) 
  496. 		Driving_to_mechanic = false 
  497. 		Using_mechanic = false 
  498. 	end 
  499. 	mission_waypoint_remove(SYNC_ALL) 
  500. 	-- Spawn car near them and mark on Minimap and in game 
  501. 	--marker_add(M04_group.starting_vehicle.vehicle, MINIMAP_ICON_USE, OI_ASSET_USE) 
  502. 	--ingame_effect_add_vehicle()? 
  503. 	-- Set objective to 'get into car' 
  504. 	objective_text(0, "m04_obj_get_car", "", "", SYNC_ALL, OI_ASSET_USE) 
  505. 	-- Make sure character is in vehicle 
  506. 	repeat  
  507. 		thread_yield()  
  508. 	until (character_is_in_vehicle(LOCAL_PLAYER) or character_is_in_vehicle(REMOTE_PLAYER)) 
  509. 	--marker_remove(M04_group.starting_vehicle.vehicle) 
  510. 	--marker_remove(Player_car) 
  511. 	--	Player_car = get_char_vehicle_name(LOCAL_PLAYER) 
  512. 	-- Set objective to 'drive to mechanic' 
  513. 	--objective_text_clear(0) 
  514. end 
  515.  
  516. -- If the player is not already at the mechanic, tell him to go to the mechanic 
  517. function m04_go_to_mechanic() 
  518.  
  519. 	if Mechanic_Reached then		 
  520. 		if(coop_is_active())then 
  521. 			-- We should be at the mechanic.  make sure 
  522. 			if (get_dist(LOCAL_PLAYER, MECHANIC_TRIGGER2) < 20 or get_dist(REMOTE_PLAYER, MECHANIC_TRIGGER) < 20) then 
  523. 				-- ok, we are still here 
  524. 				return 
  525. 			end 
  526. 		else 
  527. 			-- We should be at the mechanic.  make sure 
  528. 			if (get_dist(LOCAL_PLAYER, MECHANIC_TRIGGER2) < 20) then 
  529. 				-- ok, we are still here 
  530. 				return 
  531. 			end 
  532. 		end 
  533. 		-- Far enough away that we should be reminded to go back to the mechanic 
  534. 		Mechanic_Reached = false 
  535. 		Mechanic_breadcrumb_Reached = false 
  536. 	elseif Mechanic_breadcrumb_Reached then 
  537. 		if(coop_is_active())then 
  538. 			-- We should be close to the mechanic.  make sure 
  539. 			if (get_dist(LOCAL_PLAYER, MECHANIC_TRIGGER) < 15 or get_dist(REMOTE_PLAYER, MECHANIC_TRIGGER) < 15) then 
  540. 				-- ok, we are still here 
  541. 				thread_yield() 
  542. 				return 
  543. 			end 
  544. 		else 
  545. 			-- We should be close to the mechanic.  make sure 
  546. 			if (get_dist(LOCAL_PLAYER, MECHANIC_TRIGGER) < 15) then 
  547. 				-- ok, we are still here 
  548. 				thread_yield() 
  549. 				return 
  550. 			end 
  551. 		end 
  552. 		Mechanic_breadcrumb_Reached = false 
  553. 		m04_clear_trigger(MECHANIC_TRIGGER2) 
  554. 		Driving_to_mechanic = false 
  555. 	end 
  556.  
  557. 	if not Driving_to_mechanic then 
  558. 		objective_text(0, "m04_obj_find_mechanic", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  559. 		-- Set markers and GPS to rimjobs 
  560. 		m04_set_trigger(MECHANIC_TRIGGER, "m04_reached_mechanic") 
  561. 		mission_waypoint_add(MECHANIC_TRIGGER) 
  562. 		Driving_to_mechanic = true 
  563. 		Using_mechanic = false 
  564. 		 
  565. 		if not convo_1 then 
  566. 			M04_thread_convo = thread_new("m04_play_convo_1") 
  567. 		end 
  568.  
  569. 		-- Drive to Mechanic 
  570. 		tutorial_unlock("store_intro_mechanic", true) 
  571. 	end 
  572. 	thread_yield() 
  573. end 
  574.  
  575. function m04_mechanic_purchase_cb( store_type, player_name ) 
  576. 	if (store_type ~= "vehicle-cust") then 
  577. 		return 
  578. 	end 
  579.  
  580. 	on_purchase( "" ) 
  581. 	Mechanic_Purchase_Done = true 
  582. end 
  583.  
  584. function m04_use_mechanic() 
  585. 	-- Initialize store (mechanic store == 1) 
  586. 	if not Using_mechanic then 
  587. 		-- Set objective 'Use the mechanic to customize vehicle' 
  588. 		objective_text_clear(0) 
  589. 		objective_text(0, "m04_obj_use_mechanic", "", "", SYNC_ALL, OI_ASSET_USE) 
  590. 		Driving_to_mechanic = false 
  591. 		Using_mechanic = true 
  592. 		 
  593. 		on_purchase( "m04_mechanic_purchase_cb" ) 
  594. 	end 
  595. 	 
  596. 	-- Wait till the player has purchased something (mechanic == 1) 
  597. 	if not Mechanic_Purchase_Done then 
  598. 		thread_yield() 
  599. 		-- run our tests again 
  600. 		return 
  601. 	end 
  602. 		 
  603. 	-- Wait for player to get out of the interface before continuing 
  604. 	while (store_interface_is_active())do 
  605. 		thread_yield() 
  606. 	end 
  607. 	 
  608. 	Mechanic_Tutorial_Done = true 
  609.  
  610. end 
  611.  
  612. function m04_go_to_clothes_store() 
  613. 	M04_convo.go_to_ps.handle = audio_conversation_load(M04_convo.go_to_ps.name) 
  614. 	audio_conversation_play(M04_convo.go_to_ps.handle) 
  615. 		 
  616. 	-- Drive to Clothes Store 
  617. 	Clothes_Store_Reached = false 
  618. 	tutorial_unlock("store_intro_clothes", true) 
  619. 	-- Set objective to 'Drive to the Planet Saints store' 
  620. 	objective_text_clear(0) 
  621. 	objective_text(0, "m04_obj_find_clothes", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  622. 	-- Update minimap and GPS 
  623. 	m04_set_trigger(CLOTHES_TRIGGER, "m04_reached_clothes") 
  624. 	mission_waypoint_add("Planet_saints_gps") 
  625. 	 
  626. 	audio_conversation_wait_for_end(M04_convo.go_to_ps.handle) 
  627. 	M04_convo.go_to_ps.handle = INVALID_CONVERSATION_HANDLE 
  628. --	if not group_is_loaded(M04_group.backup_vehicle.name) then 
  629. --		group_create(M04_group.backup_vehicle.name, true) 
  630. --	end 
  631. 	--release_to_world(M04_group.backup_vehicle.vehicle ) 
  632. 	 
  633. 	 
  634. 	if not sing_along then 
  635. 		m04_play_sing_along() 
  636. 	end 
  637. 	 
  638. 	-- Check to see if player is at store 
  639. 	repeat  
  640. 		thread_yield()  
  641. 	until (Clothes_Store_Reached) 
  642. 		 
  643.    vehicle_clear_all_radio_locks() 
  644. end 
  645.  
  646. function m04_clothes_purchase_cb( store_type, player_name ) 
  647. 	if (store_type ~= "clothing") then 
  648. 		return 
  649. 	end 
  650. 		 
  651. 	on_purchase( "" ) 
  652. 	Clothes_Purchase_Done = true 
  653. 	Clothes_Tutorial_Done = true 
  654. end 
  655.  
  656. function m04_buy_clothes() 
  657. 	-- Buy Clothes 
  658. 	Clothes_Tutorial_Done = false 
  659. 	-- Set objective to 'Purchase a change of clothing.' 
  660. 	objective_text_clear(0) 
  661. 	objective_text(0, "m04_obj_buy_clothes", "", "", SYNC_ALL, OI_ASSET_USE) 
  662. 	-- Turn traffic splines in front of the store off 
  663. 	m04_traffic_off() 
  664.  
  665. 	-- HACK: Check to see if player has left clothing interface 
  666. 	--while not(store_interface_is_active())do 
  667. 	--	thread_yield() 
  668. 	--end 
  669. 	-- Reset notoriety 
  670. 	notoriety_reset("police")  
  671. 	notoriety_reset("Morningstar")  
  672. 	notoriety_reset("Deckers")  
  673. 	 
  674. 	 
  675. 	if not M04_given_clothes_cash then 
  676. 		cash_add(M04_clothes_cash) 
  677. 		if(coop_is_active())then 
  678. 			cash_add(M04_clothes_cash, REMOTE_PLAYER) 
  679. 		end 
  680. 		M04_given_clothes_cash = true 
  681. 	end 
  682. 	 
  683. 	on_purchase( "m04_clothes_purchase_cb" ) 
  684. 	 
  685. 	-- TODO: Clothing tutorial 
  686. 	-- TODO: Check to see if the player has purchased clothing 
  687. 	while not Clothes_Purchase_Done do 
  688. 		thread_yield() 
  689. 	end 
  690. 	-- TODO: Check to see if player has left clothing interface 
  691. 	--while (store_interface_is_active())do 
  692. 	--	thread_yield() 
  693. 	--end 
  694.  
  695. 	-- TODO: Remove this when the stores go in 
  696. 	--tutorial_start("store_intro_clothes", 2000, true, true) 
  697. 	--message("This is where the clothing tutorial is going to go", 5.0) 
  698. --	delay(6.0) 
  699. 	 
  700. 	repeat thread_yield() until (Clothes_Tutorial_Done) 
  701. 	--TODO: Replace this with real audio 
  702. 	-- Pierce - "Now we are styling" 
  703. 	--message("Pierce: Now we're styling", 4.0) 
  704. 	 
  705. 	-- TODO: Check to see if player has left clothing interface 
  706. 	while (store_interface_is_active())do 
  707. 		thread_yield() 
  708. 	end 
  709. 	-- Set up so that the Morningstar is visible 
  710. 	-- Possibly move brute toward player 
  711. 	m04_unhide_brute_section() 
  712. 	m04_open_ps_doors() 
  713. 	--Pierce is allowed to be stupid again 
  714. 	npc_leash_remove(M04_group.homies_001.members[1]) 
  715. end 
  716.  
  717. function m04_spawn_morningstar() 
  718. 	--Process Morningstar 
  719. 	--delay(4.0) 
  720. 	-- Spawn 3 Morningstar goons 
  721. 	--group_create(M04_group.goons_001.name, true) 
  722. 	if not (group_is_loaded(M04_group.roadblock_001.name))then 
  723. 		group_create_hidden(M04_group.roadblock_001.name, true) 
  724. 	end 
  725. 	if not(group_is_loaded(M04_group.roadblock_002.name))then 
  726. 		group_create_hidden(M04_group.roadblock_002.name, true) 
  727. 	end 
  728.  
  729. 	-- Deal with brute 
  730. 	-- Spawn Melee Brute 
  731. 	if not(group_is_loaded(M04_group.brute_001.name))then 
  732. 		group_create_hidden(M04_group.brute_001.name, true) 
  733. 	end 
  734. 	 
  735. 	if not(group_is_loaded(M04_group.brute_002.name))then 
  736. 		group_create_hidden(M04_group.brute_002.name, true) 
  737. 	end 
  738. 	 
  739. 	-- Set it so that the brute doesn't attack the player and Pierce 
  740. 	set_attack_player_flag(M04_group.brute_001.members[1], false) 
  741. 	set_attack_enemies_flag(M04_group.brute_001.members[1], false) 
  742. 	 
  743. 	--while not (character_is_in_vehicle(M04_group.brute_001.members[1], M04_group.brute_001.vehicle))do 
  744. 	--	thread_yield() 
  745. 	--end 
  746. 	 
  747.  
  748. 	for i, guard in pairs (M04_group.roadblock_001.members)do 
  749. 		npc_combat_enable(guard, false) 
  750. 	end 
  751. 	for i, guard in pairs (M04_group.roadblock_002.members)do 
  752. 		npc_combat_enable(guard, false) 
  753. 	end 
  754.  
  755. 	--TODO:  Move goons into store 
  756. --	for i, guard in pairs(M04_group.goons_001.members) do 
  757. --		ai_do_scripted_move(guard, RETAIL_MARK[i]) 
  758. --	end 
  759. 	-- Set objective  
  760. --	objective_text_clear(0)	 
  761. --	objective_text(0, "m04_obj_kill_goons", "", "", SYNC_ALL, OI_ASSET_KILL) 
  762. 	 
  763. 	-- Make sure the player kills all the goons 
  764. --	process_enemy_set(M04_group.goons_001.members) 
  765. end 
  766.  
  767. function m04_spawn_morningstar_no_brute() 
  768. 	--Process Morningstar 
  769. 	--delay(4.0) 
  770. 	-- Spawn 3 Morningstar goons 
  771. 	--group_create(M04_group.goons_001.name, true) 
  772. 	if not (group_is_loaded(M04_group.roadblock_001.name))then 
  773. 		group_create_hidden(M04_group.roadblock_001.name, true) 
  774. 	end 
  775. 	if not(group_is_loaded(M04_group.roadblock_002.name))then 
  776. 		group_create_hidden(M04_group.roadblock_002.name, true) 
  777. 	end 
  778.  
  779. end 
  780.  
  781. function m04_spawn_brute() 
  782.  
  783. 	-- Setup attack lines 
  784. 	for i, guard in pairs (M04_group.roadblock_001.members)do 
  785. 		on_attack_performed("m04_ms_attack_line_cb", guard) 
  786. 	end 
  787. 	for i, guard in pairs (M04_group.roadblock_002.members)do 
  788. 		on_attack_performed("m04_ms_attack_line_cb", guard) 
  789. 	end 
  790. 	 
  791. 	 
  792. 	--vehicle_chase(M04_group.brute_001.vehicle) 
  793. 	vehicle_pathfind_to(M04_group.brute_001.vehicle, Brute_Path, true) 
  794. 	 
  795. --	ai_do_scripted_move(M04_group.brute_001.members[1], RETAIL_MARK[1]) 
  796. 	-- Pierce - What the fuck is that thing? 
  797. 	-- Player - It looks angry 
  798. 	-- Set objective to 'Kill the Brute' 
  799. 	objective_text_clear(0) 
  800. 	objective_text(0, "m04_obj_kill_brute", "", "", SYNC_ALL, OI_ASSET_KILL) 
  801.  
  802. 	for i, guard in pairs (M04_group.roadblock_001.members)do 
  803. 		npc_combat_enable(guard, true) 
  804. 	end 
  805. 	for i, guard in pairs (M04_group.roadblock_002.members)do 
  806. 		npc_combat_enable(guard, true) 
  807. 	end 
  808.  
  809. 	-- Set it so that the brute attacks the player and Pierce 
  810. 	set_attack_player_flag(M04_group.brute_001.members[1], true) 
  811. 	set_attack_enemies_flag(M04_group.brute_001.members[1], true) 
  812. 	 
  813. 	-- Make sure the brute gets out of the truck 
  814. 	vehicle_exit(M04_group.brute_001.members[1], false) 
  815. 	vehicle_exit(M04_group.brute_002.members[1], false) 
  816. 	 
  817. 	-- Make sure the player kills the brute 
  818. 	--process_enemy_set(M04_group.brute_001.members) 
  819. 	thread_new("m04_convo", M04_convo.exit_ps, 0.0) 
  820. 	must_kill_setup(M04_group.brute_001.members) 
  821. 	 
  822.  
  823. end 
  824.  
  825. function m04_force_notoriety() 
  826. 	M04_convo.escape.handle = audio_conversation_load(M04_convo.escape.name) 
  827. 	--Force notoriety 
  828. 	Notoriety_Reached = false 
  829. 	if (group_is_loaded(M04_group.roadblock_001.name))then 
  830. 		for i, guard in pairs(M04_group.roadblock_001.members)do 
  831. 			character_set_persona(guard, "gang normal") 
  832. 			set_team(guard, "Morningstar") 
  833. 		end 
  834. 	end 
  835. 	if(group_is_loaded(M04_group.roadblock_002.name))then 
  836. 		for i, guard in pairs(M04_group.roadblock_002.members)do 
  837. 			character_set_persona(guard, "gang normal") 
  838. 			set_team(guard, "Morningstar") 
  839. 		end 
  840. 	end 
  841. 	 
  842. 	if not (group_is_loaded(M04_group.notoriety_001.name)) then 
  843. 		group_create(M04_group.notoriety_001.name, true) 
  844. 	end 
  845. 	vehicle_enter_teleport(M04_group.notoriety_001.members[1], M04_group.notoriety_001.vehicle, 0) 
  846. 	vehicle_enter_teleport(M04_group.notoriety_001.members[2], M04_group.notoriety_001.vehicle, 1) 
  847. 	 
  848. --	if not (group_is_loaded(M04_group.notoriety_002.name))then 
  849. --		group_create(M04_group.notoriety_002.name, true) 
  850. --	end 
  851. --	vehicle_enter_teleport(M04_group.notoriety_002.members[1], M04_group.notoriety_002.vehicle, 0) 
  852. --	vehicle_enter_teleport(M04_group.notoriety_002.members[2], M04_group.notoriety_002.vehicle, 1) 
  853. 	 
  854. 	if not (group_is_loaded(M04_group.notoriety_003.name))then 
  855. 		group_create(M04_group.notoriety_003.name, true) 
  856. 	end 
  857. 	vehicle_enter_teleport(M04_group.notoriety_003.members[1], M04_group.notoriety_003.vehicle, 0) 
  858. 	vehicle_enter_teleport(M04_group.notoriety_003.members[2], M04_group.notoriety_003.vehicle, 1) 
  859. 	 
  860. --	if not(group_is_loaded(M04_group.notoriety_004.name))then 
  861. --		group_create(M04_group.notoriety_004.name, true) 
  862. --	end 
  863. --	vehicle_enter_teleport(M04_group.notoriety_004.members[1], M04_group.notoriety_004.vehicle, 0) 
  864. --	vehicle_enter_teleport(M04_group.notoriety_004.members[2], M04_group.notoriety_004.vehicle, 1) 
  865. 	 
  866. 	-- Have notoriety groups chase the player 
  867. 	vehicle_chase(M04_group.notoriety_001.vehicle) 
  868. 	vehicle_chase(M04_group.notoriety_003.vehicle) 
  869. 	 
  870. 	-- If another conversation is already playing, wait for it to finish 
  871. 	if(convo_is_playing)then 
  872. 		repeat 
  873. 			thread_yield() 
  874. 		until (not convo_is_playing) 
  875. 	end 
  876. 	convo_is_playing = true 
  877. 	audio_conversation_play(M04_convo.escape.handle) 
  878. 	 
  879. 	-- Turn traffic splines back on 
  880. 	m04_traffic_on() 
  881. 	 
  882. 	-- Turn off notoriety decay 
  883. 	notoriety_set_can_decay(false) 
  884. 	notoriety_force_no_spawn("morningstar", false) 
  885. 	notoriety_force_no_spawn("deckers", false) 
  886. 	 
  887. 	-- Set notoriety to 2 stars for Morningstar 
  888. 	notoriety_set("Morningstar", 2) 
  889. 	m04_set_invisible_trigger(NOTORIETY_TRIGGER, "m04_reached_notoriety") 
  890. 	 
  891. 	audio_conversation_wait_for_end(M04_convo.escape.handle) 
  892. 	convo_is_playing = false 
  893. 	M04_convo.escape.handle = INVALID_CONVERSATION_HANDLE 
  894. end 
  895.  
  896. function m04_return_to_safehouse() 
  897. 	-- Pierce - "They know it's you, they'll be coming until we get somewhere safe.  Let's get back to the safe house." 
  898. 	Safehouse_Reached = false 
  899. 	-- Update minimap and GPS 
  900. 	m04_set_trigger(SAFEHOUSE_TRIGGER, "m04_reached_safehouse") 
  901. 	mission_waypoint_add(SAFEHOUSE_TRIGGER) 
  902.  
  903. 	-- Set objective to 'Return to safehouse to remove notoriety' 
  904. 	objective_text_clear(0) 
  905. 	objective_text(0, "m04_obj_return_home", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  906. 	-- Notoriety tutorial 
  907. 	--message("This is where the notoriety tutorial is going to go", 5.0) 
  908. 	--tutorial_start("notoriety_decreases", 5000, true, true) 
  909. 	-- Convo w/ Pierce about brute 
  910. 	if not convo_2 then 
  911. 		M04_thread_convo = thread_new("m04_play_convo_2") 
  912. 	end 
  913. 	 
  914. 	while not Notoriety_Reached do 
  915. 		thread_yield() 
  916. 	end 
  917. 	 
  918. 	-- Check to see if at safehouse 
  919. 	repeat  
  920. 		thread_yield()  
  921. 	until (Safehouse_Reached) 
  922. 	notoriety_set("Morningstar", 0) 
  923. 	notoriety_set("deckers", 0) 
  924. 	notoriety_set("Police", 0) 
  925. end 
  926.  
  927. function m04_play_convo_1() 
  928. 	convo_1 = true 
  929. 	M04_convo.drive_to_rj.handle = audio_conversation_load(M04_convo.drive_to_rj.name) 
  930. 	M04_convo.drive_to_ps.handle = audio_conversation_load(M04_convo.drive_to_ps.name) 
  931. 	delay(5.0) 
  932. 	while not(character_is_in_vehicle(LOCAL_PLAYER) and character_is_in_vehicle(M04_group.homies_001.members[1])) do 
  933. 		thread_yield() 
  934. 	end 
  935. 	audio_conversation_play(M04_convo.drive_to_rj.handle) 
  936. --	message("Pierce and player have conversation about Shaundi and Gat", 15.0) 
  937. 	audio_conversation_wait_for_end(M04_convo.drive_to_rj.handle) 
  938. 	 
  939. 	delay(5.0) 
  940. 	audio_conversation_play(M04_convo.drive_to_ps.handle) 
  941. 	audio_conversation_wait_for_end(M04_convo.drive_to_ps.handle) 
  942. 	 
  943. 	M04_convo.drive_to_ps.handle = INVALID_CONVERSATION_HANDLE 
  944. 	M04_convo.drive_to_rj.handle = INVALID_CONVERSATION_HANDLE 
  945. 	 
  946. end 
  947.  
  948. function m04_play_convo_2() 
  949. 	while not(character_is_in_vehicle(LOCAL_PLAYER) and character_is_in_vehicle(M04_group.homies_001.members[1])) do 
  950. 		thread_yield() 
  951. 	end 
  952. 	M04_convo.wtf.handle = audio_conversation_load(M04_convo.wtf.name) 
  953. 	 
  954. 	-- Set up followers 
  955. 	if not (group_is_loaded(M04_group.notoriety_002.name))then 
  956. 		group_create(M04_group.notoriety_002.name, true) 
  957. 	end 
  958. 	vehicle_enter_teleport(M04_group.notoriety_002.members[1], M04_group.notoriety_002.vehicle, 0) 
  959. 	vehicle_enter_teleport(M04_group.notoriety_002.members[2], M04_group.notoriety_002.vehicle, 1) 
  960. 	vehicle_chase(M04_group.notoriety_002.vehicle) --, LOCAL_PLAYER, false) 
  961. 	 
  962. 	if not(group_is_loaded(M04_group.notoriety_004.name))then 
  963. 		group_create(M04_group.notoriety_004.name, true) 
  964. 	end 
  965. 	vehicle_enter_teleport(M04_group.notoriety_004.members[1], M04_group.notoriety_004.vehicle, 0) 
  966. 	vehicle_enter_teleport(M04_group.notoriety_004.members[2], M04_group.notoriety_004.vehicle, 1) 
  967. 	vehicle_chase(M04_group.notoriety_004.vehicle) --, LOCAL_PLAYER, false) 
  968. 	 
  969. 	-- If another conversation is already playing, wait for it to finish 
  970. 	if(convo_is_playing)then 
  971. 		repeat 
  972. 			thread_yield() 
  973. 		until (not convo_is_playing) 
  974. 	end 
  975. 	convo_is_playing = true 
  976. 	audio_conversation_play(M04_convo.wtf.handle) 
  977. 	audio_conversation_wait_for_end(M04_convo.wtf.handle) 
  978. 	convo_is_playing = false 
  979. 	M04_convo.wtf.handle = INVALID_CONVERSATION_HANDLE 
  980. 	convo_2 = true 
  981. end 
  982.  
  983. function m04_play_sing_along() 
  984.     -- TODO: Have Pierce and player sing along w/ radio 
  985. 	local test = -1 
  986. 	delay(2.0) 
  987. 	M04_convo.sing_intro.handle = audio_conversation_load(M04_convo.sing_intro.name) 
  988. 	while not (character_is_in_vehicle(LOCAL_PLAYER))do 
  989. 		if Clothes_Store_Reached then 
  990. 			return 
  991. 		end 
  992. 		thread_yield()  
  993. 	end 
  994. 	test = radio_get_station(get_char_vehicle_name(LOCAL_PLAYER)) 
  995. 	audio_conversation_play(M04_convo.sing_intro.handle) 
  996.     vehicle_set_radio_controls_locked(get_char_vehicle_name(LOCAL_PLAYER), true) 
  997.     radio_set_station(LOCAL_PLAYER, 4) 
  998. 	delay(2.0) 
  999.     radio_set_station(LOCAL_PLAYER, 6) 
  1000. 	delay(2.0) 
  1001.     radio_set_station(LOCAL_PLAYER, 10) 
  1002. 	delay(2.0) 
  1003. 	 
  1004. 	test = radio_get_station(LOCAL_PLAYER) 
  1005. 	audio_conversation_wait_for_end(M04_convo.sing_intro.handle) 
  1006. 	M04_convo.sing_intro.handle = INVALID_CONVERSATION_HANDLE 
  1007. 	-- Sing alongs are normally not allowed during missions, override that. 
  1008. 	-- TODO: We'll need to turn this back off at the end of the mission or 
  1009. 	-- after the sing along has ended. 
  1010.     radio_set_sing_along_allowed_during_missions(true) 
  1011. 	 
  1012. 	-- Enable the player's sing along for this track during the mission. 
  1013. 	-- TODO: Call radio_clear_sing_along_track to clear this when the mission 
  1014. 	--   ends so that we don't play the sing along during regular gameplay. 
  1015. 	radio_set_sing_along_track("MIX_Sublime___What_I_Got", "M04_SINGALONG_WM_PLAYER") 
  1016.                  
  1017.     delay(7.0) 
  1018.     sing_along = true 
  1019.                  
  1020. end 
  1021.  
  1022.  
  1023. -- *************************************************** 
  1024. -- m04_initialize Helper Functions 
  1025. -- *************************************************** 
  1026.  
  1027. -- Handle any common initialization 
  1028. -- 
  1029. function m04_initialize_common() 
  1030. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  1031. 	 
  1032. end 
  1033.  
  1034. -- Checkpoint specific initialization 
  1035. -- 
  1036. -- checkpoint:		The checkpoint to be initialized 
  1037. function m04_initialize_checkpoint(checkpoint) 
  1038.  
  1039. 	if (checkpoint == M04_CHECKPOINT_START) then 
  1040. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  1041. 		-- Spawn Pierce and player outside of ShaundiBFApartment 
  1042. 		-- Add Pierce as homie 
  1043. 		m04_setup_crew() 
  1044. 	end 
  1045.  
  1046. 	if (checkpoint == M04_CHECKPOINT_CLOTHES_TUTORIAL) then 
  1047. 		teleport_coop(M04_PLAYER_CHECKPOINT_2[1], M04_COOP_CHECKPOINT_2[1], true) 
  1048. 		if not group_is_loaded(M04_group.backup_vehicle.name) then 
  1049. 			group_create(M04_group.backup_vehicle.name, true) 
  1050. 		end 
  1051. 		m04_setup_crew() 
  1052. 		teleport(M04_group.homies_001.members[1], M04_P_TELEPORT_2[1]) 
  1053. 		teleport_vehicle(M04_group.backup_vehicle.vehicle, M04_VEHICLE_CHECKPOINT_2[1]) 
  1054. 		release_to_world(M04_group.backup_vehicle.vehicle ) 
  1055. 		Mechanic_Tutorial_Done = true 
  1056. 	end 
  1057. 	 
  1058. 	if (checkpoint == M04_CHECKPOINT_BRUTE_FIGHT) then 
  1059. 		teleport_coop(M04_PLAYER_CHECKPOINT_3[1], M04_COOP_CHECKPOINT_3[1], true) 
  1060. 		 
  1061. 		m04_setup_crew() 
  1062. 		teleport(M04_group.homies_001.members[1], M04_P_TELEPORT_3[1]) 
  1063. 		teleport_vehicle(M04_group.starting_vehicle.vehicle, M04_VEHICLE_CHECKPOINT_3[1]) 
  1064. 		Mechanic_Tutorial_Done = true 
  1065. 		m04_spawn_morningstar() 
  1066. 		m04_traffic_off() 
  1067. 		 
  1068. 		m04_unhide_brute_section() 
  1069. 		m04_open_ps_doors() 
  1070. --		if not group_is_loaded(M04_group.backup_vehicle.name) then 
  1071. --			group_create(M04_group.backup_vehicle.name, true) 
  1072. --		end 
  1073. 	end 
  1074. 	 
  1075. 	if (checkpoint == M04_CHECKPOINT_NOTORIETY_REDUCTION) then 
  1076. 		teleport_coop(M04_PLAYER_CHECKPOINT_4[1], M04_COOP_CHECKPOINT_4[1], true) 
  1077. 		m04_spawn_morningstar_no_brute() 
  1078. 		m04_setup_crew() 
  1079. 		m04_force_notoriety() 
  1080. 		teleport(M04_group.homies_001.members[1], M04_P_TELEPORT_4[1]) 
  1081. 		teleport_vehicle(M04_group.starting_vehicle.vehicle, M04_VEHICLE_CHECKPOINT_3[1]) 
  1082. 		Mechanic_Tutorial_Done = true 
  1083. --		if not group_is_loaded(M04_group.backup_vehicle.name) then 
  1084. --			group_create(M04_group.backup_vehicle.name, true) 
  1085. --		end 
  1086.  
  1087. 		group_show(M04_group.roadblock_001.name) 
  1088. 		group_show(M04_group.roadblock_002.name) 
  1089. 	end 
  1090. end 
  1091.  
  1092. -- *************************************************** 
  1093. -- Miscellaneous m04 Helper Funcrtions 
  1094. -- *************************************************** 
  1095. -- Setting up homies 
  1096. function m04_setup_crew() 
  1097. 	-- Spawn Pierce and the car, add Pierce as a homie 
  1098. 	if not group_is_loaded(M04_group.homies_001.name) then 
  1099. 		group_create(M04_group.homies_001.name, true) 
  1100. 	end 
  1101. 	if not group_is_loaded(M04_group.starting_vehicle.name) then 
  1102. 		group_create(M04_group.starting_vehicle.name, true) 
  1103. 	end 
  1104. 	release_to_world(M04_group.starting_vehicle.name) 
  1105. 	party_add(M04_group.homies_001.members[1], LOCAL_PLAYER)	 
  1106. 	follower_set_can_abandon(M04_group.homies_001.members[1], true) 
  1107. 	 
  1108. 	on_death("m04_failure_pierce_died", M04_group.homies_001.members[1]) 
  1109. 	on_dismiss("m04_failure_abandon_pierce", M04_group.homies_001.members[1]) 
  1110. --	on_vehicle_destroyed("m04_failure_car_died", M04_group.starting_vehicle.vehicle) 
  1111. end 
  1112.  
  1113. -- CLEANUP FUNCTIONS\ 
  1114. function m04_cleanup_homies() 
  1115. 	if group_is_loaded(M04_group.homies_001.name) then 
  1116. 		group_destroy(M04_group.homies_001.name) 
  1117. 	end 
  1118. 	 
  1119. 	--release_to_world(M04_group.starting_vehicle.vehicle ) 
  1120. 	--release_to_world(M04_group.backup_vehicle.vehicle ) 
  1121. 	if group_is_loaded(M04_group.starting_vehicle.name) then 
  1122. 		group_destroy(M04_group.starting_vehicle.name) 
  1123. 	end 
  1124. 	 
  1125. --	if group_is_loaded(M04_group.backup_vehicle.name) then 
  1126. --		group_destroy(M04_group.backup_vehicle.name) 
  1127. --	end 
  1128. 	 
  1129. 	on_death("", M04_group.homies_001.members[1]) 
  1130. 	on_dismiss("", M04_group.homies_001.members[1]) 
  1131. 	on_vehicle_destroyed("", M04_group.starting_vehicle.vehicle) 
  1132. end 
  1133.  
  1134. function m04_cleanup_enemies() 
  1135. 	if group_is_loaded(M04_group.goons_001.name) then 
  1136. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  1137. 		for i, enemy in pairs(M04_group.goons_001.members) do 
  1138. 			if (character_is_dead(enemy) == false) then 
  1139. 				marker_remove(enemy) 
  1140. 			end 
  1141. 		end 
  1142. 		-- Cleanup the group 
  1143. 		group_destroy(M04_group.goons_001.name) 
  1144. 	end 
  1145. 	 
  1146. 	if group_is_loaded(M04_group.brute_001.name) then 
  1147. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  1148. 		must_kill_cleanup(M04_group.brute_001.members) 
  1149. 		-- Cleanup the group 
  1150. 		group_destroy(M04_group.brute_001.name) 
  1151. 	end 
  1152. 	 
  1153. 	if group_is_loaded(M04_group.brute_002.name) then 
  1154. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  1155. 		for i, enemy in pairs(M04_group.brute_002.members) do 
  1156. 			if (character_is_dead(enemy) == false) then 
  1157. 				marker_remove(enemy) 
  1158. 			end 
  1159. 		end 
  1160. 		-- Cleanup the group 
  1161. 		group_destroy(M04_group.brute_002.name) 
  1162. 	end 
  1163. 	 
  1164. 	if group_is_loaded(M04_group.roadblock_001.name) then 
  1165. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  1166. 		for i, enemy in pairs(M04_group.roadblock_001.members) do 
  1167. 			on_attack_performed("", enemy) 
  1168. 			if (character_is_dead(enemy) == false) then 
  1169. 				marker_remove(enemy) 
  1170. 			end 
  1171. 		end 
  1172. 		-- Cleanup the group 
  1173. 		group_destroy(M04_group.roadblock_001.name) 
  1174. 	end 
  1175. 	 
  1176. 	if group_is_loaded(M04_group.roadblock_002.name) then 
  1177. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  1178. 		for i, enemy in pairs(M04_group.roadblock_002.members) do 
  1179. 			on_attack_performed("", enemy) 
  1180. 			if (character_is_dead(enemy) == false) then 
  1181. 				marker_remove(enemy) 
  1182. 			end 
  1183. 		end 
  1184. 		-- Cleanup the group 
  1185. 		group_destroy(M04_group.roadblock_002.name) 
  1186. 	end 
  1187. 	 
  1188. 	if group_is_loaded(M04_group.notoriety_001.name)then 
  1189. 		group_destroy(M04_group.notoriety_001.name) 
  1190. 	end 
  1191. 	if group_is_loaded(M04_group.notoriety_002.name)then 
  1192. 		group_destroy(M04_group.notoriety_002.name) 
  1193. 	end 
  1194. 	if group_is_loaded(M04_group.notoriety_003.name)then 
  1195. 		group_destroy(M04_group.notoriety_003.name) 
  1196. 	end 
  1197. 	if group_is_loaded(M04_group.notoriety_004.name)then 
  1198. 		group_destroy(M04_group.notoriety_004.name) 
  1199. 	end 
  1200. end 
  1201. -- TRIGGER FUNCTIONS 
  1202. function m04_set_trigger(trigger, trigger_callback) 
  1203. 	trigger_enable(trigger, true) 
  1204. 	marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1205. 	on_trigger(trigger_callback, trigger) 
  1206. end 
  1207.  
  1208. function m04_clear_trigger(trigger) 
  1209. 	on_trigger("", trigger) 
  1210. 	trigger_enable(trigger, false) 
  1211. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1212. 	mission_waypoint_remove() 
  1213. end 
  1214.  
  1215. function m04_set_invisible_trigger(trigger, trigger_callback) 
  1216. 	trigger_enable(trigger, true) 
  1217. 	on_trigger(trigger_callback, trigger) 
  1218. end 
  1219.  
  1220. function m04_clear_invisible_trigger(trigger) 
  1221. 	on_trigger("", trigger) 
  1222. 	trigger_enable(trigger, false) 
  1223. end 
  1224. function must_kill_setup(enemy_table) 
  1225. 	for i, enemy in pairs(enemy_table) do 
  1226. 		if (character_is_dead(enemy) == false) then 
  1227. 			on_death("m04_enemy_killed", enemy) 
  1228. 			marker_add(enemy, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1229. 			Num_guys_to_kill = Num_guys_to_kill + 1 
  1230. 		end 
  1231. 	end 
  1232. 	 
  1233. 	thread_new("m04_convo", M04_convo.brute_combat, 10.0) 
  1234. 	while (Num_guys_to_kill > 0) do 
  1235. 		thread_yield() 
  1236. 	end	 
  1237. end 
  1238. function must_kill_cleanup(enemy_table) 
  1239. 	-- Clear enemy callbacks 
  1240. 	for i, enemy in pairs(enemy_table) do 
  1241. 		-- cleanup the callback 
  1242. 		on_death("", enemy) 
  1243. 		marker_remove(enemy, SYNC_ALL) 
  1244. 	end 
  1245. end 
  1246. -- ************************* 
  1247. -- 
  1248. -- Callback functions 
  1249. -- 
  1250. -- ************************* 
  1251. -- End the mission if Pierce dies 
  1252. function m04_failure_pierce_died() 
  1253. 	mission_end_failure("m04", M04_FAILURE_PIERCE_DIED) 
  1254. end 
  1255. -- End the mission if Pierce is abandoned 
  1256. function m04_failure_abandon_pierce() 
  1257. 	mission_end_failure("m04", M04_FAILURE_ABANDON_PIERCE) 
  1258. end 
  1259. -- End the mission if the car explodes before showing up at the mechanic 
  1260. function m04_failure_car_died() 
  1261. 	if not Mechanic_Tutorial_Done then 
  1262. 		mission_end_failure("m04", M04_FAILURE_CAR_DESTROYED) 
  1263. 	end 
  1264. end 
  1265. function m04_reached_mechanic() 
  1266. 	Mechanic_breadcrumb_Reached = true 
  1267. 	m04_clear_trigger(MECHANIC_TRIGGER) 
  1268. 	mission_waypoint_remove(SYNC_ALL) 
  1269. 	 
  1270. 	m04_set_trigger(MECHANIC_TRIGGER2, "m04_reached_mechanic2") 
  1271. end 
  1272. function m04_reached_mechanic2() 
  1273. 	Mechanic_Reached = true 
  1274. 	 
  1275. 	-- Reset the notoriety 
  1276. 	-- Reset notoriety 
  1277. 	notoriety_reset("police")  
  1278. 	notoriety_reset("Morningstar") 
  1279. 	-- Give the player some cash to play with at the store (check to add for coop too) 
  1280. 	if not M04_given_mechanic_cash then 
  1281. 		cash_add(M04_mechanic_cash) 
  1282. 		if(coop_is_active())then 
  1283. 			cash_add(M04_mechanic_cash, REMOTE_PLAYER) 
  1284. 		end 
  1285. 		M04_given_mechanic_cash = true 
  1286. 	end 
  1287. 	 
  1288. 	m04_clear_trigger(MECHANIC_TRIGGER2) 
  1289. 	mission_waypoint_remove(SYNC_ALL) 
  1290. end 
  1291.  
  1292. function m04_reached_clothes() 
  1293. 	m04_clear_trigger(CLOTHES_TRIGGER) 
  1294. 	mission_waypoint_remove(SYNC_ALL) 
  1295. 	 
  1296. 	m04_set_trigger(CLOTHES_TRIGGER2, "m04_reached_clothes2") 
  1297. end 
  1298. function m04_reached_clothes2() 
  1299. 	Clothes_Store_Reached = true 
  1300. 	m04_clear_trigger(CLOTHES_TRIGGER2) 
  1301. 	mission_waypoint_remove(SYNC_ALL) 
  1302. 	 
  1303. 	fade_out(0.5) 
  1304. 	fade_out_block() 
  1305. 	teleport_coop(M04_PLAYER_STORE[1], M04_COOP_STORE[1], true) 
  1306. 	teleport(M04_group.homies_001.members[1], M04_P_STORE[1]) 
  1307. 	hud_push_screen("store_common", SYNC_ALL) 
  1308. 	hud_push_screen("store_clothing", SYNC_ALL) 
  1309. 	-- Leash Pierce to the store so he stops doing stupid shit 
  1310. 	npc_leash_to_nav(M04_group.homies_001.members[1], M04_P_STORE[1], 3) 
  1311. 	 
  1312. 	m04_spawn_morningstar() 
  1313. --	m04_open_ps_doors() 
  1314.  
  1315.  
  1316. 	cleanup_conversations(M04_convo) 
  1317. 	-- Kill conversation thread 
  1318. 	thread_kill(M04_thread_convo) 
  1319. 	M04_thread_convo = INVALID_CONVERSATION_HANDLE 
  1320. 	 
  1321. 	fade_in(0.5) 
  1322. 	fade_in_block() 
  1323. end 
  1324.  
  1325. function m04_reached_safehouse() 
  1326. 	m04_clear_trigger(SAFEHOUSE_TRIGGER) 
  1327. 	mission_waypoint_remove(SYNC_ALL) 
  1328.  
  1329. 	tutorial_start("notoriety_decreases", 0, true, true) 
  1330. 	m04_set_trigger(SAFEHOUSE_TRIGGER2, "m04_reached_safehouse2") 
  1331. end 
  1332. function m04_reached_safehouse2() 
  1333. 	Safehouse_Reached = true 
  1334. 	m04_clear_trigger(SAFEHOUSE_TRIGGER2) 
  1335. 	mission_waypoint_remove(SYNC_ALL) 
  1336.  
  1337. end 
  1338. function m04_reached_notoriety() 
  1339. 	Notoriety_Reached = true 
  1340. 	m04_clear_invisible_trigger(NOTORIETY_TRIGGER) 
  1341.  
  1342. 	 
  1343. 	notoriety_set_can_decay(true) 
  1344.  	notoriety_force_no_spawn("morningstar", true) 
  1345.  	notoriety_force_no_spawn("deckers", true) 
  1346. end 
  1347.  
  1348. -- Turn off traffic splines in the traffic trigger 
  1349. function m04_traffic_off() 
  1350. 	set_traffic_density(0.1) 
  1351. 	set_ped_density(0.1) 
  1352. 	sidewalk_disable_nodes(TRAFFIC_TRIGGER, true) 
  1353. 	traffic_disable_lanes(TRAFFIC_TRIGGER, true) 
  1354. 	set_traffic_density(1) 
  1355. 	set_ped_density(1) 
  1356. end 
  1357. -- Turn traffic back on 
  1358. function m04_traffic_on() 
  1359. 	sidewalk_disable_nodes(TRAFFIC_TRIGGER, false) 
  1360. 	traffic_disable_lanes(TRAFFIC_TRIGGER, false) 
  1361. end 
  1362. function m04_enemy_killed(enemy) 
  1363. 	on_death("",enemy) 
  1364. 	marker_remove(enemy, SYNC_ALL) 
  1365. 	Num_guys_to_kill = Num_guys_to_kill - 1 
  1366. end 
  1367. -- Have Morningstar say something 
  1368. -- 
  1369. -- name:	(string) name of character 
  1370. -- weapon:	(string) name of weapon 
  1371. -- attack:	(string) type of attack performed 
  1372. -- 
  1373. function m04_ms_attack_line_cb(name, weapon, attack) 
  1374. 	local situation = "M04_Attack" 
  1375. 	 
  1376. 	-- don't play this if we have done this recently 
  1377. 	if(not thread_check_done(M04_thread_attack_line_timer))then 
  1378. 		return 
  1379. 	end 
  1380. 	 
  1381. 	-- start timer 
  1382. 	M04_thread_attack_line_timer = thread_new("delay", M04_Attack_Line_Time) 
  1383. 	-- Play situation 
  1384. 	audio_play_persona_line(name, situation) 
  1385. end 
  1386. -- Unhide everyone in the roadblock/brute section 
  1387. -- 
  1388. -- 
  1389. function m04_unhide_brute_section() 
  1390. 	vehicle_enter_teleport(M04_group.brute_002.members[1], M04_group.brute_001.vehicle, 0) 
  1391. 	vehicle_enter_teleport(M04_group.brute_001.members[1], M04_group.brute_001.vehicle) 
  1392. 	 
  1393. 	group_show(M04_group.roadblock_001.name) 
  1394. 	group_show(M04_group.roadblock_002.name) 
  1395. 	group_show(M04_group.brute_001.name) 
  1396. 	group_show(M04_group.brute_002.name) 
  1397. end 
  1398. -- Open the door to planet saints 
  1399. -- 
  1400. -- 
  1401. function m04_open_ps_doors() 
  1402. 	door_open("sm_psdoor1") 
  1403. 	door_open("sm_psdoor2") 
  1404. end 
  1405.  
  1406. -- Open the door to Rim Jobs 
  1407. -- 
  1408. -- 
  1409. function m04_open_rj_door() 
  1410. 	door_open("sm_rjdoor") 
  1411. end 
  1412.  
  1413. -- ************************* 
  1414. -- 
  1415. -- Thread functions 
  1416. -- 
  1417. -- ************************* 
  1418.  
  1419. -- Function to make life easier when calling conversations 
  1420. -- 
  1421. -- convo:	Conversation to play 
  1422. -- delay_time:	(float) length of delay before playing conversation 
  1423. -- 
  1424. function m04_convo(convo, delay_time) 
  1425. 	if(convo == nil)then 
  1426. 		return 
  1427. 	end 
  1428. 	-- If another conversation is already playing, wait for it to finish 
  1429. 	if(convo_is_playing)then 
  1430. 		repeat 
  1431. 			thread_yield() 
  1432. 		until (not convo_is_playing) 
  1433. 	end 
  1434. 	convo_is_playing = true 
  1435. 	-- Load the conversation 
  1436. 	convo.handle = audio_conversation_load(convo.name) 
  1437. 	-- make sure we shouldn't wait for the convo to start 
  1438. 	if(delay_time)then 
  1439. 		delay(delay_time) 
  1440. 	end 
  1441. 	-- Play the conversation 
  1442. 	audio_conversation_play(convo.handle) 
  1443. 	delay(1) 
  1444. 	-- Wait for the conversation to end 
  1445. 	audio_conversation_wait_for_end(convo.handle) 
  1446. 	convo.handle = INVALID_CONVERSATION_HANDLE 
  1447. 	convo_is_playing = false 
  1448. end