./mm_p_04.lua

  1.  
  2. --[[ 
  3. 	mm_p_04.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_04_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_04_trigger = { 
  31. 		tm = { 
  32. 			name = "TM_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_04_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_04_start(checkpoint, is_restart) 
  79. 	-- Check if this mission starting from the beginning 
  80. 	if (checkpoint == MM_P_04_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_04", "_A_TM_DT_01")		 
  92. 	end 
  93.  
  94.  
  95. 	-- Handle mission initialization for the current checkpoint 
  96. 	--mm_p_04_initialize(checkpoint) 
  97.  
  98. 	-- Run the mission from the current checkpoint 
  99. 	--mm_p_04_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_04_run(first_checkpoint) 
  108. 	local current_checkpoint = first_checkpoint 
  109.  
  110. 	-- Run the mission from the beginning 
  111. 	if( current_checkpoint == MM_P_04_checkpoint.start.name ) then 
  112. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  113. 		 
  114. 		mission_end_to_activity("mm_p_04", "_A_TM_DT_01") 
  115. 		--[[ 
  116. 		 
  117. 		-- set GPS to Tank Mayhem instance #1 
  118. 		trigger_enable( MM_P_04_trigger.tm.name, true ) 
  119. 		waypoint_add( MM_P_04_trigger.tm.name ) -- add GPS marker at TM instance #1 
  120. 		marker_add_trigger( MM_P_04_trigger.tm.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  121. 		 
  122. 		on_trigger( "mm_p_04_tm_trigger_cb", MM_P_04_trigger.tm.name ) -- register the callback for the trigger 
  123. 		objective_text( 0, "mm_p_04_obj_goto_tm", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) -- tell the player to go to the marker 
  124.  
  125. 		while not MM_P_04_trigger.tm.hit do -- wait for the player to hit the trigger at the TM start point 
  126. 			thread_yield() 
  127. 		end 
  128.  	 
  129. 		-- Call mission success?? 
  130. 		mission_end_success( "mm_p_04", 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_04_cleanup() 
  143. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  144. 	mm_p_04_clear_trigger( MM_P_04_trigger.tm.name ) 
  145. 	waypoint_remove() 
  146. 	objective_text_clear(0) -- clear the objective text 
  147. end 
  148.  
  149. -- Called when the mission has ended with success 
  150. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  151. -- 
  152. function mm_p_04_success() 
  153. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  154. 	 
  155. end 
  156.  
  157.  
  158. -- ************************* 
  159. -- 
  160. -- Local functions 
  161. -- 
  162. -- ************************* 
  163.  
  164. -- Initialize the mission for the specified checkpoint 
  165. -- 
  166. -- checkpoint:		Checkpoint to initialize the mission to 
  167. -- 
  168. function mm_p_04_initialize(checkpoint) 
  169. 	-- Make sure the screen is completly faded out 
  170. 	mission_start_fade_out(0.0) 
  171.  
  172. 	-- Set the mission author 
  173. 	set_mission_author("Jimmy Cross") 
  174.  
  175. 	-- Common initialization 
  176. 	mm_p_04_initialize_common() 
  177.  
  178. 	-- Checkpoint specific initialization 
  179. 	mm_p_04_initialize_checkpoint(checkpoint) 
  180.  
  181. 	-- Start fading in  
  182. 	mission_start_fade_in() 
  183.  
  184. end 
  185.  
  186.  
  187. -- *************************************************** 
  188. -- mm_p_04_run Helper Functions 
  189. -- *************************************************** 
  190. function mm_p_04_clear_trigger(trigger) 
  191. 	on_trigger( "", trigger ) 
  192. 	trigger_enable( trigger, false ) 
  193. 	marker_remove_trigger( trigger, SYNC_ALL ) 
  194. end 
  195.  
  196. -- *************************************************** 
  197. -- mm_p_04_initialize Helper Functions 
  198. -- *************************************************** 
  199.  
  200. -- Handle any common initialization 
  201. -- 
  202. function mm_p_04_initialize_common() 
  203. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  204. 	 
  205. end 
  206.  
  207. -- Checkpoint specific initialization 
  208. -- 
  209. -- checkpoint:		The checkpoint to be initialized 
  210. function mm_p_04_initialize_checkpoint(checkpoint) 
  211.  
  212. 	if (checkpoint == MM_P_04_checkpoint.start.name) then 
  213. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  214.  
  215. 	end 
  216.  
  217. end 
  218.  
  219.  
  220. -- *************************************************** 
  221. -- Miscellaneous mm_p_04 Helper Funcrtions 
  222. -- *************************************************** 
  223.  
  224.  
  225. -- ************************* 
  226. -- 
  227. -- Callback functions 
  228. -- 
  229. -- ************************* 
  230. function mm_p_04_tm_trigger_cb() 
  231. 	-- clear the trigger, waypoint, and objective 
  232. 	mm_p_04_clear_trigger( MM_P_04_trigger.tm.name ) 
  233. 	waypoint_remove() 
  234. 	objective_text_clear(0) -- clear the objective text 
  235. 	 
  236. 	--[[ TODO: add functionality for silent fail, when available, and start activity ]]-- 
  237. 	-- activity start triggered 
  238. 		-- fade out, load activity 
  239. 		-- end mission somehow 
  240. 		-- Player plays activity, returns 
  241. 	--[[ /TODO ]]-- 
  242. 	 
  243. 	MM_P_04_trigger.tm.hit = true 
  244. 	objective_text_clear(0) -- clear the objective text 
  245. 	 
  246. 	mission_end_to_activity("mm_p_04", "_A_TM_DT_01") 
  247. 	 
  248. 	--[[ 
  249. 	-- "fake" the activity, for now 
  250. 	message( "Tank Mayhem activity starting now" ) 
  251. 	delay( 3.0 ) 
  252. 	message( "Tank Mayhem activity end now" ) 
  253. 	]]-- 
  254. end 
  255.  
  256. -- ************************* 
  257. -- 
  258. -- Thread functions 
  259. -- 
  260. -- ************************* 
  261.  
  262.