./cmp_common.lua

  1. ------------------------------------------------------------------------------- 
  2. --Constants 
  3. ------------------------------------------------------------------------------- 
  4. CMP_TEST_MODE = false					--Modes for testing... 
  5. CMP_TEST_NO_MULTIPLIER = false 
  6.  
  7. --LUT tables... 
  8. CMP_LUT_DEFAULT = "none" 
  9. CMP_LUT_MISSION = "lut_completion_screen" 
  10.  
  11. --Screen Layout 
  12. CMP_SCREEN_LAYOUT_LEFT = 0 
  13. CMP_SCREEN_LAYOUT_RIGHT = 1 
  14.  
  15. --Screen types... 
  16. CMP_SCREEN_TITLE_INDEX = 1 
  17. CMP_SCREEN_TIERS_INDEX = 2 
  18. CMP_SCREEN_CASH_INDEX = 3 
  19. CMP_SCREEN_RESPECT_INDEX = 4 
  20. CMP_SCREEN_CONTROL_INDEX = 5 
  21. CMP_SCREEN_REWARD_INDEX = 6 
  22. CMP_SCREEN_COOP_WAIT_INDEX = 7 
  23.  
  24. --Score types... 
  25. CMP_SCORE_TYPE_CASH = 1 
  26. CMP_SCORE_TYPE_TIME = 2 
  27. CMP_SCORE_TYPE_NAKED = 3 
  28. CMP_SCORE_TYPE_FRAUD = 4 
  29.  
  30. --Hint button positions 
  31. CMP_HINT_Y = 380 
  32. CMP_TIERS_HINT_Y = 580 
  33.  
  34. --Respect Constants... 
  35. local RESPECT_START_ANGLE = 2.51 
  36. local RESPECT_END_ANGLE = 2.65 	-- This is really negative, but entering as positive to make equation work 
  37.  
  38. local RESPECT_METER_UPDATE					= 0 
  39. local RESPECT_METER_UPDATE_BONUS			= 1 
  40. local RESPECT_METER_UPDATE_NO_BONUS		= 2 
  41.  
  42. -- District Control Constants... 
  43. local CONTROL_START_ANGLE 	= 2.43 
  44. local CONTROL_END_ANGLE 	= 2.27000	-- This is really negative, but entering as positive to make equation work 
  45.  
  46. local RESPECT_METER_UPDATE					= 0 
  47. local RESPECT_METER_UPDATE_BONUS			= 1 
  48. local RESPECT_METER_UPDATE_NO_BONUS		= 2 
  49.  
  50. -- Cash/Respect Ramp Constants for Animation and Audio... (in Milliseconds) 
  51. local CMP_TIME_CASH 					= 1166 
  52. local CMP_TIME_CASH_BONUS 			= 1100 
  53. local CMP_TIME_CASH_NO_BONUS 		= 1166 
  54. local CMP_TIME_RESPECT 				= 1766 
  55. local CMP_TIME_RESPECT_BONUS		= 1580 
  56. local CMP_TIME_RESPECT_NO_BONUS	= 1166	 
  57. local CMP_TIME_CONTROL				= 1580 
  58. local CMP_TIME_SCORE					= 1166 
  59.  
  60. local CMP_COLOR_TEXT_PURPLE = {R=148/255, G=0/255, B=197/255} 
  61. local CMP_COLOR_TEXT_WHITE = {R=220/255, G=220/255, B=220/255} 
  62. local CMP_COLOR_TEXT_WHITE_2 = {R=180/255, G=180/255, B=180/255} 
  63.  
  64. --Tiers 
  65. local CMP_COLOR_TIERS_BRONZE = {R=160/255, G=74/255, B=33/255} 
  66. local CMP_COLOR_TIERS_SILVER = {R=163/255, G=163/255, B=163/255} 
  67. local CMP_COLOR_TIERS_GOLD = {R=198/255, G=137/255, B=26/255} 
  68.  
  69. local TIER_BRONZE = 1 
  70. local TIER_SILVER = 2 
  71. local TIER_GOLD = 3 
  72.  
  73. --------------------------------------------------------------------------------------------------------------------------------------------------------- 
  74. -- Globals 
  75. --------------------------------------------------------------------------------------------------------------------------------------------------------- 
  76. Cmp_screen_idx = 0										-- Index of the current screen 
  77. Cmp_screen_sequence_started = false 				-- Bool determines if we have started the screen... 
  78. Cmp_screen_is_playing = false							-- Bool determines whether the current screen is in an animation state. 
  79. Cmp_screen_is_skipped = false							-- Bool determines wheter we've hit skip already 
  80. Cmp_screen_base_x = 0									-- Base position x 
  81. Cmp_screen_base_y = 0									-- Base position Y 
  82.  
  83. Cmp_common_doc = -1										-- Handle of common document 
  84. Cmp_specific_doc  = -1									-- Handle of specific completion screen doc(mission, activity, stronghold) 
  85. Cmp_image = 0												-- Used to store reference to loaded image for any completion screen format. 
  86. Cmp_common_has_image = false							-- Used to determine if we have an image or not (cannot use the name because of the way we load the image) 
  87. Cmp_common_image_is_visible = true 					-- Used to determine if the completion image is visible or so we don't fade it out twice... 
  88. Cmp_common_bg_saints_active = false					-- Used to determine if bg saints is active or not... 
  89. Cmp_common_shake_is_playing = false					-- Did we shake the screen?  Used to prevent multiple slams 
  90.  
  91. Cmp_Input_tracker = -1									-- Input tracker 
  92. Cmp_common_input_is_blocked = true					-- Flag to block input when needed 
  93. Cmp_common_input_delay_thread = -1					-- Delay input thread id 
  94.  
  95. Cmp_common_coop_dialog_handle = 0					-- coop dialog for exiting early... 
  96.  
  97. Cmp_sequence_data = -1									-- Data reference for screen, this is set through cmp_common_screen_set_data(). 
  98. Cmp_hintbar = -1											-- Global for the Hintbar VDO used on all the screens. 
  99.  
  100. Cmp_common_audio_ramp_id = -1							-- Reference to audio ramp 
  101. Cmp_common_audio_music_id = -1						-- Reference to completion screen music... 
  102.  
  103. local Cmp_mouse_input_tracker							-- Mouse input tracker 
  104. local Cmp_bg_image										-- Handle for full screen bg image used for pc inputs 
  105. 		 
  106. -- Audio flags to ensure events only play once 
  107. local Cmp_audio_title_done 			= false			 
  108. local Cmp_audio_title_skip_done 		= false			 
  109. local Cmp_audio_tiers_done				= false	 
  110. local Cmp_audio_tiers_skip_done 		= false			 
  111. local Cmp_audio_cash_done 				= false			 
  112. local Cmp_audio_cash_skip_done		= false			 
  113. local Cmp_audio_respect_done 			= false			 
  114. local Cmp_audio_respect_skip_done	= false			 
  115. local Cmp_audio_control_done 			= false			 
  116. local Cmp_audio_control_skip_done 	= false			 
  117.  
  118. --Stars 
  119. local Cmp_stars = { 
  120. 	[1] = "star_01", 
  121. 	[2] = "star_02", 
  122. 	[3] = "star_03", 
  123. 	[4] = "star_04", 
  124. 	[5] = "star_05", 
  125. 	[6] = "star_06", 
  126. 	[7] = "star_07", 
  127. 	[8] = "star_08", 
  128. 	[9] = "star_09", 
  129. 	[10] = "star_10", 
  130. 	[11] = "star_11", 
  131. 	[12] = "star_12", 
  132. } 
  133.  
  134. --Tiers 
  135. local Tier_data = {} 
  136.  
  137. --Cash count 
  138. Cmp_screen_cash_start = 0					--When the cash count starts this the starting value... 
  139. Cmp_screen_cash_end = 0						--When the cash count ends this is the ending value... 
  140. Cmp_screen_cash_total = 0					--The total amount of cash earned... 
  141. Cmp_screen_cash_skip_bonus = false		--Determines whether or not we skip the multiplier stage... 
  142. Cmp_screen_cash_count_is_bonus = false	--Determines whether we are doing the bonus stage or not... 
  143. Cmp_screen_cash_skip = 0					--Determines if the cash screen should be skipped 
  144. Cmp_common_cash_complete_cb = 0			--Callback for function after cash is completed... 
  145.  
  146. --Score 
  147. Cmp_screen_score_start = 0 
  148. Cmp_screen_score_end = 0 
  149. Cmp_screen_score_total = 0 
  150. Cmp_screen_score_skip = false 
  151. Cmp_common_score_complete_cb = 0 
  152.  
  153. --Respect  
  154. Cmp_screen_respect_queue = {} 
  155. Cmp_screen_respect_level_dif = 0			--Difference to the next level, this gets decremented every fill. 
  156. Cmp_screen_respect_target_pct = 0		--Target percentage for final fill, this is what the meter is set to after the last full fill. 
  157.  
  158. Cmp_screen_respect_time_start = 0		--This is the fill time for the percent part of the meter....	 
  159. Cmp_screen_respect_time_mid = 0  
  160. Cmp_screen_respect_time_end = 0  
  161.  
  162. Cmp_screen_respect_level_cur = 0		--This is the current level of the respect, we will increment manually this every time the meter fills up... 
  163. Cmp_screen_respect_skip_bonus = false	--Determines whether or not we skip the multiplier stage... 
  164.  
  165. --Coop 
  166. Cmp_screen_coop_is_waiting = false			--Determines whether or not we are on the coop waiting screen. 
  167. Cmp_screen_coop_gamer_tag = "PLAYER"		--Coop gamer tag... this should get updated by c++ in cmp_common_coop_wait_start() 
  168.  
  169. local continue_hint_data = { 
  170. 	{CTRL_MENU_BUTTON_A, "COMPLETION_CONTINUE"}, 
  171. } 
  172. local coop_hint_data = { 
  173. 	{CTRL_MENU_BUTTON_BACK, "COMPLETION_COOP_DISCONNECT"}, 
  174. } 
  175.  
  176. Cmp_use_as_background = true 
  177.  
  178. function cmp_common_init() 
  179. 	--Set common doc global... 
  180. 	Cmp_common_doc = vint_document_find("cmp_common") 
  181. 	 
  182. 	pause_map_dump() 
  183. 	 
  184. 	--special dlc cmp images 
  185. 	 
  186. 	if (mission_is_active("dlc1_m04") == true) then 
  187. 		Cmp_image = "ui_cmp_dlc_paul" 
  188. 	elseif (mission_is_active("dlc1_m05") == true) then 
  189. 		Cmp_image = "ui_cmp_dlc_dino" 
  190. 	else 
  191. 		Cmp_image = "ui_cmp_crest" 
  192. 	end 
  193. 	game_peg_load_with_cb("cmp_common_pointless_callback", 1, Cmp_image) 
  194. 	 
  195. 	local h = vint_object_find("screen_grp") 
  196. 	Cmp_screen_base_x, Cmp_screen_base_y = vint_get_property(h, "anchor") 
  197. 	 
  198. 	--Init Hintbar 
  199. 	Cmp_hintbar = Vdo_hint_bar:new("hint_bar") 
  200. 	Cmp_hintbar:set_hints(continue_hint_data) 
  201. 	Cmp_hintbar:enable_text_shadow(true) 
  202. 	if( game_get_platform() ~= "PC" ) then	 
  203. 		Cmp_hintbar:pulse(1) 
  204. 	end 
  205. 	Cmp_hintbar:set_alpha(0) 
  206.  
  207. 	local coop_hintbar = Vdo_hint_bar:new("coop_hint_bar") 
  208. 	coop_hintbar:set_hints(coop_hint_data) 
  209. 	coop_hintbar:enable_text_shadow(true) 
  210. 	 
  211. 	--Hide elements 
  212. 	local h = vint_object_find("background_base") 
  213. 	vint_set_property(h, "visible", false)  
  214. 	 
  215. 	local h = vint_object_find("title_grp", 0, Cmp_common_doc) 
  216. 	vint_set_property(h, "alpha", 0) 
  217. 	 
  218. 	local h = vint_object_find("tiers_grp", 0, Cmp_common_doc) 
  219. 	vint_set_property(h, "alpha", 0) 
  220. 	 
  221. 	--Hide medal for now 
  222. 	local h = vint_object_find("big_medal_grp", 0, Cmp_common_doc) 
  223. 	vint_set_property(h, "visible", false) 
  224. 	 
  225. 	local h = vint_object_find("cash_grp", 0, Cmp_common_doc) 
  226. 	vint_set_property(h, "alpha", 0) 
  227. 	 
  228. 	local h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc) 
  229. 	vint_set_property(h, "alpha", 0) 
  230. 	 
  231. 	local h = vint_object_find("respect_grp", 0, Cmp_common_doc) 
  232. 	vint_set_property(h, "alpha", 0) 
  233. 	 
  234. 	local h = vint_object_find("control_grp", 0, Cmp_common_doc) 
  235. 	vint_set_property(h, "alpha", 0) 
  236. 	 
  237. 	local h = vint_object_find("coop_wait_grp", 0, Cmp_common_doc) 
  238. 	vint_set_property(h, "alpha", 0) 
  239. 	 
  240. 	local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc) 
  241. 	vint_set_property(img_bg_grp_h, "visible", true) 
  242. 	 
  243. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  244. 	vint_set_property(img_grp_h, "visible", false) 
  245. 	 
  246. 	-- Dynamically Replace color on all elements... 
  247. 	local purple_elements = { 
  248. 		"title_txt", 
  249. 		"cash_txt", 
  250. 		"respect_meter", 
  251. 		"respect_txt", 
  252. 	} 
  253. 	local white_elements = { 
  254. 		"complete_txt", 
  255. 		"cash_amount_txt", 
  256. 		"respect_level_text", 
  257. 	} 
  258. 	 
  259. 	local white_2_elements = { 
  260. 		"respect_bonus_txt", 
  261. 		"cash_bonus_txt", 
  262. 	} 
  263. 	 
  264. 	--[[for idx, val in pairs(purple_elements) do 
  265. 		local h = vint_object_find(val) 
  266. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_PURPLE.R, CMP_COLOR_TEXT_PURPLE.G, CMP_COLOR_TEXT_PURPLE.B) 
  267. 	end 
  268. 	 
  269. 	for idx, val in pairs(white_elements) do 
  270. 		local h = vint_object_find(val) 
  271. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE.R, CMP_COLOR_TEXT_WHITE.G, CMP_COLOR_TEXT_WHITE.B) 
  272. 	end 
  273. 	 
  274. 	for idx, val in pairs(white_2_elements) do 
  275. 		local h = vint_object_find(val) 
  276. 		vint_set_property(h, "tint", CMP_COLOR_TEXT_WHITE_2.R, CMP_COLOR_TEXT_WHITE_2.G, CMP_COLOR_TEXT_WHITE_2.B) 
  277. 	end]]-- 
  278. 	 
  279. 	--Note: Cash will end on its own because it is run via thread...	 
  280. 	--Enable Cash Callback... 
  281. 	cmp_common_cash_callback_enable(true) 
  282. 	 
  283. 	--Enable Tiers Callback... 
  284. 	cmp_common_tiers_cb_enable(true) 
  285. 	 
  286. 	--Enable Respect Callback... 
  287. 	cmp_common_respect_cb_enable(true) 
  288. 	 
  289. 	--Enable Control Callback... 
  290. 	cmp_common_control_cb_enable(true)	 
  291. 	 
  292. 	--Enable sound callbacks 
  293. 	cmp_audio_cb_enable() 
  294.  
  295. 	--Input 
  296. 	Cmp_Input_tracker = Vdo_input_tracker:new() 
  297. 	Cmp_Input_tracker:add_input("select", "cmp_process_input", 50) 
  298. 	Cmp_Input_tracker:add_input("back", "cmp_process_input", 50) 
  299. 	Cmp_Input_tracker:add_input("map", "cmp_process_input", 50) 
  300. 	Cmp_Input_tracker:add_input("pause", "cmp_process_input", 50) 
  301. 	Cmp_Input_tracker:add_input("all_unassigned", "cmp_common_do_nothing", 50) 
  302. 	Cmp_Input_tracker:subscribe(false) 
  303. 	 
  304. 	if game_get_platform() == "PC" then 
  305. 		Cmp_bg_image = Vdo_base_object:new("background_bmp", 0, Cmp_common_doc) 
  306. 		Cmp_mouse_input_tracker = Vdo_input_tracker:new() 
  307. 		Cmp_mouse_input_tracker:add_mouse_input("mouse_move", "cmp_common_mouse_move", 0, Cmp_bg_image.handle) 
  308. 		Cmp_mouse_input_tracker:add_mouse_input("mouse_click", "cmp_common_mouse_click", 0, Cmp_bg_image.handle) 
  309. 		Cmp_mouse_input_tracker:subscribe(false) 
  310. 	end 
  311. 	 
  312. 	vint_dataitem_add_subscription("completion_camera_shake", "update", "cmp_common_camera_shake_update") 
  313. end 
  314.  
  315.  
  316. function cmp_common_cleanup() 
  317.  
  318. 	--unsubscribe inputs... 
  319. 	if Cmp_Input_tracker ~= nil then 
  320. 		Cmp_Input_tracker:subscribe(false) 
  321. 	end 
  322. 	 
  323. 	if Cmp_mouse_input_tracker ~= nil then 
  324. 		Cmp_mouse_input_tracker:subscribe(false) 
  325. 	end 
  326. 	 
  327. 	--Unload image if we had one..... 
  328. 	if Cmp_image ~= 0 then 
  329. 		game_peg_unload(Cmp_image) 
  330. 	end 
  331.  
  332. 	cmp_common_lut_effect(CMP_LUT_DEFAULT) 
  333. 	 
  334. 	pause_map_restore() 
  335. 	 
  336. 	--Stop music... 
  337. 	game_audio_stop(Cmp_common_audio_music_id) 
  338. 	 
  339. 	--stop any glitches 
  340. 	vint_set_glitch_preset("hub") 
  341. 	vint_spike_glitch(0, 0) 
  342. 	 
  343. 	Cmp_hintbar:cleanup() 
  344. end 
  345.  
  346.  
  347. function cmp_common_screen_start(screen_layout) 
  348. 	--Play Intro Animation...(This is screen independant) 
  349. 	local intro_anim_h = vint_object_find("screen_in_anim", 0, Cmp_common_doc) 
  350. 	lua_play_anim(intro_anim_h, 0, Cmp_common_doc) 
  351. 	 
  352. 	Cmp_use_as_background = true 
  353.  
  354. 	--determine if we skipped a cutscene or if there is no final screen 
  355. 	local mission_doc_h = vint_document_find("cmp_mission") 
  356. 	local activity_doc_h = vint_document_find("cmp_activity") 
  357. 	local stronghold_doc_h = vint_document_find("cmp_stronghold") 
  358. 	local show_mission_image = false 
  359. 	 
  360. 	local digits_grp_h =  vint_object_find("digits_grp", 0, Cmp_common_doc) 
  361. 	local lines_grp_h = vint_object_find("lines_grp", 0, Cmp_common_doc) 
  362. 	local glow_h =  vint_object_find("glow", 0, Cmp_common_doc) 
  363. 	local swish_color_grp_h = vint_object_find("swish_color_grp", 0, Cmp_common_doc) 
  364. 	 
  365. 	--set the bg to blue for activities, purple for missions 
  366. 	if mission_doc_h ~= 0 then	 
  367. 		vint_set_property(digits_grp_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B) 
  368. 		vint_set_property(lines_grp_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B) 
  369. 		vint_set_property(glow_h, "tint", COLOR_CMP_BG_MISSION.R, COLOR_CMP_BG_MISSION.G, COLOR_CMP_BG_MISSION.B) 
  370. 		vint_set_property(swish_color_grp_h, "tint", COLOR_CMP_BG_MISSION_SWISH.R, COLOR_CMP_BG_MISSION_SWISH.G, COLOR_CMP_BG_MISSION_SWISH.B) 
  371. 	elseif activity_doc_h ~=0 then 
  372. 		vint_set_property(digits_grp_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B) 
  373. 		vint_set_property(lines_grp_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B) 
  374. 		vint_set_property(glow_h, "tint", COLOR_CMP_BG_ACTIVITY.R, COLOR_CMP_BG_ACTIVITY.G, COLOR_CMP_BG_ACTIVITY.B) 
  375. 		vint_set_property(swish_color_grp_h, "tint", COLOR_CMP_BG_ACTIVITY_SWISH.R, COLOR_CMP_BG_ACTIVITY_SWISH.G, COLOR_CMP_BG_ACTIVITY_SWISH.B) 
  376. 	end 
  377. 	 
  378. 	--check to see if we want to show the image for mission screens... 
  379. 	if mission_doc_h ~= 0 then		 
  380. 		--first check if we had an active cutscene... 
  381. 		if completion_cutscene_was_active() then  
  382. 			--now check to see if we skipped the cutscene 
  383. 			if completion_cutscene_was_skipped() then 
  384. 				show_mission_image = true 
  385. 			end 
  386. 		end 
  387. 		 
  388. 		if not completion_cutscene_was_active() then 
  389. 			show_mission_image = true 
  390. 		end 
  391. 		 
  392. 		--Show black style screen if credits were active...(used in final cutscenes m23_out and m24_out) 
  393. 		if completion_cutscene_was_active() then 
  394. 			if completion_credits_were_active() then 
  395. 				show_mission_image = true 
  396. 			end 
  397. 		end 
  398. 	end 
  399. 	 
  400. 	--Do not show image if its Jon's new Activity Cmp screen 
  401. 	if activity_doc_h ~= 0 then 
  402. 		show_mission_image = false 
  403. 	end 
  404. 	 
  405. 	--Show the image if  
  406. 	if show_mission_image then 
  407. 		--reset screen layout... 
  408. 		screen_layout = CMP_SCREEN_LAYOUT_LEFT 
  409. 		 
  410. 		--set image (this is loaded in with cmp_mission) 
  411. 		--local image = "ui_cmp_crest" 
  412. 		--Cmp_sequence_data[1].image = image 
  413. 		 
  414. 		--Set global to image name and set image names to the objects via callback. 
  415. 		 
  416. 		cmp_common_image_loaded() 
  417. 		 
  418. 		--Clear out the global image name so we don't try to clean it up. 
  419. 		--Cmp_image = 0 
  420. 		Cmp_use_as_background = false 
  421. 	else 
  422. 		Cmp_use_as_background = true 
  423. 	end 
  424. 	 
  425. 	--Show the cutscene slamout background 
  426. 	if show_mission_image ~= true and mission_doc_h ~= 0 then 
  427. 		local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc) 
  428. 		vint_set_property(img_bg_grp_h, "visible", true) 
  429. 	end 
  430. 	 
  431. 	--Show background_base... 
  432. 	local h = vint_object_find("background_base", 0, Cmp_common_doc) 
  433. 	vint_set_property(h, "visible", true)  
  434. 	vint_set_property(h, "background", Cmp_use_as_background)  
  435. 	 
  436. 	--Right Justify screen if needed... 
  437. 	if screen_layout == CMP_SCREEN_LAYOUT_RIGHT then 
  438. 		--Align screen right (screen is default left aligned) 
  439. 		 
  440. 		--TODO: Tweak this for right aligned screens 
  441. 		cmp_common_right_justification() 
  442. 	end	 
  443. 	 
  444. 	-- Advance first screen... 
  445. 	cmp_common_screen_advance(false) 
  446. 	 
  447. 	--Set that we have started the sequence... 
  448. 	Cmp_screen_sequence_started = true 
  449. 	 
  450. 	-- Unblock input. 
  451. 	Cmp_Input_tracker:subscribe(true) 
  452. 	if Cmp_mouse_input_tracker ~= nil then 
  453. 		Cmp_mouse_input_tracker:subscribe(true) 
  454. 	end 
  455. end 
  456.  
  457. function cmp_common_screen_set_data(data) 
  458. 	Cmp_sequence_data = data 
  459. end 
  460.  
  461.  
  462. -- Advances screen to next screen in sequence. 
  463. -- @param	force_advance		bool determines if we force advance to the next screen... 
  464. function cmp_common_screen_advance(force_advance) 
  465. 	if force_advance == false or force_advance == nil then 
  466. 		if Cmp_screen_is_playing then 
  467. 			--A current screen is in progress... we should force it to the end... 
  468. 			local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  469. 			if screen_data ~= nil and Cmp_screen_is_skipped == false then	 
  470. 				--Call Skip function for that particular screen type... 
  471. 				local screen_type = screen_data.type 
  472. 				Cmp_screens[screen_data.type].skip_func() 
  473. 				Cmp_screen_is_skipped = true 
  474. 			end 
  475. 			return 
  476. 		end 
  477. 	end 
  478. 	 
  479. 	-- If we aren't force advancing, we will animate it out. 
  480. 	if force_advance == false or force_advance == nil then 
  481. 		--Animate out the previous screen... 
  482. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  483. 		if screen_data ~= nil then 
  484. 			local screen_type = screen_data.type 
  485. 			Cmp_screens[screen_data.type].out_func() 
  486. 		end 
  487. 	end 
  488. 	 
  489. 	--Increment the current screen to next... 
  490. 	Cmp_screen_idx = Cmp_screen_idx + 1 
  491. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  492.  
  493. 	--if we are a screen before the  final screen we should attemp to hide bg_saints_fade_anim 
  494. 	if screen_data ~= nil then 
  495. 		if screen_data.type == CMP_SCREEN_REWARD_INDEX then 
  496. 			--Make sure image is faded out... 
  497. 			cmp_common_image_fade_out() 
  498. 		end 
  499. 		if screen_data.type == CMP_SCREEN_COOP_WAIT_INDEX then 
  500. 			--Make sure image is faded out... 
  501. 			cmp_common_image_fade_out() 
  502. 		end 
  503. 		 
  504. 		--Only for activity completion 
  505. 		local activity_doc_h = vint_document_find("cmp_activity") 
  506. 		if activity_doc_h ~= 0 then 
  507. 			if screen_data.type == CMP_SCREEN_REWARD_INDEX or screen_data.type == CMP_SCREEN_COOP_WAIT_INDEX then 
  508. 				--Wait for player exit animation to finish 
  509. 				if Player_exit_animation_has_played == false then 
  510. 					 
  511. 					--While the animation is playing out block input... 
  512. 					Cmp_common_input_is_blocked = true 
  513. 					 
  514. 					--Play the player exit animation... 
  515. 					cmp_activity_play_exit_anim() 
  516. 						 
  517. 					--Delay the next screen start until the animation is completed.  
  518. 					thread_new("cmp_common_wait_for_player_anim_thread") 
  519. 					 
  520. 					return 
  521. 				end 
  522. 			end 
  523. 		end 
  524. 		 
  525. 	end 
  526. 	--Determine if we start the next screen or exit... 
  527. 	if screen_data ~= nil then		 
  528. 		--Call Start function for that particular screen type... 
  529. 		local screen_type = screen_data.type 
  530. 		Cmp_screens[screen_data.type].start_func() 
  531. 		Cmp_screen_is_skipped = false 
  532. 	else 
  533. 		-- Do nothing... Final screen is always the coop screen 
  534. 		-- and will bypass itself automatically if not needed to display. 
  535. 		return 
  536. 	end 
  537. end 
  538.  
  539. ---------------------------------------------------------------- 
  540. -- Screen based functions 
  541. ---------------------------------------------------------------- 
  542.  
  543. ---------------------------------------------------------------- 
  544. -- Title screen 
  545. ---------------------------------------------------------------- 
  546. function cmp_common_title_start() 
  547. 	--Block input briefly to counteract button mashing 
  548. 	cmp_common_input_block_delay() 
  549. 	 
  550. 	--We're playing an animation 
  551. 	Cmp_screen_is_playing = true 
  552.  
  553. 	--Set properties from screen data... 
  554. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  555. 	local title_string = screen_data.title_string 		 
  556. 	local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc) 
  557. 	 
  558. 	vint_set_property(title_txt_h, "text_tag", title_string) 
  559. 	 
  560. 	--Setup up animation and callbacks 
  561. 	local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc)	 
  562. 	 
  563. 	--Shake the camera and glitch the screen 
  564. 	local end_event_twn_h = vint_object_find("end_event_twn", title_anim_h) 
  565. 	vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large") 
  566. 	 
  567. 	--Glitch the screen a small amount 
  568. 	local glitch_twn_h = vint_object_find("glitch_twn", title_anim_h) 
  569. 	vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small") 
  570. 	 
  571. 	--Control the game letterboxing (JAM: Do we still need this?) 
  572. 	--Load the LUT 
  573. 	local twn_h = vint_object_find("title_in_twn", title_anim_h) 
  574. 	vint_set_property(twn_h, "end_event", "cmp_common_title_slam")		 
  575. 	 
  576. 	--Show the hint bar, set Cmp_screen_is_playing to false 
  577. 	local twn_h = vint_object_find("title_end_twn", title_anim_h) 
  578. 	vint_set_property(twn_h, "end_event", "cmp_common_title_end") 
  579. 	 
  580. 	lua_play_anim(title_anim_h, 0, Cmp_common_doc) 
  581. 	 
  582. 	--Execute on start func if available... 
  583. 	if screen_data.on_start ~= nil and type(screen_data.on_start) == "function" then 
  584. 		screen_data.on_start() 
  585. 	end 
  586. end 
  587.  
  588.  
  589. function cmp_common_title_skip() 
  590. 	--Clear callbacks 
  591. 	local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc)	 
  592. 	 
  593. 	--Shake the camera and glitch the screen 
  594. 	local end_event_twn_h = vint_object_find("end_event_twn", title_anim_h) 
  595. 	vint_set_property(end_event_twn_h, "end_event", nil) 
  596. 	 
  597. 	--Glitch the screen a small amount 
  598. 	local glitch_twn_h = vint_object_find("glitch_twn", title_anim_h) 
  599. 	vint_set_property(glitch_twn_h, "end_event", nil) 
  600.  
  601. 	--Move title anim to end... 
  602. 	local title_anim_h = vint_object_find("title_in_anim", 0, Cmp_common_doc) 
  603. 	lua_play_anim(title_anim_h, -2.5, Cmp_common_doc) 
  604.  
  605. 	cmp_common_glitch_large()	 
  606. end 
  607.  
  608.  
  609. function cmp_common_title_end() 
  610. 	--Show hints... 
  611. 	cmp_common_hint_bar_show() 
  612. 	 
  613. 	--We're done playing 
  614. 	Cmp_screen_is_playing = false 
  615. end 
  616.  
  617.  
  618. --JAM: Not needed with new design, keeping for letterbox 
  619. function cmp_common_title_slam() 
  620. 	--cmp_common_lut_effect(CMP_LUT_MISSION) 
  621. 		 
  622. 	game_letterbox_fade_out(true) 
  623. end 
  624.  
  625.  
  626. function cmp_common_title_out() 
  627. 	--Fade out title 
  628. 	local title_out_anim_h = vint_object_find("title_out_anim", 0, Cmp_common_doc) 
  629. 	lua_play_anim(title_out_anim_h, 0, Cmp_common_doc) 
  630. 	 
  631. 	Cmp_common_shake_is_playing = false 
  632. 	 
  633. 	--Hide hint bar 
  634. 	cmp_common_hint_bar_hide() 
  635. end 
  636.  
  637.  
  638. --Glitch the screen a lot and shake the camera 
  639. function cmp_common_glitch_large() 
  640. 	--Don't play if we're already animating 
  641. 	if Cmp_common_shake_is_playing == false then 
  642. 		Cmp_common_shake_is_playing = true 
  643. 	 
  644. 		cmp_common_camera_shake() 
  645. 		 
  646. 		--play animation of excellence 
  647. 		local slam_anim_h = vint_object_find("slam_anim", 0, Cmp_common_doc) 
  648. 		 
  649. 		lua_play_anim(slam_anim_h) 
  650. 		 
  651. 		glitch_cell() 
  652. 		--vint_set_glitch_preset( "falling_skies" ) 
  653. 		--vint_set_glitch_percent( 1.0 ) 
  654. 		--vint_spike_glitch( 500, 0 ) 
  655. 	end 
  656. end 
  657.  
  658.  
  659. --Glitch the screen only a little 
  660. function cmp_common_glitch_small() 
  661. 	vint_set_glitch_preset("hub") 
  662. 	vint_spike_glitch( 50, .2 ) 
  663. 	--vint_set_glitch_preset( "falling_skies" ) 
  664. 	--vint_set_glitch_percent( .5 ) 
  665. 	--vint_spike_glitch( 100, 0 ) 
  666. end 
  667.  
  668.  
  669. ------------------------------------------------------------------------------- 
  670. -- Special case function to change the scale if needed. 
  671. --  
  672. function cmp_common_title_resize(scale) 
  673. 	local title_txt_h = vint_object_find("title_txt", 0, Cmp_common_doc) 
  674. 	vint_set_property(title_txt_h, "text_scale", scale, scale) 
  675. end 
  676.  
  677.  
  678. ---------------------------------------------------------------- 
  679. -- Cash screen 
  680. ---------------------------------------------------------------- 
  681. function cmp_common_cash_start() 
  682. 	--Initialize cash stuff... 
  683. 	Cmp_screen_is_playing = true 
  684. 	 
  685. 	--Get properties from screen data... 
  686. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  687. 	 
  688. 	if CMP_TEST_MODE then 
  689. 		screen_data.cash_reward = 2000  
  690. 		screen_data.cash_multiplier = 50 
  691. 		screen_data.cash_reward_inc_multiplier = 5000 
  692. 		if CMP_TEST_NO_MULTIPLIER then 
  693. 			screen_data.cash_multiplier = 0 
  694. 		end 
  695. 	end 
  696. 	 
  697. 	if screen_data.cash_reward == 0 then 
  698. 		--skip this screen if no reward granted... 
  699. 		cmp_common_cash_callback_enable(false) 
  700. 		cmp_common_screen_advance(true) 
  701. 		return 
  702. 	end 
  703. 	 
  704. 	--delay input... 
  705. 	cmp_common_input_block_delay() 
  706. 	 
  707. 	local cash_reward = screen_data.cash_reward  
  708. 	local cash_multiplier = screen_data.cash_multiplier  
  709. 	local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier  
  710. 	 
  711. 	Cmp_screen_cash_start	= 0  
  712. 	Cmp_screen_cash_end 		=	cash_reward 
  713. 	Cmp_screen_cash_total 	= cash_reward_inc_multiplier 
  714. 	 
  715. 	--Update bonus text... 
  716. 	local bonus_txt_h = vint_object_find("cash_bonus_txt", 0, Cmp_common_doc) 
  717. 	local values = {[0] = cash_multiplier} 
  718. 	local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values) 
  719. 	vint_set_property(bonus_txt_h, "text_tag", bonus_string) 
  720. 	 
  721. 	local cash_in_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc) 
  722. 	 
  723. 	--Shake the camera and glitch the screen 
  724. 	local end_event_twn_h = vint_object_find("end_event_twn", cash_in_anim_h) 
  725. 	vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large") 
  726. 	 
  727. 	--Glitch the screen a small amount 
  728. 	local glitch_twn_h = vint_object_find("glitch_twn", cash_in_anim_h) 
  729. 	vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")	 
  730. 	 
  731. 	--Set callback for cash count complete 
  732. 	if cash_multiplier > 0 then 
  733. 		--Show bonus stage... 
  734. 		Cmp_common_cash_complete_cb = "cmp_common_cash_bonus_start" 
  735. 		Cmp_screen_cash_skip_bonus = false 
  736. 	else 
  737. 		--Skip bonus stage... 
  738. 		Cmp_common_cash_complete_cb = "cmp_common_cash_end"		 
  739. 		Cmp_screen_cash_skip_bonus = true 
  740. 	end 
  741.  
  742. 	local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h) 
  743. 	vint_set_property(twn_h, "end_event", Cmp_common_cash_complete_cb)	 
  744. 	 
  745. 	--Start in the non bonus stage... 
  746. 	Cmp_screen_cash_count_is_bonus = false 
  747. 	 
  748. 	--Start cash animation in...	 
  749. 	lua_play_anim(cash_in_anim_h, 0, Cmp_common_doc) 
  750. 	 
  751. 	--Start counting the cash... 
  752. 	local cash_count_thread = thread_new("cmp_common_cash_count_thread") 
  753. end 
  754.  
  755.  
  756. function cmp_common_cash_skip() 
  757. 	--Destroy callbacks 
  758. 	cmp_common_cash_callback_enable(false) 
  759. 	 
  760. 	local cash_in_anim_h = vint_object_find("cash_in_anim", 0, Cmp_common_doc) 
  761. 	 
  762. 	--Clear cash in callback. 
  763. 	local end_event_twn_h = vint_object_find("end_event_twn", cash_in_anim_h) 
  764. 	vint_set_property(end_event_twn_h, "end_event", nil) 
  765. 	 
  766. 	--Clear Glitch callback. 
  767. 	local glitch_twn_h = vint_object_find("glitch_twn", cash_in_anim_h) 
  768. 	vint_set_property(glitch_twn_h, "end_event", nil)	 
  769.  
  770. 	--Clear out cash bonus tween callback 
  771. 	local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h) 
  772. 	vint_set_property(twn_h, "end_event", nil)	 
  773. 	 
  774. 	cmp_common_glitch_large() 
  775. 	 
  776. 	local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc) 
  777. 	vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(Cmp_screen_cash_total) .. "\n") 
  778. 	 
  779. 	if Cmp_screen_cash_skip_bonus == false then 
  780. 		--Skip bonus cash... 
  781. 		local cash_bonus_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc) 
  782. 		 
  783. 		local cash_bonus_end_twn_h = vint_object_find("cash_bonus_end_twn", cash_bonus_anim_h) 
  784. 		vint_set_property(cash_bonus_end_twn_h, "end_event", "cmp_common_cash_end")	 
  785. 			 
  786. 		lua_play_anim(cash_bonus_anim_h, -1, Cmp_common_doc) 
  787. 	else 
  788. 		--Clear out cash bonus tween callback 
  789. 		local twn_h = vint_object_find("cash_bonus_twn", cash_in_anim_h) 
  790. 		vint_set_property(twn_h, "end_event", "cmp_common_cash_end")	 
  791. 	end 
  792. 	 
  793. 	lua_play_anim(cash_in_anim_h, -2.5, Cmp_common_doc) 
  794. 	 
  795. 	--Stop ramping audio... 
  796. 	--cmp_audio_stop_ramp() 
  797. 	 
  798. 	Cmp_screen_cash_skip = true 
  799. end 
  800.  
  801.  
  802. function cmp_common_cash_slam() 
  803. 	if Cmp_screen_is_playing then		 
  804. 		if Cmp_screen_cash_skip_bonus then 
  805. 			-- skipping bonus... so, start ramp...  
  806. 			-- and of course... no multiplier 
  807. 			--cmp_audio_cash_ramp_no_multiplier() 
  808. 		else 
  809. 			--Start ramp with bonus.. 
  810. 			--cmp_audio_cash_ramp_multiplier() 
  811. 		end 
  812. 	end 
  813. end 
  814.  
  815.  
  816. function cmp_common_cash_end() 
  817. 	 
  818. 	--Show hints...	 
  819. 	-- Overriding y value because we share this screen with activities and missions 
  820. 	local new_hint_bar_y = CMP_HINT_Y 
  821. 	cmp_common_hint_bar_show(new_hint_bar_y) 
  822. 	 
  823. 	Cmp_screen_is_playing = false 
  824. end 
  825.  
  826.  
  827. function cmp_common_cash_out() 
  828. 	--Fade out Cash 
  829. 	local cash_out_anim_h = vint_object_find("cash_out_anim", 0, Cmp_common_doc) 
  830. 	lua_play_anim(cash_out_anim_h, 0, Cmp_common_doc) 
  831. 	 
  832. 	Cmp_common_shake_is_playing = false 
  833. 	 
  834. 	cmp_common_hint_bar_hide() 
  835. end 
  836.  
  837.  
  838. function cmp_common_cash_count_thread() 
  839. 	--init stuff 
  840. 	local start_cash = Cmp_screen_cash_start			-- $ amount to start cash from... 
  841. 	local cash_this_frame = -1								-- How much cash gets displayed in the current frame...	 
  842. 	local is_complete = false								-- Is the screen complete? 
  843. 	Cmp_screen_cash_skip = false							-- Did we skip the cash? 
  844.  
  845. 	--get the variables from the global 
  846. 	local cash = Cmp_screen_cash_end - start_cash 
  847. 	local cash_end = Cmp_screen_cash_end 
  848. 	 
  849. 	local amt_min = 100 
  850. 	local amt_max = 33000 
  851. 	 
  852. 	local time_min = CMP_TIME_CASH 
  853. 	local time_max = CMP_TIME_CASH 
  854. 	 
  855. 	if Cmp_screen_cash_count_is_bonus then 
  856. 		time_min = CMP_TIME_CASH_BONUS 
  857. 		time_max = CMP_TIME_CASH_BONUS 
  858. 	elseif Cmp_screen_cash_skip_bonus then 
  859. 		time_min = CMP_TIME_CASH_NO_BONUS 
  860. 		time_max = CMP_TIME_CASH_NO_BONUS 
  861. 	end 
  862. 	 
  863. 	local init_time = floor(vint_get_time_index() * 1000) 
  864. 	local cur_time = init_time 
  865. 	local time_to_count = floor(time_min + ((time_max - time_min) * (cash / amt_max))) 
  866.  
  867. 	if time_to_count > time_max then 
  868. 		time_to_count = time_max 
  869. 	end 
  870. 		 
  871. 	if cash > 0 then 
  872. 		 
  873. 		while is_complete == false do	 
  874. 		 
  875. 			local cur_time = floor(vint_get_time_index() * 1000) - init_time 
  876. 							 
  877. 			--set my values 
  878. 			cash_this_frame = cash * (cur_time / time_to_count) + start_cash 
  879. 			local cash_h = vint_object_find("cash_amount_txt", 0, Cmp_common_doc) 
  880. 			vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_this_frame) .. "\n") 
  881. 				 
  882. 			--Advance time so we skip... 
  883. 			if Cmp_screen_cash_skip == true then 
  884. 				cur_time = time_to_count 
  885. 				cash_end = Cmp_screen_cash_total 
  886. 			end 
  887. 			 
  888. 			if cur_time >= time_to_count then 
  889. 				is_complete = true 
  890. 	 
  891. 				--force the values 
  892. 				vint_set_property(cash_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_end)) 
  893. 			end 
  894. 			thread_yield() 
  895. 		end 
  896. 	else 
  897. 		-- Start next screen? 
  898. 		cmp_common_cash_end() 
  899. 	end 
  900. end 
  901.  
  902.  
  903. function cmp_common_cash_bonus_start() 
  904. 	--Start Cash Bonus Screen 
  905. 	local cash_anim_h = vint_object_find("cash_bonus_in_anim", 0, Cmp_common_doc) 
  906. 	 
  907. 	local cash_bonus_end_twn_h = vint_object_find("cash_bonus_end_twn", cash_anim_h) 
  908. 	vint_set_property(cash_bonus_end_twn_h, "end_event", "cmp_common_cash_end")	 
  909. 	 
  910. 	--Skip ahead if we skipped 
  911. 	local start_time = 0	 
  912. 	if Cmp_screen_cash_skip == true then 
  913. 		start_time = -2.5 
  914. 	end 
  915. 	 
  916. 	lua_play_anim(cash_anim_h, start_time, Cmp_common_doc) 
  917. end 
  918.  
  919.  
  920. function cmp_common_cash_bonus_slam() 
  921. 	--Initialize cash stuff... 
  922. 	 
  923. 	--Get properties from screen data... 
  924. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  925. 	local cash_reward = screen_data.cash_reward  
  926. 	local cash_multiplier = screen_data.cash_multiplier  
  927. 	local cash_reward_inc_multiplier = screen_data.cash_reward_inc_multiplier  
  928. 	 
  929. 	Cmp_screen_cash_start = cash_reward 
  930. 	Cmp_screen_cash_end = cash_reward_inc_multiplier 
  931.  
  932. 	--Cash Ramp Bonus 
  933. 	--cmp_audio_cash_bonus_ramp() 
  934. 	 
  935. 	--Start in the bonus stage... 
  936. 	Cmp_screen_cash_count_is_bonus = true 
  937. 	 
  938. 	--Start counting the cash... 
  939. 	local cash_count_thread = thread_new("cmp_common_cash_count_thread")		 
  940. end 
  941.  
  942.  
  943. -- Easy way to initialize or clear out the cash callbacks. 
  944. function cmp_common_cash_callback_enable(is_enabled) 
  945. 	local cash_slam_cb = "cmp_common_cash_slam" 
  946. 	local cash_bonus_slam_cb = "cmp_common_cash_bonus_slam" 
  947. 	 
  948. 	if is_enabled == false then 
  949. 		cash_slam_cb			=	nil 
  950. 		cash_bonus_slam_cb	=	nil 
  951. 	end 
  952. 	 
  953. 	--local twn_h = vint_object_find("cash_slam_twn", 0, Cmp_common_doc) 
  954. 	--vint_set_property(twn_h, "end_event", cash_slam_cb)		 
  955. 	 
  956. 	local twn_h = vint_object_find("cash_bonus_slam_twn", 0, Cmp_common_doc) 
  957. 	vint_set_property(twn_h, "end_event", cash_bonus_slam_cb)		 
  958. end 
  959.  
  960.  
  961. ---------------------------------------------------------------- 
  962. --Respect screen 
  963. ---------------------------------------------------------------- 
  964. function cmp_common_respect_start() 
  965. 	Cmp_screen_is_playing = true 
  966.  
  967. 	--Get properties from screen data... 
  968. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  969.  
  970. 	--respect is always displayed as one level up... (internally respect starts at 0... 
  971. 	screen_data.respect_level_old 			= screen_data.respect_level_old + 1 
  972. 	screen_data.respect_level_new 			= screen_data.respect_level_new + 1 
  973. 	screen_data.respect_level_multiplier 	= screen_data.respect_level_multiplier + 1 
  974. 	 
  975. 	if CMP_TEST_MODE then 
  976. 		screen_data.respect_pct_old 					= .1 
  977. 		screen_data.respect_level_old 				= 1 
  978. 		 
  979. 		screen_data.respect_pct_new 					= .6 
  980. 		screen_data.respect_level_new 				= 2 
  981. 		 
  982. 		screen_data.respect_multiplier 				= 40 
  983. 		 
  984. 		screen_data.respect_pct_multiplier 			= .9 
  985. 		screen_data.respect_level_multiplier 		= 3 
  986. 	end 
  987. 		 
  988. 	local respect_pct_old				= screen_data.respect_pct_old 
  989. 	local respect_level_old				= screen_data.respect_level_old 
  990. 	 
  991. 	local respect_pct_new				= screen_data.respect_pct_new 
  992. 	local respect_level_new				= screen_data.respect_level_new 
  993. 	 
  994. 	local respect_multiplier			= screen_data.respect_multiplier 
  995. 		 
  996. 	local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  997. 	local respect_level_multiplier	= screen_data.respect_level_multiplier 
  998. 	 
  999. 	if respect_level_old == respect_pct_new and screen_data.respect_level_old == screen_data.respect_level_new then 
  1000. 		--Force skip this scren... no respect to ad... 
  1001. 		cmp_common_respect_cb_enable(false) 
  1002. 		cmp_common_screen_advance(true) 
  1003. 		return 
  1004. 	end 
  1005. 	 
  1006. 	--Delay input... 
  1007. 	cmp_common_input_block_delay() 
  1008. 	 
  1009. 	--Set bonus text... 
  1010. 	local bonus_txt_h = vint_object_find("respect_bonus_txt", 0, Cmp_common_doc) 
  1011. 	local values = {[0] = respect_multiplier} 
  1012. 	local bonus_string = vint_insert_values_in_string("COMPLETION_BONUS", values) 
  1013. 	vint_set_property(bonus_txt_h, "text_tag", bonus_string) 
  1014. 	 
  1015. 	--figure out how long we are going to process the time... 
  1016. 	local base_time = CMP_TIME_RESPECT 
  1017. 	 
  1018. 	local respect_end_cb 
  1019. 	 
  1020. 	if	respect_multiplier ~= 0 then 
  1021. 		respect_end_cb = "cmp_common_respect_bonus_start" 
  1022. 	 
  1023. 		--We have respect Multiplier 
  1024. 		base_time = CMP_TIME_RESPECT 
  1025. 		 
  1026. 		--Ramp audio.. 
  1027. 		--cmp_audio_respect_ramp_multiplier() 
  1028. 	else 
  1029. 		respect_end_cb = "cmp_common_respect_end" 
  1030. 	 
  1031. 		Cmp_screen_respect_skip_bonus = true 
  1032. 		 
  1033. 		--No multiplier 
  1034. 		base_time = CMP_TIME_RESPECT_NO_BONUS  
  1035. 		 
  1036. 		--Ramp audio.. 
  1037. 		--cmp_audio_respect_ramp_no_multiplier() 
  1038. 	end 
  1039.  
  1040. 	--Start meter fill! 
  1041. 	cmp_common_respect_meter_update(respect_pct_old, respect_pct_new, respect_level_old, respect_level_new, base_time) 
  1042.  
  1043. 	local respect_in_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc) 
  1044. 	 
  1045. 	--Shake the camera and glitch the screen 
  1046. 	local end_event_twn_h = vint_object_find("end_event_twn", respect_in_anim_h) 
  1047. 	vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large") 
  1048. 	 
  1049. 	--Glitch the screen a small amount 
  1050. 	local glitch_twn_h = vint_object_find("glitch_twn", respect_in_anim_h) 
  1051. 	vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")	 
  1052. 	 
  1053. 	--Show the hint bar, set Cmp_screen_is_playing to false 
  1054. 	local twn_h = vint_object_find("respect_end_twn", respect_in_anim_h) 
  1055. 	vint_set_property(twn_h, "end_event", respect_end_cb) 
  1056. 		 
  1057. 	lua_play_anim(respect_in_anim_h, 0, Cmp_common_doc) 
  1058. end 
  1059.  
  1060. function cmp_common_respect_skip() 
  1061. 	--Stop any tween callbacks from happening... 
  1062. 	cmp_common_respect_cb_enable(false) 
  1063. 	 
  1064. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1065. 	local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  1066. 	local respect_level_multiplier	= screen_data.respect_level_multiplier 
  1067.  
  1068. 	cmp_common_respect_fill_meter(0, respect_pct_multiplier, false) 
  1069. 	 
  1070. 	--Force meter level 
  1071. 	local level = max(screen_data.respect_level_new, screen_data.respect_level_multiplier) 
  1072.  
  1073. 	--Force level of respect meter... 
  1074. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  1075. 	vint_set_property(txt_h, "text_tag", level)	 
  1076. 		 
  1077. 			 
  1078. 	local respect_in_anim_h = vint_object_find("respect_in_anim", 0, Cmp_common_doc) 
  1079. 	 
  1080. 	--Clear respect cb 
  1081. 	local end_event_twn_h = vint_object_find("end_event_twn", respect_in_anim_h) 
  1082. 	vint_set_property(end_event_twn_h, "end_event", nil) 
  1083. 	 
  1084. 	--Clear glitch cb 
  1085. 	local glitch_twn_h = vint_object_find("glitch_twn", respect_in_anim_h) 
  1086. 	vint_set_property(glitch_twn_h, "end_event", nil)	 
  1087. 	 
  1088. 	local twn_h = vint_object_find("respect_end_twn", respect_in_anim_h) 
  1089. 	vint_set_property(twn_h, "end_event", "cmp_common_respect_end") 
  1090. 	 
  1091. 	cmp_common_glitch_large() 
  1092. 	 
  1093. 	lua_play_anim(respect_in_anim_h, -2.5, Cmp_common_doc) 
  1094. 	 
  1095. 	if Cmp_screen_respect_skip_bonus == false then 
  1096. 		--fast forward bonus animation... 
  1097. 		local respect_bonus_in_anim_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc) 
  1098. 		lua_play_anim(respect_bonus_in_anim_h, -2.5) 
  1099. 	end 
  1100. 	 
  1101. 	--Stop ramping audio... 
  1102. 	--cmp_audio_stop_ramp() 
  1103. 	 
  1104. 	Cmp_screen_is_skipped = true 
  1105. end 
  1106.  
  1107.  
  1108. function cmp_common_respect_bonus_start() 
  1109. 	local start_time = 0 
  1110. 	 
  1111. 	if Cmp_screen_is_skipped == true then 
  1112. 		start_time = -2.5 
  1113. 	end 
  1114. 	 
  1115. 	local respect_bonus_in_anim_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc) 
  1116. 	 
  1117. 	local twn_h = vint_object_find("respect_bonus_end_twn", respect_bonus_in_anim_h) 
  1118. 	vint_set_property(twn_h, "end_event", "cmp_common_respect_end") 
  1119. 	 
  1120. 	lua_play_anim(respect_bonus_in_anim_h, start_time, Cmp_common_doc) 
  1121. end 
  1122.  
  1123.  
  1124. function cmp_common_respect_end() 
  1125. 	cmp_common_hint_bar_show() 
  1126. 	Cmp_screen_is_playing = false	 
  1127. end 
  1128.  
  1129.  
  1130. function cmp_common_respect_out() 
  1131. 	--Fade out Respect 
  1132. 	local respect_out_anim_h = vint_object_find("respect_out_anim", 0, Cmp_common_doc) 
  1133. 	lua_play_anim(respect_out_anim_h, 0, Cmp_common_doc) 
  1134. 	 
  1135. 	Cmp_common_shake_is_playing = false 
  1136. 	 
  1137. 	--Hide hint button 
  1138. 	cmp_common_hint_bar_hide() 
  1139. end 
  1140.  
  1141.  
  1142. --respect_up_level_up_cb_twn 
  1143. function cmp_common_respect_slam() 
  1144. end 
  1145.  
  1146.  
  1147. --Bonus slam callback... 
  1148. function cmp_common_respect_slam_bonus() 
  1149. 	if Cmp_screen_is_playing then 
  1150. 		--Get properties from screen data... 
  1151. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1152. 		local respect_pct_old				= screen_data.respect_pct_old 
  1153. 		local respect_level_old				= screen_data.respect_level_old 
  1154. 		 
  1155. 		local respect_pct_new				= screen_data.respect_pct_new 
  1156. 		local respect_level_new				= screen_data.respect_level_new 
  1157. 		 
  1158. 		local respect_multiplier			= screen_data.respect_multiplier 
  1159. 			 
  1160. 		local respect_pct_multiplier		= screen_data.respect_pct_multiplier 
  1161. 		local respect_level_multiplier	= screen_data.respect_level_multiplier 
  1162. 		 
  1163. 		--Do fillup to multiplier level... 
  1164. 		cmp_common_respect_meter_update(respect_pct_new,respect_pct_multiplier, respect_level_new, respect_level_multiplier, CMP_TIME_RESPECT_BONUS) 
  1165. 		 
  1166. 		--Set this flag so we don't play the bonus twice... 
  1167. 		Cmp_screen_respect_skip_bonus = true 
  1168. 		 
  1169. 		--Ramp audio... 
  1170. 		--cmp_audio_respect_bonus_ramp() 
  1171. 	end 
  1172. end 
  1173.  
  1174. -- Update/animate the respect meter	 
  1175. -- 
  1176. -- @param	total_respect		current total amount of respect player has 
  1177. -- @param	respect_pct		 	% the player is towards their next rank level 
  1178. -- @param	level: 				player rank level 
  1179. -- @param 	base					Base time it should take to fill up the meter from start to finish 
  1180. function cmp_common_respect_meter_update(old_respect_pct, respect_pct, old_level, new_level, base_time) 
  1181. 	--Get differences between the levels 
  1182. 	local level_dif = new_level - old_level 
  1183. 	Cmp_screen_respect_level_cur = old_level 
  1184. 	 
  1185. 	--Initialize the level of the meter... 
  1186. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  1187. 	vint_set_property(txt_h, "text_tag", old_level) 
  1188. 	 
  1189. 	--If the difference is greater than 0 then we are going to level up... 
  1190. 	if level_dif > 0 then 
  1191. 		--Store to global... 
  1192. 		Cmp_screen_respect_level_dif = level_dif 
  1193.  
  1194. 		--Store target percentage for the meter... 
  1195. 		Cmp_screen_respect_target_pct = respect_pct			 
  1196. 	 
  1197. 		local first_ramp_pct = 1 - old_respect_pct 
  1198. 		local final_ramp_pct = respect_pct 
  1199. 		 
  1200. 		local level_dif = level_dif 
  1201. 		 
  1202. 		--Calculate levels per second (total percentage / times the thing passes 0) 
  1203. 		local revolutions_per_ms = base_time / (first_ramp_pct + (level_dif - 1) + final_ramp_pct) 
  1204. 		Cmp_screen_respect_time_start = 	revolutions_per_ms * first_ramp_pct 
  1205. 		Cmp_screen_respect_time_mid 	= 	revolutions_per_ms * 1 
  1206. 		Cmp_screen_respect_time_end 	= 	revolutions_per_ms * final_ramp_pct 
  1207.  
  1208. 		--Setup callback so it can be filled again and again... 
  1209. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1210. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb") 
  1211. 		 
  1212. 		--Modify time to fill... 
  1213. 		cmp_common_respect_set_time(Cmp_screen_respect_time_start)	 
  1214. 		 
  1215. 		cmp_common_respect_fill_meter(old_respect_pct, 1, true) 
  1216. 	else 
  1217. 		--No leveling, so do a standard one meter cycle increase. 
  1218. 		Cmp_screen_respect_level_dif = 0 
  1219. 		 
  1220. 		--Reset time to fill 
  1221. 		cmp_common_respect_set_time(base_time)		 
  1222. 		 
  1223. 		--Fill meter anim... 
  1224. 		cmp_common_respect_fill_meter(old_respect_pct, respect_pct, true) 
  1225. 	end 
  1226. end 
  1227.  
  1228.  
  1229. ---------------------------------------------------------------------------  
  1230. -- Fills up the meter and plays added respect animation. 
  1231. -- After animation is complete it does a callback which checks if we've 
  1232. -- Increased a level and calls that animation... 
  1233. -- 
  1234. -- @param old_respect_pct		 
  1235. -- @param respect_pct			Percentage to transition too... 
  1236. -- @param do_animation			Text string for header 
  1237. --------------------------------------------------------------------------- 
  1238. function cmp_common_respect_fill_meter(old_respect_pct, respect_pct, do_animation) 
  1239. 		 
  1240. 	-- min/max for a percentage 
  1241. 	respect_pct = limit(respect_pct, 0, 1) 
  1242. 	 
  1243. 	local start_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * old_respect_pct) 
  1244. 	local end_respect_angle = RESPECT_START_ANGLE - ((RESPECT_START_ANGLE + RESPECT_END_ANGLE) * respect_pct) 
  1245. 	 
  1246. 	if do_animation == true then 
  1247. 		-- Animate Meter 
  1248. 		local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1249. 		local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1250. 		local meter_bg_tween_h = vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc) 
  1251. 		 
  1252. 		-- Animate from previous to new	 
  1253. 		vint_set_property(meter_tween_h, "start_value", start_respect_angle) 
  1254. 		vint_set_property(meter_tween_h, "end_value", end_respect_angle) 
  1255. 		 
  1256. 		vint_set_property(meter_bg_tween_h, "start_value", start_respect_angle - .03) 
  1257. 		vint_set_property(meter_bg_tween_h, "end_value", end_respect_angle - .03) 
  1258.  
  1259. 		lua_play_anim(respect_up_anim_h, 0, Cmp_common_doc) 
  1260. 	else 
  1261. 		--Stop Animation... 
  1262. 		local respect_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1263. 		vint_set_property(respect_up_anim_h, "is_paused", true) 
  1264. 		 
  1265. 		--Manually set bars... 
  1266. 		local respect_meter_h =  vint_object_find("respect_meter", 0, Cmp_common_doc) 
  1267. 		local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc) 
  1268. 		vint_set_property(respect_meter_h, "end_angle", end_respect_angle) 
  1269. 		vint_set_property(respect_meter_bg_h, "end_angle", end_respect_angle - .03) 
  1270. 	end 
  1271. end 
  1272.  
  1273.  
  1274. function cmp_common_respect_fill_cb() 
  1275. 	--Decrement the level difference... 
  1276. 	Cmp_screen_respect_level_dif = Cmp_screen_respect_level_dif - 1			 
  1277. 	 
  1278. 	--Swap the level 
  1279. 	local anim_h = vint_object_find("respect_level_up_anim", 0, Cmp_common_doc) 
  1280. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  1281. 	 
  1282. 	--Determine if we are going to fill up again? 
  1283. 	if Cmp_screen_respect_level_dif <= 0 then 
  1284. 	 
  1285. 		--Setup callback for this is the last time its going to be filled... 
  1286. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1287. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_end") 
  1288. 	 
  1289. 		--Set the the target fill time to something we calculated earlier.. 
  1290. 		cmp_common_respect_set_time(Cmp_screen_respect_time_end)	 
  1291. 		 
  1292. 		--This is the last fill so lets fill it up to the target percent...	 
  1293. 		cmp_common_respect_fill_meter(0, Cmp_screen_respect_target_pct, true)		 
  1294. 	else 
  1295. 		--reset callback to call this function again after meter fills. 
  1296. 		local twn_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1297. 		vint_set_property(twn_h, "end_event", "cmp_common_respect_fill_cb") 
  1298. 	 
  1299. 		--Set the the target fill time to something we calculated earlier.. 
  1300. 		cmp_common_respect_set_time(Cmp_screen_respect_time_mid)	 
  1301. 		 
  1302. 		--Do normal fill animation to the top... 
  1303. 		cmp_common_respect_fill_meter(0, 1, true) 
  1304. 	end 
  1305. end 
  1306.  
  1307.  
  1308. function cmp_common_respect_fill_end() 
  1309. 	-- Do we go into bonus? 
  1310. 	if Cmp_screen_respect_skip_bonus == false then 
  1311. 		--Lets not skip the bonus... 
  1312. 		local respect_bonus_anim_in_h = vint_object_find("respect_bonus_in_anim", 0, Cmp_common_doc) 
  1313. 		lua_play_anim(respect_bonus_anim_in_h, 0, Cmp_common_doc) 
  1314. 	else 
  1315. 		--End Screen 
  1316. 		--cmp_common_respect_end(nil, true) 
  1317. 	end 
  1318. end 
  1319.  
  1320.  
  1321. -- Upgrades the current level of the respect meter. 
  1322. -- This happens via callback of the respect level up animation... 
  1323. function cmp_common_respect_next_level() 
  1324. 	Cmp_screen_respect_level_cur = Cmp_screen_respect_level_cur + 1 
  1325. 	local txt_h = vint_object_find("respect_level_text", 0, Cmp_common_doc) 
  1326. 	vint_set_property(txt_h, "text_tag", Cmp_screen_respect_level_cur) 
  1327. end 
  1328.  
  1329.  
  1330. ---------------------------------------------------------------------------  
  1331. -- Sets the duration tweens for filling up the meter... 
  1332. -- 
  1333. -- @param t		Time it takes to fill up the meter... 
  1334. --------------------------------------------------------------------------- 
  1335. function cmp_common_respect_set_time(t) 
  1336. 	t = t * .001 
  1337. 	local meter_tween_h = vint_object_find("respect_meter_tween", 0, Cmp_common_doc) 
  1338. 	local meter_bg_tween_h =vint_object_find("respect_meter_bg_tween", 0, Cmp_common_doc) 
  1339. 	vint_set_property(meter_tween_h, "duration", t) 
  1340. 	vint_set_property(meter_bg_tween_h, "duration", t) 
  1341. end 
  1342.  
  1343.  
  1344. -- Easy way to initialize or clear out the respect callbacks. 
  1345. function cmp_common_respect_cb_enable(is_enabled) 
  1346. 	local respect_slam_cb = "cmp_common_respect_slam" 
  1347. 	local respect_bonus_cb = "cmp_common_respect_slam_bonus" 
  1348. 	local respect_level_cb = "cmp_common_respect_next_level" 
  1349. 	 
  1350. 	if is_enabled == false then 
  1351. 		respect_slam_cb	=	nil 
  1352. 		respect_bonus_cb	=	nil 
  1353. 		respect_level_cb	=	nil 
  1354. 	end 
  1355. 	 
  1356. 	--Respect Tween callbacks... 
  1357. 	--local twn_h = vint_object_find("respect_slam_twn", 0, Cmp_common_doc) 
  1358. 	--vint_set_property(twn_h, "end_event", respect_slam_cb)	 
  1359. 	 
  1360. 	local twn_h = vint_object_find("respect_bonus_twn", 0, Cmp_common_doc) 
  1361. 	vint_set_property(twn_h, "end_event", respect_bonus_cb)	 
  1362. 		 
  1363. 	-- when it is time to update the cash... 
  1364. 	local twn_h = vint_object_find("respect_level_up_twn", 0, Cmp_common_doc) 
  1365. 	vint_set_property(twn_h, "end_event", respect_level_cb) 
  1366. end 
  1367.  
  1368.  
  1369. ---------------------------------------------------------------- 
  1370. -- City Control screen 
  1371. ---------------------------------------------------------------- 
  1372. function cmp_common_control_start() 
  1373. 	Cmp_screen_is_playing = true 
  1374. 	 
  1375. 	--Get properties from screen data... 
  1376. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1377.  
  1378. 	if CMP_TEST_MODE then 
  1379. 		-- do nothing... 
  1380. 	end 
  1381.  
  1382. 	local district_pct_old				= screen_data.district_pct_old 
  1383. 	local district_pct_new				= screen_data.district_pct_new	 
  1384. 	local district_cash_per_day		= screen_data.district_cash_per_day 
  1385. 	local district_team_name			= screen_data.district_team_name 
  1386. 	 
  1387. 	if district_pct_new == 0 or district_pct_new == nil then 
  1388. 		--Force skip this scren... 
  1389. 		cmp_common_screen_advance(true) 
  1390. 		return 
  1391. 	end 
  1392. 	 
  1393. 	if district_pct_new == district_pct_old then 
  1394. 		-- Skip screen if there is no gained district. 
  1395. 		cmp_common_screen_advance(true) 
  1396. 		return 
  1397. 	end 
  1398. 	 
  1399. 	--Delay input... 
  1400. 	cmp_common_input_block_delay() 
  1401. 	 
  1402. 	--Set text... 
  1403. 	local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1404. 	local values_1 = {[0] = floor(district_pct_old * 1000) * .1 } 
  1405. 	local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1406. 	vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string) 
  1407. 		 
  1408. 	local control_txt = vint_object_find("control_txt", 0, Cmp_common_doc) 
  1409. 	local values_2 = {[0] = district_team_name} 
  1410. 	local control_string = vint_insert_values_in_string("COMPLETION_CONTROL", values_2) 
  1411. 	vint_set_property(control_txt, "text_tag", control_string) 
  1412. 	 
  1413. 	local ctrl_width, ctrl_height = element_get_actual_size(control_txt) 
  1414. 	local ctrl_width_max = 383 --HD 
  1415. 	if vint_is_std_res() then 
  1416. 		ctrl_width_max = 312 
  1417. 	end 
  1418. 	if ctrl_width > ctrl_width_max then 
  1419. 		local scale = ctrl_width_max/ctrl_width 
  1420. 		vint_set_property(control_txt, "scale", scale, scale) 
  1421. 	end 
  1422. 		 
  1423. 	local control_cash_txt_h = vint_object_find("control_cash_txt", 0, Cmp_common_doc) 
  1424. 	local values_3 = {[0] = format_cash(district_cash_per_day)} 
  1425. 	local control_cash_string = vint_insert_values_in_string("COMPLETION_CONTROL_PER_DAY", values_3) 
  1426. 	vint_set_property(control_cash_txt_h, "text_tag", control_cash_string) 
  1427. 	 
  1428. 	--figure out how long we are going to process the time... 
  1429. 	local base_time = CMP_TIME_CONTROL * .001 
  1430. 	 
  1431. 	--Ramp audio.. 
  1432. 	--cmp_audio_control_ramp() 
  1433. 	 
  1434. 	--Start meter fill! 
  1435. 	cmp_common_control_meter_update(0, district_pct_new, base_time) 
  1436.  
  1437. 	local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc) 
  1438. 	 
  1439. 	--Shake the camera and glitch the screen 
  1440. 	local end_event_twn_h = vint_object_find("end_event_twn", control_in_anim_h) 
  1441. 	vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large") 
  1442. 	 
  1443. 	--Glitch the screen a small amount 
  1444. 	local glitch_twn_h = vint_object_find("glitch_twn", control_in_anim_h) 
  1445. 	vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")	 
  1446. 	 
  1447. 	--Show the hint bar, set Cmp_screen_is_playing to false 
  1448. 	local twn_h = vint_object_find("control_end_twn", control_in_anim_h) 
  1449. 	vint_set_property(twn_h, "end_event", "cmp_common_control_end")	 
  1450. 	 
  1451. 	lua_play_anim(control_in_anim_h, 0, Cmp_common_doc) 
  1452.  
  1453. 	--Slam in numbers 
  1454. 	local control_level_up_anim_h = vint_object_find("control_level_up_anim", 0, Cmp_common_doc) 
  1455. 	lua_play_anim(control_level_up_anim_h, 0, Cmp_common_doc) 
  1456. end 
  1457.  
  1458.  
  1459. function cmp_common_control_skip() 
  1460. 	if Cmp_screen_is_playing then 
  1461. 		--Stop any tween callbacks from happening... 
  1462. 		cmp_common_control_cb_enable(false) 
  1463. 		 
  1464. 		local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1465. 		local district_pct_new = screen_data.district_pct_new	 
  1466.  
  1467. 		--Force meter level 
  1468. 		cmp_common_control_fill_meter(0, district_pct_new, false) 
  1469. 		 
  1470. 		-- Force text into meter... 
  1471. 		local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1472. 		local values_1 = {[0] = floor(district_pct_new * 1000) * .1 } 
  1473. 		local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1474. 		vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string) 
  1475. 		 
  1476. 		--prevent audio callback from playing twice... I don't like this but its the only way (JMH 8/23/2011) 
  1477. 		--Control Cash Slam 
  1478. 		local twn_h = vint_object_find("control_cash_audio_slam_twn", 0, Cmp_common_doc) 
  1479. 		vint_set_property(twn_h, "end_event", nil)	 
  1480. 		 
  1481. 		local control_in_anim_h = vint_object_find("control_in_anim", 0, Cmp_common_doc) 
  1482. 		 
  1483. 		--Shake the camera and glitch the screen 
  1484. 		local end_event_twn_h = vint_object_find("end_event_twn", control_in_anim_h) 
  1485. 		vint_set_property(end_event_twn_h, "end_event", nil) 
  1486. 		 
  1487. 		--Glitch the screen a small amount 
  1488. 		local glitch_twn_h = vint_object_find("glitch_twn", control_in_anim_h) 
  1489. 		vint_set_property(glitch_twn_h, "end_event", nil)	 
  1490. 		 
  1491. 		--Show the hint bar, set Cmp_screen_is_playing to false 
  1492. 		local twn_h = vint_object_find("control_end_twn", control_in_anim_h) 
  1493. 		vint_set_property(twn_h, "end_event", "cmp_common_control_end")	 
  1494. 		 
  1495. 		cmp_common_glitch_large() 
  1496. 		 
  1497. 		lua_play_anim(control_in_anim_h, -3.5, Cmp_common_doc)		 
  1498. 		 
  1499. 		--stop ramping audio... 
  1500. 		--cmp_audio_stop_ramp() 
  1501. 	end 
  1502. end 
  1503.  
  1504.  
  1505. function cmp_common_control_end() 
  1506. 	cmp_common_hint_bar_show() 
  1507. 	 
  1508. 	Cmp_screen_is_playing = false 
  1509. end 
  1510.  
  1511.  
  1512. function cmp_common_control_out()	 
  1513. 	--Fade out Respect 
  1514. 	local control_out_anim_h = vint_object_find("control_out_anim", 0, Cmp_common_doc) 
  1515. 	lua_play_anim(control_out_anim_h, 0, Cmp_common_doc) 
  1516. 	 
  1517. 	cmp_common_hint_bar_hide() 
  1518. end 
  1519.  
  1520. ------------------------------------------------------------------------------- 
  1521. --Acitivies only... 
  1522. --Delays the next start function until the player exit animation has completed... 
  1523. -- 
  1524. function cmp_common_wait_for_player_anim_thread() 
  1525. 	local delay_time = 0 
  1526. 	while Player_exit_animation_done == false do 
  1527. 		delay(0.1) 
  1528. 		 
  1529. 		delay_time = delay_time + 0.1 
  1530. 		 
  1531. 		if delay_time > 5 then 
  1532. 			break 
  1533. 		end 
  1534. 	end 
  1535. 	 
  1536. 	--Reset the block flag here to false, to possibly gain input back to the controller.s 
  1537. 	Cmp_common_input_is_blocked = false 
  1538. 	 
  1539. 	--Determine if we start the next screen or exit... 
  1540. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1541. 	if screen_data ~= nil then		 
  1542. 		--Call Start function for that particular screen type... 
  1543. 		local screen_type = screen_data.type 
  1544. 		Cmp_screens[screen_data.type].start_func() 
  1545. 		Cmp_screen_is_skipped = false 
  1546. 	else 
  1547. 		-- Do nothing... Final screen is always the coop screen 
  1548. 		-- and will bypass itself automatically if not needed to display. 
  1549. 		return 
  1550. 	end 
  1551. end 
  1552.  
  1553.  
  1554. -- When the meter flys in and stops we do this via tween cb... 
  1555. function cmp_common_control_slam() 
  1556. 	if Cmp_screen_is_playing then 
  1557. 		cmp_common_camera_shake() 
  1558. 		cmp_common_star_power_start() 
  1559. 	end 
  1560. end 
  1561.  
  1562. -- Update/animate the respect meter	 
  1563. -- 
  1564. -- @param	old_pct		current total amount of control player has over district 
  1565. -- @param	new_pct		current total amount of control player has over district 
  1566. -- @param 	base_time	Base time it should take to fill up the meter from start to finish 
  1567. function cmp_common_control_meter_update(pct_old, pct_new, base_time)	 
  1568. 	--Reset time to fill 
  1569. 	cmp_common_control_set_time(base_time) 
  1570. 	 
  1571. 	--Setup callback for this is the only time its going to be filled... 
  1572. 	local twn_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1573. 	vint_set_property(twn_h, "end_event", "cmp_common_control_fill_end") 
  1574. 	 
  1575. 	--Fill meter anim... 
  1576. 	cmp_common_control_fill_meter(pct_old, pct_new, true) 
  1577. end 
  1578.  
  1579. ---------------------------------------------------------------------------  
  1580. -- Fills up the meter and plays added respect animation. 
  1581. -- After animation is complete it does a callback which checks if we've 
  1582. -- Increased a level and calls that animation... 
  1583. -- 
  1584. -- @param pct_old		 
  1585. -- @param pct_new			Percentage to transition too... 
  1586. -- @param do_animation			Text string for header 
  1587. --------------------------------------------------------------------------- 
  1588. function cmp_common_control_fill_meter(pct_old, pct_new, do_animation)	 
  1589. 	-- min/max for a percentage 
  1590. 	pct_old = limit(pct_old, 0, 1) 
  1591. 	pct_new = limit(pct_new, 0, 1) 
  1592. 	 
  1593. 	local start_angle = 	CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_old) 
  1594. 	local end_angle = 	CONTROL_START_ANGLE - ((CONTROL_START_ANGLE + CONTROL_END_ANGLE) * pct_new) 
  1595.  
  1596. 	if do_animation == true then 
  1597. 		-- Animate Meter 
  1598. 		local control_up_anim_h = vint_object_find("control_up_anim", 0, Cmp_common_doc) 
  1599. 		local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1600. 		local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc) 
  1601. 		 
  1602. 		-- Animate from previous to new	 
  1603. 		vint_set_property(meter_tween_h, "start_value", start_angle) 
  1604. 		vint_set_property(meter_tween_h, "end_value", end_angle) 
  1605. 		 
  1606. 		vint_set_property(meter_bg_tween_h, "start_value", start_angle - .03) 
  1607. 		vint_set_property(meter_bg_tween_h, "end_value", end_angle - .03) 
  1608. 		 
  1609. 		lua_play_anim(control_up_anim_h, 0, Cmp_common_doc) 
  1610. 	else 
  1611. 		--Stop Animation... 
  1612. 		local control_up_anim_h = vint_object_find("respect_up_anim", 0, Cmp_common_doc) 
  1613. 		vint_set_property(control_up_anim_h, "is_paused", true) 
  1614. 		 
  1615. 		--Manually set bars... 
  1616. 		local respect_meter_h =  vint_object_find("respect_meter", 0, Cmp_common_doc) 
  1617. 		local respect_meter_bg_h = vint_object_find("respect_meter_bg", 0, Cmp_common_doc) 
  1618. 		vint_set_property(respect_meter_h, "end_angle", end_angle) 
  1619. 		vint_set_property(respect_meter_bg_h, "end_angle", end_angle - .03) 
  1620. 	end 
  1621. 	 
  1622. 	-- Force text into meter... 
  1623. 	local control_meter_pct_text_h = vint_object_find("control_meter_pct_text", 0, Cmp_common_doc) 
  1624. 	local values_1 = {[0] = floor(pct_new * 1000) * .1 } 
  1625. 	local control_pct_string = vint_insert_values_in_string("{0}%%%", values_1) 
  1626. 	vint_set_property(control_meter_pct_text_h, "text_tag", control_pct_string)	 
  1627. end 
  1628.  
  1629.  
  1630. function cmp_common_control_fill_end() 
  1631. end 
  1632.  
  1633.  
  1634. ---------------------------------------------------------------------------  
  1635. -- Sets the duration tweens for filling up the meter... 
  1636. -- 
  1637. -- @param t		Time it takes to fill up the meter... 
  1638. --------------------------------------------------------------------------- 
  1639. function cmp_common_control_set_time(t) 
  1640. 	local meter_tween_h = vint_object_find("control_meter_tween", 0, Cmp_common_doc) 
  1641. 	local meter_bg_tween_h = vint_object_find("control_meter_bg_tween", 0, Cmp_common_doc) 
  1642. 	vint_set_property(meter_tween_h, "duration", t) 
  1643. 	vint_set_property(meter_bg_tween_h, "duration", t) 
  1644. end 
  1645.  
  1646. -- Easy way to initialize or clear out the control callbacks. 
  1647. function cmp_common_control_cb_enable(is_enabled) 
  1648.  
  1649. 	local control_slam_cb = "cmp_common_control_slam" 
  1650.  
  1651. 	if is_enabled == false then 
  1652. 		control_slam_cb	=	nil 
  1653. 	end 
  1654. 	 
  1655. 	--Respect Tween callbacks... 
  1656. 	--local twn_h = vint_object_find("control_slam_twn", 0, Cmp_common_doc) 
  1657. 	--vint_set_property(twn_h, "end_event", control_slam_cb)	 
  1658. end 
  1659.  
  1660.  
  1661. ---------------------------------------------------------------- 
  1662. -- Rewards screen 
  1663. ---------------------------------------------------------------- 
  1664. function cmp_common_rewards_start()	 
  1665. 	Cmp_screen_is_playing = true 
  1666. 	cmp_common_input_block_delay() 
  1667. 	--Get properties from screen data... 
  1668. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1669. 	local rewards_count = screen_data.rewards_count 
  1670. 	 
  1671. 	--Set rewards count so it knows how many screens to display... 
  1672. 	reward_granted_set_reward_count(rewards_count) 
  1673. 	 
  1674. 	--Set callback on the reward screen, so we know when it is over... 
  1675. 	set_reward_granted_end_cb(cmp_common_rewards_end) 
  1676. 	 
  1677. 	--Start reward screen... 
  1678. 	reward_granted_start() 
  1679. end 
  1680.  
  1681. function cmp_common_rewards_skip() 
  1682. end 
  1683.  
  1684. function cmp_common_rewards_end() 
  1685. 	--Bring in background full black. so when we exit the reward screen we don't fade anything  
  1686. 	--weird uncleaned up... 
  1687. 	 
  1688. 	--hide the completion bg 
  1689. 	local h = vint_object_find("background_bmp", 0, Cmp_common_doc) 
  1690. 	vint_set_property(h, "alpha", 1) 
  1691. 	vint_set_property(h, "depth", -4000) 
  1692. 	 
  1693. 	--hide the character 
  1694. 	h = vint_object_find("background_base", 0, Cmp_common_doc) 
  1695. 	vint_set_property(h, "background", false)  
  1696. 	 
  1697. 	--Hide everything local to the common screen... afterwards we should always transition back to game, 
  1698. 	--So nothing else should display here from the main screen. This cleans up any 
  1699. 	--Stars or stuff leftover, this does not fix the player popping back in. (JMH 3/24/2011) 
  1700. 	local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc) 
  1701. 	local stars_h = vint_object_find("stars", 0, Cmp_common_doc) 
  1702. 	vint_set_property(screen_h, "visible", false) 
  1703. 	vint_set_property(stars_h, "visible", false) 
  1704.  
  1705. 	Cmp_screen_is_playing = false 
  1706. 	cmp_common_screen_advance(false) 
  1707. end 
  1708.  
  1709. function cmp_common_rewards_out()	 
  1710. end 
  1711.  
  1712. -------------------------------------------------------------------------------------------- 
  1713. -- Tiers Screen 
  1714. -------------------------------------------------------------------------------------------- 
  1715. function cmp_common_tiers_slam()	 
  1716.  
  1717. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1718. 		 
  1719. 	--Cmp_screen_score_end = screen_data.current_score 
  1720. 	Cmp_common_score_complete_cb = cmp_common_tiers_end 
  1721. 	 
  1722. 	local tiers_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc) 
  1723. 	 
  1724. 	local score_type = CMP_SCORE_TYPE_CASH 
  1725. 		 
  1726. 	--Create table for tier elements 
  1727. 	for idx, tier in pairs(screen_data.tier_data) do 
  1728. 		local twn_h = vint_object_find("tier_meter_twn_".. idx, tiers_anim_h, Cmp_common_doc) 
  1729. 		local grp_h = vint_object_find("tier_grp_".. idx, 0, Cmp_common_doc) 
  1730. 		local medal_img_h = vint_object_find("medal_img_".. idx, grp_h, Cmp_common_doc) 
  1731. 		local title_h = vint_object_find("tier_title_txt_".. idx, grp_h, Cmp_common_doc) 
  1732. 		local value_h = vint_object_find("tier_value_txt_".. idx, grp_h, Cmp_common_doc)	 
  1733. 		local anim_h = vint_object_find("tier_reached_anim_".. idx, 0, Cmp_common_doc) 
  1734. 		local goal = tier.tier_goal	 
  1735. 		local fill_pct = tier.percent  
  1736. 		 
  1737. 		-- Determine if we are time or cash 
  1738. 		if tier.score_type == CMP_SCORE_TYPE_TIME then 
  1739. 			 
  1740. 			if goal ~= 0 then 
  1741. 				--format_time(time_in_seconds, show_ms, show_units) 
  1742. 				vint_set_property(value_h, "text_tag", format_time(goal, false, false, nil, true))				 
  1743. 			else 
  1744. 				vint_set_property(value_h, "text_tag", "ACTIVITY_COMPLETED") 
  1745. 			end 
  1746.  
  1747. 			score_type = CMP_SCORE_TYPE_TIME			 
  1748. 		elseif tier.score_type == CMP_SCORE_TYPE_NAKED then		 
  1749. 			 
  1750. 			vint_set_property(value_h, "text_tag", format_cash(goal).."")	 
  1751. 		elseif tier.score_type == CMP_SCORE_TYPE_FRAUD then 
  1752. 			 
  1753. 			vint_set_property(value_h, "text_tag", format_cash(goal).."") 
  1754. 			score_type = CMP_SCORE_TYPE_FRAUD 
  1755. 		else 
  1756. 			vint_set_property(value_h, "text_tag", "{GAME_CASH}" .. format_cash(goal))					 
  1757. 		end 
  1758. 		 
  1759. 		--Set meter value		 
  1760. 		vint_set_property(twn_h, "end_value", fill_pct, 1)		 
  1761. 		 
  1762. 		--If medal was reached then show medal image 
  1763. 		vint_set_property(medal_img_h, "visible", false) 
  1764. 		 
  1765. 		if fill_pct >= 1 then 
  1766. 			vint_set_property(medal_img_h, "visible", true) 
  1767. 		end 
  1768. 		 
  1769. 		--Set end event 
  1770. 		--JM: disabling tier reached anims for now 
  1771. 		--vint_set_property(twn_h, "end_event", "cmp_common_tier_reached_cb") 
  1772. 		 
  1773. 		--Save off handles 
  1774. 		Tier_data[idx] = {	 
  1775. 			twn_h = twn_h, 
  1776. 			grp_h = grp_h, 
  1777. 			title_h = title_h, 
  1778. 			value_h = value_h, 
  1779. 			anim_h = anim_h, 
  1780. 			goal = goal,		 
  1781. 			percent = tier.percent 
  1782. 		}	 
  1783. 	end	 
  1784. 	 
  1785. 	-- Determine which title to set: "SCORE" or "TIME REMAINING" 
  1786. 	local score_label_txt_h = vint_object_find("score_label_txt", 0, Cmp_common_doc)	 
  1787. 	if score_type == CMP_SCORE_TYPE_TIME then 
  1788. 		vint_set_property(score_label_txt_h, "text_tag", "COMPLETION_ACTIVITY_TIME_REMAINING") 
  1789. 	elseif score_type == CMP_SCORE_TYPE_FRAUD then 
  1790. 		vint_set_property(score_label_txt_h, "text_tag", "ACT_FRAUD_SCORE_UNIT") 
  1791. 	else 
  1792. 		vint_set_property(score_label_txt_h, "text_tag", "COMPLETION_ACTIVITY_SCORE") 
  1793. 	end 
  1794. end 
  1795.  
  1796.  
  1797. --Callback for each tier twn.  Kicks off a separate anim when a tier is completed 
  1798. function cmp_common_tier_reached_cb(tween_handle) 
  1799. 	 
  1800. 	for idx, tier in pairs(Tier_data) do 
  1801. 		local anim_h = tier.anim_h 
  1802. 		local twn_h = tier.twn_h 
  1803. 		if twn_h == tween_handle and tier.percent == 1 then 
  1804. 			lua_play_anim(anim_h, 0) 
  1805. 		end 
  1806. 	end 
  1807. end 
  1808.  
  1809.  
  1810. function cmp_common_tiers_start()	 
  1811.  
  1812. 	--Block input briefly 
  1813. 	cmp_common_input_block_delay() 
  1814. 	 
  1815. 	--We're playing an animation 
  1816. 	Cmp_screen_is_playing = true 
  1817. 	 
  1818. 	local tiers_in_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc) 
  1819. 	 
  1820. 	--Shake the camera and glitch the screen 
  1821. 	local end_event_twn_h = vint_object_find("end_event_twn", tiers_in_anim_h) 
  1822. 	vint_set_property(end_event_twn_h, "end_event", "cmp_common_glitch_large") 
  1823. 	 
  1824. 	--Glitch the screen a small amount 
  1825. 	local glitch_twn_h = vint_object_find("glitch_twn", tiers_in_anim_h) 
  1826. 	vint_set_property(glitch_twn_h, "end_event", "cmp_common_glitch_small")	 
  1827. 	 
  1828. 	--Show the hint bar, set Cmp_screen_is_playing to false 
  1829. 	local twn_h = vint_object_find("tiers_end_twn", tiers_in_anim_h) 
  1830. 	vint_set_property(twn_h, "end_event", "cmp_common_tiers_end") 
  1831. 	 
  1832. 	lua_play_anim(tiers_in_anim_h, 0, Cmp_common_doc)	 
  1833. 	 
  1834. 	--Start counting the score... 
  1835. 	local score_count_thread = thread_new("cmp_common_score_count_thread") 
  1836.  
  1837. 	--Awarding new medal script--------------------------------------------------------------- 
  1838. 	--if tier_is_new == true then 
  1839. 		--local end_event_twn = vint_object_find("tiers_big_twn", 0, Cmp_common_doc) 
  1840. 		--vint_set_property(end_event_twn, "end_event", "cmp_common_tiers_play_progress")	 
  1841. 				 
  1842. 		--lua_play_anim(tiers_big_anim_h, 0, Cmp_common_doc) 
  1843. 	--end 
  1844. 		--lua_play_anim(tiers_progress_anim_h, 0, Cmp_common_doc) 
  1845. 	--end 
  1846. 	------------------------------------------------------------------------------------------ 
  1847. end 
  1848.  
  1849.  
  1850. function cmp_common_tiers_skip() 
  1851. 	--Clear callbacks 
  1852. 	local tiers_in_anim_h = vint_object_find("tiers_in_anim", 0, Cmp_common_doc) 
  1853. 	 
  1854. 	--Shake the camera and glitch the screen 
  1855. 	local end_event_twn_h = vint_object_find("end_event_twn", tiers_in_anim_h) 
  1856. 	vint_set_property(end_event_twn_h, "end_event", nil) 
  1857. 	 
  1858. 	--Glitch the screen a small amount 
  1859. 	local glitch_twn_h = vint_object_find("glitch_twn", tiers_in_anim_h) 
  1860. 	vint_set_property(glitch_twn_h, "end_event", nil)	 
  1861.  
  1862. 	--Move animation to end... 
  1863. 	lua_play_anim(tiers_in_anim_h, -2.5, Cmp_common_doc) 
  1864. 	 
  1865. 	cmp_common_glitch_large() 
  1866. end 
  1867.  
  1868.  
  1869. function cmp_common_tiers_end() 
  1870. 	--Show hints... 
  1871. 	cmp_common_hint_bar_show() 
  1872. 	 
  1873. 	--We're done playing 
  1874. 	Cmp_screen_is_playing = false	 
  1875. end 
  1876.  
  1877.  
  1878. function cmp_common_tiers_out() 
  1879. 	--Fade out tiers 
  1880. 	local tiers_out_anim_h = vint_object_find("tiers_out_anim", 0, Cmp_common_doc) 
  1881. 	lua_play_anim(tiers_out_anim_h, 0, Cmp_common_doc) 
  1882. 	 
  1883. 	Cmp_common_shake_is_playing = false	 
  1884. 	 
  1885. 	--Hide hint button 
  1886. 	cmp_common_hint_bar_hide() 
  1887. end 
  1888.  
  1889.  
  1890. function cmp_common_tiers_play_progress(tween_h) 
  1891. 	local tiers_progress_anim_h = vint_object_find("tiers_progress_anim", 0, Cmp_common_doc) 
  1892. 	lua_play_anim(tiers_progress_anim_h, 0, Cmp_common_doc) 
  1893. end 
  1894.  
  1895.  
  1896. -- Easy way to initialize or clear out the control callbacks. 
  1897. function cmp_common_tiers_cb_enable(is_enabled) 
  1898. 	local tiers_slam_cb = "cmp_common_tiers_slam" 
  1899.  
  1900. 	if is_enabled == false then 
  1901. 		tiers_slam_cb	=	nil 
  1902. 	end 
  1903. 	 
  1904. 	--Tiers Tween callbacks... 
  1905. 	local twn_h = vint_object_find("tiers_slam_twn", 0, Cmp_common_doc) 
  1906. 	vint_set_property(twn_h, "end_event", tiers_slam_cb)		 
  1907. end 
  1908.  
  1909.  
  1910. function cmp_common_score_count_thread() 
  1911.  
  1912. 	--Get score 
  1913. 	local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  1914. 	 
  1915. 	Cmp_screen_score_end = screen_data.current_score 
  1916. 	 
  1917. 	local score_type = screen_data.tier_data[1].score_type 
  1918. 	local score_h = vint_object_find("score_txt", 0, Cmp_common_doc) 
  1919. 	 
  1920. 	--init stuff 
  1921. 	local start_score = Cmp_screen_score_start		-- score amount to start score from... 
  1922. 	local score_this_frame = -1							-- How much score gets displayed in the current frame...	 
  1923. 	local is_complete = false								-- Is the screen complete? 
  1924. 	Cmp_screen_score_skip = false							-- Did we skip the score? 
  1925.  
  1926. 	--get the variables from the global 
  1927. 	local score = Cmp_screen_score_end - start_score 
  1928. 	local score_end = Cmp_screen_score_end 
  1929. 	 
  1930. 	local amt_min = 100 
  1931. 	local amt_max = 33000 
  1932. 	 
  1933. 	local time_min = CMP_TIME_SCORE 
  1934. 	local time_max = CMP_TIME_SCORE 
  1935. 	 
  1936. 	local init_time = floor(vint_get_time_index() * 1000) 
  1937. 	local cur_time = init_time 
  1938. 	local time_to_count = floor(time_min + ((time_max - time_min) * (score / amt_max))) 
  1939.  
  1940. 	if time_to_count > time_max then 
  1941. 		time_to_count = time_max 
  1942. 	end 
  1943. 		 
  1944. 	if score > 0 then 
  1945. 		 
  1946. 		while is_complete == false do 
  1947. 		 
  1948. 			local cur_time = floor(vint_get_time_index() * 1000) - init_time 
  1949. 							 
  1950. 			--set my values 
  1951. 			score_this_frame = floor( score * (cur_time / time_to_count) + start_score ) 
  1952. 			 
  1953. 			-- Determine what score type we are CASH, PERCENT or TIME 
  1954. 			if score_type == CMP_SCORE_TYPE_TIME then 
  1955. 				vint_set_property(score_h, "text_tag", format_time(score_this_frame, false, false, nil, true))	 
  1956. 			elseif score_type == CMP_SCORE_TYPE_NAKED then 
  1957. 				vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."") 
  1958. 			elseif score_type == CMP_SCORE_TYPE_CASH then	 
  1959. 				vint_set_property(score_h, "text_tag", "{GAME_CASH}"..format_cash(score_this_frame).."\n") 
  1960. 			elseif score_type == CMP_SCORE_TYPE_FRAUD then					 
  1961. 				 
  1962. 				vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."") 
  1963. 			else 
  1964. 				vint_set_property(score_h, "text_tag", format_cash(score_this_frame).."\n") 
  1965. 			end 
  1966. 				 
  1967. 			--Advance time so we skip... 
  1968. 			if Cmp_screen_score_skip == true then 
  1969. 				cur_time = time_to_count 
  1970. 				cash_end = Cmp_screen_score_total 
  1971. 				--Cmp_common_score_complete_cb = cmp_common_tiers_end 
  1972. 			end 
  1973. 			 
  1974. 			if cur_time >= time_to_count then 
  1975. 				is_complete = true 
  1976. 	 
  1977. 				-- Determine what score type we are CASH, PERCENT or TIME 
  1978. 				if score_type == CMP_SCORE_TYPE_TIME then 
  1979. 					vint_set_property(score_h, "text_tag", format_time(score_end, false, false, nil, true))	 
  1980. 				elseif score_type == CMP_SCORE_TYPE_NAKED then 
  1981. 					vint_set_property(score_h, "text_tag", format_cash(score_end).."") 
  1982. 				elseif score_type == CMP_SCORE_TYPE_CASH then	 
  1983. 					vint_set_property(score_h, "text_tag", "{GAME_CASH}"..format_cash(score_end).."\n")					 
  1984. 				elseif score_type == CMP_SCORE_TYPE_FRAUD then					 
  1985. 					vint_set_property(score_h, "text_tag", format_cash(score_end).."") 
  1986. 				else 
  1987. 					vint_set_property(score_h, "text_tag", format_cash(score_end).."\n") 
  1988. 				end 
  1989. 				 
  1990. 				--Cmp_common_score_complete_cb() 
  1991. 			end 
  1992. 			thread_yield() 
  1993. 		end 
  1994. 	else 
  1995. 		-- Start next screen? 
  1996. 		cmp_common_tiers_skip() 
  1997. 	end 
  1998. end 
  1999.  
  2000.  
  2001. ---------------------------------------------------------------- 
  2002. -- Unlock screen 
  2003. ---------------------------------------------------------------- 
  2004.  
  2005. ---------------------------------------------------------------- 
  2006. -- Coop Wait screen 
  2007. ---------------------------------------------------------------- 
  2008.  
  2009. --Fades in an start coop wait screen... 
  2010. function cmp_common_coop_wait_start() 
  2011. 	Completion_user_is_done_viewing() -- Notify other player that we're ready to move on 
  2012. 	if Completion_should_wait_for_coop() then 
  2013. 		--Play Fade In anim... 
  2014. 		local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc) 
  2015. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  2016. 		 
  2017. 		--Play Pulse Anim... 
  2018. 		local coop_anim_h = vint_object_find("coop_waiting_pulse_anim", 0, Cmp_common_doc) 
  2019. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  2020. 		 
  2021. 		--Set Coop Player Gamer tag 
  2022. 		Cmp_screen_coop_gamer_tag = Completion_get_other_player_name() 
  2023. 		local values = {[0] = Cmp_screen_coop_gamer_tag} 
  2024. 		local waiting_string = vint_insert_values_in_string("COMPLETION_COOP_WAITING", values) 
  2025. 		local waiting_txt_h = vint_object_find("coop_waiting_txt", 0, Cmp_common_doc) 
  2026. 		vint_set_property(waiting_txt_h,"text_tag", waiting_string) 
  2027. 		 
  2028. 		Cmp_screen_is_playing = true 
  2029. 		Cmp_screen_coop_is_waiting = true 
  2030. 	else 
  2031. 		-- Do nothing... the game will call cmp_common_exit when we want to leave... 
  2032. 	end 
  2033.  
  2034. end 
  2035.  
  2036. function cmp_common_coop_wait_skip() 
  2037. 	--Does nothing... 
  2038. end 
  2039.  
  2040. --Fade out coop wait screen... 
  2041. function cmp_common_coop_wait_out() 
  2042. 	--only fade out if we had the coop screen up... 
  2043. 	if Cmp_screen_coop_is_waiting then 
  2044. 		local coop_anim_h = vint_object_find("coop_in_anim", 0, Cmp_common_doc) 
  2045. 		vint_set_property(coop_anim_h, "is_paused", true) 
  2046. 	 
  2047. 		local coop_anim_h = vint_object_find("coop_out_anim", 0, Cmp_common_doc) 
  2048. 		lua_play_anim(coop_anim_h, 0, Cmp_common_doc) 
  2049. 	end 
  2050. end 
  2051.  
  2052. function cmp_common_coop_wait_dialog() 
  2053. 	local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" } 
  2054. 	Cmp_common_coop_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "cmp_common_coop_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false) 
  2055. end 
  2056.  
  2057. function cmp_common_coop_disconnect(result, action) 
  2058. 	if result == 0 then 
  2059. 		dialog_box_disconnect() 
  2060. 		 
  2061. 		--WHAT SHOULD I DO HERE? 
  2062. 		cmp_common_exit() 
  2063. 	end 
  2064. 	 
  2065. 	Cmp_common_coop_dialog_handle = 0 
  2066. end 
  2067.  
  2068. ---------------------------------------------------------------- 
  2069. -- Tables for packing screen based functions and constants 
  2070. ---------------------------------------------------------------- 
  2071. Cmp_screens = { 
  2072. 	[CMP_SCREEN_TITLE_INDEX] = { 
  2073. 		start_func = cmp_common_title_start, 
  2074. 		skip_func = cmp_common_title_skip, 
  2075. 		out_func = cmp_common_title_out, 
  2076. 		hint_bar_y = CMP_HINT_Y, --1, --set via cmp_common_title_start()... 		 
  2077. 	}, 
  2078. 	[CMP_SCREEN_TIERS_INDEX] = { 
  2079. 		start_func = cmp_common_tiers_start, 
  2080. 		skip_func = cmp_common_tiers_skip, 
  2081. 		out_func = cmp_common_tiers_out, 
  2082. 		hint_bar_y = CMP_TIERS_HINT_Y, 
  2083. 	}, 
  2084. 	[CMP_SCREEN_CASH_INDEX] = { 
  2085. 		start_func = cmp_common_cash_start, 
  2086. 		skip_func = cmp_common_cash_skip, 
  2087. 		out_func = cmp_common_cash_out, 
  2088. 		hint_bar_y = CMP_HINT_Y,   
  2089. 	}, 
  2090. 	[CMP_SCREEN_RESPECT_INDEX] = { 
  2091. 		start_func = cmp_common_respect_start, 
  2092. 		skip_func = cmp_common_respect_skip, 
  2093. 		out_func = cmp_common_respect_out, 
  2094. 		hint_bar_y = CMP_HINT_Y,   
  2095. 	}, 
  2096. 	[CMP_SCREEN_CONTROL_INDEX] = { 
  2097. 		start_func = cmp_common_control_start, 
  2098. 		skip_func = cmp_common_control_skip, 
  2099. 		out_func = cmp_common_control_out, 
  2100. 		hint_bar_y = CMP_HINT_Y,   
  2101. 	}, 
  2102. 	[CMP_SCREEN_REWARD_INDEX] = { 
  2103. 		start_func = cmp_common_rewards_start, 
  2104. 		skip_func = cmp_common_rewards_skip, 
  2105. 		out_func = cmp_common_rewards_out, 
  2106. 		hint_bar_y = nil,  
  2107. 	}, 
  2108. 	[CMP_SCREEN_COOP_WAIT_INDEX] = { 
  2109. 		start_func = cmp_common_coop_wait_start, 
  2110. 		skip_func = cmp_common_coop_wait_skip, 
  2111. 		out_func = cmp_common_coop_wait_out, 
  2112. 		hint_bar_y = nil,   
  2113. 	}, 
  2114. } 
  2115.  
  2116. ---------------------------------------------------------------- 
  2117. -- Common Screen functions 
  2118. ---------------------------------------------------------------- 
  2119.  
  2120. -- Hint bar 
  2121. function cmp_common_hint_bar_move(x,y) 
  2122. 	Cmp_hintbar:set_anchor(x,y) 
  2123. end 
  2124.  
  2125. function cmp_common_hint_bar_show(new_y) 
  2126. 	--Move hintbar 
  2127. 	--Get values from the hintbar and screen type table... 
  2128. 	local x, y = Cmp_hintbar:get_anchor() 
  2129. 	y = Cmp_screens[Cmp_screen_idx].hint_bar_y 
  2130. 	 
  2131. 	-- Override y value if new value is sent in 
  2132. 	if new_y ~= nil then 
  2133. 		y = new_y 
  2134. 	end 
  2135. 	 
  2136. 	Cmp_hintbar:set_anchor(x,y) 
  2137. 	 
  2138. 	local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc) 
  2139. 	vint_set_property(anim_h, "is_paused", true) 
  2140. 	 
  2141. 	local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc) 
  2142. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  2143. end 
  2144.  
  2145. function cmp_common_hint_bar_hide() 
  2146. 	local anim_h = vint_object_find("hint_bar_in_anim", 0, Cmp_common_doc) 
  2147. 	vint_set_property(anim_h, "is_paused", true) 
  2148. 	local anim_h = vint_object_find("hint_bar_out_anim", 0, Cmp_common_doc) 
  2149. 	lua_play_anim(anim_h, 0, Cmp_common_doc) 
  2150. end 
  2151.  
  2152. --Plays the star power animation... 
  2153. local Cmp_screen_star_power_screen = -1 
  2154. function cmp_common_star_power_start() 
  2155. 	--Only play the star power if we aren't playing already... 
  2156. 	if Cmp_screen_star_power_screen ~= Cmp_screen_idx then 
  2157. 		 
  2158. 		--Check if we aren't already playing for the screen 
  2159. 		local anim_h = vint_object_find("star_explode_anim", 0, Cmp_common_doc) 
  2160. 		lua_play_anim(anim_h, 0, Cmp_common_doc) 
  2161. 		game_set_refraction_situation("screen_cmp")  
  2162. 		 
  2163. 		--[[ 
  2164. 		for i = 1, #Cmp_stars do 
  2165. 			local h = vint_object_find(Cmp_stars[i], 0, Cmp_common_doc) 
  2166. 			local scale = rand_float(0.7, 1.1) 
  2167. 			local rotation = rand_float(0.1,0.3) 
  2168. 			local rotation_og = vint_get_property(h, "rotation") 
  2169. 			vint_set_property(h, "scale", scale, scale) 
  2170. 			vint_set_property(h, "rotation", rotation_og) 
  2171. 		end 
  2172. 		]] 
  2173. 		 
  2174. 		Cmp_screen_star_power_screen = Cmp_screen_idx 
  2175. 	end 
  2176. end 
  2177.  
  2178.  
  2179. --Exit screen 
  2180. function cmp_common_exit() 
  2181. 	 
  2182. 	--Tell game that we are done with the completion screen... 
  2183. 	completion_screen_finished() 
  2184. end 
  2185.  
  2186. ---------------------------------------------------------------- 
  2187. -- Input Processing 
  2188. ---------------------------------------------------------------- 
  2189. function cmp_process_input(event, acceleration) 
  2190. 	--only allow input if input isn't blocked... 
  2191. 	if Cmp_common_input_is_blocked == false then 
  2192. 		--Only process input if the screen has started... 
  2193. 		if Cmp_screen_sequence_started then 
  2194. 			--Last minute hack!! if somehow inputs are not set in reward granted, we will pass input from this screen to the reward granted screen. 
  2195. 			--looks like occassionaly reward_granted does not claim input, and we don't know why. (Jeff/Sean) 
  2196. 			local screen_data = Cmp_sequence_data[Cmp_screen_idx] 
  2197. 			if screen_data ~= nil then	 
  2198. 				--Call Skip function for that particular screen type... 
  2199. 				local screen_type = screen_data.type 
  2200. 				if screen_type == CMP_SCREEN_REWARD_INDEX then 
  2201. 					reward_granted_button_press() 
  2202. 					return 
  2203. 				end 
  2204. 			end 
  2205. 			if event == "select" then 
  2206. 				cmp_common_screen_advance(false) 
  2207. 			elseif event == "map" then 
  2208. 				--If we are waiting on the coop screen the bring up the dialog box... 
  2209. 				if Cmp_screen_coop_is_waiting then 
  2210. 					cmp_common_coop_wait_dialog() 
  2211. 				end 
  2212. 			elseif event == "back" then 
  2213. 				--Do nothing... 
  2214. 				--cmp_common_screen_advance() 
  2215. 			else 
  2216. 				--Do nothing... 
  2217. 			end 
  2218. 		end 
  2219. 	end 
  2220. end 
  2221.  
  2222.  
  2223. ---------------------------------------------------------------- 
  2224. -- Camera Shake... 
  2225. -- 
  2226. -- @di_param	x			Horizontal offset 
  2227. -- @di_param	y			Vertical offset 
  2228. ---------------------------------------------------------------- 
  2229. function cmp_common_camera_shake_update(di_h) 
  2230. 	local x, y = vint_dataitem_get(di_h) 
  2231. 	local screen_h = vint_object_find("screen_grp", 0, Cmp_common_doc) 
  2232.  
  2233. 	 
  2234. 	--Invert parameters and multiply by 2, then add to base position... 
  2235. 	x = Cmp_screen_base_x + (x * -1) 
  2236. 	y = Cmp_screen_base_y + (y * -1) 
  2237. 	 
  2238. 	vint_set_property(screen_h, "anchor", x, y) 
  2239. end 
  2240.  
  2241. ---------------------------------------------------------------- 
  2242. -- Wrappers for C Based functions... 
  2243. ---------------------------------------------------------------- 
  2244.  
  2245. --Wrapper for c++ camera shake function... 
  2246. function cmp_common_camera_shake(shake_type) 
  2247. 	completion_camera_shake() 
  2248. 	 
  2249. 	vint_set_glitch_preset( "falling_skies" ) 
  2250. 	vint_set_glitch_percent( 1.0 ) 
  2251. 	vint_spike_glitch( 500, 0 ) 
  2252. end 
  2253.  
  2254.  
  2255. --Wrapper for c++ lut swap function... 
  2256. function cmp_common_lut_effect(lut_table_string) 
  2257.  
  2258. 	if lut_table_string ~= CMP_LUT_DEFAULT then 
  2259. 		local platform = game_get_platform() 
  2260. 		local lut_platform_string = "" 
  2261. 		 
  2262. 		if platform == "PS3" then 
  2263. 			lut_platform_string = "_ps3" 
  2264. 		elseif platform == "XBOX360" then 
  2265. 			lut_platform_string = "_xbox2" 
  2266. 		elseif platform == "XBOX3" then 
  2267. 			lut_platform_string = "_xbox3" 
  2268. 		elseif platform == "PS4" then 
  2269. 			lut_platform_string = "_ps4" 
  2270. 		elseif platform == "PC" then 
  2271. 			lut_platform_string = "_pc" 
  2272. 		end 
  2273. 		completion_load_lut(lut_table_string .. lut_platform_string) 
  2274. 	else 
  2275. 		completion_load_lut(lut_table_string) 
  2276. 	end 
  2277. end 
  2278.  
  2279. function cmp_common_bitmap_loaded() 
  2280. end 
  2281.  
  2282.  
  2283. ------------------------------------------------------------------- 
  2284. -- AUDIO 
  2285. ------------------------------------------------------------------- 
  2286.  
  2287. --Callbacks for audio placed directly on tweens... 
  2288. function cmp_audio_cb_enable() 
  2289. 		 
  2290. 	--Title intro... ("title_in_anim") 
  2291. 	local twn_h = vint_object_find("audio_twn_title_intro", 0, Cmp_common_doc) 
  2292. 	vint_set_property(twn_h, "start_event", "cmp_audio_title_intro_cb") 
  2293. 	 
  2294. 	--Title skip... ("title_in_anim") 
  2295. 	local twn_h = vint_object_find("audio_twn_title_skip", 0, Cmp_common_doc) 
  2296. 	vint_set_property(twn_h, "start_event", "cmp_audio_title_skip_cb")	 
  2297.  
  2298. 	--Title music... ("title_in_anim") 
  2299. 	local twn_h = vint_object_find("audio_twn_title_music", 0, Cmp_common_doc) 
  2300. 	vint_set_property(twn_h, "start_event", "cmp_audio_music_cb") 
  2301. 	 
  2302. 	--Tiers intro...("tiers_in_anim") 
  2303. 	local twn_h = vint_object_find("audio_twn_tiers_intro", 0, Cmp_common_doc) 
  2304. 	vint_set_property(twn_h, "start_event", "cmp_audio_tiers_intro_cb") 
  2305. 	 
  2306. 	--Tiers skip...("cash_anim_in") 
  2307. 	local twn_h = vint_object_find("audio_twn_tiers_skip", 0, Cmp_common_doc) 
  2308. 	vint_set_property(twn_h, "start_event", "cmp_audio_tiers_skip_cb")	 
  2309.  
  2310. 	--Cash intro...("cash_anim_in") 
  2311. 	local twn_h = vint_object_find("audio_twn_cash_intro", 0, Cmp_common_doc) 
  2312. 	vint_set_property(twn_h, "start_event", "cmp_audio_cash_intro_cb") 
  2313. 	 
  2314. 	--Cash skip...("cash_anim_in") 
  2315. 	local twn_h = vint_object_find("audio_twn_cash_skip", 0, Cmp_common_doc) 
  2316. 	vint_set_property(twn_h, "start_event", "cmp_audio_cash_skip_cb")	 
  2317. 	 
  2318. 	--Cash Bonus...("cash_bonus_anim_in") 
  2319. 	local twn_h = vint_object_find("audio_twn_cash_bonus", 0, Cmp_common_doc) 
  2320. 	vint_set_property(twn_h, "start_event", "cmp_audio_cash_bonus_cb") 
  2321. 	 
  2322. 	--Respect intro...("respect_in_anim") 
  2323. 	local twn_h = vint_object_find("audio_twn_respect_intro", 0, Cmp_common_doc) 
  2324. 	vint_set_property(twn_h, "start_event", "cmp_audio_respect_intro_cb")	 
  2325. 	 
  2326. 	--Respect skip...("respect_in_anim") 
  2327. 	local twn_h = vint_object_find("audio_twn_respect_skip", 0, Cmp_common_doc) 
  2328. 	vint_set_property(twn_h, "start_event", "cmp_audio_respect_skip_cb")		 
  2329.  
  2330. 	--Respect Bonus...("respect_bonus_in_anim") 
  2331. 	local twn_h = vint_object_find("audio_twn_respect_bonus", 0, Cmp_common_doc) 
  2332. 	vint_set_property(twn_h, "start_event", "cmp_audio_respect_bonus_cb") 
  2333. 	 
  2334. 	--Control intro...("control_in_anim") 
  2335. 	local twn_h = vint_object_find("audio_twn_control_intro", 0, Cmp_common_doc) 
  2336. 	vint_set_property(twn_h, "start_event", "cmp_audio_control_intro_cb")	 
  2337. 	 
  2338. 	--Control skip...("control_in_anim") 
  2339. 	local twn_h = vint_object_find("audio_twn_control_skip", 0, Cmp_common_doc) 
  2340. 	vint_set_property(twn_h, "start_event", "cmp_audio_control_skip_cb")	 
  2341. end 
  2342.  
  2343.  
  2344. --Audio callbacks... 
  2345. function cmp_audio_title_intro_cb() 
  2346. 	if Cmp_audio_title_done == false then 
  2347. 		ui_audio_post_event("UI_Mission_Complete_Banner") 
  2348. 	end 
  2349. 	Cmp_audio_title_done = true 
  2350. end 
  2351.  
  2352. function cmp_audio_title_skip_cb()	 
  2353. 	if Cmp_audio_title_skip_done == false then 
  2354. 		ui_audio_post_event("UI_Mission_Complete_Slam")		 
  2355. 	end 
  2356. 	Cmp_audio_title_skip_done = true 
  2357. end 
  2358.  
  2359. function cmp_audio_music_cb() 
  2360. 	--Ensure that music only plays once 
  2361. 	if Cmp_common_audio_music_id == -1 then 
  2362. 		Cmp_common_audio_music_id = game_audio_play("UI_Music", "UI_Music", "Mission_Completion") 
  2363. 	end 
  2364. end 
  2365.  
  2366. function cmp_audio_tiers_intro_cb() 
  2367. 	if Cmp_audio_tiers_done == false then 
  2368. 		ui_audio_post_event("UI_Activity_Medal_Banner") 
  2369. 	end 
  2370. 	Cmp_audio_tiers_done = true	 
  2371. end 
  2372.  
  2373. function cmp_audio_tiers_skip_cb() 
  2374. 	if Cmp_audio_tiers_skip_done == false then 
  2375. 		ui_audio_post_event("UI_Activity_Medal_Slam") 
  2376. 	end 
  2377. 	Cmp_audio_tiers_skip_done = true 
  2378. end 
  2379.  
  2380. function cmp_audio_cash_intro_cb() 
  2381. 	if Cmp_audio_cash_done == false then 
  2382. 		ui_audio_post_event("UI_Cache_Ramp") 
  2383. 	end 
  2384. 	Cmp_audio_cash_done = true 
  2385. end 
  2386.  
  2387. function cmp_audio_cash_skip_cb() 
  2388. 	if Cmp_audio_cash_skip_done == false then 
  2389. 		ui_audio_post_event("UI_Cache_Slam")	 
  2390. 	end 
  2391. 	Cmp_audio_cash_skip_done = true 
  2392. end 
  2393.  
  2394. function cmp_audio_cash_bonus_cb() 
  2395. 	ui_audio_post_event("UI_Cache_Bonus_Ramp") 
  2396. end 
  2397.  
  2398. function cmp_audio_respect_intro_cb() 
  2399. 	if Cmp_audio_respect_done == false then 
  2400. 		ui_audio_post_event("UI_XP_Ramp") 
  2401. 	end	 
  2402. 	Cmp_audio_respect_done = true 
  2403. end 
  2404.  
  2405. function cmp_audio_respect_skip_cb() 
  2406. 	if Cmp_audio_respect_skip_done == false then 
  2407. 		ui_audio_post_event("UI_XP_Slam") 
  2408. 	end 
  2409. 	Cmp_audio_respect_skip_done = true 
  2410. end 
  2411.  
  2412. function cmp_audio_respect_bonus_cb() 
  2413. 	ui_audio_post_event("UI_XP_Bonus_Ramp") 
  2414. end 
  2415.  
  2416. function cmp_audio_control_intro_cb() 
  2417. 	if Cmp_audio_control_done == false then 
  2418. 		ui_audio_post_event("UI_District_Ramp") 
  2419. 	end 
  2420. 	Cmp_audio_control_done = true 
  2421. end 
  2422.  
  2423. function cmp_audio_control_skip_cb() 
  2424. 	if Cmp_audio_control_skip_done == false then 
  2425. 		ui_audio_post_event("UI_Cache_Slam") --CHANGE THIS 
  2426. 	end 
  2427. 	Cmp_audio_control_skip_done = true 
  2428. end 
  2429.  
  2430.  
  2431. --Ramps... 
  2432. function cmp_audio_cash_ramp_no_multiplier() 
  2433. 	--CashRamLong 2sec 09 frames... 
  2434. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp") 
  2435. end 
  2436. function cmp_audio_cash_ramp_multiplier() 
  2437. 	--short Cash Ramp 
  2438. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Base") 
  2439. end 
  2440. function cmp_audio_cash_bonus_ramp() 
  2441. 	--Bonus Ramp... 
  2442. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Cash_Ramp_Bonus") 
  2443. end 
  2444. function cmp_audio_respect_ramp_no_multiplier() 
  2445. 	--respect ramp full 3  
  2446. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp") 
  2447. end 
  2448. function cmp_audio_respect_ramp_multiplier() 
  2449. 	--respect ramp base 1sec 22...  
  2450. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Base") 
  2451. end 
  2452. function cmp_audio_respect_bonus_ramp() 
  2453. 	--respect ramp Bonus 1sec 14... 
  2454. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus") 
  2455. end 
  2456. function cmp_audio_control_ramp() 
  2457. 	--respect ramp Bonus 1sec 14... 
  2458. 	Cmp_common_audio_ramp_id = game_UI_audio_play("UI_Completion_Respect_Ramp_Bonus") 
  2459. end 
  2460.  
  2461.  
  2462. function cmp_audio_stop_ramp() 
  2463. 	game_audio_stop(Cmp_common_audio_ramp_id) 
  2464. end 
  2465.  
  2466. function cmp_common_mouse_click(event, target_handle) 
  2467. 	if target_handle == Cmp_bg_image.handle then 
  2468. 		if Cmp_screen_coop_is_waiting == true then 
  2469. 			cmp_process_input("back") 
  2470. 		else  
  2471. 			cmp_process_input("select") 
  2472. 		end 
  2473. 	end 
  2474. 	 
  2475. end 
  2476.  
  2477. function cmp_common_mouse_move(event, target_handle) 
  2478. end 
  2479.  
  2480.  
  2481. ------------------------------------------------------------------------------- 
  2482. -- Sets up the screen for right justification 
  2483. ------------------------------------------------------------------------------- 
  2484. function cmp_common_right_justification() 
  2485.  
  2486. 	--Adjust base screen coords 
  2487. 	Cmp_screen_base_x = 25  
  2488. 	Cmp_screen_base_y = -100 
  2489. 	 
  2490. 	--If standard definition we need to adjust some more even... 
  2491. 	if vint_is_std_res() then 
  2492. 		Cmp_screen_base_x = -50 
  2493. 		Cmp_screen_base_y = -75 
  2494. 	end	 
  2495. 	 
  2496. 	 
  2497. 	local global_conversion_table = { 
  2498. 		--Screen Group Rotation... 
  2499. 		{ 
  2500. 			name = "screen_grp", 
  2501. 			prop = "rotation", 
  2502. 			val_1 = 0.13962634, --  8 degrees. 
  2503. 		}, 
  2504. 		--Shift screen around... 
  2505. 		{ 
  2506. 			name = "screen_grp", 
  2507. 			prop = "anchor", 
  2508. 			val_1 = Cmp_screen_base_x,  
  2509. 			val_2 = Cmp_screen_base_y, 
  2510. 		} 
  2511. 	} 
  2512. 	 
  2513. 	local title_converstion_table = { 
  2514. 		--Title  Alignments 
  2515. 		{	 
  2516. 			name = "complete_txt", 
  2517. 			prop = "auto_offset", 
  2518. 			val_1 = "ne", 
  2519. 		}, 
  2520. 		{	 
  2521. 			name = "title_txt", 
  2522. 			prop = "auto_offset", 
  2523. 			val_1 = "ne", 
  2524. 		}, 
  2525. 		{	 
  2526. 			name = "title_txt", 
  2527. 			prop = "horz_align", 
  2528. 			val_1 = "right", 
  2529. 		}, 
  2530. 		--Title Tweens 
  2531. 		{	 
  2532. 			name = "title_in_twn", 
  2533. 			prop = "start_value_x", 
  2534. 			val_1 = -20, 
  2535. 		}, 
  2536. 		{	 
  2537. 			name = "complete_txt_slide_twn", 
  2538. 			prop = "start_value_x", 
  2539. 			val_1 = -20, 
  2540. 		}, 
  2541. 		--End position overrides... 
  2542. 		{	 
  2543. 			name = "title_in_twn", 
  2544. 			prop = "end_value_x", 
  2545. 			val_1 = 647.0, 
  2546. 		}, 
  2547. 	} 
  2548. 	 
  2549. 	local cash_conversion_table = { 
  2550. 		--Cash Alignments 
  2551. 		{	 
  2552. 			name = "cash_txt", 
  2553. 			prop = "auto_offset", 
  2554. 			val_1 = "ne", 
  2555. 		}, 
  2556. 		{	 
  2557. 			name = "cash_bonus_txt", 
  2558. 			prop = "auto_offset", 
  2559. 			val_1 = "ne", 
  2560. 		}, 
  2561. 		{	 
  2562. 			name = "cash_amount_txt", 
  2563. 			prop = "auto_offset", 
  2564. 			val_1 = "ne", 
  2565. 		}, 
  2566. 		--Cash Tweens 
  2567. 		{	 
  2568. 			name = "cash_amount_slide_twn", 
  2569. 			prop = "start_value_x", 
  2570. 			val_1 = -20, 
  2571. 		}, 
  2572. 		{	 
  2573. 			name = "cash_slam_twn", 
  2574. 			prop = "start_value_x", 
  2575. 			val_1 = -20, 
  2576. 		}, 
  2577. 		{	 
  2578. 			name = "cash_bonus_slam_twn", 
  2579. 			prop = "start_value_x", 
  2580. 			val_1 = -20, 
  2581. 		}, 
  2582. 		--End position overrides 
  2583. 		{	 
  2584. 			name = "cash_amount_slide_twn", 
  2585. 			prop = "end_value_x", 
  2586. 			val_1 = 646, 
  2587. 		}, 
  2588. 		{	 
  2589. 			name = "cash_slam_twn", 
  2590. 			prop = "end_value_x", 
  2591. 			val_1 = 646, 
  2592. 		}, 
  2593. 	} 
  2594. 	local respect_conversion_table = { 
  2595. 		--Respect Alignments 
  2596. 		{	 
  2597. 			name = "respect_bonus_txt", 
  2598. 			prop = "auto_offset", 
  2599. 			val_1 = "ne", 
  2600. 		}, 
  2601. 		{	 
  2602. 			name = "respect_txt", 
  2603. 			prop = "auto_offset", 
  2604. 			val_1 = "ne", 
  2605. 		}, 
  2606. 		  
  2607. 		--Respect Tweens Start 
  2608. 		{	 
  2609. 			name = "respect_slam_twn", 
  2610. 			prop = "start_value_x", 
  2611. 			val_1 = -20, 
  2612. 		}, 
  2613. 		{	 
  2614. 			name = "respect_txt_twn", 
  2615. 			prop = "start_value_x", 
  2616. 			val_1 = -20, 
  2617. 		}, 
  2618. 		{	 
  2619. 			name = "respect_bonus_twn", 
  2620. 			prop = "start_value_x", 
  2621. 			val_1 = -20, 
  2622. 		}, 
  2623. 		--Respect Tweens End 
  2624. 		{	 
  2625. 			name = "respect_slam_twn", 
  2626. 			prop = "end_value_x", 
  2627. 			val_1 = 600, 
  2628. 		}, 
  2629. 		{	 
  2630. 			name = "respect_txt_twn", 
  2631. 			prop = "end_value_x", 
  2632. 			val_1 = 470, 
  2633. 		}, 
  2634. 		{	 
  2635. 			name = "respect_bonus_twn", 
  2636. 			prop = "end_value_x", 
  2637. 			val_1 = 472, 
  2638. 		}, 
  2639. 	} 
  2640. 	 
  2641. 	local control_conversion_table = { 
  2642. 		--Control Alignments 
  2643. 		{	 
  2644. 			name = "control_cash_txt", 
  2645. 			prop = "auto_offset", 
  2646. 			val_1 = "ne", 
  2647. 		}, 
  2648. 		{	 
  2649. 			name = "control_txt", 
  2650. 			prop = "horz_align", 
  2651. 			val_1 = "right", 
  2652. 		}, 
  2653. 		{	 
  2654. 			name = "control_txt", 
  2655. 			prop = "auto_offset", 
  2656. 			val_1 = "ne", 
  2657. 		}, 
  2658. 		  
  2659. 		--Control Tweens Start 
  2660. 		{	 
  2661. 			name = "control_slam_twn", 
  2662. 			prop = "start_value_x", 
  2663. 			val_1 = -20, 
  2664. 		}, 
  2665. 		{	 
  2666. 			name = "control_txt_twn", 
  2667. 			prop = "start_value_x", 
  2668. 			val_1 = -20, 
  2669. 		}, 
  2670. 		{	 
  2671. 			name = "control_cash_twn", 
  2672. 			prop = "start_value_x", 
  2673. 			val_1 = -20, 
  2674. 		}, 
  2675. 		--Control Tweens End 
  2676. 		{	 
  2677. 			name = "control_slam_twn", 
  2678. 			prop = "end_value_x", 
  2679. 			val_1 = 600, 
  2680. 		}, 
  2681. 		{	 
  2682. 			name = "control_txt_twn", 
  2683. 			prop = "end_value_x", 
  2684. 			val_1 = 470, 
  2685. 		}, 
  2686. 		{	 
  2687. 			name = "control_cash_twn", 
  2688. 			prop = "end_value_x", 
  2689. 			val_1 = 472, 
  2690. 		}, 
  2691. 	} 
  2692. 	 
  2693. 	local conversion_tables = { 
  2694. 		global_conversion_table, 
  2695. 		title_converstion_table, 
  2696. 		cash_conversion_table, 
  2697. 		respect_conversion_table, 
  2698. 		control_conversion_table, 
  2699. 	} 
  2700. 	 
  2701. 	local h 
  2702. 	local value_1, value_2 
  2703. 	 
  2704. 	--Loop through all the conversion tables 
  2705. 	for i, conversion_table in pairs(conversion_tables) do  
  2706. 		--Get specific conversion table 
  2707. 		for idx, val in pairs(conversion_table) do  
  2708. 			--Go through each item and start converting properties... 
  2709. 			h = vint_object_find(val.name, 0, Cmp_common_doc) 
  2710. 			local prop = val.prop 
  2711. 			if h ~= 0 then 
  2712. 				--Check for "special properties" so we can maintain variables on certain vectors. 
  2713. 				if prop == "start_value_x" then 
  2714. 					local x, y = vint_get_property(h, "start_value") 
  2715. 					vint_set_property(h, "start_value", val.val_1, y) 
  2716. 				elseif prop == "end_value_x" then 
  2717. 					local x, y = vint_get_property(h, "end_value") 
  2718. 					vint_set_property(h, "end_value", val.val_1, y) 
  2719. 				elseif prop == "anchor" then 
  2720. 					vint_set_property(h, "anchor", val.val_1, val.val_2) 
  2721. 				else 
  2722. 					vint_set_property(h, val.prop, val.val_1) 
  2723. 				end 
  2724. 			else 
  2725. 				--can't find object... 
  2726. 				debug_print("vint", "Item in conversion table is missing\n") 
  2727. 			end 
  2728. 		end 
  2729. 		 
  2730. 	end 
  2731. 	 
  2732. 	--Shift button hint over... 
  2733. 	local x, y = Cmp_hintbar:get_anchor() 
  2734. 	local width, height = Cmp_hintbar:get_size() 
  2735. 	Cmp_hintbar:set_anchor(x - width - 15, y) 
  2736. end 
  2737.  
  2738.  
  2739. ------------------------------------------------------------------------------- 
  2740. -- Callback for when we have our completion image fully loaded... 
  2741. -- 
  2742. function cmp_common_image_loaded() 
  2743. 	--image is loaded... 
  2744. 	local h = vint_object_find("background_base") 
  2745. 	vint_set_property(h, "visible", true)  
  2746. 	 
  2747. 	local img_bg_grp_h = vint_object_find("img_bg_grp", 0, Cmp_common_doc) 
  2748. 	vint_set_property(img_bg_grp_h, "visible", true) 
  2749. 	 
  2750. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  2751. 	vint_set_property(img_grp_h, "visible", true) 
  2752. 	 
  2753. 	--replace all 3 images for rgb shift...	 
  2754. 	local screen_image_r = vint_object_find("screen_image_r", 0, Cmp_common_doc) 
  2755. 	local screen_image_g = vint_object_find("screen_image_g", 0, Cmp_common_doc) 
  2756. 	local screen_image_b = vint_object_find("screen_image_b", 0, Cmp_common_doc) 
  2757. 	local screen_image_black = vint_object_find("screen_image_black", 0, Cmp_common_doc) 
  2758. 	 
  2759. 	vint_set_property(screen_image_r, "image", Cmp_image) 
  2760. 	vint_set_property(screen_image_g, "image", Cmp_image) 
  2761. 	vint_set_property(screen_image_b, "image", Cmp_image) 
  2762. 	vint_set_property(screen_image_black, "image", Cmp_image) 
  2763. 	 
  2764. 	--make sure they don't pop in before the intro anim 
  2765. 	vint_set_property(screen_image_r, "scale", 0, 0) 
  2766. 	vint_set_property(screen_image_g, "scale", 0, 0) 
  2767. 	vint_set_property(screen_image_b, "scale", 0, 0) 
  2768. 	vint_set_property(screen_image_black, "alpha", 0) 
  2769. 	 
  2770. 	Cmp_common_has_image = true 
  2771. end 
  2772.  
  2773. function cmp_common_pointless_callback() 
  2774. end 
  2775.  
  2776. function cmp_common_image_fade_out() 
  2777. 	if Cmp_common_has_image and Cmp_common_image_is_visible then 
  2778. 		local image_fade_out_anim_h = vint_object_find("image_fade_out_anim", 0, Cmp_common_doc) 
  2779. 		lua_play_anim(image_fade_out_anim_h, 0, Cmp_common_doc) 
  2780. 		Cmp_common_image_is_visible = false 
  2781. 	end 
  2782. end 
  2783.  
  2784.  
  2785. function cmp_common_input_block_delay() 
  2786. 	Cmp_common_input_is_blocked = true 
  2787. 	 
  2788. 	if Cmp_common_input_delay_thread ~= -1 then 
  2789. 		thread_kill(Cmp_common_input_delay_thread) 
  2790. 	end 
  2791. 	 
  2792. 	if Cmp_common_input_delay_thread == -1 then 
  2793. 		Cmp_common_input_delay_thread = thread_new("cmp_common_input_block_thread") 
  2794. 	end 
  2795. end 
  2796.  
  2797.  
  2798. function cmp_common_input_block_thread() 
  2799. 	delay(.75) 
  2800. 	Cmp_common_input_is_blocked = false 
  2801. 	Cmp_common_input_delay_thread = -1 
  2802. end 
  2803.  
  2804.  
  2805. --Debug stuff put in for jon bruer JMH(3/24/2011) 
  2806. function cmp_bg_hide() 
  2807. 	local h = vint_object_find("background_base") 
  2808. 	vint_set_property(h, "visible", false)  
  2809. end 
  2810.  
  2811. function cmp_common_do_nothing() 
  2812. 	local x = 0 
  2813. end