sr2lua/sh_ss_student_union.lua

  1. ---Tables 
  2. recruiters = {"sh_ss_student_union_$c000","sh_ss_student_union_$c001","sh_ss_student_union_$c002","sh_ss_student_union_$c004", "sh_ss_student_union_$c005"} 
  3. boss = {"sh_ss_student_union_$c023", "sh_ss_student_union_$c022", "sh_ss_student_union_$c021", "sh_ss_student_union_$c020", "sh_ss_student_union_$c019", "sh_ss_student_union_$c018", "sh_ss_student_union_$c017", "sh_ss_student_union_$c016", "sh_ss_student_union_$c015"} 
  4. guards = {"sh_ss_student_union_$c003", "sh_ss_student_union_$c024", "sh_ss_student_union_$c025", "sh_ss_student_union_$c026", "sh_ss_student_union_$c028", "sh_ss_student_union_$c029", "sh_ss_student_union_$c030", "sh_ss_student_union_$c031", "sh_ss_student_union_$c032", "sh_ss_student_union_$c033", "sh_ss_student_union_$c034", "sh_ss_student_union_$c035", "sh_ss_student_union_$c036", "sh_ss_student_union_$c037", "sh_ss_student_union_$c038", "sh_ss_student_union_$c039", "sh_ss_student_union_$c040", "sh_ss_student_union_$c041", "sh_ss_student_union_$c042", "sh_ss_student_union_$c043", "sh_ss_student_union_$c044", "sh_ss_student_union_$c045", "sh_ss_student_union_$c046", "sh_ss_student_union_$c047", "sh_ss_student_union_$c048", "sh_ss_student_union_$c049"} 
  5. groups = {"sh_ss_student_union_$GRecruiters", "sh_ss_student_union_$GGuards", "sh_ss_student_union_$GUnion", "sh_ss_student_union_$GSUGUARDS", "sh_ss_student_union_$GSUPEDS", "sh_ss_student_union_$GTruckNDriver", "sh_ss_student_union_$Gfodder"} 
  6.  
  7. --Global Varibles 
  8. recruiters_count = 0 
  9. recruiters_total = sizeof_table( recruiters ) 
  10. boss_count = 0 
  11. boss_total = sizeof_table( boss ) 
  12. guards_count = 0 
  13. guards_total = sizeof_table ( guards ) 
  14. groups_total = sizeof_table(groups) 
  15. thrower_two = "sh_ss_student_union_$c023" 
  16. DOOR_LOCK1="sh_ss_student_union_UnionDoorMM060" 
  17. DOOR_LOCK2="sh_ss_student_union_UnionDoorMM050" 
  18. DOOR_LOCK3="sh_ss_student_union_UnionDoorMM030" 
  19. DOOR_LOCK4="sh_ss_student_union_UnionDoorMM040" 
  20.  
  21.  
  22.  
  23.  
  24.  
  25. function sh_ss_student_union_start(checkpoint, is_restart) 
  26. 	set_mission_author("David Bowring") 
  27.  
  28. 	--set character slots cap so that stream resource limits are not breached 
  29. 	character_slots_cap_for_team( "samedi", 1 ) 
  30.    character_slots_cap_for_team( "police", 1 ) 
  31.  
  32.  
  33. 	if checkpoint == MISSION_START_CHECKPOINT then 
  34. 		mission_start_fade_out() 
  35. 		teleport_coop("sh_ss_student_union_$nstart","sh_ss_student_union_$nstart") 
  36. 		notoriety_set("police", 0) 
  37. 		notoriety_set_min("samedi", 0) 
  38. 		notoriety_set_max("samedi", 2) 
  39. 		notoriety_force_no_spawn("samedi", true) 
  40. 		--notoriety_set("samedhi", 0)	 
  41. 		door_lock("sh_ss_student_union_UnionDoorMM010", true) 
  42. 		door_lock("sh_ss_student_union_UnionDoorMM020", true) 
  43. 		door_lock("shops_sr2_city_UN_gift_door1", true) 
  44. 		door_lock("shops_sr2_city_UN_gift_door2", true) 
  45. 		door_lock(DOOR_LOCK1, true) 
  46. 		door_lock(DOOR_LOCK2, true) 
  47. 		door_lock(DOOR_LOCK3, true) 
  48. 		door_lock(DOOR_LOCK4, true) 
  49. 		group_create_hidden("sh_ss_student_union_$GRecruiters") 
  50. 		if (not is_restart) then 
  51. 			cutscene_play("sh_ss_student_union_ct1") 
  52. 		end 
  53.  
  54. 		group_show("sh_ss_student_union_$GRecruiters") 
  55. 		--teleport("#PLAYER#","sh_ss_student_union_$nstart") 
  56. 		--teleport("#PLAYER2#","sh_ss_student_union_$nstart") 
  57. 		on_trigger("sh_ss_student_union_frontdoor", "sh_ss_student_union_$tfrontdoor") 
  58. 		on_trigger("sh_ss_student_union_fire", "sh_ss_student_union_$tfire") 
  59. 		on_trigger("sh_ss_student_union_fire_two", "sh_ss_student_union_$t000") 
  60. 		trigger_enable("sh_ss_student_union_$tfire", true) 
  61. 		--group_create("sh_ss_student_union_$GRecruiters", true) 
  62. 		--release_to_world("sh_ss_student_union_$GRecruiters") 
  63.  
  64. 	for i = 1, recruiters_total, 1 do 
  65. 		marker_add_npc(recruiters[i], MINIMAP_ICON_KILL, INGAME_EFFECT_KILL) 
  66. 		on_death("sh_ss_student_union_killcount", recruiters[i]) 
  67. 	end 
  68.  
  69. 	--group_create("sh_ss_student_union_$GSUPEDS", true)	 
  70. 	group_create("sh_ss_student_union_$GGuards", true) 
  71. 	release_to_world("sh_ss_student_union_$GGuards") 
  72.  
  73. 	--removed this group to make sure the stream resource limits are not breached 
  74. 	--if not group_is_loaded("sh_ss_student_union_$Gfodder") and coop_is_active()== false then 
  75. 	--	group_create("sh_ss_student_union_$Gfodder", true) 
  76. 	--end 
  77.  
  78. 	if group_is_loaded("sh_ss_student_union_$Gfodder") then 
  79. 		release_to_world("sh_ss_student_union_$Gfodder")		 
  80. 	end 
  81. 	mission_start_fade_in() 
  82. 	mission_help_table("sh_ss_student_union_Instruct_One") 
  83. 	objective_text(0, "sh_ss_student_union_Recruiters_Left", recruiters_count, recruiters_total)		 
  84. 	else 
  85. 	 fade_in(.2) 
  86. 	on_trigger("sh_ss_student_union_frontdoor", "sh_ss_student_union_$tfrontdoor") 
  87. 	on_trigger("sh_ss_student_union_fire", "sh_ss_student_union_$tfire") 
  88. 	on_trigger("sh_ss_student_union_fire_two", "sh_ss_student_union_$t000") 
  89. 	for i = 1, boss_total, 1 do 
  90. 			on_death("sh_ss_student_union_killcount_boss", boss[i]) 
  91. 	end 
  92. 	sh_ss_student_union_SU() 
  93. 	end 
  94. end 
  95.  
  96.  
  97. function sh_ss_student_union_fire() 
  98. local loop = 1 
  99. 	 
  100. 	 
  101. 	if not character_is_dead("sh_ss_student_union_$c018") then 
  102. 		move_to_safe("sh_ss_student_union_$c018", "sh_ss_student_union_$n000", 2, true, true) 
  103. 	end 
  104.  
  105. 	if not character_is_dead("sh_ss_student_union_$c037") then 
  106. 		move_to_safe("sh_ss_student_union_$c037", "sh_ss_student_union_$n037", 2, true, true) 
  107. 	end 
  108.  
  109. 	if not character_is_dead("sh_ss_student_union_$c035") then 
  110. 		move_to_safe("sh_ss_student_union_$c035", "sh_ss_student_union_$nmove1", 2, true, true) 
  111. 	end 
  112. 	 
  113. 	 
  114. 	while (character_is_dead("sh_ss_student_union_$c044") == false) do 
  115. 		--loop = loop +1	 
  116. 		force_throw_char("sh_ss_student_union_$c044", "#PLAYER#", 0) 
  117. 		delay(4) 
  118. 	end 
  119. end 
  120.  
  121. function sh_ss_student_union_fire_two() 
  122. local loop = 1 
  123.  
  124. 	while (character_is_dead("sh_ss_student_union_$c044") == false) do 
  125. 	--loop = loop +1	 
  126. 	force_throw_char("sh_ss_student_union_$c023", "#PLAYER#", 0) 
  127. 	delay(7) 
  128. 	end 
  129. end 
  130.  
  131. function sh_ss_student_union_killcount(char) 
  132. 	recruiters_count = recruiters_count + 1 
  133. 	marker_remove_npc(char) 
  134. 	objective_text_clear(0) 
  135. 	objective_text(0, "sh_ss_student_union_Recruiters_Left", recruiters_count, recruiters_total)	 
  136. 	on_death("", char) 
  137. 	release_to_world(char) 
  138.  
  139. 	 
  140. 	if	(recruiters_count == recruiters_total - 3) then 
  141. 		--group_create("sh_ss_student_union_$GSUGUARDS", true) 
  142. 		spawning_pedestrians(false,false)  
  143. 		notoriety_set_max("samedi", 3) 
  144. 		notoriety_set_min("samedi", 3)		 
  145. 		for i = 1, boss_total, 1 do 
  146. 			on_death("sh_ss_student_union_killcount_boss", boss[i]) 
  147. 		end	 
  148. 	end 
  149. 	 
  150. 	 
  151. 	if	(recruiters_count == recruiters_total) then 
  152. 		--group_create("sh_ss_student_union_$GUnion", false) 
  153. 		objective_text_clear(0) 
  154. 		--delay(1) 
  155. 		mission_set_checkpoint("front") 
  156. 		sh_ss_student_union_SU()	 
  157. 	end 
  158. end 
  159.  
  160. function	sh_ss_student_union_car()	 
  161. 	group_create("sh_ss_student_union_$GTruckNDriver") 
  162. 	vehicle_enter("sh_ss_student_union_$c062", "sh_ss_student_union_$v000", 0) 
  163. 	vehicle_set_allow_ram_ped("sh_ss_student_union_$v000", true)  
  164. 	attack("sh_ss_student_union_$c062") 
  165. end 
  166.  
  167.  
  168.  
  169. function sh_ss_student_union_swarm(CHAR)	 
  170. 	move_to(CHAR, "sh_ss_student_union_$nflood", 3) 
  171. 	attack(CHAR) 
  172. 	delay(1) 
  173. end 
  174.  
  175. function sh_ss_student_union_SU() 
  176. 	--code for short bus attack	 
  177. 	group_create("sh_ss_student_union_$GSUGUARDS", true) 
  178. 	delay(3) 
  179. 	door_lock("sh_ss_student_union_UnionDoorMM010", false) 
  180. 	door_lock("sh_ss_student_union_UnionDoorMM020", false) 
  181. 	door_open("sh_ss_student_union_UnionDoorMM010") 
  182. 	door_open("sh_ss_student_union_UnionDoorMM020")	 
  183. 	for i = 1, guards_total, 1 do			 
  184. 			thread_new("sh_ss_student_union_swarm",guards[i]) 
  185. 	end 
  186.  
  187. 	--group_create("sh_ss_student_union_$GSUGUARDS", true) 
  188. 	group_create("sh_ss_student_union_$Gboss", true) 
  189. 	delay(3) 
  190. 	group_create("sh_ss_student_union_$GSUPEDS", true) 
  191. 	release_to_world("sh_ss_student_union_$GSUPEDS")	 
  192. 	mission_help_table("sh_ss_student_union_Instruct_Two") 
  193. 	delay(.5)	 
  194. 	trigger_enable("sh_ss_student_union_$t000", true) 
  195. 	trigger_enable("sh_ss_student_union_$tfrontdoor", true) 
  196. 	marker_add_navpoint("sh_ss_student_union_$nfrontdoor", MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION)	 
  197. 	notoriety_set_min("samedi", 3) 
  198. 	notoriety_set_max("samedi", 3) 
  199. 	notoriety_force_no_spawn("samedi", false)	 
  200. 		 
  201. 	for i = 1, guards_total, 1 do			 
  202. 		attack(guards[i]) 
  203. 		--move_to(guards[i], "sh_ss_student_union_$nflood", 3) 
  204. 	end		 
  205. end 
  206.  
  207.  
  208. function sh_ss_student_union_killcount_boss(char) 
  209. 	boss_count = boss_count + 1 
  210. 	marker_remove_npc(char) 
  211. 	objective_text(0, "sh_ss_student_union_Leaders_Left",boss_count, boss_total) 
  212. 	delay(3) 
  213. 	--[[ 
  214. 	if char ~= thrower_two then 
  215. 	release_to_world(char) 
  216. 	end 
  217. 	--]] 
  218. 	if	(boss_count == boss_total) then 
  219. 		objective_text_clear(0) 
  220. 		delay(3) 
  221. 		mission_end_success("sh_ss_student_union") 
  222. 		delay(3) 
  223. 	end 
  224. end 
  225.  
  226.  
  227. ----------------------------------------if you fail, you fail---------------------------------------- 
  228. function sh_ss_student_union_failure() 
  229. 	mission_end_failure("sh_ss_student_union","sh_ss_student_union_fail") 
  230. end 
  231.  
  232. function sh_ss_student_union_success()	 
  233. 	release_to_world("sh_ss_student_union_$GSUGUARDS") 
  234. 	--release_to_world("sh_ss_student_union_$GSUPEDS") 
  235. 	release_to_world("sh_ss_student_union_$GUnion")	 
  236. 	-- mission_end_success("sh_ss_student_union") 
  237. end 
  238.  
  239. function sh_ss_student_union_fail() 
  240.  
  241. 	 
  242.  
  243. end 
  244.  
  245.  
  246. function sh_ss_student_union_frontdoor() 
  247. 	 
  248. 	--door_open("sh_ss_student_union_MS_C32_FDoor_Store") 
  249. 	--delay(10) 
  250. 	door_lock("shops_sr2_city_UN_gift_door1", false) 
  251. 	door_lock("shops_sr2_city_UN_gift_door2", false) 
  252. 	door_open("shops_sr2_city_UN_gift_door1") 
  253. 	door_open("shops_sr2_city_UN_gift_door2") 
  254. 	--delay(10) 
  255. 	marker_remove_navpoint("sh_ss_student_union_$nfrontdoor") 
  256. 	mission_help_table("sh_ss_student_union_Instruct_Three") 
  257. 	objective_text(0,"sh_ss_student_union_Leaders_Left",boss_count, boss_total) 
  258. 	group_create("sh_ss_student_union_$GUnion", false)	 
  259. 	for i = 1, boss_total, 1 do 
  260. 		marker_add_npc(boss[i], MINIMAP_ICON_KILL, INGAME_EFFECT_KILL) 
  261. 		--on_death("sh_ss_student_union_killcount_boss", boss[i]) 
  262. 	end 
  263. end 
  264.  
  265. function sh_ss_student_union_cleanup() 
  266.  
  267. 	--teleport("#PLAYER#","sh_ss_student_union_$nstart") 
  268.  
  269. 	notoriety_set_min("samedi", 0) 
  270. 	notoriety_set_max("samedi", 5) 
  271. 	notoriety_set("samedi", 0) 
  272. 	notoriety_force_no_spawn("samedi", false) 
  273. 	marker_remove_navpoint("sh_ss_student_union_$nfrontdoor") 
  274. 	trigger_enable("sh_ss_student_union_$t000", false) 
  275. 	trigger_enable("sh_ss_student_union_$tfrontdoor", false) 
  276. 	on_trigger("", "sh_ss_student_union_$tfrontdoor") 
  277. 	on_trigger("", "sh_ss_student_union_$tfire") 
  278. 	on_trigger("", "sh_ss_student_union_$t000") 
  279. 	trigger_enable("sh_ss_student_union_$tfire", false) 
  280.  
  281. 	 
  282. 	for i = 1, boss_total, 1 do 
  283. 		marker_remove_npc(boss[i], SYNC_ALL)				 
  284. 	end 
  285.  
  286. 	for i = 1, recruiters_total, 1 do 
  287. 		marker_remove_npc(recruiters[i], SYNC_ALL)			 
  288. 	end	 
  289.  
  290. 	for i=1, groups_total, 1 do 
  291. 		if(group_is_loaded(groups[i])) then 
  292. 			release_to_world(groups[i]) 
  293. 		end 
  294. 	end 
  295. 	character_slots_clear_caps() 
  296. 	door_close("sh_ss_student_union_UnionDoorMM010") 
  297. 	door_close("sh_ss_student_union_UnionDoorMM020")	 
  298. 	objective_text_clear(0) 
  299. end 
  300.