./tultor.lua

  1.  
  2. --[[ USING THE MISSION START TEMPLATE  
  3. 		1.	Read "SR3 Mission Scripting Standards" if you haven't already. 
  4. 		2.	Save this file as "tUltor.lua" in the missions directory. 
  5. 		3.	Replace "tUltor" with the name of your mission (must use the same name as your mission start node). 
  6. 		3a.	Replace "tUltor" with the capitalized name of your mission 
  7. 		4.	Replace "20130821" with today's date. 
  8. 		5.	Replace "hvs" with your name. 
  9. 		6.	Replace "first_checkpoint_nav" with the name of the first location to go to 
  10. 		7.	Replace "fcp with a 3-4 letter abbreviation for the first checkpoint. 
  11. 		8.	Replace "next_checkpoint_nav" with the second checkpoint name (first is named start) 
  12. 		9.	Replace "ncp" with a 3-4 letter abbreviation for the next checkpoint. 
  13. 		10.	If you find an error with this template, fix it and check it in!!!! 
  14. 		11.	Remove these instructions.  You're on your own now! 
  15. ]]-- 
  16.  
  17. --[[ 
  18. 	tUltor.lua 
  19. 	SR3 Mission Script 
  20. 	DATE: 2013-09-23 
  21. 	AUTHOR:	Arturo Mata 
  22. ]]-- 
  23.  
  24.  
  25. -- Debug flags -- 
  26.  
  27. -- Tweakable Parameters -- 
  28.  
  29. -------------------------------------------------------------------------------------------------- 
  30. 																				--[[ GROUPS ]]-- 
  31. -------------------------------------------------------------------------------------------------- 
  32. 	tUltor_group = { 
  33. 									--[[ startup GROUPS ]]--	 
  34. 									 
  35. 									--[[ first_checkpoint_nav GROUPS ]]--	 
  36. 		 
  37. 									--[[ next_checkpoint_nav GROUPS ]]-- 
  38. 	} 
  39.  
  40. -------------------------------------------------------------------------------------------------- 
  41. 																				--[[ THREADS ]]-- 
  42. -------------------------------------------------------------------------------------------------- 
  43. 	tUltor_thread = { 
  44. 		-- = INVALID_THREAD_HANDLE, 
  45. 	} 
  46.  
  47. -------------------------------------------------------------------------------------------------- 
  48. 																			--[[ CHECKPOINTS ]]-- 
  49. -------------------------------------------------------------------------------------------------- 
  50. 	tUltor_checkpoint = { 
  51. 		{ 
  52. 			name = MISSION_START_CHECKPOINT,		-- First Checkpoint (fcp) 
  53. 			init = "tUltor_fcp_init",				-- init(bool mission_restart) 
  54. 			run = "tUltor_fcp_run",					-- run() 
  55. 			cleanup = "tUltor_fcp_cleanup",			-- cleanup(bool mission_exit) (+++MUST RETURN IMMEDIATELY+++) 
  56. 			next_checkpoint = "tUltor_next_checkpoint_nav", 
  57. 			host_start = "player_start_nav_host", 
  58. 			client_start = "player_start_nav_client", 
  59. 			p1_car_nav = "", 
  60. 			p2_car_nav = "", 
  61. 			start_groups = { }, 
  62. 			cp_only_groups = { }, 
  63. 		}, 
  64. 		 
  65. 		{ 
  66. 			name = "tUltor_next_checkpoint_nav",					-- Second Checkpoint (ncp) 
  67. 			init = "tUltor_ncp_init", 
  68. 			run = "tUltor_ncp_run", 
  69. 			cleanup = "tUltor_ncp_cleanup", 
  70. 			next_checkpoint = nil, 
  71. 			host_start = "player_end_host", 
  72. 			client_start = "player_end_client", 
  73. 			p1_car_nav = "", 
  74. 			p2_car_nav = "", 
  75. 			start_groups = { }, 
  76. 			cp_only_groups = { }, 
  77. 		}, 
  78. 	} 
  79. 	 
  80. -------------------------------------------------------------------------------------------------- 
  81. 																			--[[ CUTSCENES ]]-- 
  82. -------------------------------------------------------------------------------------------------- 
  83. 	tUltor_scene = { 
  84. 		intro = "", 
  85. 		outro = "" 
  86. 	} 
  87.  
  88. -------------------------------------------------------------------------------------------------- 
  89. 																			--[[ CONVERSATIONS ]]-- 
  90. -------------------------------------------------------------------------------------------------- 
  91.  
  92. 	tUltor_convo = { 
  93. 		--[[ = { 
  94. 			name = "file_name without voice (_bm, _wm, _bf...", 
  95. 			player_talks = true or false, 
  96. 			handle = INVALID_CONVERSATION_HANDLE, 
  97. 			convo_thread = INVALID_THREAD_HANDLE, 
  98. 			max_wait_seconds = 60,	-- if the conversation doesn't complete before this time, kill it 
  99. 			timer_thread = INVALID_THREAD_HANDLE, 
  100. 			priority = CONVO_PRIORITY_HIGH or CONVO_PRIORITY_NORMAL or CONVO_PRIORITY_OPTIONAL 
  101. 			(optional) persona_line = true,	-- this is a single line 
  102. 			(required if persona_line) speaker_name = "name of speaker",	-- single line speaker (might be set before call to play is made?) 
  103. 			(optional)phone_call = true,  -- this is a phone conversation (phone persona must be preloaded) 
  104. 			(required if phone_call) receiving_call = true or false  -- auto-answer is always true in missions (until proven otherwise) 
  105. 			 
  106. 		},]] 
  107.  
  108. 	} 
  109. 	 
  110. 	tUltor_convo_queue = { 
  111. 		--[[start_drive_queue = {  
  112. 			{ delay = 2.0, convo = tUltor_convo.goto_first_checkpoint_nav }, 
  113. 			{ delay = 4.0, convo = tUltor_convo.goto_first_checkpoint_nav2 }, 
  114. 			{ delay = 3.0, convo = tUltor_convo.goto_first_checkpoint_nav3 }, 
  115. 			{ delay = 5.0, convo = tUltor_convo.goto_first_checkpoint_nav4 } 
  116. 		}, 
  117. 		]]-- 
  118. 	} 
  119. 	 
  120. -------------------------------------------------------------------------------------------------- 
  121. 																			--[[ TRIGGERS ]]-- 
  122. -------------------------------------------------------------------------------------------------- 
  123. 	tUltor_trigger = { 
  124. 		-- = { 
  125. 		--	name = "_trigger", 
  126. 		--	hit = false, 
  127. 		-- 	last_hit_by = nil, -- 	last_hit_human = nil (set to the last human to enter the trigger in the default trigger callback) 
  128. 		--  (optional)callback = "tUltor_function_name_cb" 
  129. 		--	(optional)marker = TRIGGER_LOCATION or TRIGGER_USE or custom or don't include for no marker 
  130. 		--  (optional)waypoint = true, 
  131. 		--  (optional)teleport_to = { 
  132. 		--						host = "host_nav", 
  133. 		--						client = "client_nav"  
  134. 		--					},		 
  135. 		--	(optional)conversation = tUltor_convo.convo_name  -- play a conversation 
  136. 		--	(optional)next_trigger = "next_trigger_name" sets up next trigger when triggered (breadcrumbs) 
  137. 		--}, 
  138. 		 
  139. 									--[[ first_checkpoint_nav TRIGGERS ]]-- 
  140.  
  141. 		end_trigger = { 
  142. 			name = "end_mission_trigger", 
  143. 			hit = false, 
  144. 			marker = TRIGGER_LOCATION, 
  145. 			waypoint = false, 
  146. 		}, 
  147. 		 
  148. 									--[[ next_checkpoint_nav TRIGGERS ]]--	 
  149.  
  150.  
  151. 		--trigger_01 = { 
  152. 		--	name = "trigger<001>", 
  153. 		--	hit = false, 
  154. 		--	marker = TRIGGER_LOCATION, 
  155. 		--	waypoint = true, 
  156. 		--}, 
  157.  
  158.  
  159. 	} 
  160. 	 
  161. -------------------------------------------------------------------------------------------------- 
  162. 																	  --[[ INTERROGATION DATA ]]-- 
  163. -------------------------------------------------------------------------------------------------- 
  164. 	--tUltor_interrogate = { 
  165. 	--	leader = { 
  166. 	--		target = tUltor_group.friendly_fire.owner, 
  167. 	--		persona = "Interrogation", 
  168. 	--		objective = "tUltor_INTERROGATE_OWNER", 
  169. 	--	--	(optional)conversation = tUltor_convo.convo_name  -- play a conversation while interrogating 
  170. 	--	}, 
  171. 	--} 
  172. 		 
  173. -------------------------------------------------------------------------------------------------- 
  174. 																				   --[[ OTHER ]]-- 
  175. -------------------------------------------------------------------------------------------------- 
  176.  
  177.  
  178. -------------------------------------------------------------------------------------------------- 
  179. 								--[[**********************]]-- 
  180. 								--[[                      ]]-- 
  181. 								--[[  Standard functions  ]]-- 
  182. 								--[[                      ]]-- 
  183. 								--[[**********************]]-- 
  184.  
  185. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  186. -- at the specified checkpoint. 
  187. -- CALLED FROM CODE 
  188. -- 
  189. -- start_checkpoint_name:	(string) The checkpoint the mission should begin at 
  190. -- is_restart:					(bool) TRUE if the mission is restarting, FALSE otherwise 
  191. -- 
  192. function tUltor_start(start_checkpoint_name, is_restart) 
  193. 	mission_start_fade_out(0.0) 
  194. 	city_zone_swap("u_train", true) 
  195.  
  196. 	-- initialize systems 
  197. 	mission_startup(tUltor_trigger, tUltor_convo) -- tUltor_checkpoint 
  198. 	-- if using interrogations 
  199. 	--interrogate_startup(tUltor_interrogate) 
  200. 	 
  201. 	local start_cp = get_table_by_name(tUltor_checkpoint, MISSION_START_CHECKPOINT) 
  202.  
  203. 	-- Check if this mission starting from the beginning 
  204. 	if (start_checkpoint_name == start_cp.name) then 
  205. 		if (is_restart == false and tUltor_scene.intro ~= "") then 
  206. 			-- First time playing mission 
  207. 			local fade_in_after = false 
  208. 			cutscene_play(tUltor_scene.intro, nil, {start_cp.host_start, start_cp.client_start}, fade_in_after) 
  209. 		else 
  210. 			teleport_coop(start_cp.host_start, start_cp.client_start, true) 
  211. 		end 
  212. 		fade_out(0) 
  213. 	end 
  214.  
  215. 	-- Handle mission initialization for the current checkpoint 
  216. 	tUltor_initialize(start_checkpoint_name) 
  217.  
  218. 	-- Run the mission from the current checkpoint 
  219. 	checkpoint_run_mission(tUltor_checkpoint, start_checkpoint_name) 
  220. 	 
  221. 	mission_end_success("tUltor")--, tUltor_scene.outro, {, }) 
  222. end 
  223.  
  224. -- This is the primary function responsible for cleaning up the entire mission 
  225. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATELY+++) 
  226. -- 
  227. function tUltor_cleanup() 
  228. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  229. 	--make sure zone is off 
  230. 	city_zone_swap("u_train", false) 
  231. 	 
  232. 	-- cleanup all threads 
  233. 	cleanup_threads(tUltor_thread) 
  234. 	 
  235. 	-- run checkpoint cleanups (move into mission_shutdown?) 
  236. 	checkpoint_cleanup_mission(tUltor_checkpoint) 
  237. 	 
  238. 	-- cleanup triggers, convos, kill_list and interrogations 
  239. 	mission_shutdown() 
  240. 	 
  241. 	-- cleanup all groups 
  242. 	cleanup_groups(tUltor_group) 
  243. end 
  244.  
  245. -- Called when the mission has ended with success 
  246. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATELY+++) 
  247. -- 
  248. function tUltor_success() 
  249. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  250. 	 
  251. end 
  252.  
  253. -------------------------------------------------------------------------------------------------- 
  254. 								--[[**********************]]-- 
  255. 								--[[                      ]]-- 
  256. 								--[[ Initialize functions ]]-- 
  257. 								--[[                      ]]-- 
  258. 								--[[**********************]]-- 
  259.  
  260. -- Initialize the mission for the specified checkpoint 
  261. -- 
  262. -- checkpoint_name:		(string) Checkpoint to initialize the mission to 
  263. -- 
  264. function tUltor_initialize(checkpoint_name) 
  265. 	-- Common initialization 
  266. 	tUltor_initialize_common() 
  267. 	 
  268. 	-- Checkpoint specific initialization 
  269. 	checkpoint_init(tUltor_checkpoint, checkpoint_name) 
  270.  
  271. 	-- Remove any present subtitles 
  272. 	message_remove_all() 
  273.  
  274. 	-- Start fading in  
  275. 	mission_start_fade_in() 
  276. end 
  277.  
  278. -- Handle any common initialization 
  279. -- 
  280. function tUltor_initialize_common() 
  281. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  282. 	 
  283. end 
  284.  
  285. -------------------------------------------------------------------------------------------------- 
  286. 								--[[**********************]]-- 
  287. 								--[[                      ]]-- 
  288. 								--[[ Checkpoint functions ]]-- 
  289. 								--[[                      ]]-- 
  290. 								--[[**********************]]-- 
  291.  
  292. -------------------------------------------------------------------------------------------------- 
  293. 																	--[[ First Checkpoint Name ]]-- 
  294. -------------------------------------------------------------------------------------------------- 
  295.  
  296. -- Initialize this checkpoint. 
  297. -- 
  298. -- mission_start: (bool) Whether we're initializing from a mission (re)start or from 
  299. --					a natural play-through. 
  300. -- 
  301. function tUltor_fcp_init(mission_start) 
  302. 	--trigger_setup( tUltor_trigger.trigger_01 ) 
  303.  
  304. end 
  305.  
  306. -- The first objective 
  307. -- 
  308. function tUltor_fcp_run() 
  309.  
  310. 	objective_text(0,"","","",SYNC_ALL,OI_ASSET_LOCATION) 
  311. 	trigger_setup(tUltor_trigger.end_trigger) 
  312. 	 
  313. 	while not tUltor_trigger.end_trigger.hit do 
  314. 		thread_yield() 
  315. 	end 
  316.  
  317. end 
  318.  
  319. -- Do any cleanup for this checkpoint. 
  320. -- 
  321. -- (+++THIS IS CALLED FROM MISSION CLEANUP, MUST RETURN IMMEDIATELY+++) 
  322. -- 
  323. -- mission_exit: (bool) Whether we're exiting the mission entirely, or just 
  324. --					moving on to the next checkpoint. 
  325. -- 
  326. function tUltor_fcp_cleanup(mission_exit) 
  327. end 
  328.  
  329. ------------------------------------ 
  330. -- 
  331. -- Checkpoint helper functions 
  332. -- 
  333. ------------------------------------ 
  334.  
  335. ------------------------------------ 
  336. -- 
  337. -- Checkpoint callback functions 
  338. -- 
  339. ------------------------------------ 
  340.  
  341. ------------------------------------ 
  342. -- 
  343. -- Checkpoint thread functions 
  344. -- 
  345. ------------------------------------ 
  346.  
  347. -------------------------------------------------------------------------------------------------- 
  348. 																	--[[ next_checkpoint_nav ]]-- 
  349. -------------------------------------------------------------------------------------------------- 
  350.  
  351. -- Initialize this checkpoint. 
  352. -- 
  353. -- mission_start: (bool) Whether we're initializing from a mission (re)start or from 
  354. --					a natural play-through. 
  355. -- 
  356. function tUltor_ncp_init(mission_start) 
  357.  
  358. 	if not mission_start then 
  359. 		mission_start_fade_out() 
  360. 		local cp = get_table_by_name(tUltor_checkpoint, "tUltor_next_checkpoint_nav") 
  361. 		teleport_coop(cp.host_start, cp.client_start, true) 
  362. 		city_zone_swap("u_train", false) 
  363. 		mission_start_fade_in()	 
  364. 	end 
  365.  
  366. end 
  367. 								 
  368. -- The next objective 
  369. -- 
  370. function tUltor_ncp_run() 
  371.  
  372. 	delay( 1.0 ) 
  373.  
  374. end 
  375.  
  376. -- Do any cleanup for this checkpoint. 
  377. -- 
  378. -- (+++THIS IS CALLED FROM MISSION CLEANUP, MUST RETURN IMMEDIATELY+++) 
  379. -- 
  380. -- mission_exit: (bool) Whether we're exiting the mission entirely, or just 
  381. --					moving on to the next checkpoint. 
  382. -- 
  383. function tUltor_ncp_cleanup(mission_exit) 
  384. end 
  385.  
  386. ------------------------------------ 
  387. -- 
  388. -- Checkpoint helper functions 
  389. -- 
  390. ------------------------------------ 
  391.  
  392. ------------------------------------ 
  393. -- 
  394. -- Checkpoint callback functions 
  395. -- 
  396. ------------------------------------ 
  397.  
  398. ------------------------------------ 
  399. -- 
  400. -- Checkpoint thread functions 
  401. -- 
  402. ------------------------------------ 
  403.  
  404. -------------------------------------------------------------------------------------------------- 
  405. 								--[[**********************]]-- 
  406. 								--[[                      ]]-- 
  407. 								--[[   Common functions   ]]-- 
  408. 								--[[                      ]]-- 
  409. 								--[[**********************]]-- 
  410.  
  411. -------------------------------------------------------------------------------------------------- 
  412. 								--[[**********************]]-- 
  413. 								--[[                      ]]-- 
  414. 								--[[  Callback functions  ]]-- 
  415. 								--[[                      ]]-- 
  416. 								--[[**********************]]-- 
  417.  
  418. -------------------------------------------------------------------------------------------------- 
  419. 								--[[**********************]]-- 
  420. 								--[[                      ]]-- 
  421. 								--[[   Thread functions   ]]-- 
  422. 								--[[                      ]]-- 
  423. 								--[[**********************]]--