./mm_p_05.lua

  1.  
  2. --[[ 
  3. 	mm_p_05.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.  
  14. -- Groups -- 
  15.  
  16. 	MM_P_05_group = { 
  17. 		--[[ = { 
  18. 			name = "name from editor", 
  19. 			members = { "optional", "list", "of", "members" }, 
  20. 		}, 
  21. 		 
  22. 		 = { 
  23. 			name = "next group name" 
  24. 		},]] 
  25. 	} 
  26.  
  27. -- Navpoints -- 
  28.  
  29. -- Triggers -- 
  30. 	MM_P_05_trigger = { 
  31. 		rm = { 
  32. 			name = "RM_trigger", 
  33. 			hit = false 
  34. 		} 
  35. 	} 
  36.  
  37. -- Characters -- 
  38.  
  39. -- Vehicles -- 
  40.  
  41. -- Mesh Movers -- 
  42.  
  43. -- Text -- 
  44.  
  45. -- Threads -- 
  46.  
  47. -- Checkpoints -- 
  48. 	MM_P_05_checkpoint = { 
  49. 		start = { 
  50. 			name = MISSION_START_CHECKPOINT, 
  51. 			nav1 = "start_nav 001", 
  52. 			nav2 = "start_nav 002" 
  53. 		} 
  54. 	} 
  55. 	 
  56. -- Cutscenes -- 
  57. 	CUTSCENE_MISSION_INTRO = "" 
  58. 	CUTSCENE_MISSION_OUTRO = "" 
  59.  
  60. -- Conversations -- 
  61. 		 
  62. -- Other -- 
  63.  
  64.  
  65. -- ************************* 
  66. -- 
  67. -- Standard functions 
  68. -- 
  69. -- ************************* 
  70.  
  71. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  72. -- at the specified checkpoint. 
  73. -- CALLED FROM CODE 
  74. -- 
  75. -- checkpoint:	The checkpoint the mission should begin at 
  76. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  77. -- 
  78. function mm_p_05_start(checkpoint, is_restart) 
  79. 	-- Check if this mission starting from the beginning 
  80. 	if (checkpoint == MM_P_05_checkpoint.start.name) then 
  81. 		if (is_restart == false) then 
  82. 			-- First time playing mission 
  83. 			 
  84. 			-- Play an intro cutscene??? 
  85. 			if (CUTSCENE_MISSION_INTRO ~= "") then 
  86. 				cutscene_play(CUTSCENE_MISSION_INTRO) 
  87. 			end 
  88. 		end 
  89. 		fade_out(0) 
  90. 		fade_out_block() 
  91. 		mission_end_to_activity("mm_p_05", "_A_RM_DT_01")		 
  92. 	end 
  93.  
  94.  
  95. 	-- Handle mission initialization for the current checkpoint 
  96. 	mm_p_05_initialize(checkpoint) 
  97.  
  98. 	-- Run the mission from the current checkpoint 
  99. 	mm_p_05_run(checkpoint) 
  100. 	 
  101. end 
  102.  
  103. -- This is the primary function responsible for running the entire mission from start to finish. 
  104. -- 
  105. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  106. -- 
  107. function mm_p_05_run(first_checkpoint) 
  108. 	local current_checkpoint = first_checkpoint 
  109.  
  110. 	-- Run the mission from the beginning 
  111. 	if( current_checkpoint == MM_P_05_checkpoint.start.name ) then 
  112. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  113. 		 
  114. 		mission_end_to_activity("mm_p_05", "_A_RM_DT_01") 
  115. 		--[[ 
  116. 		 
  117. 		trigger_enable( MM_P_05_trigger.rm.name, true ) 
  118. 		-- set GPS to Running man instance #1 
  119. 		waypoint_add( MM_P_05_trigger.rm.name ) -- add GPS marker at RM instance #1 
  120. 		marker_add_trigger( MM_P_05_trigger.rm.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  121. 		 
  122. 		on_trigger( "mm_p_05_rm_trigger_cb", MM_P_05_trigger.rm.name ) -- register the callback for the trigger 
  123. 		objective_text( 0, "mm_p_05_obj_goto_rm", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) -- tell the player to go to the marker 
  124. 		 
  125. 		while not MM_P_05_trigger.rm.hit do -- wait for the player to hit the trigger at the RM start point 
  126. 			thread_yield() 
  127. 		end 
  128. 		 
  129. 		-- Call mission success?? 
  130. 		mission_end_success( "mm_p_05", CUTSCENE_MISSION_OUTRO ) 
  131. 		 
  132. 		-- tell Player new mission available 
  133. 		message( "!!A new mission is available", 6.0 )	 
  134. 		-- mission_unlock( "next_mission" ) -- unlock the next mission 
  135. 		]]-- 
  136. 	end 
  137. end 
  138.  
  139. -- This is the primary function responsible for cleaning up the entire mission 
  140. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  141. -- 
  142. function mm_p_05_cleanup() 
  143. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  144. 	mm_p_05_clear_trigger( MM_P_05_trigger.rm.name ) 
  145. end 
  146.  
  147. -- Called when the mission has ended with success 
  148. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  149. -- 
  150. function mm_p_05_success() 
  151. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  152. 	 
  153. end 
  154.  
  155.  
  156. -- ************************* 
  157. -- 
  158. -- Local functions 
  159. -- 
  160. -- ************************* 
  161.  
  162. -- Initialize the mission for the specified checkpoint 
  163. -- 
  164. -- checkpoint:		Checkpoint to initialize the mission to 
  165. -- 
  166. function mm_p_05_initialize(checkpoint) 
  167. 	-- Make sure the screen is completly faded out 
  168. 	mission_start_fade_out(0.0) 
  169.  
  170. 	-- Set the mission author 
  171. 	set_mission_author("Jimmy Cross") 
  172.  
  173. 	-- Common initialization 
  174. 	mm_p_05_initialize_common() 
  175.  
  176. 	-- Checkpoint specific initialization 
  177. 	mm_p_05_initialize_checkpoint(checkpoint) 
  178.  
  179. 	-- Start fading in  
  180. 	mission_start_fade_in() 
  181.  
  182. end 
  183.  
  184.  
  185. -- *************************************************** 
  186. -- mm_p_05_run Helper Functions 
  187. -- *************************************************** 
  188.  
  189.  
  190. -- *************************************************** 
  191. -- mm_p_05_initialize Helper Functions 
  192. -- *************************************************** 
  193.  
  194. -- Handle any common initialization 
  195. -- 
  196. function mm_p_05_initialize_common() 
  197. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  198. 	 
  199. end 
  200.  
  201. -- Checkpoint specific initialization 
  202. -- 
  203. -- checkpoint:		The checkpoint to be initialized 
  204. function mm_p_05_initialize_checkpoint(checkpoint) 
  205.  
  206. 	if (checkpoint == MM_P_05_checkpoint.start.name) then 
  207. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  208.  
  209. 	end 
  210.  
  211. end 
  212.  
  213.  
  214. -- *************************************************** 
  215. -- Miscellaneous mm_p_05 Helper Funcrtions 
  216. -- *************************************************** 
  217. function mm_p_05_clear_trigger(trigger) 
  218. 	on_trigger( "", trigger ) 
  219. 	trigger_enable( trigger, false ) 
  220. 	marker_remove_trigger( trigger, SYNC_ALL ) 
  221. end 
  222.  
  223. -- ************************* 
  224. -- 
  225. -- Callback functions 
  226. -- 
  227. -- ************************* 
  228.  
  229. function mm_p_05_rm_trigger_cb() 
  230. 	-- clear the trigger 
  231. 	mm_p_05_clear_trigger( MM_P_05_trigger.rm.name ) 
  232. 	waypoint_remove() 
  233. 	objective_text_clear(0) -- clear the objective text 
  234. 	MM_P_05_trigger.rm.hit = true 
  235. 	 
  236. 	-- activity start triggered 
  237. 	mission_end_to_activity("mm_p_05", "_A_RM_DT_01") 
  238. end 
  239.  
  240. -- ************************* 
  241. -- 
  242. -- Thread functions 
  243. -- 
  244. -- ************************* 
  245.  
  246.