./mintrobb.lua

  1. --[[ 
  2.  
  3. 			_____       _             ____  ____   
  4. 		   |_   _|     | |           |  _ \|  _ \  
  5.   _ __ ___   | |  _ __ | |_ _ __ ___ | |_) | |_) | 
  6.  | '_ ` _ \  | | | '_ \| __| '__/ _ \|  _ <|  _ <  
  7.  | | | | | |_| |_| | | | |_| | | (_) | |_) | |_) | 
  8.  |_| |_| |_|_____|_| |_|\__|_|  \___/|____/|____/  
  9. 												   
  10. 												   
  11.  
  12. --]] 
  13.  
  14. --[[ 
  15. 	mIntroBB.lua 
  16. 	SRG Map Event Script 
  17. 	DATE: 2014-05-05 
  18. 	AUTHOR:	Eric Stoll 
  19. ]]-- 
  20.  
  21. -- Tweakable Parameters -- 
  22. mIntroBB_far_distance = 75 
  23. mIntroBB_hud_time_ms = 10000 
  24.  
  25. mIntroBB_wave_1 = 15 
  26. mIntroBB_wave_2 = 20 
  27. mIntroBB_wave_3 = 25 
  28.  
  29. mIntroBB_imp_animation_state = "attach ship" 
  30.  
  31. SUPERPOWER_SUMMON = 0 
  32.  
  33. local local_player_had_hammer = 0 
  34. local remote_player_had_hammer = 0 
  35.  
  36. -------------------------------------------------------------------------------------------------- 
  37. --[[ 
  38.  
  39.    _____                            
  40.   / ____|                           
  41.  | |  __ _ __ ___  _   _ _ __  ___  
  42.  | | |_ | '__/ _ \| | | | '_ \/ __| 
  43.  | |__| | | | (_) | |_| | |_) \__ \ 
  44.   \_____|_|  \___/ \__,_| .__/|___/ 
  45. 						| |         
  46. 						|_|         
  47.  
  48. ]]-- 
  49. -------------------------------------------------------------------------------------------------- 
  50. 	mIntroBB_group = { 
  51.  
  52. 		start_blackbeard = { 
  53. 			name = "blackbeard_group", 
  54. 			blackbeard = "npc_Blackbeard", 
  55. 		}, 
  56.  
  57. 		ship = { 
  58. 			name = "ship_group", 
  59. 			ship = "Blackbeard_ship", 
  60. 		}, 
  61.  
  62. 		cin_imp = { 
  63. 			name = "cin_imp_group", 
  64. 			imp = { "cin_imp<001>", "cin_imp<002>" }, 
  65. 		}, 
  66.  
  67. 		imp_wave = { 
  68. 			name = "imp_wave1_group", 
  69. 			npcs = {	"imp<001>", "imp<002>", "imp<003>", "imp<004>", "imp<005>","imp<006>", "imp<007>", "imp<008>", "imp<009>", "imp<010>", 
  70. 						"imp<011>", "imp<012>", "imp<013>", "imp<014>", "imp<015>","imp<016>", "imp<017>", "imp<018>", "imp<019>", "imp<020>", 
  71. 						"imp<021>", "imp<022>", "imp<023>", "imp<024>", "imp<025>"}, 
  72. 		}, 
  73. 	} 
  74.  
  75. -------------------------------------------------------------------------------------------------- 
  76. --[[ 
  77.  
  78.   _   _                         _       _        
  79.  | \ | |                       (_)     | |       
  80.  |  \| | __ ___   ___ __   ___  _ _ __ | |_ ___  
  81.  | . ` |/ _` \ \ / / '_ \ / _ \| | '_ \| __/ __| 
  82.  | |\  | (_| |\ V /| |_) | (_) | | | | | |_\__ \ 
  83.  |_| \_|\__,_| \_/ | .__/ \___/|_|_| |_|\__|___/ 
  84. 				   | |                           
  85. 				   |_|                           
  86.  
  87. ]]-- 
  88. --------------------------------------------------------------------------------------------------	 
  89.  
  90. 	mIntroBB_navpoints = { 
  91. 		warhammer_crate = "whammer_nav",		 
  92. 	} 
  93. -------------------------------------------------------------------------------------------------- 
  94. --[[ 
  95.  
  96.   _______ _                        _      
  97.  |__   __| |                      | |     
  98. 	| |  | |__  _ __ ___  __ _  __| |___  
  99. 	| |  | '_ \| '__/ _ \/ _` |/ _` / __| 
  100. 	| |  | | | | | |  __/ (_| | (_| \__ \ 
  101. 	|_|  |_| |_|_|  \___|\__,_|\__,_|___/ 
  102. 										  
  103. 										  
  104. ]]-- 
  105. -------------------------------------------------------------------------------------------------- 
  106. 	mIntroBB_thread = { 
  107. 		navpoint_reset = INVALID_THREAD_HANDLE, 
  108. 		killzone_thread = INVALID_THREAD_HANDLE, 
  109. 		distance_thread = INVALID_THREAD_HANDLE, 
  110. 		ship_health_thread = INVALID_THREAD_HANDLE, 
  111. 		imp_attack_thread = INVALID_THREAD_HANDLE, 
  112. 	} 
  113.  
  114. --------------------------------------------------------------------------------------------------mIntroBB 
  115. --[[ 
  116. 				 _             _   _           _        _____        _         
  117. 	 /\         (_)           | \ | |         | |      |  __ \      | |        
  118. 	/  \   _ __  _ _ __ ___   |  \| | ___   __| | ___  | |  | | __ _| |_ __ _  
  119.    / /\ \ | '_ \| | '_ ` _ \  | . ` |/ _ \ / _` |/ _ \ | |  | |/ _` | __/ _` | 
  120.   / ____ \| | | | | | | | | | | |\  | (_) | (_| |  __/ | |__| | (_| | || (_| | 
  121.  /_/    \_\_| |_|_|_| |_| |_| |_| \_|\___/ \__,_|\___| |_____/ \__,_|\__\__,_| 
  122. 																			   
  123. ]]-- 
  124. --------------------------------------------------------------------------------------------------      
  125.  
  126. 	mIntroBB_anim_node = { 
  127. 		raise_ship = "SAM_Raise_Ship", 
  128. 		impfestation = "SAM_Impfestation", 
  129. 		power = "SAM_BB_Power", 
  130. 	}	                                                                   
  131.  
  132. -------------------------------------------------------------------------------------------------- 
  133. --[[ 
  134.  
  135.    _____ _               _                _       _        
  136.   / ____| |             | |              (_)     | |       
  137.  | |    | |__   ___  ___| | ___ __   ___  _ _ __ | |_ ___  
  138.  | |    | '_ \ / _ \/ __| |/ / '_ \ / _ \| | '_ \| __/ __| 
  139.  | |____| | | |  __/ (__|   <| |_) | (_) | | | | | |_\__ \ 
  140.   \_____|_| |_|\___|\___|_|\_\ .__/ \___/|_|_| |_|\__|___/ 
  141. 							 | |                           
  142. 							 |_|                           
  143.  
  144. ]]-- 
  145. -------------------------------------------------------------------------------------------------- 
  146. 	mIntroBB_checkpoint = { 
  147. 		{ 
  148. 			name = MISSION_START_CHECKPOINT,					-- First Checkpoint (imp) 
  149. 			init = "mIntroBB_imp_init", 
  150. 			run = "mIntroBB_imp_run", 
  151. 			cleanup = "mIntroBB_imp_cleanup", 
  152. 			next_checkpoint = "mIntroBB_imp_battle", 
  153. 			host_start = "player_ship_host", 
  154. 			client_start = "player_ship_client", 
  155. 			p1_car_nav = "", 
  156. 			p2_car_nav = "", 
  157. 			start_groups = {}, 
  158. 			cp_only_groups = {}, 
  159. 	 
  160. 		}, 
  161.  
  162. 		{ 
  163. 			name = "mIntroBB_imp_battle",					-- Imp Battle (bat) 
  164. 			init = "mIntroBB_bat_init", 
  165. 			run = "mIntroBB_bat_run", 
  166. 			cleanup = "mIntroBB_bat_cleanup", 
  167. 			next_checkpoint = "nil", 
  168. 			host_start = "player_ship_host", 
  169. 			client_start = "player_ship_client", 
  170. 			p1_car_nav = "", 
  171. 			p2_car_nav = "", 
  172. 			start_groups = {}, 
  173. 			cp_only_groups = {}, 
  174. 		 
  175. 		}, 
  176. 	} 
  177. 	 
  178. -------------------------------------------------------------------------------------------------- 
  179. --[[ 
  180.  
  181.    _____      _                                 
  182.   / ____|    | |                                
  183.  | |    _   _| |_ ___  ___ ___ _ __   ___  ___  
  184.  | |   | | | | __/ __|/ __/ _ \ '_ \ / _ \/ __| 
  185.  | |___| |_| | |_\__ \ (_|  __/ | | |  __/\__ \ 
  186.   \_____\__,_|\__|___/\___\___|_| |_|\___||___/ 
  187. 											    
  188. 											    
  189. ]]-- 
  190. -------------------------------------------------------------------------------------------------- 
  191. 	mIntroBB_scene = { 
  192. 		intro = "", 
  193. 		outro = "Bink_Blackbeard_Aided" 
  194. 	} 
  195.  
  196. -------------------------------------------------------------------------------------------------- 
  197. --[[ 
  198.  
  199.    _____                                    _   _                  
  200.   / ____|                                  | | (_)                 
  201.  | |     ___  _ ____   _____ _ __ ___  __ _| |_ _  ___  _ __  ___  
  202.  | |    / _ \| '_ \ \ / / _ \ '__/ __|/ _` | __| |/ _ \| '_ \/ __| 
  203.  | |___| (_) | | | \ V /  __/ |  \__ \ (_| | |_| | (_) | | | \__ \ 
  204.   \_____\___/|_| |_|\_/ \___|_|  |___/\__,_|\__|_|\___/|_| |_|___/ 
  205. 																   
  206. 																   
  207. ]]-- 
  208. -------------------------------------------------------------------------------------------------- 
  209.  
  210. 	mIntroBB_persona = {  
  211. 		Johnny = { 
  212. 			persona_name = "Johnny_Gat", 
  213. 			persona_id = INVALID_PERSONA_HANDLE 
  214. 		}, 
  215. 		Kinzie = { 
  216. 			persona_name = "Kinzie", 
  217. 			persona_id = INVALID_PERSONA_HANDLE 
  218. 		}, 
  219. 		Blackbeard = { 
  220. 			persona_name = "Blackbeard", 
  221. 			persona_id = INVALID_PERSONA_HANDLE 
  222. 		}, 
  223. 	} 
  224.  
  225. 	mIntroBB_convo = { 
  226. 		--[[ = { 
  227. 			name = "file_name without voice (_bm, _wm, _bf...", 
  228. 			player_talks = true or false, 
  229. 			handle = INVALID_CONVERSATION_HANDLE, 
  230. 			convo_thread = INVALID_THREAD_HANDLE, 
  231. 			max_wait_seconds = 60,	-- if the conversation doesn't complete before this time, kill it 
  232. 			timer_thread = INVALID_THREAD_HANDLE, 
  233. 			priority = CONVO_PRIORITY_HIGH or CONVO_PRIORITY_NORMAL or CONVO_PRIORITY_OPTIONAL 
  234. 			(optional) persona_line = true,	-- this is a single line 
  235. 			(required if persona_line) speaker_name = "name of speaker",	-- single line speaker (might be set before call to play is made?) 
  236. 			(optional)phone_call = true,  -- this is a phone conversation (phone persona must be preloaded) 
  237. 			(required if phone_call) receiving_call = true or false  -- auto-answer is always true in missions (until proven otherwise) 
  238. 			 
  239. 		},]] 
  240. 		 
  241. 		get_warhammer = { 
  242. 			name = "mIntroBB_BB_Get_War_Hammer",  
  243. 			player_talks = false, 
  244. 			handle = INVALID_CONVERSATION_HANDLE, 
  245. 			convo_thread = INVALID_THREAD_HANDLE, 
  246. 			max_wait_seconds = 60, 
  247. 			timer_thread = INVALID_THREAD_HANDLE, 
  248. 			priority = CONVO_PRIORITY_NORMAL, 
  249. 		}, 
  250. 		 
  251. 		gat_warhammer = { 
  252. 			name = "mIntroBB_Gat_Warhammer_01",  
  253. 			player_talks = false, 
  254. 			handle = INVALID_CONVERSATION_HANDLE, 
  255. 			convo_thread = INVALID_THREAD_HANDLE, 
  256. 			max_wait_seconds = 60, 
  257. 			timer_thread = INVALID_THREAD_HANDLE, 
  258. 			priority = CONVO_PRIORITY_NORMAL, 
  259. 		}, 
  260. 		 
  261. 		kinzie_warhammer = { 
  262. 			name = "mIntroBB_Kinzie_Warhammer_01",  
  263. 			player_talks = false, 
  264. 			handle = INVALID_CONVERSATION_HANDLE, 
  265. 			convo_thread = INVALID_THREAD_HANDLE, 
  266. 			max_wait_seconds = 60, 
  267. 			timer_thread = INVALID_THREAD_HANDLE, 
  268. 			priority = CONVO_PRIORITY_NORMAL, 
  269. 		}, 
  270. 		 
  271. 		gat_convo = { 
  272. 			name = "mIntroBB_Con_Gat_A",  
  273. 			player_talks = false, 
  274. 			handle = INVALID_CONVERSATION_HANDLE, 
  275. 			convo_thread = INVALID_THREAD_HANDLE, 
  276. 			max_wait_seconds = 60, 
  277. 			timer_thread = INVALID_THREAD_HANDLE, 
  278. 			priority = CONVO_PRIORITY_NORMAL, 
  279. 		}, 
  280. 		 
  281. 		kinzie_convo = { 
  282. 			name = "mIntroBB_Con_Kinzie_A",  
  283. 			player_talks = false, 
  284. 			handle = INVALID_CONVERSATION_HANDLE, 
  285. 			convo_thread = INVALID_THREAD_HANDLE, 
  286. 			max_wait_seconds = 60, 
  287. 			timer_thread = INVALID_THREAD_HANDLE, 
  288. 			priority = CONVO_PRIORITY_NORMAL, 
  289. 		}, 
  290. 		 
  291. 		bb_frustrated = { 
  292. 			name = "mIntroBB_BB_Blackbeard_Frustrat",  
  293. 			player_talks = false, 
  294. 			handle = INVALID_CONVERSATION_HANDLE, 
  295. 			convo_thread = INVALID_THREAD_HANDLE, 
  296. 			max_wait_seconds = 60, 
  297. 			timer_thread = INVALID_THREAD_HANDLE, 
  298. 			priority = CONVO_PRIORITY_NORMAL, 
  299. 		}, 
  300. 		 
  301. 		imp_explain_1 = { 
  302. 			name = "mIntroBB_BB_Imp_Explain_01",  
  303. 			player_talks = false, 
  304. 			handle = INVALID_CONVERSATION_HANDLE, 
  305. 			convo_thread = INVALID_THREAD_HANDLE, 
  306. 			max_wait_seconds = 60, 
  307. 			timer_thread = INVALID_THREAD_HANDLE, 
  308. 			priority = CONVO_PRIORITY_NORMAL, 
  309. 		}, 
  310. 		 
  311. 		imp_explain_2 = { 
  312. 			name = "mIntroBB_BB_Imp_Explain_02",  
  313. 			player_talks = false, 
  314. 			handle = INVALID_CONVERSATION_HANDLE, 
  315. 			convo_thread = INVALID_THREAD_HANDLE, 
  316. 			max_wait_seconds = 60, 
  317. 			timer_thread = INVALID_THREAD_HANDLE, 
  318. 			priority = CONVO_PRIORITY_NORMAL, 
  319. 		}, 
  320. 		 
  321. 		grant_power = { 
  322. 			name = "mIntroBB_Blackbeard_grant_power",  
  323. 			player_talks = false, 
  324. 			handle = INVALID_CONVERSATION_HANDLE, 
  325. 			convo_thread = INVALID_THREAD_HANDLE, 
  326. 			max_wait_seconds = 60, 
  327. 			timer_thread = INVALID_THREAD_HANDLE, 
  328. 			priority = CONVO_PRIORITY_NORMAL, 
  329. 		}, 
  330.  
  331. 		bb_swarmed = { 
  332. 			name = "Mission_Intro_BB_Blackbeard_BB_Attack", 
  333. 			player_talks = false, 
  334. 			handle = INVALID_CONVERSATION_HANDLE, 
  335. 			convo_thread = INVALID_THREAD_HANDLE, 
  336. 			max_wait_seconds = 10,	-- if the conversation doesn't complete before this time, kill it 
  337. 			timer_thread = INVALID_THREAD_HANDLE, 
  338. 			priority = CONVO_PRIORITY_NORMAL, 
  339. 			persona_line = true, 
  340. 			speaker_name = mIntroBB_group.start_blackbeard.blackbeard, 
  341. 		},	 
  342. 	} 
  343. 	 
  344. 	mIntroBB_convo_queue = { 
  345. 		--[[start_drive_queue = {  
  346. 			{ delay = 2.0, convo = mIntroBB_convo.goto_first_checkpoint_nav }, 
  347. 			{ delay = 4.0, convo = mIntroBB_convo.goto_first_checkpoint_nav2 }, 
  348. 			{ delay = 3.0, convo = mIntroBB_convo.goto_first_checkpoint_nav3 }, 
  349. 			{ delay = 5.0, convo = mIntroBB_convo.goto_first_checkpoint_nav4 } 
  350. 		}, 
  351. 		]]-- 
  352. 	} 
  353. 	 
  354. -------------------------------------------------------------------------------------------------- 
  355. --[[ 
  356.  
  357.   _______   _                            
  358.  |__   __| (_)                           
  359. 	| |_ __ _  __ _  __ _  ___ _ __ ___  
  360. 	| | '__| |/ _` |/ _` |/ _ \ '__/ __| 
  361. 	| | |  | | (_| | (_| |  __/ |  \__ \ 
  362. 	|_|_|  |_|\__, |\__, |\___|_|  |___/ 
  363. 			   __/ | __/ |               
  364. 			  |___/ |___/                
  365.  
  366. ]]-- 
  367. -------------------------------------------------------------------------------------------------- 
  368. 	mIntroBB_trigger = { 
  369. 		-- = { 
  370. 		--	name = "_trigger", 
  371. 		--	hit = false, 
  372. 		-- 	last_hit_by = nil, -- 	last_hit_human = nil (set to the last human to enter the trigger in the default trigger callback) 
  373. 		--  (optional)callback = "mIntroBB_function_name_cb" 
  374. 		--	(optional)marker = TRIGGER_LOCATION or TRIGGER_USE or custom or don't include for no marker 
  375. 		--  (optional)waypoint = true, 
  376. 		--  (optional)teleport_to = { 
  377. 		--						host = "host_nav", 
  378. 		--						client = "client_nav"  
  379. 		--					},		 
  380. 		--	(optional)conversation = mIntroBB_convo.convo_name  -- play a conversation 
  381. 		--	(optional)next_trigger = "next_trigger_name" sets up next trigger when triggered (breadcrumbs) 
  382. 		--}, 
  383. 		 
  384. 		--[[ first_checkpoint_nav TRIGGERS ]]-- 
  385. 		-- Killzone triggers 
  386. 		kt_ship_killzone_trigger = { 
  387. 			name = "ship_killzone_trigger", 
  388. 			hit = false, 
  389. 		}, 
  390. 		open_chest_trig = { 
  391.         	name = "chest_open_trig<001>", 
  392. 	        hit = false, 
  393. 	        marker = TRIGGER_USE, 
  394.        		--callback = "open_chest_cb", 
  395.                                                         
  396. 		}, 	 
  397. 	} 
  398. 	 
  399. -------------------------------------------------------------------------------------------------- 
  400. 																	  --[[ INTERROGATION DATA ]]-- 
  401. -------------------------------------------------------------------------------------------------- 
  402. 	--mIntroBB_interrogate = { 
  403. 	--	leader = { 
  404. 	--		target = mIntroBB_group.friendly_fire.owner, 
  405. 	--		persona = "Interrogation", 
  406. 	--		objective = "mIntroBB_INTERROGATE_OWNER", 
  407. 	--	--	(optional)conversation = mIntroBB_convo.convo_name  -- play a conversation while interrogating 
  408. 	--	}, 
  409. 	--} 
  410. 		 
  411. -------------------------------------------------------------------------------------------------- 
  412. --[[ 
  413.  
  414.   _____                   _____        _         
  415.  |_   _|                 |  __ \      | |        
  416.    | |  _ __ ___  _ __   | |  | | __ _| |_ __ _  
  417.    | | | '_ ` _ \| '_ \  | |  | |/ _` | __/ _` | 
  418.   _| |_| | | | | | |_) | | |__| | (_| | || (_| | 
  419.  |_____|_| |_| |_| .__/  |_____/ \__,_|\__\__,_| 
  420. 				 | |                             
  421. 				 |_|                             
  422.  
  423. ]]-- 
  424. -------------------------------------------------------------------------------------------------- 
  425. 	mIntroBB_imp_navs = { 
  426. 		{ start_pos = "imp_spawn<001>", in_use = false }, 
  427. 		{ start_pos = "imp_spawn<002>", in_use = false }, 
  428. 		{ start_pos = "imp_spawn<003>", in_use = false }, 
  429. 		{ start_pos = "imp_spawn<004>", in_use = false }, 
  430. 		{ start_pos = "imp_spawn<005>", in_use = false }, 
  431. 		{ start_pos = "imp_spawn<006>", in_use = false }, 
  432. 		{ start_pos = "imp_spawn<007>", in_use = false }, 
  433. 		{ start_pos = "imp_spawn<008>", in_use = false }, 
  434. 		{ start_pos = "imp_spawn<009>", in_use = false }, 
  435.  
  436. 	} 
  437.  
  438. 	imp_attack_navs = {	 
  439. 		{ name = "ship_attack_point<001>", taken = false }, 
  440. 		{ name = "ship_attack_point<002>", taken = false }, 
  441. 		{ name = "ship_attack_point<003>", taken = false }, 
  442. 		{ name = "ship_attack_point<004>", taken = false }, 
  443. 		{ name = "ship_attack_point<005>", taken = false }, 
  444. 		{ name = "ship_attack_point<006>", taken = false }, 
  445. 		{ name = "ship_attack_point<007>", taken = false }, 
  446. 		{ name = "ship_attack_point<008>", taken = false }, 
  447. 		{ name = "ship_attack_point<009>", taken = false }, 
  448. 		{ name = "ship_attack_point<010>", taken = false }, 
  449. 		{ name = "ship_attack_point<011>", taken = false }, 
  450. 		{ name = "ship_attack_point<012>", taken = false }, 
  451. 		{ name = "ship_attack_point<013>", taken = false }, 
  452. 		{ name = "ship_attack_point<014>", taken = false }, 
  453. 		{ name = "ship_attack_point<015>", taken = false }, 
  454. 		{ name = "ship_attack_point<016>", taken = false }, 
  455. 		{ name = "ship_attack_point<017>", taken = false }, 
  456. 		{ name = "ship_attack_point<018>", taken = false }, 
  457. 		{ name = "ship_attack_point<019>", taken = false }, 
  458. 		{ name = "ship_attack_point<020>", taken = false }, 
  459. 		{ name = "ship_attack_point<021>", taken = false }, 
  460. 	 } 
  461. -------------------------------------------------------------------------------------------------- 
  462. --[[ 
  463.  
  464.    ____  _   _                
  465.   / __ \| | | |               
  466.  | |  | | |_| |__   ___ _ __  
  467.  | |  | | __| '_ \ / _ \ '__| 
  468.  | |__| | |_| | | |  __/ |    
  469.   \____/ \__|_| |_|\___|_|    
  470. 							  
  471. 							  
  472. ]]-- 
  473. -------------------------------------------------------------------------------------------------- 
  474.  
  475. 	mIntroBB_homie = { 
  476. 			blackbeard = "", 
  477. 	} 
  478. 	mIntroBB_saints = { 
  479. 		--Will be filled in when the mission starts 
  480. 	} 
  481. 	 
  482. 	mIntroBB_tweakables = { 
  483. 		--chances that an imp has to attack the ship during the wave (range 0-1) 
  484. 		wave1_chance = 1.0, 
  485. 		wave2_chance = .5, 
  486. 		wave3_chance = 0.0, 
  487. 		max_ship_health = 10000, 
  488. 		damage_per_sec_imp = 20.0, -- this is per imp that is attacking the ship. 
  489. 	} 
  490.  
  491. 	mIntroBB_is_defending = false 
  492.  
  493. 	mIntroBB_runtime = { 
  494. 		rs_sam_complete = false, 
  495. 		if_sam_complete = false, 
  496. 		power_sam_complete = false, 
  497. 	} 
  498.  
  499. 	mIntroBB_current_ship_health = mIntroBB_tweakables.max_ship_health 
  500. 	mIntroBB_attacking_imps = { --stores the imps that are attacking the ship 
  501. 	} 
  502. 	mIntroBB_attacking_effects = { --stores the imps that are attacking the ship 
  503. 		{imp = "", 
  504. 		effect = 0,}, 
  505. 		{imp = "", 
  506. 		effect = 0,}, 
  507. 		{imp = "", 
  508. 		effect = 0,}, 
  509. 		{imp = "", 
  510. 		effect = 0,}, 
  511. 		{imp = "", 
  512. 		effect = 0,}, 
  513. 		{imp = "", 
  514. 		effect = 0,}, 
  515. 		{imp = "", 
  516. 		effect = 0,}, 
  517. 		{imp = "", 
  518. 		effect = 0,}, 
  519. 		{imp = "", 
  520. 		effect = 0,}, 
  521. 		{imp = "", 
  522. 		effect = 0,}, 
  523. 		{imp = "", 
  524. 		effect = 0,}, 
  525. 		{imp = "", 
  526. 		effect = 0,}, 
  527. 		{imp = "", 
  528. 		effect = 0,}, 
  529. 		{imp = "", 
  530. 		effect = 0,}, 
  531. 		{imp = "", 
  532. 		effect = 0,}, 
  533. 		{imp = "", 
  534. 		effect = 0,}, 
  535. 		{imp = "", 
  536. 		effect = 0,}, 
  537. 		{imp = "", 
  538. 		effect = 0,}, 
  539. 		{imp = "", 
  540. 		effect = 0,}, 
  541. 	} 
  542. 	mIntroBB_attacking_effects_num = 0 
  543. 	mIntroBB_num_attack_imps = 0 
  544. -------------------------------------------------------------------------------------------------- 
  545. --[[ 
  546.  
  547.    _____ _                  _               _   ______                _   _                  
  548.   / ____| |                | |             | | |  ____|              | | (_)                 
  549.  | (___ | |_ __ _ _ __   __| | __ _ _ __ __| | | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  550.   \___ \| __/ _` | '_ \ / _` |/ _` | '__/ _` | |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  551.   ____) | || (_| | | | | (_| | (_| | | | (_| | | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  552.  |_____/ \__\__,_|_| |_|\__,_|\__,_|_|  \__,_| |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  553. 																							 
  554. 																							 
  555. ]]-- 
  556.  
  557. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  558. -- at the specified checkpoint. 
  559. -- CALLED FROM CODE 
  560. -- 
  561. -- start_checkpoint_name:	(string) The checkpoint the mission should begin at 
  562. -- is_restart:					(bool) TRUE if the mission is restarting, FALSE otherwise 
  563. -- 
  564. function mIntroBB_start(start_checkpoint_name, is_restart) 
  565. 	mIntroBB_saints[1] = LOCAL_PLAYER 
  566. 	mIntroBB_saints[2] = mIntroBB_homie.blackbeard 
  567. 	if (coop_is_active() == true) then 
  568. 		mIntroBB_saints[2] = REMOTE_PLAYER 
  569. 	end 
  570. 	set_ped_override_density(.1) 
  571. 	set_traffic_density(.1) 
  572. 	parking_spot_disable_all(true) 
  573. 	mission_start_fade_out(0.0) 
  574.  
  575. 	 
  576. 	-- initialize systems 
  577. 	mission_startup(mIntroBB_trigger, mIntroBB_convo) -- mIntroBB_checkpoint 
  578. 	 
  579. 	-- HVS_BDF: we don't necessarily want to call load_persona() because this creates a 2D 
  580. 	-- version, which can prevent actual in-game characters from lip syncing their VO if 
  581. 	-- the 2D persona was loaded prior to their character being spawned. 
  582. 	-- In the case of PC characters, they are present in the world  
  583. 	-- and their characters should lip sync their VO.  Same with BB. 
  584. 	--load_persona(mIntro_persona.Johnny) 
  585. 	--load_persona(mIntro_persona.Kinzie) 
  586. 	--load_persona(mIntroBB_persona.Blackbeard) 
  587. 	-- if using interrogations 
  588. 	--interrogate_startup(mIntroBB_interrogate) 
  589. 	 
  590. 	local start_cp = get_table_by_name(mIntroBB_checkpoint, MISSION_START_CHECKPOINT) 
  591.  
  592. 	-- TEMPORARY: give player approximate loadout of weapons & superpowers 
  593. 	-- TODO: remove this before the game ships!!! 
  594. 	--hvUnlockLoadout("mIntroBB") 
  595.  
  596. 	-- Check if this mission starting from the beginning 
  597.  
  598. 	player_movement_disable(LOCAL_PLAYER) 
  599. 	if( coop_is_active() == true) then 
  600. 		player_movement_disable(REMOTE_PLAYER) 
  601. 	end 
  602.  
  603. 	if (start_checkpoint_name == start_cp.name) then 
  604. 		if (is_restart == false and mIntroBB_scene.intro ~= "") then 
  605. 			-- First time playing mission 
  606. 			local fade_in_after = false 
  607. 			cutscene_play(mIntroBB_scene.intro, nil, {start_cp.host_start, start_cp.client_start}, fade_in_after) 
  608. 		else 
  609. 			teleport_coop(start_cp.host_start, start_cp.client_start, true) 
  610. 		end 
  611. 		fade_out(0) 
  612. 	end 
  613. 	 
  614. 	-- Handle mission initialization for the current checkpoint 
  615. 	mIntroBB_initialize(start_checkpoint_name) 
  616.  
  617. 	player_movement_enable(LOCAL_PLAYER) 
  618. 	if( coop_is_active() == true) then 
  619. 		player_movement_enable(REMOTE_PLAYER) 
  620. 	end 
  621.  
  622. 	local_player_had_hammer = inv_has_item("Melee-Warhammer", LOCAL_PLAYER) 
  623. 	inv_item_remove("Melee-Warhammer", LOCAL_PLAYER) 
  624. 	if( coop_is_active() == true) then 
  625. 		remote_player_had_hammer = inv_has_item("Melee-Warhammer", REMOTE_PLAYER) 
  626. 		inv_item_remove("Melee-Warhammer", REMOTE_PLAYER) 
  627. 	end 
  628.  
  629. 	-- Run the mission from the current checkpoint 
  630. 	checkpoint_run_mission(mIntroBB_checkpoint, start_checkpoint_name) 
  631. 	 
  632. 	mission_end_success("mIntroBB") --, mIntroBB_scene.outro, {start_cp.host_start, start_cp.client_start}) 
  633. end 
  634.  
  635. -- This is the primary function responsible for cleaning up the entire mission 
  636. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATELY+++) 
  637. -- 
  638. function mIntroBB_cleanup() 
  639. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  640. 	 
  641. 	imp_jump_occasionals_enable( true ) 
  642. 	set_ped_override_density(-1) 
  643. 	set_traffic_density(1) 
  644. 	parking_spot_disable_all(false) 
  645. 	-- cleanup all threads 
  646. 	cleanup_threads(mIntroBB_thread) 
  647. 	 
  648. 	-- run checkpoint cleanups (move into mission_shutdown?) 
  649. 	checkpoint_cleanup_mission(mIntroBB_checkpoint) 
  650. 	 
  651. 	-- cleanup triggers, convos, kill_list and interrogations 
  652. 	mission_shutdown() 
  653. 	 
  654. 	-- cleanup all groups 
  655. 	cleanup_groups(mIntroBB_group) 
  656.  
  657. 	-- cleanup all sams 
  658. 	seamless_animated_moment_cleanup() 
  659. 	on_seamless_animated_moment_end("") 
  660.  
  661. 	--return normal player jump/sprint values 
  662. 	tweak_table_restore_value ("Jump_super_max_height_scripted") 
  663. 	tweak_table_restore_value ("Sprint_super_max_speed_scripted") 
  664. 	notoriety_set_min_and_max("police", 0, MAX_NOTORIETY_LEVEL) 
  665.  
  666. 	player_movement_enable(LOCAL_PLAYER) 
  667. 	if( coop_is_active() == true) then 
  668. 		player_movement_enable(REMOTE_PLAYER) 
  669. 	end 
  670.  
  671. 	player_controls_enable(LOCAL_PLAYER) 
  672. 	if( coop_is_active() == true) then 
  673. 		player_controls_enable(REMOTE_PLAYER) 
  674. 	end 
  675.  
  676. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  677. 	if coop_is_active then 
  678. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  679. 	end 
  680.  
  681. 	if mission_is_failed() then 
  682. 		--inv_item_remove("Melee-Warhammer", LOCAL_PLAYER); 
  683. 		inv_weapon_remove_temporary(LOCAL_PLAYER,"Melee-Warhammer") 
  684. 		if coop_is_active then 
  685. 			--inv_item_remove("Melee-Warhammer", REMOTE_PLAYER); 
  686. 			inv_weapon_remove_temporary(REMOTE_PLAYER,"Melee-Warhammer") 
  687. 		end 
  688. 	end 
  689. 	if not mission_is_failed() then 
  690. 		player_unlock_super_power( SUPERPOWER_SUMMON, LOCAL_PLAYER, true ) 
  691. 		if coop_is_active() then 
  692. 			player_unlock_super_power( SUPERPOWER_SUMMON, REMOTE_PLAYER, true ) 
  693. 		end 
  694. 	end 
  695.  
  696. 	if local_player_had_hammer or not mission_is_failed()then 
  697. 		inv_item_add("Melee-Warhammer", 1, LOCAL_PLAYER, true, 0) 
  698. 	end 
  699.  
  700. 	if (coop_is_active() == true) then 
  701. 		if remote_player_had_hammer or not mission_is_failed() then 
  702. 			inv_item_add("Melee-Warhammer", 1, REMOTE_PLAYER, true, 0) 
  703. 		end 
  704. 	end 
  705.  
  706. end 
  707.  
  708. -- Called when the mission has ended with success 
  709. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATELY+++) 
  710. -- 
  711. function mIntroBB_success() 
  712. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  713. 	-- Equip the superpower if we finished successfully 
  714. 	audio_object_post_event("PirateShip_Music_Stop") 
  715. 	 
  716. end 
  717.  
  718. -------------------------------------------------------------------------------------------------- 
  719. --[[ 
  720.  
  721.  
  722.   _____       _ _   _       _ _           ______                _   _                  
  723.  |_   _|     (_) | (_)     | (_)         |  ____|              | | (_)                 
  724.    | |  _ __  _| |_ _  __ _| |_ _______  | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  725.    | | | '_ \| | __| |/ _` | | |_  / _ \ |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  726.   _| |_| | | | | |_| | (_| | | |/ /  __/ | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  727.  |_____|_| |_|_|\__|_|\__,_|_|_/___\___| |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  728. 																					   
  729. 																					   
  730. ]]-- 
  731.  
  732. -- Initialize the mission for the specified checkpoint 
  733. -- 
  734. -- checkpoint_name:		(string) Checkpoint to initialize the mission to 
  735. -- 
  736. function mIntroBB_initialize(checkpoint_name) 
  737. 	-- Common initialization 
  738. 	mIntroBB_initialize_common() 
  739.  
  740. 	 
  741. 	-- Checkpoint specific initialization 
  742. 	checkpoint_init(mIntroBB_checkpoint, checkpoint_name) 
  743.  
  744. 	-- Remove any present subtitles 
  745. 	message_remove_all() 
  746.  
  747. 	-- Start fading in  
  748. 	mission_start_fade_in() 
  749. end 
  750.  
  751. -- Handle any common initialization 
  752. -- 
  753. function mIntroBB_initialize_common() 
  754. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  755. 	notoriety_set_min_and_max("police", 0, 4) 
  756. 	 
  757. 	imp_jump_occasionals_enable( false ) 
  758. 	audio_object_post_event("PirateShip_Music") 
  759.  
  760. end 
  761.  
  762. -------------------------------------------------------------------------------------------------- 
  763. --[[ 
  764.  
  765.  
  766.    _____ _               _                _       _     ______                _   _                  
  767.   / ____| |             | |              (_)     | |   |  ____|              | | (_)                 
  768.  | |    | |__   ___  ___| | ___ __   ___  _ _ __ | |_  | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  769.  | |    | '_ \ / _ \/ __| |/ / '_ \ / _ \| | '_ \| __| |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  770.  | |____| | | |  __/ (__|   <| |_) | (_) | | | | | |_  | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  771.   \_____|_| |_|\___|\___|_|\_\ .__/ \___/|_|_| |_|\__| |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  772. 							 | |                                                                     
  773. 							 |_|                                                                     
  774.  
  775. ]]-- 
  776. -------------------------------------------------------------------------------------------------- 
  777. -------------------------------------------------------------------------------------------------- 
  778. --[[ 
  779.   _____       _                _____         __  __  
  780.  |_   _|     | |              / ____|  /\   |  \/  | 
  781.    | |  _ __ | |_ _ __ ___   | (___   /  \  | \  / | 
  782.    | | | '_ \| __| '__/ _ \   \___ \ / /\ \ | |\/| | 
  783.   _| |_| | | | |_| | | (_) |  ____) / ____ \| |  | | 
  784.  |_____|_| |_|\__|_|  \___/  |_____/_/    \_\_|  |_| 
  785. 													 
  786. ]]-- 
  787. -------------------------------------------------------------------------------------------------- 
  788.  
  789. function mIntroBB_imp_init(mission_start) 
  790.  
  791. 	fade_out(0.0) 
  792.  
  793.  
  794. 	-- TP the players into position 
  795. 	group_create( mIntroBB_group.cin_imp.name, true)	 
  796. 	mIntroBB_create_blackbeard(mIntroBB_group.start_blackbeard) 
  797. 	 
  798. 	--teleport_coop("tele_host", "tele_client", true) 
  799. 	-- Create Blackbeard and the imp for the cinema 
  800. 	 
  801. 	-- Give BB his weapon 
  802. 	inv_item_add( "Pistol-HandCrossbow", 1, mIntroBB_homie.blackbeard, true ) 
  803.  
  804. 	-- Register a callback for when the seamless animated moment completes 
  805. 	on_seamless_animated_moment_end("mIntroBB_ext_cb_impfestation_complete") 
  806.  
  807. 	--Determine and assign appropriate player character actor 
  808. 	local Johnny_SAM = "" 
  809. 	local Kinzie_SAM = "" 
  810. 	if character_get_anim_set(LOCAL_PLAYER) == "PLYM" then 
  811. 		Johnny_SAM = LOCAL_PLAYER 
  812. 	else 
  813. 		Kinzie_SAM = LOCAL_PLAYER 
  814. 	end 
  815.  
  816. 	local actor_list2 = { mIntroBB_homie.blackbeard, Johnny_SAM, mIntroBB_group.cin_imp.imp[1], mIntroBB_group.cin_imp.imp[2], Kinzie_SAM} 
  817. 	 
  818. 	-- Play the SAM 
  819. 	seamless_animated_moment_prep(mIntroBB_anim_node.impfestation, actor_list2) 
  820. 	seamless_animated_moment_start(mIntroBB_anim_node.impfestation, actor_list2) 
  821. 	--mission_start_fade_in()	 
  822. 	audio_object_post_event("Play_MKing_BB_Intro") 
  823. 	-- audio_object_post_event("PirateShip_Music") 
  824.  
  825. 	fade_in(0.2) 
  826. 		 
  827. end 
  828.  
  829. function mIntroBB_imp_run() 
  830. 		 
  831. 	--failsafe so players don't get their controls enabled. SAM will do it upon completion and there is an enable call in the cleanup in case player exits during SAM. 
  832. 	player_controls_disable(LOCAL_PLAYER) 
  833. 	if coop_is_active() then 
  834. 		player_controls_disable(REMOTE_PLAYER) 
  835. 	end 
  836.  
  837. 	-- Wait until the SAM is finished 
  838. 	while not mIntroBB_runtime.if_sam_complete do 
  839. 		thread_yield() 
  840. 	end 
  841.  
  842. 	-- Remove callback 
  843. 	on_seamless_animated_moment_end("") 
  844.  
  845. 	--player_controls_enable(LOCAL_PLAYER) 
  846. 	--if( coop_is_active() == true) then 
  847. 		--player_controls_enable(REMOTE_PLAYER) 
  848. 	--end 
  849.  
  850. end 
  851.  
  852. function mIntroBB_imp_cleanup(mission_exit) 
  853. 	if mission_exit then 
  854. 		mIntroBB_cleanup_blackbeard()		 
  855. 		player_super_attacks_enable( true )	 
  856. 	end 
  857. 	on_seamless_animated_moment_end("") 
  858. end 
  859. -------------------------------------------------------------------------------------------------- 
  860. --[[ 
  861.   _  ___ _ _   _____                      
  862.  | |/ (_) | | |_   _|                     
  863.  | ' / _| | |   | |  _ __ ___  _ __  ___  
  864.  |  < | | | |   | | | '_ ` _ \| '_ \/ __| 
  865.  | . \| | | |  _| |_| | | | | | |_) \__ \ 
  866.  |_|\_\_|_|_| |_____|_| |_| |_| .__/|___/ 
  867. 							  | |         
  868. 							  |_|         
  869. ]]-- 
  870. -------------------------------------------------------------------------------------------------- 
  871.  
  872. -- Initialize this checkpoint. 
  873. -- 
  874. -- mission_start: (bool) Whether we're initializing from a mission (re)start or from 
  875. --					a natural play-through. 
  876. -- 
  877. function mIntroBB_bat_init(mission_start) 
  878. 		 
  879.  
  880.  
  881. 	--camera_shake_play_looping("pirate_ship_deck", 1.0) 
  882.  
  883. 	mIntroBB_create_blackbeard(mIntroBB_group.start_blackbeard) 
  884.  
  885. 	-- Setup how BB takes damage 
  886. 	character_limb_immune_to_imp( mIntroBB_homie.blackbeard,3) 
  887. 	--on_take_damage("mImpest_blackbeard_hit_cb", mIntroBB_homie.blackbeard) 
  888. 	 
  889. 	if mIntroBB_homie.blackbeard ~= nil and mIntroBB_homie.blackbeard ~= "" then 
  890. 		set_attack_enemies_flag(mIntroBB_homie.blackbeard) 
  891. 	end  
  892. 	 
  893. 	-- Set the sprint/jump limitations  
  894. 	--[[ 
  895. 	trigger_setup(mIntroBB_trigger.js_ship_limit_trigger) 
  896. 	on_trigger("mIntroBB_ship_limit_enter_cb", mIntroBB_trigger.js_ship_limit_trigger.name) 
  897. 	on_trigger_exit("mIntroBB_trigger_limit_exit_cb", mIntroBB_trigger.js_ship_limit_trigger.name) 
  898. 	--]] 
  899. 	--no notoriety during this checkpoint 
  900. 	notoriety_set_max("police", 0) 
  901. 	notoriety_set_can_decay(true) 
  902. 	hud_bar_set_ship_health_percent(mIntroBB_current_ship_health / mIntroBB_tweakables.max_ship_health) 
  903.  
  904. 	-- Lock the crate containing the warhammer 
  905. 	door_lock("whammer_crate_mover", true) 
  906.  
  907. 	--HVS_BAS - we need to make sure that the chest is hidden 
  908. 	mesh_mover_show("Chest_Mover<001>") 
  909. 	mesh_mover_hide("Chest_Mover<001>") 
  910. end 
  911. 								 
  912. -- The next objective 
  913. -- 
  914. function mIntroBB_bat_run() 
  915.  
  916. 	objective_text_clear(0) 
  917. 	objective_text(0,"GM_IMPFEST_OBJ_PROTECT_SHIP","","",SYNC_ALL,OI_ASSET_DEFEND) 
  918. 	marker_add( mIntroBB_homie.blackbeard, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND) 
  919. 	convo_start(mIntroBB_convo.bb_frustrated) 
  920.  
  921. 	imp_attack_face(true) 
  922. 	mIntroBB_imp_waves() 
  923.  
  924. 	marker_remove( mIntroBB_homie.blackbeard ) 
  925. 	objective_text_clear(0) 
  926.  
  927. 	if character_get_anim_set(LOCAL_PLAYER) == "PLYM" then 
  928. 		convo_start(mIntroBB_convo.gat_convo) 
  929. 	else 
  930. 		convo_start(mIntroBB_convo.kinzie_convo) 
  931. 	end 
  932. 	convo_wait_for_end() 
  933.  
  934.  
  935. 	delay(2.0) 
  936.  
  937. 	player_controls_disable(LOCAL_PLAYER) 
  938. 	if coop_is_active() then 
  939. 		player_controls_enable(REMOTE_PLAYER) 
  940. 	end 
  941. 	local start_cp = get_table_by_name(mIntroBB_checkpoint, MISSION_START_CHECKPOINT) 
  942. 	cutscene_play(mIntroBB_scene.outro, nil, {"player_end_host", "player_end_client"}, true ) 
  943.  
  944. 	party_dismiss(mIntroBB_homie.blackbeard) 
  945. 	teleport( mIntroBB_homie.blackbeard, "Blackbeard_point") 
  946. 	npc_leash_to_nav( mIntroBB_homie.blackbeard, "Blackbeard_point", 1) 
  947. 	set_script_animation_state(mIntroBB_homie.blackbeard,"stand")	 
  948.  
  949. 	if cutscene_check_exiting() then 
  950. 		thread_yield()		 
  951. 	end 
  952. 	convo_start(mIntroBB_convo.grant_power) 
  953. 	on_seamless_animated_moment_end("mIntroBB_PowerSAM_Complete") 
  954.     local actor_list = {  LOCAL_PLAYER, mIntroBB_group.start_blackbeard.blackbeard} 
  955.     seamless_animated_moment_prep(mIntroBB_anim_node.power, actor_list) 
  956.     seamless_animated_moment_start(mIntroBB_anim_node.power, actor_list) 
  957. 	effect_play_on_human( "vfx_Altars_PowerUp", LOCAL_PLAYER, "spine2" ) 
  958. 	 while(mIntroBB_runtime.power_sam_complete == false) do 
  959.         thread_yield() 
  960.     end 
  961. 	-- Have player(s) fully power up (non-blocking) 
  962. --	local anim_name = "altars_powerup" 
  963. --	local morph_name = anim_name 
  964. --	local force_play = false 
  965. --	local stand_still = true 
  966. --	local zero_movement = true 
  967.  
  968. --	action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  969. --	if coop_is_active() then 
  970. --		effect_play_on_human( "vfx_Altars_PowerUp", REMOTE_PLAYER, "spine2"  ) 
  971. --		action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  972. --	end 
  973.  
  974. 	-- Wait for player to react 
  975. 	--delay(6) 
  976. 	fade_out(1) 
  977. 	fade_out_block() 
  978. 	force_spawn_contacts() 
  979. 	player_super_power_select( "summon", SYNC_ALL, "summon_imp" ) 
  980. end 
  981.  
  982. -- Do any cleanup for this checkpoint. 
  983. -- 
  984. -- (+++THIS IS CALLED FROM MISSION CLEANUP, MUST RETURN IMMEDIATELY+++) 
  985. -- 
  986. -- mission_exit: (bool) Whether we're exiting the mission entirely, or just 
  987. --					moving on to the next checkpoint. 
  988. -- 
  989. function mIntroBB_bat_cleanup(mission_exit) 
  990. 	imp_attack_face(false) 
  991. 	if mission_exit then 
  992. 		mIntroBB_cleanup_blackbeard()		 
  993. 		player_super_attacks_enable( true )	 
  994. 	end 
  995. 	hud_critical_timer_stop() 
  996. 	thread_kill(mIntroBB_thread.killzone_thread) 
  997. 	thread_kill(mIntroBB_thread.distance_thread) 
  998. 	thread_kill(mIntroBB_thread.ship_health_thread) 
  999. 	thread_kill(mIntroBB_thread.imp_attack_thread) 
  1000. 	hud_bar_set_ship_health_percent(0) 
  1001. 	 
  1002. 	notoriety_set_min_and_max("police", 0, MAX_NOTORIETY_LEVEL) 
  1003. 	--camera_shake_stop() 
  1004. 	for i, npc in pairs(mIntroBB_group.imp_wave.npcs) do 
  1005. 		on_anim_trigger("", npc) 
  1006. 	end 
  1007. 	for i, entry in pairs(mIntroBB_attacking_effects) do 
  1008. 		if(entry.imp ~= "") then 
  1009. 			on_death("", entry.imp) 
  1010. 		end 
  1011. 	end 
  1012.  
  1013. 	inv_weapon_remove_temporary(LOCAL_PLAYER,"Melee-Warhammer") 
  1014.  
  1015. 	if (coop_is_active() == true) then 
  1016. 		inv_weapon_remove_temporary(REMOTE_PLAYER,"Melee-Warhammer") 
  1017. 	end 
  1018.  
  1019. 	if local_player_had_hammer then 
  1020. 		inv_item_add("Melee-Warhammer", 1, LOCAL_PLAYER, true, 0) 
  1021. 	end 
  1022.  
  1023. 	if (coop_is_active() == true) then 
  1024. 		if remote_player_had_hammer then 
  1025. 			inv_item_add("Melee-Warhammer", 1, REMOTE_PLAYER, true, 0) 
  1026. 		end 
  1027. 	end 
  1028.  
  1029.  
  1030. 	on_door_opened("", "whammer_crate_mover") 
  1031. 	on_seamless_animated_moment_end("") 
  1032. end 
  1033.  
  1034. ------------------------------------ 
  1035. -- 
  1036. -- Checkpoint helper functions 
  1037. -- 
  1038. ------------------------------------ 
  1039.  
  1040. --control how we want the spawning of the imps to go 
  1041. function mIntroBB_imp_waves() 
  1042.  
  1043. 	--check continuously for NPCs that fall off the ship 
  1044. 	mIntroBB_thread.killzone_thread = thread_new("mIntroBB_killzone_check") 
  1045. 	mIntroBB_thread.distance_thread = thread_new("mIntroBB_player_too_far_thread") 
  1046. 	mIntroBB_thread.ship_health_thread = thread_new("mIntroBB_ship_health_thread") 
  1047. 	mIntroBB_thread.imp_attack_thread = thread_new("mIntroBB_attack_ship_thread") 
  1048. 	-- wave 1 
  1049. 	mIntroBB_num_attack_imps = 0 
  1050. 	group_create_hidden(mIntroBB_group.imp_wave.name, true) 
  1051. 	for i, npc in pairs(mIntroBB_group.imp_wave.npcs) do 
  1052. 		-- space them out a little 
  1053. 		if i >= mIntroBB_wave_1 then 
  1054. 			break 
  1055. 		end 
  1056. 		mIntroBB_spawn_imp(npc, mIntroBB_tweakables.wave1_chance, false) 
  1057. 		local delay_time = rand_float(0.2, 0.4) 
  1058. 		if coop_is_active() then 
  1059. 			delay_time = delay_time * 1.5 
  1060. 		end 
  1061. 		delay(delay_time) 
  1062. 	--	ai_add_enemy_target( npc, mIntroBB_homie.blackbeard, ATTACK_NOW, true, true ) 
  1063. 	end 
  1064. 	--character_make_priority_target( mIntroBB_homie.blackbeard, true) 
  1065. 	 
  1066.  
  1067. 	--keep spawning until we killed alot  
  1068. 	while (kill_list_get_count() > 0) do 
  1069. 		thread_yield() 
  1070. 	end 
  1071. 	mIntroBB_cleanup_wave() 
  1072.  
  1073. 	-- Get the warhammer (blocking) 
  1074. 	mIntroBB_get_warhammer() 
  1075.  
  1076. 	-- wave 2 
  1077. 	group_create_hidden(mIntroBB_group.imp_wave.name, true) 
  1078. 	for i, npc in pairs(mIntroBB_group.imp_wave.npcs) do 
  1079. 		if i >= mIntroBB_wave_2 then 
  1080. 			break 
  1081. 		end 
  1082. 		-- space them out a little 
  1083. 		mIntroBB_spawn_imp(npc, mIntroBB_tweakables.wave2_chance, false) 
  1084. 		local delay_time = rand_float(0.2, 0.4) 
  1085. 		if coop_is_active() then 
  1086. 			delay_time = delay_time * 1.5 
  1087. 		end 
  1088. --		delay(delay_time) 
  1089. 		--ai_add_enemy_target( npc, mIntroBB_homie.blackbeard, ATTACK_NOW, true, true ) 
  1090. 	end 
  1091. 	--character_make_priority_target( mIntroBB_homie.blackbeard, true) 
  1092. 	--keep spawning until we killed alot  
  1093. 	while (kill_list_get_count() > 0) do 
  1094. 		thread_yield() 
  1095. 	end 
  1096.  
  1097. 	convo_start(mIntroBB_convo.imp_explain_1) 
  1098. 	convo_wait_for_end() 
  1099. 	convo_start(mIntroBB_convo.imp_explain_2) 
  1100. 	convo_wait_for_end() 
  1101.  
  1102. 	 
  1103. 	mIntroBB_cleanup_wave() 
  1104. 	-- wave 3 
  1105. 	group_create_hidden(mIntroBB_group.imp_wave.name, true) 
  1106.  
  1107. 	for i, npc in pairs(mIntroBB_group.imp_wave.npcs) do 
  1108. 		if i >= mIntroBB_wave_3 then 
  1109. 			break 
  1110. 		end 
  1111. 		-- space them out a little 
  1112. 		mIntroBB_spawn_imp(npc, mIntroBB_tweakables.wave3_chance) 
  1113. 		local delay_time = 0.1 
  1114. 		if coop_is_active() then 
  1115. 			delay_time =.25 
  1116. 		end 
  1117. 		delay(delay_time) 
  1118. 	--	ai_add_enemy_target( npc, mIntroBB_homie.blackbeard, ATTACK_NOW, true, true ) 
  1119. 	end 
  1120.  
  1121. 	delay(1.0) 
  1122. 	convo_start(mIntroBB_convo.bb_swarmed) 
  1123. 	--character_make_priority_target( mIntroBB_homie.blackbeard, true) 
  1124. 	--keep spawning until we killed alot  
  1125. 	while (kill_list_get_count() > 0) do 
  1126. 		thread_yield() 
  1127. 	end 
  1128. 	 
  1129. 	thread_kill(mIntroBB_thread.killzone_thread) 
  1130. 	thread_kill(mIntroBB_thread.distance_thread) 
  1131. 	thread_kill(mIntroBB_thread.ship_health_thread) 
  1132. 	thread_kill(mIntroBB_thread.imp_attack_thread) 
  1133.  
  1134. 	--turn off the ship bar 
  1135. 	hud_bar_set_ship_health_percent(0) 
  1136. end 
  1137.  
  1138. function mIntroBB_get_warhammer() 
  1139. 	-- Clear the current objective 
  1140. 	objective_text_clear(0) 
  1141. 	objective_text(0,"GM_IMPFEST_OBJ_WARHAMMER","","",SYNC_ALL,OI_ASSET_USE) 
  1142.  
  1143. 	--door_message_override("whammer_crate_mover", "GM_INTROBB_OPEN_CHEST") 
  1144.  
  1145. 	trigger_setup(mIntroBB_trigger.open_chest_trig) 
  1146. 	marker_add(mIntroBB_trigger.open_chest_trig, MINIMAP_ICON_USE, OI_ASSET_USE ) 
  1147. 	convo_start(mIntroBB_convo.get_warhammer) 
  1148.  
  1149. 	while(mIntroBB_trigger.open_chest_trig.hit == false) do 
  1150. 		thread_yield() 
  1151. 	end 
  1152.  
  1153. 	local human = LOCAL_PLAYER 
  1154. 	if (coop_is_active() == true) then 
  1155. 		if (mIntroBB_trigger.open_chest_trig.last_hit_by == REMOTE_PLAYER) then 
  1156. 				human = REMOTE_PLAYER 
  1157. 		end 
  1158. 	end 
  1159. 	--Make sure they cant do any wierd stuff right before the animation 
  1160. 	player_controls_disable(human) 
  1161. 	player_pos_correct(human, "whammer_crate_mover") 
  1162. 	-- Unlock the crate containing the warhammer 
  1163. 	door_lock("whammer_crate_mover", false) 
  1164. 	door_open("whammer_crate_mover", false, true, human, "open crate", "chest_anim_sync_nav") 
  1165. 	--on_door_opened("mIntroBB_warhammer_crate_opened_cb", "whammer_crate_mover") 
  1166. 	--Wait until animation is done so hammer does not clip into chest. 
  1167. 	delay(2.5)		 
  1168. 	-- Wait until the player has picked up the warhammer 
  1169. 	mIntroBB_give_warhammer() 
  1170.  
  1171. 	while not inv_has_item("Melee-Warhammer") do 
  1172. 		thread_yield() 
  1173. 	end 
  1174. 	player_controls_enable(human) 
  1175. 	--marker_remove(mIntroBB_navpoints.warhammer_crate) 
  1176. 	objective_text_clear(0) 
  1177. 	objective_text(0,"GM_IMPFEST_OBJ_PROTECT_SHIP","","",SYNC_ALL,OI_ASSET_DEFEND) 
  1178. end 
  1179.  
  1180. function mIntroBB_killzone_check() 
  1181. 	while(true) do 
  1182. 		mIntroBB_killzone_exit_check() 
  1183. 		thread_yield() 
  1184. 	end 
  1185. end 
  1186.  
  1187. function mIntroBB_cleanup_wave() 
  1188. 	mIntroBB_num_attack_imps = 0 
  1189. 	--set all the points to go after it again. 
  1190. 	for i,nav in pairs(imp_attack_navs) do 
  1191. 		nav.taken = false 
  1192. 	end 
  1193. 	for i, imp in pairs(mIntroBB_attacking_imps) do 
  1194. 		mIntroBB_attacking_imps[i] = nil 
  1195. 	end 
  1196. 	for i, entry in pairs(mIntroBB_attacking_effects) do 
  1197. 		if(entry.imp ~= "") then 
  1198. 			on_death("", entry.imp) 
  1199. 		end 
  1200. 		entry.imp = "" 
  1201. 		entry.effect = "" 
  1202. 	end 
  1203. 	 
  1204. 	mIntroBB_attacking_effects_num = 0 
  1205. 	delay(2) 
  1206. 	group_destroy(mIntroBB_group.imp_wave.name) 
  1207.  
  1208. 	 
  1209. end 
  1210.  
  1211. function  mIntroBB_spawn_imp(imp_name, percent, spawn_anyway) 
  1212. 	spawn_anyway = spawn_anyway or true 
  1213. 	--character_hide(imp_name) 
  1214. 	npc_revive(imp_name) 
  1215. 	local nav_table = nil 
  1216. 	repeat 
  1217. 		local nav_idx = rand_int(1, #mIntroBB_imp_navs) 
  1218. 		for i=1, #mIntroBB_imp_navs do 
  1219. 			if (mIntroBB_imp_navs[nav_idx].in_use == false or spawn_anyway) then 
  1220. 				nav_table = mIntroBB_imp_navs[nav_idx] 
  1221. 				nav_table.in_use = true -- mark the navpoint as in use 
  1222. 				break 
  1223. 			end 
  1224. 			 
  1225. 			nav_idx = nav_idx + 1 
  1226. 			if (nav_idx > #mIntroBB_imp_navs) then 
  1227. 				nav_idx = 2 
  1228. 			end 
  1229. 		end 
  1230. 		thread_yield() 
  1231. 	until(nav_table ~= nil) 
  1232. 	teleport(imp_name, nav_table.start_pos, false, true, 0.0, 0.0, 0.0, false, false) 
  1233. 	 
  1234. 	--Only show them when they are at their destination 
  1235. 	while (get_dist(imp_name, nav_table.start_pos) > 1) do 
  1236. 	 
  1237. 		thread_yield() 
  1238. 	end 
  1239. 	--make sure no superpower's interrupt the animation 
  1240. 	character_enable_superpower_immunity(imp_name, true) 
  1241. 	-- Show and play the climb animation 
  1242. 	ai_clear_scripted_action(imp_name) 
  1243. 	clear_animation_state(imp_name) 
  1244. 	character_show(imp_name) 
  1245. 	character_collision_enable(imp_name, false) 
  1246. 	human_gravity_enable(imp_name, false) 
  1247.  
  1248. 	on_anim_trigger("mIntroBB_imp_cb", imp_name) 
  1249. 	--do the blocking ourselves considering that death is a consideration 
  1250. 	local random = rand_int(1,10) 
  1251. 	if random < 7 then 
  1252. 		action_play_non_blocking(imp_name, "spawn_tube") 
  1253. 	else 
  1254. 		action_play_non_blocking(imp_name, "spawn_tube_a") 
  1255. 	end 
  1256. 	 
  1257. 	delay(.5) 
  1258. 	kill_list_add( imp_name, OI_ASSET_KILL ) 
  1259. 	--make some go after the ship 
  1260. 	local chance = rand_float(0,1) 
  1261. 	if chance <= percent then 
  1262. 		--attack the ship!!! 
  1263. 		local attack_point = nil 
  1264. 		local attempts = 0 
  1265. 		while( (attack_point == nil or attack_point.taken == true) and attempts < 50) do 
  1266. 			attack_point = get_random_table_entry(imp_attack_navs) 
  1267. 			attempts = attempts + 1 
  1268. 		end 
  1269. 		if(attack_point.taken == false) then 
  1270. 			ai_do_scripted_move(imp_name, attack_point.name, true, false) 
  1271. 			attack_point.taken = true 
  1272. 			 
  1273. 			thread_new("mIntroBB_get_to_nav_thread",imp_name,attack_point.name) 
  1274. 		end 
  1275. 	end 
  1276. 	mIntroBB_thread.navpoint_reset = thread_new("mIntroBB_Reset_navpoint", nav_table) 
  1277. 	 
  1278. end 
  1279.  
  1280. -- wait for Imp to finish spawning before navpoint can be used again 
  1281. function mIntroBB_Reset_navpoint(nav_table) 
  1282. 	delay(.5) 
  1283. 	 
  1284. 	-- Mark the navpoint as available 
  1285. 	nav_table.in_use = false 
  1286. end 
  1287.  
  1288. function mIntroBB_cleanup_blackbeard() 
  1289. 	if mIntroBB_homie.blackbeard ~= nil and mIntroBB_homie.blackbeard ~= "" then 
  1290. 		on_death("", mIntroBB_homie.blackbeard) 
  1291. 		on_dismiss("", mIntroBB_homie.blackbeard) 
  1292. 		on_take_damage("", mIntroBB_homie.blackbeard) 
  1293. 	 
  1294. 		marker_remove( mIntroBB_homie.blackbeard) 
  1295. 	end 
  1296. end 
  1297.  
  1298. --check to see if everyone is on the ship 
  1299. function mIntroBB_killzone_exit_check() 
  1300. 	local radius = trigger_get_radius(mIntroBB_trigger.kt_ship_killzone_trigger.name) 
  1301. 	local members = kill_list_get_members() 
  1302. 	for i, npc in pairs(members) do 
  1303. 		if not character_is_dead (npc) and (get_dist(npc,mIntroBB_trigger.kt_ship_killzone_trigger.name) > radius) then 
  1304. 			character_kill(npc) 
  1305. 		end 
  1306. 		if(character_hidden(npc)) then 
  1307. 			character_kill(npc) 
  1308. 		end 
  1309. 	end 
  1310. 	if not character_is_dead (mIntroBB_homie.blackbeard) and (get_dist(mIntroBB_homie.blackbeard,mIntroBB_trigger.kt_ship_killzone_trigger.name) > radius) then 
  1311. 		character_kill(mIntroBB_homie.blackbeard) 
  1312. 	end 
  1313. end 
  1314.  
  1315. ------------------------------------ 
  1316. -- 
  1317. -- Checkpoint callback functions 
  1318. -- 
  1319. ------------------------------------ 
  1320.  
  1321. function mIntroBB_ship_limit_enter_cb() 
  1322. 	message("Jump/Sprint Limits On", 1.0, false) 
  1323. 	tweak_table_override_value("Sprint_super_max_speed_scripted", 26) 
  1324. end 
  1325.  
  1326. function mIntroBB_imp_cb(imp_name) 
  1327. 	character_enable_superpower_immunity(imp_name, false) 
  1328.  
  1329. 	human_gravity_enable(imp_name, true) 
  1330. 	character_collision_enable(imp_name, true) 
  1331.  
  1332. 	 
  1333. end 
  1334. function mIntroBB_imp_death_cb(imp) 
  1335. 	for i, entry in pairs(mIntroBB_attacking_effects) do 
  1336. 		if entry.imp == imp then 
  1337. 			effect_stop(entry.effect) 
  1338. 		end 
  1339. 	end 
  1340. 	kill_list_clear(imp) 
  1341. end 
  1342.  
  1343. function mIntroBB_warhammer_crate_opened_cb() 
  1344. 	mIntroBB_give_warhammer() 
  1345. end 
  1346.  
  1347. -- Give player(s) war hammer 
  1348. function mIntroBB_give_warhammer() 
  1349. 	thread_yield() 
  1350.  
  1351. 	local weapon_name = "Melee-Warhammer" 
  1352. 	local count = 1 
  1353. 	local unlimited = true 
  1354. 	local equip_now = true 
  1355. 	local dual_wielding = false 
  1356. 	local force_override = false 
  1357. 	local upgrade_flags =  0  
  1358. 	local allow_downgrade = true 
  1359. 	inv_weapon_add_temporary(LOCAL_PLAYER, weapon_name, count, unlimited, equip_now, dual_wielding, force_override, upgrade_flags, allow_downgrade) 
  1360.  
  1361. 	 if (coop_is_active() == true) then 
  1362. 			inv_weapon_add_temporary(REMOTE_PLAYER, weapon_name, count, unlimited, equip_now, dual_wielding, force_override, upgrade_flags, allow_downgrade) 
  1363. 			convo_start(mIntroBB_convo.gat_warhammer) 
  1364. 			convo_wait_for_end() 
  1365. 			convo_start(mIntroBB_convo.kinzie_warhammer) 
  1366. 	 end 
  1367.  
  1368. 	 
  1369. 	if not coop_is_active() then 
  1370. 		if character_get_anim_set(LOCAL_PLAYER) == "PLYM" then 
  1371. 			convo_start(mIntroBB_convo.gat_warhammer) 
  1372. 		else 
  1373. 			convo_start(mIntroBB_convo.kinzie_warhammer) 
  1374. 		end 
  1375. 	end 
  1376. end 
  1377.  
  1378. --when the player is too far for too long, end it 
  1379. function mIntroBB_too_far_cb() 
  1380. 	mission_end_failure("mIntroBB", "GM_IMPFEST_FAIL_BB_DISMISSED") 
  1381. end 
  1382. ------------------------------------ 
  1383. -- 
  1384. -- Checkpoint thread functions 
  1385. -- 
  1386. ------------------------------------ 
  1387. function playSAMRaise() 
  1388.  
  1389. 	-- Register a callback for when the seamless animated moment completes 
  1390. 	on_seamless_animated_moment_end("mIntroBB_ext_cb_raise_complete") 
  1391.  
  1392. 	local actor_list = { LOCAL_PLAYER, "" } 
  1393. 	seamless_animated_moment_prep(mIntroBB_anim_node.raise_ship, actor_list) 
  1394. 	seamless_animated_moment_start(mIntroBB_anim_node.raise_ship, actor_list) 
  1395.  
  1396. 	while not mIntroBB_runtime.rs_sam_complete do 
  1397. 		thread_yield() 
  1398. 	end 
  1399.  
  1400. 	-- Remove callback 
  1401. 	on_seamless_animated_moment_end("") 
  1402. end 
  1403.  
  1404.  
  1405.  
  1406. --this will keep track of the imps we sent to attack the ship 
  1407. function mIntroBB_attack_ship_thread() 
  1408. 	while true do 
  1409. 		--figure out how many imps are attacking the ship 
  1410. 		local attacking_imps = 0 
  1411. 		for i, imp in pairs(mIntroBB_attacking_imps) do 
  1412. 			if imp ~= nil and not character_is_dead(imp) then 
  1413. 				--make sure they are there and doing their attack animation 
  1414. 				if check_script_animation_state(imp, mIntroBB_imp_animation_state) and not human_is_frozen(imp) then 
  1415. 					attacking_imps = attacking_imps + 1 
  1416. 				end 
  1417.  
  1418. 				--deal with the on/off vfx 
  1419. 				for i, entry in pairs(mIntroBB_attacking_effects) do 
  1420. 					if entry.imp == imp then 
  1421. 						if entry.effect == 0 and not human_is_frozen(imp) then 
  1422. 							entry.effect = effect_play_on_human(imp_attack_navs[1].name, imp, nil, true) 
  1423. 						else if human_is_frozen(imp) then 
  1424. 							effect_stop(entry.effect) 
  1425. 							entry.effect = 0 
  1426. 						end	 
  1427. 					end	 
  1428. 					break 
  1429. 				end 
  1430. 			end 
  1431. 		end 
  1432. 	end 
  1433.  
  1434. 		mIntroBB_current_ship_health = mIntroBB_current_ship_health - attacking_imps * mIntroBB_tweakables.damage_per_sec_imp /10 --divided due to the delay, since we are do this every 1/10 of a sec 
  1435. 		delay(.1) 
  1436. 	end 
  1437. end 
  1438.  
  1439. --this determines if we have reached our navpoint to attack the ship 
  1440. function mIntroBB_get_to_nav_thread(imp_name, nav) 
  1441. 	local reached = false 
  1442. 	while not character_is_dead(imp_name) and not reached do 
  1443. 		if ai_scripted_action_is_complete(imp_name) then 
  1444. 			ai_clear_scripted_action(imp_name) 
  1445. 			reached = true 
  1446. 			--put them in the animation state, but only if they have successfully reached the destination 
  1447. 			if(get_dist(imp_name,nav) <= 1.5) then 
  1448. 				--hold on to these imps for later use 
  1449. 				mIntroBB_attacking_imps[mIntroBB_num_attack_imps] = imp_name 
  1450. 				mIntroBB_num_attack_imps = mIntroBB_num_attack_imps + 1 
  1451. 				set_script_animation_state(imp_name, mIntroBB_imp_animation_state) 
  1452. 				--make sure thye are facing the right way 
  1453. 				character_set_orient_from_nav(imp_name,nav) 
  1454.  
  1455. 				--play effect 
  1456. 				mIntroBB_attacking_effects_num = mIntroBB_attacking_effects_num + 1 
  1457. 				mIntroBB_attacking_effects[mIntroBB_attacking_effects_num].effect = effect_play_on_human(nav, imp_name, nil, true) 
  1458. 				mIntroBB_attacking_effects[mIntroBB_attacking_effects_num].imp = imp_name 
  1459. 				 
  1460. 				on_death("mIntroBB_imp_death_cb", imp_name) 
  1461.  
  1462. 				character_enable_supersprint_immunity(imp_name) 
  1463. 			end 
  1464. 		end 
  1465. 		thread_yield() 
  1466. 	end 
  1467. end 
  1468.  
  1469. --this will keep track of the ship health for usPistol-HandCrossbow 
  1470. function mIntroBB_ship_health_thread() 
  1471. 	while true do 
  1472. 		 
  1473. 		if mIntroBB_current_ship_health <= 0 then 
  1474. 		mIntroBB_current_ship_health = 0 
  1475. 			--we failed 
  1476. 			mission_end_failure("mIntroBB", "GM_IMPFEST_FAIL_SHIP") 
  1477. 		end 
  1478. 		hud_bar_set_ship_health_percent(mIntroBB_current_ship_health / mIntroBB_tweakables.max_ship_health) 
  1479. 		thread_yield() 
  1480. 	end 
  1481. end 
  1482.  
  1483. function mIntroBB_player_too_far_thread() 
  1484. 	local is_too_far = false 
  1485. 	while true do 
  1486. 		thread_yield() 
  1487. 		--check to see if the player is too far away 
  1488. 		local dist = get_dist(LOCAL_PLAYER,mIntroBB_homie.blackbeard) 
  1489. 		if coop_is_active() then 
  1490. 			local dist_remote = get_dist(REMOTE_PLAYER,mIntroBB_homie.blackbeard) 
  1491. 			if dist_remote > dist then 
  1492. 				dist = dist_remote 
  1493. 			end 
  1494. 		end 
  1495. 		if dist > mIntroBB_far_distance  then 
  1496. 			if not is_too_far then 
  1497. 				is_too_far = true 
  1498. 				hud_critical_timer_set(mIntroBB_hud_time_ms, "GM_IMPFEST_OBJ_WARN_CLOSER", "mIntroBB_too_far_cb") 
  1499. 			end 
  1500. 		else 
  1501. 			 if is_too_far then 
  1502. 				--reset the timer 
  1503. 				is_too_far = false 
  1504. 				hud_critical_timer_stop() 
  1505. 			end 
  1506. 		end 
  1507. 	end 
  1508. end 
  1509.  
  1510. -------------------------------------------------------------------------------------------------- 
  1511. --[[ 
  1512.  
  1513.    _____                                        ______                _   _                  
  1514.   / ____|                                      |  ____|              | | (_)                 
  1515.  | |     ___  _ __ ___  _ __ ___   ___  _ __   | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  1516.  | |    / _ \| '_ ` _ \| '_ ` _ \ / _ \| '_ \  |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  1517.  | |___| (_) | | | | | | | | | | | (_) | | | | | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  1518.   \_____\___/|_| |_| |_|_| |_| |_|\___/|_| |_| |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  1519. 																							 
  1520. 																							 
  1521. ]]-- 
  1522.  
  1523. function mIntroBB_create_blackbeard(blackbeard_group) 
  1524. 	if not group_is_loaded(blackbeard_group) then 
  1525. 		group_create(blackbeard_group, true) 
  1526. 	end 
  1527. 	 
  1528. 	inv_item_add( "Pistol-HandCrossbow", 1, blackbeard_group.blackbeard, true ) 
  1529. 	character_enable_superpower_immunity(blackbeard_group.blackbeard, true) 
  1530. 	mIntroBB_homie.blackbeard = blackbeard_group.blackbeard 
  1531. 	--need to make him immune to player damage 
  1532. 	--turn_invulnerable(mIntroBB_homie.blackbeard) 
  1533. 	character_allow_ragdoll(mIntroBB_homie.blackbeard,false) 
  1534. 	follower_remain_in_car(mIntroBB_homie.blackbeard, true) 
  1535. 	 
  1536. 	on_death("mIntroBB_failure_blackbeard_died_cb", mIntroBB_homie.blackbeard) 
  1537. 	on_dismiss("mIntroBB_failure_dismissed_cb", mIntroBB_homie.blackbeard) 
  1538. 	 
  1539. end	 
  1540.  
  1541. function mIntroBB_setup_and_wait_trigger(trigger, callback) 
  1542. 	trigger_setup(trigger) 
  1543. 	if callback ~= nil then 
  1544. 		on_trigger(callback, trigger.name) 
  1545. 	end 
  1546. 	while trigger.hit == false do 
  1547. 		thread_yield() 
  1548. 	end 
  1549. 	on_trigger("", trigger.name) 
  1550. 	trigger_clear(trigger.name) 
  1551. end 
  1552. -------------------------------------------------------------------------------------------------- 
  1553. --[[ 
  1554.  
  1555.    _____      _ _ _                _      ______                _   _                  
  1556.   / ____|    | | | |              | |    |  ____|              | | (_)                 
  1557.  | |     __ _| | | |__   __ _  ___| | __ | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  1558.  | |    / _` | | | '_ \ / _` |/ __| |/ / |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  1559.  | |___| (_| | | | |_) | (_| | (__|   <  | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  1560.   \_____\__,_|_|_|_.__/ \__,_|\___|_|\_\ |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  1561. 																					   
  1562. 																					   
  1563. ]]-- 
  1564.  
  1565. function mIntroBB_failure_dismissed_cb() 
  1566. 	mission_end_failure("mIntroBB", "GM_IMPFEST_FAIL_BB_DISMISSED") 
  1567. end 
  1568.  
  1569. function mIntroBB_failure_blackbeard_died_cb() 
  1570. 	-- End the mission, blackbeard died 
  1571. 	mission_end_failure("mIntroBB", "GM_IMPFEST_FAIL_BLACKBEARD") 
  1572. end 
  1573.  
  1574. function mIntroBB_trigger_limit_exit_cb() 
  1575. 	message("Jump/Sprint Limits Off", 1.0, false) 
  1576. 	tweak_table_restore_value("Jump_super_max_height_scripted") 
  1577. 	tweak_table_restore_value("Sprint_super_max_speed_scripted") 
  1578. end 
  1579.  
  1580. --function to actually hurt blackbeard if it's not from the player. A workaround from the player shooting and blowing him up 
  1581. function mImpest_blackbeard_hit_cb(character, attacker, health_percent, from_explosion, from_melee, vomit, damage) 
  1582. 	if damage ~= nil and( attacker == nil or (not character_is_dead(attacker) and not character_is_player(attacker) ))then 
  1583. 		turn_vulnerable(character) 
  1584. 		character_damage(character, damage, true, attacker) 
  1585. 		turn_invulnerable(character) 
  1586. 	end 
  1587. end 
  1588.  
  1589. -- Callback for when the Raise Ship SAM completes 
  1590. function mIntroBB_ext_cb_raise_ship_complete() 
  1591. 	group_destroy(mIntroBB_group.ship) 
  1592. 	mIntroBB_runtime.rs_sam_complete = true 
  1593. 	message("SAM Raise Ship complete", 2.0, false) 
  1594. end 
  1595.  
  1596. -- Callback for when the Raise Ship SAM completes 
  1597. function mIntroBB_ext_cb_raise_complete() 
  1598. 	mIntroBB_runtime.rs_sam_complete = true 
  1599. end 
  1600.  
  1601. -- Callback for when the Impfestation SAM completes 
  1602. function mIntroBB_ext_cb_impfestation_complete() 
  1603. 	group_destroy(mIntroBB_group.cin_imp) 
  1604. 	mIntroBB_runtime.if_sam_complete = true 
  1605. end 
  1606.  
  1607. -- Callback for when gaining the summon power sam is complete 
  1608. function mIntroBB_PowerSAM_Complete() 
  1609. 	mIntroBB_runtime.power_sam_complete = true 
  1610. end 
  1611. -------------------------------------------------------------------------------------------------- 
  1612. --[[ 
  1613.  
  1614.   _______ _                        _   ______                _   _                  
  1615.  |__   __| |                      | | |  ____|              | | (_)                 
  1616. 	| |  | |__  _ __ ___  __ _  __| | | |__ _   _ _ __   ___| |_ _  ___  _ __  ___  
  1617. 	| |  | '_ \| '__/ _ \/ _` |/ _` | |  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __| 
  1618. 	| |  | | | | | |  __/ (_| | (_| | | |  | |_| | | | | (__| |_| | (_) | | | \__ \ 
  1619. 	|_|  |_| |_|_|  \___|\__,_|\__,_| |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ 
  1620. 																				    
  1621. 																				    
  1622. ]]-- 
  1623.  
  1624.