./mm_a_01.lua

  1.  
  2. --[[ 
  3. 	MM_A_01.lua 
  4. 	SR3 Mission Script 
  5. 	DATE: 10-28-2010 
  6. 	AUTHOR:	Jimmy Cross 
  7. ]]-- 
  8.  
  9.  
  10. -- Debug flags -- 
  11.  
  12. -- Tweakable Parameters -- 
  13.  
  14. -- Groups -- 
  15. 	MM_A_01_group = { 
  16. 		vehicles = { 
  17. 			name = "MM_A_01_VEH", 
  18. 			car = "MM_A_01_CAR" 
  19. 		} 
  20. 	} 
  21.  
  22. -- Navpoints -- 
  23. 	MM_A_01_navs = {		 
  24. 		cp_start = { "local_player", "remote_player" } 
  25. 	} 
  26. 	 
  27. -- Triggers -- 
  28. 	MM_A_01_trigger = { 
  29. 		i_f = { 
  30. 			name = "IF_trigger", 
  31. 			hit = false 
  32. 		}  
  33. 	} 
  34. 				 
  35. -- Characters -- 
  36.  
  37. -- Vehicles -- 
  38.  
  39. -- Mesh Movers -- 
  40.  
  41. -- Text -- 
  42.  
  43. -- Threads -- 
  44.  
  45. -- Checkpoints -- 
  46. 	MM_A_01_checkpoint = { 
  47. 		start = { 
  48. 			name = MISSION_START_CHECKPOINT, 
  49. 		} 
  50. 	} 
  51. 	 
  52. -- Cutscenes -- 
  53. 	MM_A_01_cutscene = { 
  54. 		angel_intro = "A_Z01" 
  55. 		--angel_intro = "" 
  56. 	} 
  57. 	CUTSCENE_MISSION_INTRO = "" 
  58. 	CUTSCENE_MISSION_OUTRO = "" 
  59.  
  60. -- Conversations -- 
  61. 	MM_A_01_convo = { 
  62. 		--[[mission_start = { 
  63. 			name = "MM_A_01_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_A_01_start(checkpoint, is_restart) 
  86. 	-- Check if this mission starting from the beginning 
  87. 	if (checkpoint == MM_A_01_checkpoint.start.name) then 
  88. 		if (is_restart == false) then 
  89. 			-- First time playing mission 
  90. 			 
  91. 			if( MM_A_01_cutscene.angel_intro ~= "" ) then 
  92. 				zscene_prep( MM_A_01_cutscene.angel_intro ) 
  93. 				--cutscene_in() 
  94. 				cutscene_play( MM_A_01_cutscene.angel_intro, nil, MM_A_01_navs.cp_start, false ) 
  95. 				--cutscene_out() 
  96. 			else 
  97. 				fade_out( 0.5 ) 
  98. 				fade_out_block() 
  99. 				 
  100. 				group_create( MM_A_01_group.npcs.name, true ) --create the NPC group 
  101. 				group_create( MM_A_01_group.vehicles.name, true ) --create the vehicles group 
  102. 				vehicle_car_alarm_enable( MM_A_01_group.vehicles.car, false ) 
  103. 				 
  104. 				delay( 1.5 ) 
  105. 				 
  106. 				fade_in( 0.5 ) 
  107. 				fade_in_block() 
  108. 			end 
  109. 		end 
  110. 		-- start activity 
  111. 		mission_end_to_activity("MM_A_01", "_A_IF_SW01")		 
  112. 	end 
  113.  
  114.  
  115. 	-- Handle mission initialization for the current checkpoint 
  116. 	MM_A_01_initialize(checkpoint) 
  117.  
  118. 	-- Run the mission from the current checkpoint 
  119. 	MM_A_01_run(checkpoint) 
  120. 	 
  121. end 
  122.  
  123. -- This is the primary function responsible for running the entire mission from start to finish. 
  124. -- 
  125. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  126. -- 
  127. function MM_A_01_run(first_checkpoint) 
  128. 	local current_checkpoint = first_checkpoint 
  129.  
  130. 	-- Run the mission from the beginning 
  131. 	if( current_checkpoint == MM_A_01_checkpoint.start.name  ) then 
  132. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  133.  
  134. 		--[[ 
  135. 		-- Intro animations 
  136. 		-- Player(s) look cool GO! 
  137. 		local anim_name = "M06 Player Mission Start" 
  138. 		local morph_name = "M06 Player Mission Start" 
  139. 		local force_play = false 
  140. 		local stand_still = false 
  141. 		local zero_movement = false 
  142. 		action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  143. 		player_script_controlled_clear(LOCAL_PLAYER)	-- let player escape this animation 
  144. 		if (coop_is_active()) then 
  145. 			action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  146. 			player_script_controlled_clear(REMOTE_PLAYER)	-- let player escape this animation 
  147. 		end 
  148.  
  149. 		-- set GPS to Insurance Fraud instance #1  
  150. 		trigger_enable( MM_A_01_trigger.i_f.name, true ) 
  151. 		waypoint_add( MM_A_01_trigger.i_f.name ) -- add GPS marker at the start of the DT activity 
  152. 		marker_add_trigger( MM_A_01_trigger.i_f.name, MINIMAP_ICON_LOCATION, "VFX_InsuranceFraudIcon", nil, OI_FLAGS_LOCATION, SYNC_ALL ) -- INGAME_EFFECT_CHECKPOINT 
  153. 		 
  154. 		on_trigger( "MM_A_01_if_trigger_cb", MM_A_01_trigger.i_f.name ) -- register the callback for the trigger 
  155. 		--objective_text( 0, "MM_A_01_obj_meet_angel", "", "", SYNC_ALL ) -- tell the player to meet Angel 
  156. 		objective_text( 0, "MM_A_01_obj_goto_if", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) -- tell the player to go to insurance fraud start 
  157.  
  158. 		while not MM_A_01_trigger.i_f.hit do -- wait for the player to hit the trigger at the IF start point 
  159. 			thread_yield() 
  160. 		end  
  161. 		]]-- 
  162. 	end 
  163. end 
  164.  
  165. -- This is the primary function responsible for cleaning up the entire mission 
  166. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  167. -- 
  168. function MM_A_01_cleanup() 
  169. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  170. 	MM_A_01_clear_trigger( MM_A_01_trigger.i_f.name ) 
  171. 	group_destroy( MM_A_01_group.vehicles ) 
  172. end 
  173.  
  174. -- Called when the mission has ended with success 
  175. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  176. -- 
  177. function MM_A_01_success() 
  178. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  179. 	 
  180. end 
  181.  
  182.  
  183. -- ************************* 
  184. -- 
  185. -- Local functions 
  186. -- 
  187. -- ************************* 
  188.  
  189. -- Initialize the mission for the specified checkpoint 
  190. -- 
  191. -- checkpoint:		Checkpoint to initialize the mission to 
  192. -- 
  193. function MM_A_01_initialize(checkpoint) 
  194. 	-- Make sure the screen is completly faded out 
  195. 	mission_start_fade_out(0.0) 
  196.  
  197. 	-- Set the mission author 
  198. 	set_mission_author("Jimmy Cross") 
  199.  
  200. 	-- Common initialization 
  201. 	MM_A_01_initialize_common() 
  202.  
  203. 	-- Checkpoint specific initialization 
  204. 	MM_A_01_initialize_checkpoint(checkpoint) 
  205.  
  206. 	-- Start fading in  
  207. 	mission_start_fade_in() 
  208.  
  209. end 
  210.  
  211.  
  212. -- *************************************************** 
  213. -- MM_A_01_run Helper Functions 
  214. -- *************************************************** 
  215.  
  216.  
  217. -- *************************************************** 
  218. -- MM_A_01_initialize Helper Functions 
  219. -- *************************************************** 
  220.  
  221. -- Handle any common initialization 
  222. -- 
  223. function MM_A_01_initialize_common() 
  224. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  225. 	 
  226. end 
  227.  
  228. -- Checkpoint specific initialization 
  229. -- 
  230. -- checkpoint:		The checkpoint to be initialized 
  231. function MM_A_01_initialize_checkpoint(checkpoint) 
  232.  
  233. 	if (checkpoint == MM_A_01_checkpoint.start.name) then 
  234. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  235.  
  236. 	end 
  237.  
  238. end 
  239.  
  240.  
  241. -- *************************************************** 
  242. -- Miscellaneous MM_A_01 Helper Funcrtions 
  243. -- *************************************************** 
  244. function MM_A_01_clear_trigger(trigger) 
  245. 	on_trigger( "", trigger ) 
  246. 	trigger_enable( trigger, false ) 
  247. 	marker_remove_trigger( trigger, SYNC_ALL ) 
  248. end 
  249.  
  250. -- ************************* 
  251. -- 
  252. -- Callback functions 
  253. -- 
  254. -- ************************* 
  255.  
  256. -- Trigger callback, used to handle the start of the activity and silent failing of the mission 
  257. -- 
  258. --  
  259. function MM_A_01_if_trigger_cb() 
  260. 	-- clear the trigger, waypoint, and objective 
  261. 	MM_A_01_trigger.i_f.hit = true 
  262. 	MM_A_01_clear_trigger( MM_A_01_trigger.i_f.name ) 
  263. 	waypoint_remove() 
  264. 	objective_text_clear(0) -- clear the objective text 
  265. 	 
  266. 	-- activity start triggered 
  267. 	mission_end_to_activity("MM_A_01", "_A_IF_SW01") 
  268. 	 
  269. end 
  270.  
  271. -- ************************* 
  272. -- 
  273. -- Thread functions 
  274. -- 
  275. -- ************************* 
  276.  
  277.