./mm_p_03.lua

  1.  
  2. --[[ 
  3. 	mm_p_03.lua 
  4. 	SR3 Mission Script 
  5. 	DATE: 9-3-2010 
  6. 	AUTHOR:	Jimmy Cross 
  7. ]]-- 
  8.  
  9.  
  10. -- Debug flags -- 
  11.  
  12. -- Tweakable Parameters -- 
  13. 	MM_P_03_PIERCE_SPAWN_DIST = 55.0 
  14. 	MM_P_03_PIERCE_ADD_DIST = 5.0 
  15. 	PURCHASE_STORE_OBJ_DIST = 5.0 
  16. 	FLASHPOINT_SPAWN_DIST = 75.0 
  17. 	FLASHPOINT_NOT_ACTIVE = 1 
  18. 	FLASHPOINT_FAILED = 3 
  19.     FLASHPOINT_COMPLETE = 4 
  20.  
  21.  
  22. -- Groups -- 
  23.  
  24. 	MM_P_03_group = { 
  25. 		npcs = { 
  26. 			name 	= "MM_P_03_NPC", 
  27. 			pierce 	= "MM_P_03_NPC_Pierce" 
  28. 		}, 
  29. 		 
  30. 		fp = { 
  31. 			name	= "MM_P_03_FP" 
  32. 		}, 
  33. 		 
  34. 		vehicles = { 
  35. 			name	= "MM_P_03_Vehicle_Group", 
  36. 			vehicle = "MM_P_03_vehicle" 
  37. 		}, 
  38. 		 
  39. 		CTE_MMP03_01 = { 
  40. 			name     = "CTE_MMP03_Pierce_Car_01" 
  41. 		}, 
  42. 		 
  43. 		post_cte = { "MM_P_03_NPC", "MM_P_03_Vehicle_Group" } 
  44. 	} 
  45.  
  46. -- Navpoints -- 
  47. checkpoint_nav = "MM_P_03_Nav_Store_Front" -- navpoint to teleport Pierce to at checkpoint 
  48.  
  49. 	MM_P_03_navs = { 
  50. 		fp 	= "MM_P_03_Nav_FP", 
  51. 		fp2 = "MM_P_03_Nav_FP02", 
  52. 		sf	= "MM_P_03_Nav_Store_Front", 
  53. 		collectible = "MM_P_03_Nav_Collectible", 
  54. 		store = "MM_P_03_Nav_Store", 
  55. 		store_int = "MM_P_03_Nav_Inside_Store", 
  56. 		 
  57.  
  58. 		cp_start = {  
  59. 		player_local = "Local Player Start",  
  60. 		player_remote = "Remote Player Start"  
  61. 		} 
  62. 		 
  63. 	} 
  64.  
  65. -- Triggers -- 
  66. 	MM_P_03_trigger = { 
  67. 		fp1 = { 
  68. 			name = "trigger_fp1", 
  69. 			is_triggered = false 
  70. 		}, 
  71. 		 
  72. 		fp2 = { 
  73. 			name = "trigger_fp2", 
  74. 			is_triggered = false 
  75. 		} 
  76. 	} 
  77. -- Characters -- 
  78.  
  79.  
  80. -- Vehicles -- 
  81.  
  82. -- Mesh Movers -- 
  83.  
  84. -- Text -- 
  85.  
  86. -- Threads -- 
  87. local PIERCE_WATCHER_THREAD = INVALID_THREAD_HANDLE 
  88. local MMP03_PLAY_CONVO_THREAD = INVALID_THREAD_HANDLE 
  89.  
  90. -- Checkpoints -- 
  91. 	MM_P_03_checkpoint = { 
  92. 		start = { 
  93. 			name = MISSION_START_CHECKPOINT, 
  94. 			navs = { "cp_start_local", "cp_start_remote"	 } 
  95. 			}, 
  96. 		 
  97. 		flashpoint = { 
  98. 			name = "flashpoint", 
  99. 			nav1 = "Local Player Start", 
  100. 			nav2 = "Remote Player Start", 
  101. 			nav3 = "MM_P_03_Nav_Store_Front" 
  102. 		} 
  103. 	} 
  104.  
  105. -- Cutscenes -- 
  106. 	CUTSCENE_MISSION_INTRO = "" 
  107. 	MMP03_CUTSCENE_CTE_INTRO = "mmp03_cte_01" 
  108. 	CUTSCENE_MISSION_OUTRO = "" 
  109.  
  110. -- Conversations -- 
  111. MM_P_03_convo = { 
  112. 	start = { 
  113. 		name = "MM_P_03_Start", 
  114. 		handle = INVALID_CONVERSATION_HANDLE 
  115. 	}, 
  116. 	 
  117. 	store_purchased = { 
  118. 		name = "MM_P_03_After_Purchase", 
  119. 		handle = INVALID_CONVERSATION_HANDLE 
  120. 	}, 
  121. 	 
  122. 	collect =  { 
  123. 		name = "MM_P_03_Find_Collectable", 
  124. 		handle = INVALID_CONVERSATION_HANDLE 
  125. 	}, 
  126. 	 
  127. 	buy_bld = { 
  128. 		name = "MM_P_03_Go_Buy_Building", 
  129. 		handle = INVALID_CONVERSATION_HANDLE 
  130. 	}, 
  131. 	 
  132. 	drive_fp = { 
  133. 		name = "MM_P_03_Drive_To_Flashpoint", 
  134. 		handle = INVALID_CONVERSATION_HANDLE 
  135. 	}, 
  136. 	 
  137. 	finished_fp = { 
  138. 		name = "MM_P_03_2nd_Flashpoint", 
  139. 		handle = INVALID_CONVERSATION_HANDLE 
  140. 	}, 
  141. 	 
  142. 	fp2 = { 
  143. 		name = "MM_P_03_Finished_Flashpoint", 
  144. 		handle = INVALID_CONVERSATION_HANDLE 
  145. 	}, 
  146. 	 
  147. 	notoriety = { 
  148. 		name = "MM_P_03_Drive_To_Lose", 
  149. 		handle = INVALID_CONVERSATION_HANDLE 
  150. 	} 
  151. } 
  152.  
  153. -- Failure text -- 
  154. local PIERCE_DEAD = "mm_p_03_pierce_died" -- Pierce Died 
  155. local PIERCE_ABANDONDED = "mm_p_03_pierce_abandonded" 
  156. local FAIL_FP = "mm_p_03_fail_fp" 
  157.  
  158.  
  159. -- Misc Globals 
  160. local MM_P_03_NAG_ACTIVE = false 
  161. local MM_P_03_FP_NAG = "MM03_NAG_FP"--"mm_p_03_nag_fp"-- 
  162. local mm_p_03_convo_playing = false 
  163.  
  164. -- ************************* 
  165. -- 
  166. -- Standard functions 
  167. -- 
  168. -- ************************* 
  169.  
  170. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  171. -- at the specified checkpoint. 
  172. -- CALLED FROM CODE 
  173. -- 
  174. -- checkpoint:	The checkpoint the mission should begin at 
  175. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  176. -- 
  177. function mm_p_03_start(checkpoint, is_restart) 
  178. 	-- Check if this mission starting from the beginning 
  179. 	if (checkpoint == MM_P_03_checkpoint.start.name) then 
  180. 		if (is_restart == false) then 
  181. 			-- First time playing mission	 
  182. 			local fade_in_after = false 
  183. 			-- Play CTE before any code happens 
  184. 			group_create( MM_P_03_group.CTE_MMP03_01.name, true ) 
  185. 			cutscene_play( MMP03_CUTSCENE_CTE_INTRO, nil, MM_P_03_checkpoint.start.navs, fade_in_after ) 
  186. 			group_destroy( MM_P_03_group.CTE_MMP03_01.name ) 
  187. 		else 
  188. 			teleport_coop(MM_P_03_checkpoint.start.navs[1], MM_P_03_checkpoint.start.navs[2], true) 
  189. 		end 
  190. 		fade_out(0) 
  191. 	end 
  192.  
  193. 	-- Handle mission initialization for the current checkpoint 
  194. 	mm_p_03_initialize(checkpoint) 
  195.  
  196. 	-- Run the mission from the current checkpoint 
  197. 	mm_p_03_run(checkpoint) 
  198.  
  199. end 
  200.  
  201. -- This is the primary function responsible for running the entire mission from start to finish. 
  202. -- 
  203. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  204. -- 
  205. function mm_p_03_run(first_checkpoint) 
  206. 	local current_checkpoint = first_checkpoint 
  207.  
  208. 	-- Run the mission from the beginning 
  209. 	if( current_checkpoint == MM_P_03_checkpoint.start.name ) then		 
  210. 				 
  211. 		delay(1.5) 
  212. 		MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.start)	 
  213. 		 
  214. 		mm_p_03_go_to_storefront() 
  215. 		mm_p_03_collectibles() 
  216. 		mm_p_03_go_to_property() 
  217. 		 
  218. 		current_checkpoint = MM_P_03_checkpoint.flashpoint.name 
  219. 		mission_set_checkpoint( MM_P_03_checkpoint.flashpoint.name, true ) 
  220. 	end 
  221.  
  222. 	if( current_checkpoint == MM_P_03_checkpoint.flashpoint.name ) then 
  223.  
  224. 		mm_p_03_go_to_flashpoint() 
  225. 		mm_p_03_lower_notoriety() 
  226. 	end 
  227.  
  228. 	-- Call mission success?? 
  229. 	mission_end_success( "mm_p_03", CUTSCENE_MISSION_OUTRO ) 
  230.  
  231. 	-- get rid of Pierce 
  232. 	party_dismiss( MM_P_03_group.npcs.pierce ) 
  233.  
  234. 	-- tell Player new mission available 
  235. 	--message( "!!A new mission is available", 6.0 ) 
  236. 	-- mission_unlock( "next_mission" ) -- unlock the next mission 
  237.  
  238. end 
  239.  
  240. -- This is the primary function responsible for cleaning up the entire mission 
  241. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  242. -- 
  243. function mm_p_03_cleanup() 
  244. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  245.  
  246. 	tutorial_stop("notoriety_decreases") 
  247.  
  248. 	mm_p_03_clear_trigger( MM_P_03_trigger.fp1.name ) 
  249. 	mm_p_03_clear_trigger( MM_P_03_trigger.fp2.name ) 
  250. 	marker_remove( MM_P_03_navs.sf, SYNC_ALL ) 
  251. 	marker_remove( MM_P_03_navs.collectible, SYNC_ALL ) 
  252. 	marker_remove( MM_P_03_navs.store, SYNC_ALL ) 
  253. 	marker_remove( MM_P_03_navs.fp, SYNC_ALL ) 
  254. 	marker_remove( MM_P_03_navs.fp2, SYNC_ALL ) 
  255. 	marker_remove( MM_P_03_navs.store_int, SYNC_ALL )		 
  256. 	mission_waypoint_remove() 
  257. 	 
  258. 	if group_is_loaded(MM_P_03_group.vehicles.name) then 
  259. 		group_destroy(MM_P_03_group.vehicles.name) 
  260. 	end 
  261. 	 
  262. 	-- make sure clerks are turned back on 
  263. 	shop_ignore_clerk(false) 
  264. 	 
  265. 	on_death( "", MM_P_03_group.npcs.pierce ) 
  266. 	on_dismiss( "", MM_P_03_group.npcs.pierce ) 
  267. 	 
  268. 	group_destroy( MM_P_03_group.npcs.name ) 
  269. 	 
  270. 	flashpoints_enable( true ) 
  271. 	mm_p_03_unregister_trigger(1) 
  272. 	mm_p_03_unregister_trigger(2) 
  273. 	 
  274. 	notoriety_set_max("morningstar", 5)	 
  275. 	notoriety_set_max("police", 5) 
  276. 	notoriety_set("morningstar", 0)	 
  277. 	notoriety_set("police", 0) 
  278. end 
  279.  
  280. -- Called when the mission has ended with success 
  281. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  282. -- 
  283. function mm_p_03_success() 
  284. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  285.  
  286. end 
  287.  
  288.  
  289. -- ************************* 
  290. -- 
  291. -- Local functions 
  292. -- 
  293. -- ************************* 
  294.  
  295. -- Initialize the mission for the specified checkpoint 
  296. -- 
  297. -- checkpoint:		Checkpoint to initialize the mission to 
  298. -- 
  299. function mm_p_03_initialize(checkpoint) 
  300. 	-- Make sure the screen is completly faded out 
  301. 	mission_start_fade_out(0.0) 
  302.  
  303. 	-- Set the mission author 
  304. 	set_mission_author("Jimmy Cross") 
  305.  
  306. 	-- Common initialization 
  307. 	mm_p_03_initialize_common() 
  308.  
  309. 	-- Checkpoint specific initialization 
  310. 	mm_p_03_initialize_checkpoint(checkpoint) 
  311.  
  312. 	-- Start fading in 
  313. 	mission_start_fade_in() 
  314.  
  315. end 
  316.  
  317. -- Getting the player to the Saints HQ after mission accepted on phone 
  318. -- 
  319. -- 
  320. function mm_p_03_go_to_storefront() 
  321.  
  322. 	local property = false 
  323. 	local store_cost = 100 
  324. 	 
  325. 	if not mission_store_purchased(property) then 
  326. 		shop_ignore_clerk(true)	-- ignore clerk related problems with store purchasing 
  327. 		-- give player some monies 
  328. 		cash_add(store_cost) 
  329. 		-- maybe we shouldn't give coop money because he's not required to purchase?  meh. 
  330. 		if(coop_is_active())then 
  331. 			cash_add(store_cost, "#PLAYER2#") 
  332. 		end 
  333. 		-- probably need to set an objective marker and waypoint here to make clear which store must be purchased 
  334. 		mission_waypoint_add(	MM_P_03_navs.store, SYNC_ALL) 
  335. 		marker_add(	MM_P_03_navs.store, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  336. 		 
  337. 		-- tell player to buy it 
  338. 		objective_text( 0, "MM03_OBJ_PURCHASE_STORE", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  339. 		 
  340. 		-- wait until store is purchased 
  341. 		while not mission_store_purchased(property) do 
  342. 			thread_yield() 
  343. 		end 
  344. 		shop_ignore_clerk(false) 
  345. 		mission_waypoint_remove( SYNC_ALL ) 
  346. 		marker_remove(	MM_P_03_navs.store, SYNC_ALL ) 
  347. 		 
  348. 		delay(6) 
  349. 		MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.store_purchased)	 
  350. 	end 
  351. end 
  352.  
  353. function mm_p_03_go_to_property() 
  354. 	objective_text_clear(0) 
  355. 	objective_text( 0, "MM03_OBJ_GOTO_PROPERTY", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  356. 	 
  357. 	MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.buy_bld)	 
  358. 	 
  359. 	local property = true 
  360. 	local property_cost = 100 
  361. 	if not mission_store_purchased(property) then 
  362. 		-- give player some monies 
  363. 		cash_add(property_cost) 
  364. 		-- maybe we shouldn't give coop money because he's not required to purchase?  meh. 
  365. 		if(coop_is_active())then 
  366. 			cash_add(property_cost, "#PLAYER2#") 
  367. 		end 
  368. 		 
  369. 		mission_waypoint_add(	MM_P_03_navs.sf, SYNC_ALL) 
  370. 		marker_add(	MM_P_03_navs.sf, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  371. 		 
  372. 		repeat thread_yield() until ( get_dist_closest_player_to_object( 	MM_P_03_navs.sf ) < 5 ) 
  373. 		 
  374. 		objective_text_clear(0) 
  375. 		 
  376. 		-- tell player to buy it 
  377. 		objective_text( 0, "MM03_OBJ_PURCHASE_PROPERTY", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  378. 		 
  379. 		-- wait until store is purchased 
  380. 		while not mission_store_purchased(property) do 
  381. 			thread_yield() 
  382. 		end 
  383. 			--insert processing for property purchase here 
  384. 		mission_waypoint_remove( SYNC_ALL ) 
  385. 		marker_remove(	MM_P_03_navs.sf, SYNC_ALL ) 
  386. 	end 
  387. end 
  388.  
  389. function mm_p_03_collectibles() 
  390. 	 
  391. 	objective_text_clear(0) 
  392. 	objective_text( 0, "MM03_OBJ_GOTO_COLLECTIBLE", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  393. 	 
  394. 	if not mission_collectible_collected() then 
  395. 		 
  396. 		-- probably need to set an objective marker and waypoint here to make clear which collectable to go to 
  397. 		 
  398. 		mission_waypoint_add(MM_P_03_navs.collectible, SYNC_ALL) 
  399. 		marker_add(MM_P_03_navs.collectible, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  400. 		 
  401. 		repeat thread_yield() until ( get_dist_closest_player_to_object( MM_P_03_navs.collectible ) < 10 ) 
  402. 		 
  403. 		objective_text_clear(0) 
  404. 		objective_text( 0, "MM03_OBJ_ACQUIRE_COLLECTIBLE", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  405. 		 
  406. 		-- wait until it is collected 
  407. 		while not mission_collectible_collected() do 
  408. 			thread_yield() 
  409. 		end 
  410. 		 
  411. 		MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.collect)	 
  412. 		 
  413. 		marker_remove( MM_P_03_navs.collectible, SYNC_ALL) 
  414. 		mission_waypoint_remove( SYNC_ALL ) 
  415. 	end	 
  416. end 
  417.  
  418. function mm_p_03_go_to_flashpoint() 
  419. 	local flashpoint_num = 1 --DD: Which flashpoint we're dealing with 
  420. 	local fp_nav = "" --DD: Will store the waypoint marker navpoint 
  421. 	 
  422. 	delay(5) 
  423. 	 
  424. 	MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.drive_fp)	 
  425.  
  426. 	while not ( flashpoint_num == 3 ) do 
  427.  
  428. 		--DD: Set which navpoint we're referring to for the waypoint marker 
  429. 		if ( flashpoint_num == 1 ) then 
  430. 			fp_nav = MM_P_03_navs.fp 
  431. 		else 
  432. 			fp_nav = MM_P_03_navs.fp2 
  433. 		end 
  434. 		 
  435. 		mm_p_03_register_trigger( flashpoint_num ) --setup the bounding trigger 
  436.  
  437. 		objective_text( 0, "MM03_OBJ_GOTO_FP", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  438.  
  439. 		-- update GPS info 
  440. 		mission_waypoint_add( fp_nav ) -- add GPS marker at the flashpoint activity 
  441. 		marker_add( fp_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  442. 		--marker_add_trigger( MM_P_03_trigger.fp.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT,  OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  443.  
  444. 		-- wait for the Player to get to the flashpoint point 
  445. 		repeat thread_yield() until ( get_dist_closest_player_to_object( fp_nav ) < FLASHPOINT_SPAWN_DIST ) 
  446. 		 
  447. 		flashpoints_enable(true) 
  448. 		flashpoint_start_mission( flashpoint_num ) 
  449. 		local flashpoint_complete = false 
  450. 		 
  451. 		repeat  
  452. 			thread_yield() 						-- make sure player is close enough to activate the flashpoint 
  453. 		until ( get_dist_closest_player_to_object( fp_nav ) < 17 ) or (flashpoint_mission_status() ~= FLASHPOINT_NOT_ACTIVE) 
  454. 		 
  455. 		objective_text_clear(0) 
  456.  
  457. 		mission_waypoint_remove() 
  458. 		marker_remove( fp_nav, SYNC_ALL ) 
  459. 		objective_text( 0, "MM03_OBJ_KILL_FP", nil, nil, SYNC_ALL, OI_ASSET_KILL ) --tell the player to destroy the flashpoint 
  460.  
  461. 		while not flashpoint_complete do 
  462. 			local fp_status = flashpoint_mission_status() 
  463. 			if fp_status == FLASHPOINT_FAILED then 
  464. 				mm_p_03_fail_fp() 
  465. 				--mission_end_failure("mm_p_03", FAIL_FP ) --"You failed the flashpoint") 
  466. 				--mission_end_failure("mm_p_03", FAIL_FP ) --"You failed the flashpoint") 
  467. 			elseif fp_status == FLASHPOINT_COMPLETE then 
  468. 				mm_p_03_unregister_trigger(flashpoint_num) --make sure the bounding trigger is unregistered 
  469. 				flashpoint_complete = true 
  470. 				 
  471. 				if flashpoint_num == 1 then 
  472. 					MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.finished_fp) 
  473. 				else 
  474. 					MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.fp2)	 
  475. 				end 
  476. 				 
  477. 				flashpoint_num = flashpoint_num + 1 
  478. 			end 
  479. 			thread_yield() 
  480. 		end 
  481.  
  482. 		objective_text_clear(0) 
  483.  
  484. 	end 
  485.  
  486. 	-- tell the Player flashpoints now available across entire city 
  487. 	--message( "!!Flashpoints are now unlocked across the entire city and can be done at any time for increased cash flow ", 6.0 ) 
  488. 	--need: script action to unlock flashpoints 
  489. end 
  490.  
  491. function mm_p_03_lower_notoriety() 
  492. 	 
  493. 	mission_waypoint_add(	MM_P_03_navs.store_int, SYNC_ALL) 
  494. 	marker_add(	MM_P_03_navs.store_int, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  495. 	 
  496. 	-- tell player to go back to the store to lower notoriety 
  497. 	objective_text( 0, "MM03_OBJ_CLEAR_NOTORIETY", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  498. 	 
  499. 	MMP03_PLAY_CONVO_THREAD = thread_new("mm_p_03_play_convo_thread", MM_P_03_convo.notoriety)	 
  500. 	 
  501. 	tutorial_unlock( "notoriety_decreases", true ) 
  502. 	 
  503. 	repeat thread_yield() until ( get_dist_closest_player_to_object( MM_P_03_navs.store_int ) < 3 ) 
  504. 	 
  505. 	mission_waypoint_remove() 
  506. 	marker_remove( MM_P_03_navs.store_int, SYNC_ALL ) 
  507. 	 
  508. 	if tutorial_visible() == true then 
  509. 		tutorial_stop_current()  
  510. 	end 
  511. 	 
  512. 	tutorial_start("notoriety_decreases", 0, true, true) 
  513. 	 
  514. 	notoriety_set_max( "morningstar", 0 ) 
  515. 	notoriety_set( "morningstar", 0 ) 
  516. 	notoriety_set_max("police", 0)	 
  517. 	notoriety_set("police", 0)	 
  518. 	 
  519. 	while tutorial_visible() == true do 
  520. 		thread_yield() 
  521. 	end 
  522. 	 
  523. 	delay(3) 
  524. 	 
  525. end 
  526.  
  527. -- *************************************************** 
  528. -- mm_p_03_run Helper Functions 
  529. -- *************************************************** 
  530. function mm_p_03_pierce_dead() 
  531. 	mission_end_failure( "mm_p_03", PIERCE_DEAD ) 
  532. end 
  533.  
  534. function mm_p_03_pierce_abandoned() 
  535. 	mission_end_failure( "mm_p_03", PIERCE_ABANDONDED ) 
  536. end 
  537.  
  538. function mm_p_03_spawn_watcher_thread() 
  539.  
  540. 	if PIERCE_WATCHER_THREAD == INVALID_THREAD_HANDLE then 
  541. 		PIERCE_WATCHER_THREAD = thread_new( "mm_p_03_pierce_in_party" ) 
  542. 	end 
  543. end 
  544.  
  545. function mm_p_03_spawn_initial() 
  546. 	-- Spawn courtesy vehicle 
  547. 	if not group_is_loaded(MM_P_03_group.vehicles.name) then 
  548. 		group_create(MM_P_03_group.vehicles.name, true) 
  549. 	end 
  550. 	--release_to_world(MM_P_03_group.vehicles.name) 
  551.  
  552. 	group_create( MM_P_03_group.npcs.name, true ) --create the NPC group 
  553. 	--teleport_coop(MM_P_03_checkpoint.start.nav1, MM_P_03_checkpoint.start.nav2, true) 
  554.  
  555. 	on_death( "mm_p_03_pierce_dead", MM_P_03_group.npcs.pierce ) --callback for pierce dying 
  556. 	on_dismiss( "mm_p_03_pierce_abandoned", MM_P_03_group.npcs.pierce ) --abandoning  pierce makes him sadface 
  557. 	 
  558. 	party_add( MM_P_03_group.npcs.pierce ) 
  559. 	follower_set_can_abandon(MM_P_03_group.npcs.pierce, true) 
  560.  
  561. 	mm_p_03_spawn_watcher_thread() 
  562. end 
  563.  
  564.  
  565. function mm_p_03_unregister_trigger( flashpoint_num ) 
  566. 	 
  567. 	if MM_P_03_NAG_ACTIVE == true then 
  568. 		--hud_critical_timer_stop( 1 ) 
  569. 		MM_P_03_NAG_ACTIVE = false 
  570. 	end 
  571. 	 
  572. 	if ( flashpoint_num == 1 ) then 
  573. 			on_trigger_exit( "", MM_P_03_trigger.fp1.name ) 
  574. 			on_trigger( "", MM_P_03_trigger.fp1.name ) 
  575. 			trigger_enable( MM_P_03_trigger.fp1.name, false )	 
  576. 		else 
  577. 			on_trigger_exit( "", MM_P_03_trigger.fp2.name ) 
  578. 			on_trigger( "", MM_P_03_trigger.fp2.name ) 
  579. 			trigger_enable( MM_P_03_trigger.fp2.name, false ) 
  580. 	end 
  581. end 
  582.  
  583.  
  584. function mm_p_03_register_trigger( flashpoint_num ) 
  585. 	if ( flashpoint_num == 1 ) then 
  586. 			trigger_enable( MM_P_03_trigger.fp1.name, true ) 
  587. 			on_trigger( "mm_p_03_entered_fp_area_trigger", MM_P_03_trigger.fp1.name ) 
  588. 			--on_trigger_exit( "mm_p_03_left_fp_area_trigger", MM_P_03_trigger.fp.name ) --move to the on_trigger callback 
  589. 		else 
  590. 			trigger_enable( MM_P_03_trigger.fp2.name, true) 
  591. 			on_trigger( "mm_p_03_entered_fp_area_trigger", MM_P_03_trigger.fp2.name ) 
  592. 			--on_trigger_exit( "mm_p_03_left_fp_area_trigger", MM_P_03_trigger.fp.name ) 
  593. 	end 
  594. end 
  595.  
  596. -- *************************************************** 
  597. -- mm_p_03_initialize Helper Functions 
  598. -- *************************************************** 
  599.  
  600. -- Handle any common initialization 
  601. -- 
  602. function mm_p_03_initialize_common() 
  603. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  604.  
  605. end 
  606.  
  607. -- Checkpoint specific initialization 
  608. -- 
  609. -- checkpoint:		The checkpoint to be initialized 
  610. function mm_p_03_initialize_checkpoint(checkpoint) 
  611.  
  612. 	notoriety_set_max("morningstar", 3)	 
  613. 	notoriety_set_max("police", 1)	 
  614. 	flashpoints_enable( false ) 
  615. 		 
  616. 	if( checkpoint == MM_P_03_checkpoint.start.name ) then 
  617. 		mm_p_03_spawn_initial() 
  618. 	end 
  619. 	 
  620. 	if( checkpoint == MM_P_03_checkpoint.flashpoint.name ) then 
  621. 		if not group_is_loaded( MM_P_03_group.npcs.name ) then --see if the NPC group is loaded 
  622. 			group_create( MM_P_03_group.npcs.name, true ) --create the NPC group 
  623. 			 
  624. 			teleport_coop(MM_P_03_checkpoint.flashpoint.nav1, MM_P_03_checkpoint.flashpoint.nav2, true) 
  625. 			teleport( MM_P_03_group.npcs.pierce, MM_P_03_checkpoint.flashpoint.nav3, true )  
  626.  
  627. 			on_death( "mm_p_03_pierce_dead", MM_P_03_group.npcs.pierce ) --callback for pierce dying 
  628. 			on_dismiss( "mm_p_03_pierce_abandoned", MM_P_03_group.npcs.pierce ) --abandoning  pierce makes him sadface 
  629.  
  630. 			party_add( MM_P_03_group.npcs.pierce ) 
  631. 			follower_set_can_abandon(MM_P_03_group.npcs.pierce, true) 
  632.  
  633. 			mm_p_03_spawn_watcher_thread() 
  634. 			teleport_coop( MM_P_03_navs.cp_start.player_local, MM_P_03_navs.cp_start.player_remote, true ) 
  635. 		end 
  636. 	end 
  637.  
  638. end 
  639.  
  640.  
  641. -- *************************************************** 
  642. -- Miscellaneous mm_p_03 Helper Funcrtions 
  643. -- *************************************************** 
  644. function mm_p_03_clear_trigger(trigger) 
  645. 	on_trigger( "", trigger ) 
  646. 	trigger_enable( trigger, false ) 
  647. 	marker_remove_trigger( trigger, SYNC_ALL ) 
  648. end 
  649.  
  650. -- ************************* 
  651. -- 
  652. -- Callback functions 
  653. -- 
  654. -- ************************* 
  655.  
  656. function mm_p_03_sp_trigger_cb() 
  657. 	-- clear the trigger, waypoint, and objective 
  658. 	mm_p_03_clear_trigger( MM_P_03_trigger.sp.name ) 
  659. 	waypoint_remove() 
  660. 	marker_remove( MM_P_03_navs.sf, SYNC_ALL ) 
  661. 	objective_text_clear(0) 
  662.  
  663. 	MM_P_03_trigger.sp.hit = true 
  664.  
  665. 	--[[ TODO: add functionality for purchasing building/store ]]-- 
  666. 	-- Hit the trigger at the purchase point, trigger purchase screen 
  667. 	--message( "Bought a building" ) -- fake buying a building 
  668. 	delay( 3.0 ) 
  669. 	--[[ /TODO ]]-- 
  670.  
  671. 	-- objective complete, update checkpoint and move on to flashpoint 
  672. --	current_checkpoint = MM_P_03_checkpoint.flashpoint.name 
  673. --	mission_set_checkpoint( current_checkpoint, true ) 
  674. end 
  675.  
  676. function mm_p_03_entered_fp_area_trigger( player_name, trigger_name ) 
  677. 	 
  678. 	--message("inside fp trigger", 2) 
  679. 	 
  680. 	--stop nagging the player 
  681. 	if MM_P_03_NAG_ACTIVE == true then 
  682. 		--hud_critical_timer_stop( 1 ) 
  683. 		if player_name == LOCAL_PLAYER then 
  684. 			mission_help_clear(SYNC_LOCAL)  
  685. 		else 
  686. 			mission_help_clear(SYNC_REMOTE) 
  687. 		end 
  688. 	end 
  689. 	 
  690. 	MM_P_03_NAG_ACTIVE = false 
  691. 	 
  692. 	on_trigger_exit( "mm_p_03_left_fp_area_trigger", trigger_name ) 
  693. end 
  694.  
  695. function mm_p_03_left_fp_area_trigger( player_name, trigger_name ) 
  696.  
  697. 	MM_P_03_NAG_ACTIVE = true 
  698. 	 
  699. 	--message("left the trigger, you're gonna fail!!", 8) 
  700. 	 
  701. 	--nag the player that he's going to fail the flashpoint 
  702. 	local sync = SYNC_LOCAL 
  703. 	if ( player_name == REMOTE_PLAYER ) then 
  704. 		sync = SYNC_REMOTE 
  705. 	end 
  706.  
  707. 	--hud_critical_timer_set( 20000, MM_P_03_FP_NAG, "mm_p_03_fail_fp", sync )  --FAIL_TIMER_INDICES[player_name] 
  708. 	mission_help_table_nag( MM_P_03_FP_NAG, "", "", sync ) 
  709. 	--mission_help_table( MM_P_03_FP_NAG, nil, nil, sync ) 
  710. 	 
  711. 	-- Player is no longer in this trigger, so register a new on_trigger callback 
  712. 	on_trigger( "mm_p_03_entered_fp_area_trigger", trigger_name ) 
  713. end 
  714.  
  715. function mm_p_03_fail_fp() 
  716. 	mission_end_failure("mm_p_03", FAIL_FP ) --"You failed the flashpoint") 
  717. end 
  718.  
  719. -- ************************* 
  720. -- 
  721. -- Thread functions 
  722. -- 
  723. -- ************************* 
  724. function mm_p_03_pierce_in_party() 
  725.  
  726. 	 while npc_is_in_party( MM_P_03_group.npcs.pierce ) == true do 
  727. 		thread_yield() 
  728. 	 end 
  729.  
  730. end 
  731.  
  732. function mm_p_03_play_convo_thread(convo) 
  733. 	convo.handle = audio_conversation_load(convo.name) 
  734. 	 
  735. 	while mm_p_03_convo_playing == true do 
  736. 		thread_yield() 
  737. 	end 
  738. 	 
  739. 	mm_p_03_convo_playing = true 
  740. 	 
  741. 	audio_conversation_play(convo.handle) 
  742. 	audio_conversation_wait_for_end(convo.handle) 
  743. 	audio_conversation_end(convo.handle) 
  744. 	 
  745. 	mm_p_03_convo_playing = false 
  746. 	--convo.handle = INVALID_CONVERSATION_HANDLE 
  747. end 
  748.