./mm_p_02.lua

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