./mm_p_01.lua

  1. --[[ 
  2. 	mm_p_01.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.  
  13. -- Groups -- 
  14.  
  15. 	MM_P_01_group = { 
  16. 		helicopter = "mm_p_01_heli" 
  17. 	} 
  18.  
  19. -- Navpoints -- 
  20. 	MM_P_01_navs = { 
  21. 		hq = "MM_P_01_Nav_Saints_HQ", 
  22. 		cp_start = { "local_tele", "remote_tele" } 
  23. 	} 
  24.  
  25. -- Triggers -- 
  26. 	MM_P_01_trigger = { 
  27.  
  28. 	--[[ 
  29. 		hq = { 
  30. 			name = "HQ_trigger", 
  31. 			hit = false 
  32. 		} 
  33. 		]]-- 
  34. 	} 
  35. 		 
  36. -- Characters -- 
  37. MM_P_01_DRIVER = "npc_Heli_Pilot" 
  38.  
  39. -- Vehicles -- 
  40. MM_P_01_HELICOPTER = "veh_Player_Heli" 
  41.  
  42. -- Mesh Movers -- 
  43.  
  44. -- Text -- 
  45.  
  46. -- Threads -- 
  47. MM_P_01_HELI_FLIGHT = INVALID_THREAD_HANDLE 
  48.  
  49. -- Checkpoints -- 
  50. 	MM_P_01_checkpoint = { 
  51. 		start = { 
  52. 			name = MISSION_START_CHECKPOINT, 
  53. 			nav1 = "start_nav 001", 
  54. 			nav2 = "start_nav 002" 
  55. 		} 
  56. 	} 
  57. 	 
  58. -- Cutscenes -- 
  59. MM_P_01_cutscene = "P_Z01" 
  60.  
  61. -- Other -- 
  62. local MM_P_01_HELI_PATH = "heli_path" 
  63. local MM_P_01_HELI_SPEED = 35 
  64. local MM_P_01_HELI_MAX_BANK_ANGLE = 12 
  65. local mission_success = false 
  66.  
  67. -- ************************* 
  68. -- 
  69. -- Standard functions 
  70. -- 
  71. -- ************************* 
  72.  
  73. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  74. -- at the specified checkpoint. 
  75. -- CALLED FROM CODE 
  76. -- 
  77. -- checkpoint:	The checkpoint the mission should begin at 
  78. -- is_restart:	TRUE if the mission is restarting, FALSE otherwise 
  79. -- 
  80. function mm_p_01_start(checkpoint, is_restart) 
  81. 	--zscene_prep( MM_P_01_cutscene ) 
  82. 	 
  83. 	if( MM_P_01_cutscene ~= "" ) then 
  84. 		--cutscene_in() 
  85. 		zscene_prep( MM_P_01_cutscene )  
  86. 		while( not zscene_is_loaded(MM_P_01_cutscene) ) do 
  87. 				thread_yield() 
  88. 		end 
  89. 		cutscene_play( MM_P_01_cutscene, nil, MM_P_01_navs.cp_start, false )  
  90. 		--cutscene_out() 
  91. 	end 
  92.  
  93. 	-- Handle mission initialization for the current checkpoint 
  94. 	mm_p_01_initialize(checkpoint) 
  95.  
  96. 	-- Run the mission from the current checkpoint 
  97. 	mm_p_01_run(checkpoint) 
  98. 	 
  99. end 
  100.  
  101. -- This is the primary function responsible for running the entire mission from start to finish. 
  102. -- 
  103. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  104. -- 
  105. function mm_p_01_run(first_checkpoint) 
  106. 	local current_checkpoint = first_checkpoint 
  107.  
  108. 	-- Run the mission from the beginning 
  109. 	if( current_checkpoint == MM_P_01_checkpoint.start.name ) then 
  110. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  111. 		 
  112. 		inv_weapon_add_temporary( LOCAL_PLAYER, "Explosive-RocketLauncher" ) 
  113. 		if coop_is_active() then 
  114. 			inv_weapon_add_temporary( REMOTE_PLAYER, "Explosive-RocketLauncher" ) 
  115. 		end 
  116. 		 
  117. 		inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_EXPLOSIVE, true, SYNC_ALL ) 
  118. 		 
  119. 		vehicle_enter_teleport( MM_P_01_DRIVER, MM_P_01_HELICOPTER, 0, true )  
  120. 		vehicle_enter_teleport( LOCAL_PLAYER, MM_P_01_HELICOPTER, 2, true )  
  121. 		set_player_can_enter_exit_vehicles( LOCAL_PLAYER, false ) 
  122.  
  123. 		if coop_is_active() then 
  124. 			vehicle_enter_teleport( REMOTE_PLAYER, MM_P_01_HELICOPTER, 3, true ) 
  125. 			set_player_can_enter_exit_vehicles( REMOTE_PLAYER, false ) 
  126. 		end 
  127. 		 
  128. 		-- Start fading in  
  129. 		mission_start_fade_in() 
  130. 		 
  131. 		delay(1) 
  132. 		 
  133. 		mission_set_cancel_warp_location( "local_player", "remote_player" ) 
  134. 		 
  135. 		marker_add( MM_P_01_navs.hq, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  136. 		objective_text( 0, "MM01_OBJ_GOTO_GA", nil, nil , SYNC_ALL, OI_ASSET_LOCATION ) 
  137. 		 
  138. 		if MM_P_01_HELI_FLIGHT == INVALID_THREAD_HANDLE then 
  139. 			MM_P_01_HELI_FLIGHT = thread_new("mm_p_01_heli_flight") 
  140. 		end	 
  141.  
  142. 		delay(4.5) 
  143. 		audio_persona_load_2d("Pierce") 
  144. 		local mission_convo_handle = audio_conversation_load("mm_p_01_ga_drive_start") --("MM_P_01_GA_Drive_Start")	 
  145. 		audio_conversation_play( mission_convo_handle ) 
  146. 		 
  147. 		audio_conversation_wait_for_end( mission_convo_handle ) 
  148. 		audio_conversation_end( mission_convo_handle ) 
  149. 		 
  150. 		delay(.5) 
  151. 		mission_success = true 
  152. 		 
  153. 		fade_out(0) 
  154. 		fade_out_block() 
  155.  
  156. 		-- Delay to hopefully let the client catch up 
  157. 		delay(1) 
  158.  
  159. 		-- Clear the cancel warps, so that we don't warp an extra time before starting the activity 
  160. 		mission_set_cancel_warp_location() 
  161.  
  162. 		mission_end_to_activity("mm_p_01", "_A_GA_DT_03") 
  163. 	end	 
  164. end 
  165.  
  166. -- This is the primary function responsible for cleaning up the entire mission 
  167. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  168. -- 
  169. function mm_p_01_cleanup() 
  170. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  171.  
  172. 	objective_text_clear(0) 
  173. 	marker_remove( MM_P_01_navs.hq, SYNC_ALL ) 
  174. 	inv_weapon_disable_all_slots( false, SYNC_ALL ) 
  175. 	 
  176. 	inv_weapon_remove_temporary( LOCAL_PLAYER, "Explosive-RocketLauncher" ) 
  177. 	if coop_is_active() then 
  178. 		inv_weapon_remove_temporary( REMOTE_PLAYER, "Explosive-RocketLauncher" ) 
  179. 	end 
  180. 	 
  181. 	inv_weapon_disable_all_slots( false, SYNC_ALL ) 
  182. 	 
  183. 	if MM_P_01_HELI_FLIGHT ~= INVALID_THREAD_HANDLE then 
  184. 		thread_kill( MM_P_01_HELI_FLIGHT ) 
  185. 		MM_P_01_HELI_FLIGHT = thread_new("mm_p_01_heli_flight") 
  186. 	end	 
  187. 	 
  188. 	set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true ) 
  189. 	if coop_is_active() then 
  190. 		set_player_can_enter_exit_vehicles( REMOTE_PLAYER, true ) 
  191. 	end 
  192. 	 
  193. 	group_destroy( MM_P_01_group.helicopter ) 
  194. end 
  195.  
  196. -- Called when the mission has ended with success 
  197. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  198. -- 
  199. function mm_p_01_success() 
  200. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  201. 	 
  202. end 
  203.  
  204.  
  205. -- ************************* 
  206. -- 
  207. -- Local functions 
  208. -- 
  209. -- ************************* 
  210.  
  211. -- Initialize the mission for the specified checkpoint 
  212. -- 
  213. -- checkpoint:		Checkpoint to initialize the mission to 
  214. -- 
  215. function mm_p_01_initialize(checkpoint) 
  216. 	-- Make sure the screen is completly faded out 
  217. 	mission_start_fade_out(0.0) 
  218.  
  219. 	-- Set the mission author 
  220. 	set_mission_author("Jimmy Cross") 
  221.  
  222. 	-- Common initialization 
  223. 	mm_p_01_initialize_common() 
  224.  
  225. 	-- Checkpoint specific initialization 
  226. 	mm_p_01_initialize_checkpoint(checkpoint) 
  227.  
  228. end 
  229.  
  230. -- *************************************************** 
  231. -- mm_p_01_run Helper Functions 
  232. -- *************************************************** 
  233.  
  234.  
  235. -- *************************************************** 
  236. -- mm_p_01_initialize Helper Functions 
  237. -- *************************************************** 
  238.  
  239. -- Handle any common initialization 
  240. -- 
  241. function mm_p_01_initialize_common() 
  242. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  243. 	 
  244. end 
  245.  
  246. -- Checkpoint specific initialization 
  247. -- 
  248. -- checkpoint:		The checkpoint to be initialized 
  249. function mm_p_01_initialize_checkpoint(checkpoint) 
  250.  
  251. 	if (checkpoint == MM_P_01_checkpoint.start.name) then 
  252. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  253. 		group_create( MM_P_01_group.helicopter, true ) 
  254. 	end 
  255.  
  256. end 
  257.  
  258.  
  259. -- *************************************************** 
  260. -- Miscellaneous mm_p_01 Helper Funcrtions 
  261. -- *************************************************** 
  262.  
  263.  
  264. -- ************************* 
  265. -- 
  266. -- Callback functions 
  267. -- 
  268. -- ************************* 
  269.  
  270.  
  271. -- ************************* 
  272. -- 
  273. -- Thread functions 
  274. -- 
  275. -- ************************* 
  276. function mm_p_01_heli_flight() 
  277. 	helicopter_set_max_bank_angle( MM_P_01_HELICOPTER, MM_P_01_HELI_MAX_BANK_ANGLE )	 
  278. 	helicopter_fly_to(MM_P_01_HELICOPTER, MM_P_01_HELI_SPEED, MM_P_01_HELI_PATH) 
  279. end