sr2lua/sh_ss_trailerpark.lua

  1. --[[------------------------------------------------------------------------------- 
  2. -- sh_ss_trailerpark.lua 
  3. -- sons of samedi stronghold 1 - Suburbs traler park 
  4. -- Good Stuff by David Bowring 
  5. --]] 
  6.  
  7.  
  8.  
  9.  
  10.  
  11. ---Tables--- 
  12.  
  13. trailers = {"sh_ss_trailerpark_ARNTP2A_Hull060", "sh_ss_trailerpark_ARNTP2A_Hull040", "sh_ss_trailerpark_ARNTP2A_Hull020", "sh_ss_trailerpark_ARNTP2A_Hull030", "sh_ss_trailerpark_ARNTP2A_Hull070"} 
  14. groups = {"sh_ss_trailerpark_$GroupOne", "sh_ss_trailerpark_$Greinf", "sh_ss_trailerpark_$GLts"} 
  15. boss = {"sh_ss_trailerpark_$c013", "sh_ss_trailerpark_$c013 (0)", "sh_ss_trailerpark_$c013 (1)", "sh_ss_trailerpark_$c013 (2)", "sh_ss_trailerpark_$c013 (3)", "sh_ss_trailerpark_$c013 (4)", "sh_ss_trailerpark_$c013 (5)"} 
  16. reinf = {"sh_ss_trailerpark_$c010 (2)", "sh_ss_trailerpark_$c012 (3)",  "sh_ss_trailerpark_$c012 (2)", "sh_ss_trailerpark_$c010", "sh_ss_trailerpark_$c010 (0)", "sh_ss_trailerpark_$c010 (2)"} 
  17. ---globals--- 
  18. trailers_destroyed = {false, false, false, false, false} 
  19. trailers_count = 0 
  20. trailers_total = sizeof_table( trailers ) 
  21. boss_count = 0 
  22. boss_total = sizeof_table( boss ) 
  23. Process_thread_handle = "" 
  24. reinf_total= sizeof_table( reinf ) 
  25. animate=false 
  26. map_found=false 
  27.  
  28. function sh_ss_trailerpark_start(checkpoint, is_restart) 
  29. 	set_mission_author("David Bowring") 
  30. 	 
  31. 	if checkpoint == MISSION_START_CHECKPOINT then 
  32. 	mission_start_fade_out() 
  33. 	teleport_coop("sh_ss_trailerpark_$nstart","sh_ss_trailerpark_$nstart (0)") 
  34. 	group_create("sh_ss_trailerpark_$Gweapons", true) 
  35. 	notoriety_set_max("police", 1) 
  36. 	notoriety_set("samedi", 0)	 
  37. 	mission_debug("Mission Start") 
  38. 	sh_ss_trailerpark_trailer_blown() 
  39. 	if (not coop_is_active()) then 
  40. 		notoriety_force_no_spawn("samedi", true) 
  41. 	end 
  42. 	animate=true 
  43. 	if (not is_restart) then 
  44. 		cutscene_play("sh_ss_trailerpark_ct2") 
  45. 	end 
  46. 	door_lock("sh_ss_trailerpark_LM_DoorExtMM010", true) 
  47. 	door_lock("sh_ss_trailerpark_LM_MeshMover020", true) 
  48. 	on_trigger("sh_ss_trailerpark_set_alert", "sh_ss_trailerpark_$talert") 
  49. 	on_trigger("sh_ss_trailerpark_checkpoint", "sh_ss_trailerpark_$tmap") 
  50. 	--on_trigger("sh_ss_trailerpark_animate", "sh_ss_trailerpark_$tanimate") 
  51. 	--trigger_enable("sh_ss_trailerpark_$tanimate", true) 
  52. 	trigger_enable("sh_ss_trailerpark_$talert", true) 
  53. 	trigger_enable("sh_ss_trailerpark_$tmap", true) 
  54. 	marker_add_navpoint("sh_ss_trailerpark_$tmap",MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION) 
  55. 	 
  56. 	--group_create("sh_ss_trailerpark_$GSaintAgent", true) 
  57. 	 
  58. 	 
  59. 	mission_debug("creating groups") 
  60. 	if group_is_loaded("sh_ss_trailerpark_$GroupFour") == false then 
  61. 	group_create("sh_ss_trailerpark_$GroupFour",true) 
  62. 	end 
  63. 	delay(.25) 
  64. 	if group_is_loaded("sh_ss_trailerpark_$GroupOne") == false then 
  65. 	group_create("sh_ss_trailerpark_$GroupOne",true) 
  66. 	end 
  67. 	delay(.25) 
  68. 	if group_is_loaded("sh_ss_trailerpark_$GroupOne") == false then 
  69. 	group_create("sh_ss_trailerpark_$GroupTwo",true) 
  70. 	end 
  71. 	delay(.25) 
  72. 	if group_is_loaded("sh_ss_trailerpark_$GroupThree") == false then 
  73. 	group_create("sh_ss_trailerpark_$GroupThree",true) 
  74. 	end 
  75. 	--If the player attacks then bad guys will respond! 
  76.  sh_ss_trailerpark_reinforcments() 
  77. 	mission_start_fade_in() 
  78. 	 delay(.25) 
  79. 	 sh_ss_trailerpark_phasetwo() 
  80. else 
  81. fade_in(1) 
  82. group_create("sh_ss_trailerpark_$Gweapons", true) 
  83. sh_ss_trailerpark_blow() 
  84.  
  85. end 
  86.  
  87. 	 
  88.  
  89. end 
  90.  
  91.  
  92. function sh_ss_trailerpark_satchel()		 
  93. 	on_pickup("sh_ss_trailerpark_checkpoint", "sh_ss_trailerpark_$isatchel")  
  94. end 
  95.  
  96.  
  97.  
  98. function sh_ss_trailerpark_trailer_blown() 
  99. 	for i = 1 , trailers_total, 1 do	 
  100. 		on_mover_destroyed("sh_ss_trailerpark_killcount", trailers[i]) 
  101. 	end 
  102. end 
  103.  
  104. function sh_ss_trailerpark_checkpoint() 
  105. 	mission_set_checkpoint("blow") 
  106. 	delay(.2) 
  107. 	sh_ss_trailerpark_blow() 
  108. end 
  109.  
  110. function sh_ss_trailerpark_blow() 
  111. 	 
  112. 	objective_text_clear(0) 
  113. 	marker_remove_navpoint("sh_ss_trailerpark_$tmap") 
  114. 	trigger_enable("sh_ss_trailerpark_$tmap",false) 
  115. 	on_trigger("", "sh_ss_trailerpark_$tmap") 
  116. 	door_lock("sh_ss_trailerpark_LM_DoorExtMM010", false) 
  117. 	door_lock("sh_ss_trailerpark_LM_MeshMover020", false) 
  118. 	if	(trailers_count == trailers_total) then 
  119. 	--log that we've destroyed all of the trailers 
  120. 	--gamelog_log_event("STRONGHOLD_EVENT", "trailers all destroyed", 0) 
  121. 	objective_text_clear(0) 
  122. 	delay(3) 
  123. 	--sh_ss_trailerpark_demo() 
  124. 	mission_end_success("sh_ss_trailerpark")	 
  125. 	end 
  126. 	--on_vehicle_enter("sh_ss_trailerpark_player_in_car", LOCAL_PLAYER)  
  127. 	--marker_remove_item("sh_ss_trailerpark_$isatchel") 
  128. 	delay(3) 
  129. 	mission_help_table("sh_ss_trailer_trailer_give_instructtwo") 
  130. 	objective_text(0, "sh_ss_trailer_trailer_count",trailers_count , trailers_total) 
  131. 	map_found=true 
  132. 	for i = 1 , trailers_total, 1 do 
  133. 		if mesh_mover_destroyed(trailers[i]) == false then 
  134. 		--turn_vulnerable(trailers[i]) 		 
  135. 		mission_debug("Draw Markers") 
  136. 		mesh_mover_reset(trailers[i]) 
  137. 		marker_add_mover(trailers[i], MINIMAP_ICON_KILL,  INGAME_EFFECT_VEHICLE_KILL) 
  138. 		on_mover_destroyed("sh_ss_trailerpark_killcount", trailers[i]) 
  139. 		end 
  140. 	end 	  
  141. end 
  142.  
  143.  
  144. function sh_ss_trailerpark_player_in_car() 
  145. 	group_create("sh_ss_trailerpark_$Gculled") 
  146. end 
  147.  
  148. function sh_ss_trailerpark_set_alert() 
  149. 	on_trigger("", "sh_ss_trailerpark_$talert") 
  150. 	trigger_enable("sh_ss_trailerpark_$talert", false) 
  151. 	--trigger_enable("sh_ss_trailerpark_$tanimate", false) 
  152. 	if notoriety_get("samedi") <= 2 then 
  153. 		notoriety_set_max("samedi", 2) 
  154. 		notoriety_set_min("samedi", 2) 
  155. 	end 
  156. 	for i = 1, reinf_total, 1 do	 
  157. 		attack(reinf[i]) 
  158. 		delay(.8) 
  159. 	end 
  160.  
  161.  
  162. end 
  163.  
  164.  
  165. function sh_ss_trailerpark_talk_to_agent() 
  166. 	marker_add_npc("sh_ss_trailerpark_$cSaintAgent", MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_PROTECT_ACQUIRE)	 
  167. 	move_to("sh_ss_trailerpark_$cSaintAgent","sh_ss_trailerpark_$n000", 3, true) 
  168. 	on_death("sh_ss_trailerpark_agentkill","sh_ss_trailerpark_$cSaintAgent") 
  169. 	delay(3)	 
  170. 	marker_remove_npc("sh_ss_trailerpark_$cSaintAgent") 
  171. 	turn_to_char("sh_ss_trailerpark_$cSaintAgent","#PLAYER#") 
  172. 	mission_help_table("sh_ss_trailer_trailer_give_instruct") 
  173. 	action_play("sh_ss_trailerpark_$cSaintAgent", "compliment b") 
  174. 	delay(5) 
  175. 	mission_help_table("sh_ss_trailer_trailer_give_instructtwo") 
  176. 	action_play("sh_ss_trailerpark_$cSaintAgent", "compliment b") 
  177. 	delay(5) 
  178. 	mission_help_table("sh_ss_trailer_trailer_give_instructthree") 
  179. 	on_death("","sh_ss_trailerpark_$cSaintAgent")  --turn off death failure for agent 
  180. end 
  181.  
  182.  
  183.  
  184. function sh_ss_trailerpark_killcount(mesh) 
  185. 	trailers_count = trailers_count + 1	 
  186. 	--log that we've destroyed a trailer 
  187. 	--gamelog_log_event("STRONGHOLD_EVENT", "trailer destroyed", trailers_count) 
  188. 	if map_found then 
  189. 		marker_remove_mover(mesh) 
  190. 		objective_text(0, "sh_ss_trailer_trailer_count",trailers_count , trailers_total) 
  191. 	end 
  192.  
  193. 	if	(trailers_count == 1) then 
  194. 		mission_help_table_nag("sh_ss_trailer_conformation") 
  195. 		notoriety_set_max("samedi", 3) 
  196. 		notoriety_set_min("samedi", 3) 
  197. 		notoriety_force_no_spawn("samedi", true) 
  198. 	end 
  199.  
  200.  
  201. 	if	(trailers_count == 3) then 
  202. 		notoriety_set_max("samedi", 4) 
  203. 		notoriety_set_min("samedi", 4)	 
  204. 		notoriety_force_no_spawn("samedi", false) 
  205. 	end 
  206.  
  207. 	if	(trailers_count == trailers_total) then 
  208. 	--log that we've destroyed all of the trailers 
  209. 	--gamelog_log_event("STRONGHOLD_EVENT", "trailers all destroyed", 0) 
  210. 	objective_text_clear(0) 
  211. 	delay(3) 
  212. 	--sh_ss_trailerpark_demo() 
  213. 	mission_end_success("sh_ss_trailerpark") 
  214. 	--sh_ss_trailerpark_reinforcments() 
  215. 	end 
  216.  
  217. end 
  218.  
  219.  
  220. function sh_ss_trailerpark_phasetwo() 
  221. 		delay(.25) 
  222. 		--[[disabling until support for this can be coded 
  223. 		for i = 1 , trailers_total, 1 do	 
  224. 			mission_debug("invulnerable="..trailers[i]) 
  225. 			turn_invulnerable(trailers[i], false)  
  226. 		end  
  227. 		--]]		 
  228. 		mission_help_table("sh_ss_trailerpark_instruct_one") 
  229. 		group_create("sh_ss_trailerpark_$GLts") 
  230. 		delay(.25) 
  231. end 
  232.  
  233. function sh_ss_trailerpark_reinforcments() 
  234. 	mission_debug("reinforcments create") 
  235. 	animate=false 
  236. 	group_create("sh_ss_trailerpark_$Greinf", true) 
  237. 	delay(.25)	 
  238. 	for i = 1, reinf_total, 1 do 
  239. 		thread_new("sh_ss_trailerpark_animate", reinf[i]) 
  240. 		on_take_damage("sh_ss_trailerpark_set_alert", reinf[i]) 
  241. 	end		 
  242. end 
  243.  
  244. function sh_ss_trailerpark_animate(char) 
  245. 	--while(animate) do 
  246. 		mission_debug("char="..char) 
  247. 		delay(3) 
  248. 		npc_use_closest_action_node_of_type(char, "Blunt_Smoker")		 
  249. 	--end	 
  250. 	return 
  251. end 
  252.  
  253.  
  254.  
  255. function sh_ss_trailerpark_killcount_boss(char) 
  256. 	boss_count = boss_count + 1 
  257. 	--log that we've killed a lieutenant 
  258. 	--gamelog_log_event("STRONGHOLD_EVENT", "lieutenant killed", boss_count) 
  259. 	marker_remove_npc(char) 
  260. 	objective_text(0, "sh_ss_trailer_lt_count", boss_count, boss_total) 
  261. 	if	(boss_count == boss_total) then 
  262. 		objective_text_clear(0) 
  263. 		delay(3)		 
  264. 		mission_end_success("sh_ss_trailerpark") 
  265. 	end 
  266. end 
  267.  
  268.  
  269. function sh_ss_trailerpark_demo() 
  270. 	group_create("sh_ss_trailerpark_$Gdemo")	 
  271. 	vehicle_enter_teleport("#PLAYER#", "sh_ss_trailerpark_$v002", 0)	 
  272. 	if (coop_is_active()) then 
  273. 		vehicle_enter_teleport("#PLAYER2#","sh_ss_trailerpark_$v002 (0)", 0) 
  274. 	end 
  275. 	release_to_world("sh_ss_trailerpark_$Gdemo") 
  276. end 
  277.  
  278.  
  279. function sh_ss_trailerpark_agentkill() 
  280. 	mission_end_failure("sh_ss_trailerpark") 
  281. end 
  282.  
  283.  
  284. function sh_ss_trailerpark_failure() 
  285. 	mission_end_failure("sh_ss_trailerpark") 
  286. end 
  287.  
  288.  
  289. function sh_ss_trailerpark_cleanup() 
  290. 	notoriety_force_no_spawn("samedi", false) 
  291. 	on_trigger("", "sh_ss_trailerpark_$talert") 
  292. 	on_trigger("", "sh_ss_trailerpark_$tmap") 
  293. 	marker_remove_navpoint("sh_ss_trailerpark_$tmap") 
  294. 	on_vehicle_enter("", LOCAL_PLAYER) 
  295. 	on_pickup("", "sh_ss_trailerpark_$isatchel") 
  296. 	door_lock("sh_ss_trailerpark_LM_DoorExtMM010", false) 
  297. 	door_lock("sh_ss_trailerpark_LM_MeshMover020", false) 
  298. 	for i = 1 , trailers_total, 1 do			 
  299. 		marker_remove_mover(trailers[i]) 
  300. 		on_mover_destroyed("", trailers[i]) 
  301. 	end 		 
  302. end 
  303.  
  304.  
  305.  
  306. function sh_ss_trailerpark_success() 
  307.  
  308.  
  309.  
  310. end