./cmp_activity.lua

  1. --Global Mission Sequence Table... 
  2.  
  3. Player_exit_animation_done = false 
  4. Player_exit_animation_has_played = false 
  5.  
  6. Cmp_activity_seq = {} 
  7.  
  8. Cmp_activity_anim_event_listener = 0 
  9.  
  10. Player_exit_anim_has_played = false 
  11.  
  12. function cmp_activity_init() 
  13. 	Cmp_specific_doc = vint_document_find("cmp_activity") 
  14.  
  15. 	--Populate data... 
  16. 	vint_dataresponder_request("cmp_activity_success", "cmp_activity_populate", 0) 
  17. 	vint_dataresponder_request("cmp_activity_success", "cmp_activity_populate_tiers", 0, "tiers") 
  18. 	--Set sequence... 
  19. 	cmp_common_screen_set_data(Cmp_activity_seq) 
  20. 	 
  21. 	Cmp_activity_anim_event_listener = vint_scriptevent_listen( "completion_activity_anim", "cmp_activity_anim_finished" ) 
  22. end 
  23.  
  24. function cmp_activity_cleanup() 
  25. 	if CMP_TEST_MODE then 
  26. 		debug_print("vint", "cleanup cmp_activity_cleanup()\n") 
  27. 	end 
  28. 	 
  29. 	--game_peg_unload(Cmp_image) 
  30. 	 
  31. 	screen_fade_unhide() 
  32. 	vint_scriptevent_stop_listening( Cmp_activity_anim_event_listener ) 
  33. end 
  34.  
  35.  
  36. ------------------------------------------------------------------------------- 
  37. -- on the first from of title sequence, this gets called via callback 
  38. -- 
  39. function cmp_activity_first_frame() 
  40. 	--Do nothing 
  41. 	local h = vint_object_find("background_force_black", 0, Cmp_common_doc) 
  42. 	vint_set_property(h, "visible", true) 
  43.  
  44. 	--h = vint_object_find("background_base", 0, Cmp_common_doc) 
  45. 	--h = vint_object_find("safe_frame", 0, Cmp_common_doc) 
  46. 	--vint_set_property(h, "background", true)	 
  47. 	 
  48. 	h = vint_object_find( "safe_frame" ) 
  49. 	vint_set_property(h, "background", true) 
  50. 	 
  51. 	screen_fade_hide() 
  52. 	 
  53. 	-- distance, height, pitch, lateral, fov 
  54. 	vint_scriptevent_post( "completion_activity", "start_anim" )	 
  55. 	 
  56. 	--vint_scriptevent_post( "completion_activity", "finish_anim" ) 
  57. end 
  58.  
  59.  
  60. --Start exit anim, play only once 
  61. function cmp_activity_play_exit_anim() 
  62. 	if Player_exit_anim_has_played == false then 
  63. 		vint_scriptevent_post( "completion_activity", "finish_anim" ) 
  64. 	end 
  65. 	 
  66.    Player_exit_animation_has_played = true	 
  67. end 
  68.  
  69.  
  70. --Wait for the exit animation to finish before we show the reward screen 
  71. function cmp_activity_anim_finished() 
  72. 	Player_exit_animation_done = true 
  73. 	 
  74. 	--hide the player character... 
  75. 	local h = vint_object_find("background_base", 0, Cmp_common_doc) 
  76. 	vint_set_property(h, "background", false)  
  77. end 
  78.  
  79. ------------------------------------------------------------- 
  80. --Populates the script from the dataresponder... 
  81. ------------------------------------------------------------- 
  82.  
  83. -- @param	mission_name						This is the mission name... "DEATH AT SMILING JACKS" 
  84. -- @param	layout								"Left" or "Right" formats		(Not used by cmp_common JMH, it is sent in as a paremeter 11/3/2010) 
  85. -- @param	num_unlockables_to_follow		# of unlockables in the mission flow... ? not sure if this is relevant at this stage... I have no problem doing the unlockable data_responder once and logging all the data from the game. 
  86.  
  87. -- @param	cash_reward							This is the cash reward... "4000" 
  88. -- @param	cash_multiplier					Multiplier for cash			"4.0" 
  89. -- @param	cash_reward_inc_multiplier		Cash_reward with the multiplier... "12000" (This could be calculated internally) 
  90.  
  91. -- @param	respect_points_old				Respect points before... 
  92. -- @param	respect_pct_old					Respect percentage before... 
  93. -- @param	respect_level_old					Respect level before... 
  94.  
  95. -- @param	respect_points_new				Respect points after... 
  96. -- @param	respect_pct_new					Respect percent after... 
  97. -- @param	respect_level_new					Respect level after... 
  98.  
  99. -- @param	respect_multiplier				Respect multiplier "2.0" 
  100. -- @param	respect_points_multiplier		Respect points after multiplier 
  101. -- @param	respect_pct_multiplier			Respect percent after multiplier 
  102. -- @param	respect_level_multiplier		Respect level after multiplier 
  103.  
  104. -- @param	district_pct_old					District percent before... 
  105. -- @param	district_pct_new					District percent after... 
  106. -- @param	district_cash_per_day			Cash per day... 
  107.  
  108. function cmp_activity_populate(unlockables_to_follow, mission_number, mission_name, layout, cash_reward, cash_multiplier, cash_reward_inc_multiplier, respect_points_old, respect_pct_old, respect_level_old, respect_points_new, respect_pct_new, respect_level_new, respect_multiplier, respect_points_multiplier, respect_pct_multiplier, respect_level_multiplier, district_pct_old, district_pct_new, district_cash_per_day, district_team_name, image) 
  109. --[[ 
  110. 	debug_print("vint", "unlockable# = " 						.. var_to_string(unlockables_to_follow).."\n") 
  111. 	debug_print("vint", "mission number = " 					.. var_to_string(mission_number).."\n") 
  112. 	debug_print("vint", "mission name = " 					.. var_to_string(mission_name).."\n") 
  113. 	debug_print("vint", "layout number = " 					.. var_to_string(layout).."\n") 
  114. 	debug_print("vint", "cash_reward" 							.. var_to_string(cash_reward).."\n") 
  115. 	debug_print("vint", "cash_multiplier = " 					.. var_to_string(cash_multiplier).."\n") 
  116. 	debug_print("vint", "cash_reward_inc_multiplier = " 	.. var_to_string(cash_reward_inc_multiplier).."\n") 
  117. 	debug_print("vint", "respect_points_old = " 				.. var_to_string(respect_points_old).."\n") 
  118. 	debug_print("vint", "respect_pct_old = " 					.. var_to_string(respect_pct_old).."\n") 
  119. 	debug_print("vint", "respect_level_old = " 				.. var_to_string(respect_level_old).."\n") 
  120. 	debug_print("vint", "respect points_new = " 				.. var_to_string(respect_points_new).."\n") 
  121. 	debug_print("vint", "respect_pct_new = " 					.. var_to_string(respect_pct_new).."\n") 
  122. 	debug_print("vint", "respect_level_new = " 				.. var_to_string(respect_level_new).."\n") 
  123. 	debug_print("vint", "respect_multiplier = " 				.. var_to_string(respect_multiplier).."\n") 
  124. 	debug_print("vint", "respect_points_multiplier = " 	.. var_to_string(respect_points_multiplier).."\n") 
  125. 	debug_print("vint", "respect_pct_multiplier = " 		.. var_to_string(respect_pct_multiplier).."\n") 
  126. 	debug_print("vint", "respect_level_multiplier = " 		.. var_to_string(respect_level_multiplier).."\n") 
  127. 	debug_print("vint", "district_pct_old = " 				.. var_to_string(district_pct_new).."\n") 
  128. 	debug_print("vint", "district_pct_new = " 				.. var_to_string(district_pct_new).."\n") 
  129. 	debug_print("vint", "district_cash_per_day = " 			.. var_to_string(district_cash_per_day).."\n") 
  130. 	debug_print("vint", "district_team_name = " 				.. var_to_string(district_team_name).."\n") 
  131. ]] 
  132. 	if image == nil or image == "" then 
  133. 		image = "ui_cmp_tank_mayhem" 
  134. 	end 
  135. 	 
  136. 	-- Store our image name to global... 
  137. 	--Cmp_image = image 
  138. 	 
  139. 	--Callback with image... 
  140. 	--game_peg_load_with_cb("cmp_common_image_loaded", 1, image) 
  141.  
  142. 	Cmp_activity_seq[1].type = CMP_SCREEN_TITLE_INDEX 
  143. 	Cmp_activity_seq[1].title_string = mission_name 
  144. 	Cmp_activity_seq[1].image = image 
  145. 	 
  146. 	--[[ 
  147. 	Cmp_activity_seq[2].tiers_bronze_goal = tiers_bronze_goal 
  148. 	Cmp_activity_seq[2].tiers_silver_goal = tiers_silver_goal 
  149. 	Cmp_activity_seq[2].tiers_gold_goal = tiers_gold_goal 
  150. 	Cmp_activity_seq[2].tier_completed = tier_completed 
  151. 	Cmp_activity_seq[2].tier_is_new = tier_is_new 
  152.  
  153.  
  154. 	--test data for tiers 
  155. 	Cmp_activity_seq[2].tiers_bronze_goal = "$20,000" 
  156. 	Cmp_activity_seq[2].tiers_silver_goal = "$50,000" 
  157. 	Cmp_activity_seq[2].tiers_gold_goal = "$100,000" 
  158. 	Cmp_activity_seq[2].tier_completed = 3 
  159. 	Cmp_activity_seq[2].tier_is_new = true 
  160. 	]] 
  161. 	Cmp_activity_seq[3].type = CMP_SCREEN_CASH_INDEX 
  162. 	Cmp_activity_seq[3].cash_reward = cash_reward 
  163. 	Cmp_activity_seq[3].cash_multiplier = cash_multiplier 
  164. 	Cmp_activity_seq[3].cash_reward_inc_multiplier = cash_reward_inc_multiplier 
  165.  
  166. 	Cmp_activity_seq[4].respect_points_old 			= respect_points_old 			 
  167. 	Cmp_activity_seq[4].respect_pct_old					= respect_pct_old				 
  168. 	Cmp_activity_seq[4].respect_level_old				= respect_level_old			 
  169. 	Cmp_activity_seq[4].respect_points_new				= respect_points_new			 
  170. 	Cmp_activity_seq[4].respect_pct_new					= respect_pct_new				 
  171. 	Cmp_activity_seq[4].respect_level_new				= respect_level_new			 
  172. 	Cmp_activity_seq[4].respect_multiplier				= respect_multiplier			 
  173. 	Cmp_activity_seq[4].respect_points_multiplier	= respect_points_multiplier	 
  174. 	Cmp_activity_seq[4].respect_pct_multiplier		= respect_pct_multiplier		 
  175. 	Cmp_activity_seq[4].respect_level_multiplier		= respect_level_multiplier	 
  176. 	 
  177. 	Cmp_activity_seq[5].district_pct_old			= district_pct_old 
  178. 	Cmp_activity_seq[5].district_pct_new			= district_pct_new  
  179. 	Cmp_activity_seq[5].district_cash_per_day		= district_cash_per_day 
  180. 	Cmp_activity_seq[5].district_team_name			=  district_team_name 
  181. 	 
  182. --	Cmp_activity_seq[4].district_pct_old			= .22 --district_pct_new --.22 
  183. --	Cmp_activity_seq[4].district_pct_new			= .325 --district_pct_new --.325 
  184. --	Cmp_activity_seq[4].district_cash_per_day		= 3000 --district_cash_per_day -- 3000 
  185. --	Cmp_activity_seq[4].district_team_name			= "Luchador" --"Luchador" 
  186.  
  187. 	--Do we show rewards or not? 
  188. 	if unlockables_to_follow > 0 then 
  189. 		Cmp_activity_seq[6] = {} 
  190. 		Cmp_activity_seq[6].type = CMP_SCREEN_REWARD_INDEX 
  191. 		Cmp_activity_seq[6].rewards_count = unlockables_to_follow 
  192. 	else  
  193. 		--Swap out unlockables with Completion... 
  194. 		Cmp_activity_seq[6] = table_clone(Cmp_activity_seq[7]) 
  195. 		Cmp_activity_seq[7] = nil 
  196. 	end 
  197. end 
  198.  
  199. function cmp_activity_populate_tiers(tier_index, tier_goal, tier_goal_text, percent, best_prev_percent, reward_unlocked, just_completed, current_score, prev_best_score, score_type) 
  200. 	debug_print("vint", "\n\n cmp_activity_populate_tiers()\n") 
  201. 	 
  202. 	local function debug_quick_print(name, value)  
  203. 		debug_print("vint", name ..":" .. var_to_string(value) .. "\n") 
  204. 	end 
  205. 	 
  206. 	debug_quick_print("tier_index", tier_index) 
  207. 	debug_quick_print("tier_goal", tier_goal) 
  208. 	debug_quick_print("tier_goal_text", tier_goal_text ) 
  209. 	debug_quick_print("percent", percent) 
  210. 	debug_quick_print("best_prev_percent", best_prev_percent ) 
  211. 	debug_quick_print("reward_unlocked", reward_unlocked) 
  212. 	debug_quick_print("just_completed", just_completed) 
  213. 	debug_quick_print("current_score", current_score) 
  214. 	debug_quick_print("prev_best_score", prev_best_score) 
  215. 	debug_print("vint", "\n") 
  216.  
  217. 	if Cmp_activity_seq[2].tier_data == nil then 
  218. 		Cmp_activity_seq[2].tier_data = { } 
  219. 		Cmp_activity_seq[2].tier_is_new = false 
  220. 		Cmp_activity_seq[2].tier_completed = false 
  221. 	end 
  222.  
  223. 	Cmp_activity_seq[2].tier_data[ tier_index ] = { 
  224. 		[ "tier_goal" ]			= tier_goal, 
  225. 		[ "percent" ]				= percent, 
  226. 		[ "best_prev_percent" ]	= best_prev_percent, 
  227. 		[ "reward_unlocked" ]	= reward_unlocked, 
  228. 		[ "just_completed" ]		= just_completed, 
  229. 		[ "score_type" ]			= score_type, 
  230. 	} 
  231. 	 
  232. 	if just_completed == true then 
  233. 		Cmp_activity_seq[2].tier_is_new = true 
  234. 	end 
  235. 	 
  236. 	--if tier_index > 1 and percent >= 1 then 
  237. 	--	Cmp_activity_seq[2].tier_data[ tier_index ].tier_completed = true 
  238. 	--end 
  239. 	 
  240. 	Cmp_activity_seq[2].current_score = current_score 
  241. 	Cmp_activity_seq[2].prev_best_score = prev_best_score 
  242. end 
  243.  
  244. Cmp_activity_seq = { 
  245. 	[1] = { 
  246. 		type 				= CMP_SCREEN_TITLE_INDEX, 
  247. 		title_string 	= "DEATH AT SMILING JACKS", 
  248. 		image				= 0, 
  249. 		on_start			= cmp_activity_first_frame, 
  250. 	}, 
  251. 	[2] = { 
  252. 		type = CMP_SCREEN_TIERS_INDEX, 
  253. 		 
  254. 		on_start = nil, 
  255. 	}, 
  256. 	[3] = { 
  257. 		type = CMP_SCREEN_CASH_INDEX, 
  258. 		cash_reward						= 20000, 
  259. 		cash_multiplier 				= 45, 
  260. 		cash_reward_inc_multiplier = 38000, 
  261. 		on_start = nil, 
  262. 	}, 
  263. 	[4] = { 
  264. 		type = CMP_SCREEN_RESPECT_INDEX, 
  265. 		on_start = nil, 
  266. 		respect_points_old			= 200, 
  267. 		respect_pct_old				= .4, 
  268. 		respect_level_old				=	2, 
  269. 		 
  270. 		respect_points_new			= 2000, 
  271. 		respect_pct_new				= .5, 
  272. 		respect_level_new				= 3, 
  273. 		respect_multiplier			= 40, 
  274. 		 
  275. 		respect_points_multiplier	=	2000,	 
  276. 		respect_pct_multiplier		= 	.5, 
  277. 		respect_level_multiplier	=	5,	 
  278. 	},	 
  279. 	[5] = { 
  280. 		type = CMP_SCREEN_CONTROL_INDEX, 
  281. 		on_start = nil, 
  282. 		district_pct_old			= .22, 
  283. 		district_pct_new			= .325, 
  284. 		district_cash_per_day	= 3000, 
  285. 		district_team_name		= "Luchador", 
  286. 	}, 
  287. 	[6] = { 
  288. 		type = CMP_SCREEN_REWARD_INDEX, 
  289. 		rewards_count = 0 
  290. 	}, 
  291. 	[7] = { 
  292. 		type = CMP_SCREEN_COOP_WAIT_INDEX, 
  293. 	}, 
  294. } 
  295.