./mm_p_06.lua

  1. --[[ 
  2. 	mm_p_06.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 9-2-2010 
  5. 	AUTHOR:	Jimmy Cross 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10.  
  11. -- Tweakable Parameters -- 
  12. 	MM_P_06_PIERCE_TRIGGER_DIST = 4.0 -- distance at which to start the Zscene ("close", by definition of the spec) 
  13. 	MM_P_06_PIERCE_SPAWN_DIST = 200.0 
  14. 	 
  15. -- Groups -- 
  16.  
  17. 	MM_P_06_group = { 
  18.  
  19. 	} 
  20.  
  21. -- Navpoints -- 
  22. 	MM_P_06_navs = { 
  23. 		hq = "MM_P_06_Nav_Saints_HQ", 
  24. 		cp_start = { "local_player", "remote_player"	} 
  25. 	} 
  26.  
  27. -- Triggers -- 
  28.  
  29. 		 
  30. -- Characters --. 
  31. 	MM_P_06_char = { 
  32. 		--pierce = "NPC Pierce" 
  33. 	} 
  34.  
  35. -- Vehicles -- 
  36.  
  37. -- Mesh Movers -- 
  38.  
  39. -- Text -- 
  40.  
  41. -- Threads -- 
  42.  
  43. -- Checkpoints -- 
  44. 	MM_P_06_checkpoint = { 
  45. 		start = { 
  46. 			name = MISSION_START_CHECKPOINT, 
  47. 			nav1 = "start_nav 001", 
  48. 			nav2 = "start_nav 002" 
  49. 		} 
  50. 	} 
  51. 	 
  52. -- Cutscenes -- 
  53. MM_P_06_cutscene = { 
  54. 		pierce_outro = "P_Z02" 
  55. 	} 
  56. 	CUTSCENE_MISSION_INTRO = "" 
  57. 	CUTSCENE_MISSION_OUTRO = "" 
  58.  
  59. -- Conversations -- 
  60. 	MM_P_06_convo = { 
  61. 	--[[ 
  62. 		mission_start = { 
  63. 			name = "mm_p_06_convo_1", 
  64. 			handle = INVALID_CONVERSATION_HANDLE 
  65. 		} 
  66. 	]]-- 
  67. 	} 
  68. 		 
  69. -- Other -- 
  70.  
  71.  
  72. -- ************************* 
  73. -- 
  74. -- Standard functions 
  75. -- 
  76. -- ************************* 
  77.  
  78. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  79. -- at the specified checkpoint. 
  80. -- CALLED FROM CODE 
  81. -- 
  82. -- checkpoint:	The checkpoint the mission should begin at 
  83. -- is_restart:	TRUE if the mission is restarting, FALSE otherwise 
  84. -- 
  85. function mm_p_06_start(checkpoint, is_restart) 
  86. 	-- Check if this mission starting from the beginning 
  87. 	if (checkpoint == MM_P_06_checkpoint.start.name) then 
  88. 		if (is_restart == false) then 
  89. 			-- First time playing mission 
  90. 			 
  91. 			-- Play an intro cutscene??? 
  92. 			zscene_prep( MM_P_06_cutscene.pierce_outro )  
  93.  
  94. 			while( not zscene_is_loaded(MM_P_06_cutscene.pierce_outro) ) do 
  95. 				thread_yield() 
  96. 			end 
  97. 			 
  98. 			--cutscene_in() 
  99. 			cutscene_play( MM_P_06_cutscene.pierce_outro, nil, MM_P_06_navs.cp_start, false ) 
  100. 		end 
  101.  
  102. 		fade_out(0) 
  103. 	end 
  104.  
  105. 	-- Handle mission initialization for the current checkpoint 
  106. 	mm_p_06_initialize(checkpoint) 
  107.  
  108. 	-- Run the mission from the current checkpoint 
  109. 	mm_p_06_run(checkpoint) 
  110. 	 
  111. end 
  112.  
  113. -- This is the primary function responsible for running the entire mission from start to finish. 
  114. -- 
  115. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  116. -- 
  117. function mm_p_06_run(first_checkpoint) 
  118. 	local current_checkpoint = first_checkpoint 
  119.  
  120. 	-- Run the mission from the beginning 
  121. 	if( current_checkpoint == MM_P_06_checkpoint.start.name ) then 
  122. 		-- conversation with Pierce on phone, tells the Player to meet him and they'll talk about how to hurt the Syndicate 
  123. 		-- audio_conversation_play( MM_P_06_convo.mission_start.handle ) 
  124.  
  125. 		--cutscene_out() 
  126. 		--[[ 
  127. 		-- Player(s) look cool GO! 
  128. 		local anim_name = "M06 Player Mission Start" 
  129. 		local morph_name = "M06 Player Mission Start" 
  130. 		local force_play = false 
  131. 		local stand_still = false 
  132. 		local zero_movement = false 
  133. 		action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  134. 		player_script_controlled_clear(LOCAL_PLAYER)	-- let player escape this animation 
  135. 		if (coop_is_active()) then 
  136. 			action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  137. 			player_script_controlled_clear(REMOTE_PLAYER)	-- let player escape this animation 
  138. 		end 
  139. 		 
  140. 		delay(3) 
  141. 		--while action_play_is_finished( LOCAL_PLAYER, 1.5 ) == false or action_play_is_finished( REMOTE_PLAYER, 1.5 ) == false do 
  142. 			--thread_yield() 
  143. 		--end 
  144. 		]]-- 
  145.  
  146. 		mission_unlock("_A_IF_DT_01") 
  147. 		mission_unlock("_A_HA_DT_01") 
  148.  
  149. 		 
  150. 		mission_set_completed("mm_p_06") 
  151. 		 
  152. 		mission_end_silently(false)	 
  153. 		mission_autosave() 
  154. 	end	 
  155. end 
  156.  
  157. -- This is the primary function responsible for cleaning up the entire mission 
  158. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  159. -- 
  160. function mm_p_06_cleanup() 
  161. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  162. 	--group_destroy( MM_P_06_group.npcs.name ) 
  163. end 
  164.  
  165. -- Called when the mission has ended with success 
  166. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  167. -- 
  168. function mm_p_06_success() 
  169. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  170. 	 
  171. end 
  172.  
  173.  
  174. -- ************************* 
  175. -- 
  176. -- Local functions 
  177. -- 
  178. -- ************************* 
  179.  
  180. -- Initialize the mission for the specified checkpoint 
  181. -- 
  182. -- checkpoint:		Checkpoint to initialize the mission to 
  183. -- 
  184. function mm_p_06_initialize(checkpoint) 
  185. 	-- Make sure the screen is completly faded out 
  186. 	mission_start_fade_out(0.0) 
  187.  
  188. 	-- Set the mission author 
  189. 	set_mission_author("Jimmy Cross") 
  190.  
  191. 	-- Common initialization 
  192. 	mm_p_06_initialize_common() 
  193.  
  194. 	-- Checkpoint specific initialization 
  195. 	mm_p_06_initialize_checkpoint(checkpoint) 
  196.  
  197. 	-- Start fading in  
  198. 	mission_start_fade_in() 
  199.  
  200. end 
  201.  
  202. -- Getting the player to the Saints HQ 
  203. -- 
  204. -- 
  205. function mm_p_06_go_to_saints_hq() 
  206. 	-- set GPS to Saints HQ 
  207. 	mission_waypoint_add( MM_P_06_navs.hq ) -- add GPS marker at Saints HQ 
  208. 	marker_add( MM_P_06_navs.hq, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION ) 
  209. 	objective_text( 0, "mm_p_06_obj_meet_pierce", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  210. 	 
  211. 	--don't spawn Pierce until the player is close 
  212. 	--repeat thread_yield() until ( get_dist_closest_player_to_object( MM_P_06_group.npcs.pierce ) < MM_P_06_PIERCE_SPAWN_DIST ) 
  213. 	--group_create( MM_P_06_group.npcs.name, true ) --create the NPC group 
  214.  
  215. 	--Wait for one of the players to get close to Pierce 
  216. 	repeat thread_yield() until ( get_dist_closest_player_to_object( MM_P_06_navs.hq ) < MM_P_06_PIERCE_TRIGGER_DIST ) 
  217. 	 
  218. 	mission_waypoint_remove(SYNC_ALL) 
  219. 	marker_remove(MM_P_06_navs.hq, SYNC_ALL) 
  220. 	 
  221. 	-- trigger zscene with Pierce explaining city takeover 
  222. 	if( MM_P_06_cutscene.pierce_outro ~= "" ) then 
  223. 			--cutscene_in() 
  224. 			--fade_out( 0.5 ) 
  225. 			--fade_out_block() 
  226. 			cutscene_in() 
  227. 			delay( 2 ) 
  228. 			--bink_play( MM_P_06_cutscene.pierce_outro ) 
  229. 			cutscene_play( MM_P_06_cutscene.pierce_outro,  nil, MM_P_06_navs.cp_start, false ) 
  230. 			--cutscene_play( MM_P_06_cutscene.pierce_outro ) 
  231. 			--teleport_coop( MM_P_06_navs.cp_start.player_local, MM_P_06_navs.cp_start.player_remote, true ) 
  232. 			cutscene_out() 
  233. 			--fade_in( 0.5 ) 
  234. 			--fade_in_block() 
  235. 		else --just fade out and fade back 
  236. 			fade_out( 0.5 ) 
  237. 			fade_out_block() 
  238. 			 
  239. 			delay( 1.5 ) 
  240. 			 
  241. 			fade_in( 0.5 ) 
  242. 			fade_in_block() 
  243. 		end	 
  244. end 
  245.  
  246. -- *************************************************** 
  247. -- mm_p_06_run Helper Functions 
  248. -- *************************************************** 
  249.  
  250.  
  251. -- *************************************************** 
  252. -- mm_p_06_initialize Helper Functions 
  253. -- *************************************************** 
  254.  
  255. -- Handle any common initialization 
  256. -- 
  257. function mm_p_06_initialize_common() 
  258. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  259. 	 
  260. end 
  261.  
  262. -- Checkpoint specific initialization 
  263. -- 
  264. -- checkpoint:		The checkpoint to be initialized 
  265. function mm_p_06_initialize_checkpoint(checkpoint) 
  266.  
  267. 	if (checkpoint == MM_P_06_checkpoint.start.name) then 
  268. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  269.  
  270. 	end 
  271.  
  272. end 
  273.  
  274.  
  275. -- *************************************************** 
  276. -- Miscellaneous mm_p_06 Helper Funcrtions 
  277. -- *************************************************** 
  278.  
  279.  
  280. -- ************************* 
  281. -- 
  282. -- Callback functions 
  283. -- 
  284. -- ************************* 
  285.  
  286.  
  287. -- ************************* 
  288. -- 
  289. -- Thread functions 
  290. -- 
  291. -- ************************* 
  292.  
  293.