./cmp_stronghold.lua

  1. --Global Mission Sequence Table... 
  2. Cmp_stronghold_seq = {} 
  3.  
  4. local Cmp_stronghold_images = { 
  5. 	["sh01"] = "ui_cmp_sh01", 
  6. 	["sh02"] = "ui_cmp_sh02", 
  7. 	["sh03"] = "ui_cmp_sh03", 
  8. 	["sh04"] = "ui_cmp_sh04", 
  9. } 
  10.  
  11. function cmp_stronghold_init() 
  12. 	Cmp_specific_doc = vint_document_find("cmp_stronghold") 
  13.  
  14. 	--Populate data... 
  15. 	vint_dataresponder_request("cmp_stronghold_success", "cmp_stronghold_populate", 0) 
  16. 	--Set sequence... 
  17. 	cmp_common_screen_set_data(Cmp_stronghold_seq) 
  18. end 
  19.  
  20. function cmp_stronghold_cleanup() 
  21. 	if CMP_TEST_MODE then 
  22. 		debug_print("vint", "cleanup cmp_stronghold_cleanup()\n") 
  23. 	end 
  24. end 
  25.  
  26. function cmp_stronghold_first_frame() 
  27. 	--Do nothing 
  28. 	local h = vint_object_find("background_force_black", 0, Cmp_common_doc) 
  29. 	vint_set_property(h, "visible", true) 
  30.  
  31. 	local h = vint_object_find("background_base", 0, Cmp_common_doc) 
  32. 	vint_set_property(h, "background", false)	 
  33. end 
  34.  
  35. ------------------------------------------------------------- 
  36. --Populates the script from the dataresponder... 
  37. ------------------------------------------------------------- 
  38.  
  39. -- @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. 
  40. -- @param	mission_internal_name			This is the mission internal name "sh01", "sh02", 
  41. -- @param	mission_name						This is the mission name... "DEATH AT SMILING JACKS" 
  42. -- @param	layout								"Left" or "Right" formats		(Not used by cmp_common JMH, it is sent in as a paremeter 11/3/2010) 
  43.  
  44. -- @param	cash_reward							This is the cash reward... "4000" 
  45. -- @param	cash_multiplier					Multiplier for cash			"4.0" 
  46. -- @param	cash_reward_inc_multiplier		Cash_reward with the multiplier... "12000" (This could be calculated internally) 
  47.  
  48. --[[ 
  49. 	dr->set_element(0, Completion_info.awards.num_unlockables);		//	We have unlockables to do. 
  50. 	dr->set_element(1, encoded_string);							//	Activity Title 
  51. 	dr->set_element(2, Completion_info.layout);				// layout format 
  52.  
  53. 	//	Award cash 
  54. 	dr->set_element(3, Completion_info.awards.cash);		//	Cash Award	 
  55. 	dr->set_element(4, fl_floor((cash_multiplier + 0.005f - 1.0f) * 100.0f));	// cash multiplier 
  56. 	dr->set_element(5, Completion_info.awards.cash * cash_multiplier);		//	Cash reward including multiplier 
  57. 	dr->set_element(6, Completion_info.image_name_base); 
  58. 	 
  59. 	// Respect 
  60. 	dr->set_element(7, curr_respect[0]); 
  61. 	dr->set_element(8, respect_pct[0]); 
  62. 	dr->set_element(9, respect_lvl[0]); 
  63.  
  64. 	dr->set_element(10, curr_respect[1]); 
  65. 	dr->set_element(11, respect_pct[1]); 
  66. 	dr->set_element(12, respect_lvl[1]); 
  67.  
  68. 	dr->set_element(13, fl_floor((completion_get_total_respect_multiplier() + 0.005f - 1.0f) * 100.0f));	// respect multiplier 
  69. 	dr->set_element(14, curr_respect[2]); 
  70. 	dr->set_element(15, respect_pct[2]); 
  71. 	dr->set_element(16, respect_lvl[2]); 
  72.  
  73. ]] 
  74.  
  75. function cmp_stronghold_populate(unlockables_to_follow, mission_name, layout, cash_reward, cash_multiplier, cash_reward_inc_multiplier, mission_internal_name, 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) 
  76. --[[ 
  77. 	debug_print("vint", "unlockable# = " 						.. var_to_string(unlockables_to_follow).."\n") 
  78. 	debug_print("vint", "mission name = " 					.. var_to_string(mission_name).."\n") 
  79. 	debug_print("vint", "layout number = " 					.. var_to_string(layout).."\n") 
  80. 	debug_print("vint", "cash_reward" 							.. var_to_string(cash_reward).."\n") 
  81. 	debug_print("vint", "cash_multiplier = " 					.. var_to_string(cash_multiplier).."\n") 
  82. 	debug_print("vint", "cash_reward_inc_multiplier = " 	.. var_to_string(cash_reward_inc_multiplier).."\n") 
  83. ]] 
  84. 	local image = nil 
  85. 	if mission_internal_name ~= nil and mission_internal_name ~= "" then 
  86. 		image = Cmp_stronghold_images[mission_internal_name] 
  87. 	end 
  88.  
  89. 	-- DAD - 4/8/11 - In the event you do get a mission_internal name, but theres no matching image in the table for it: 
  90. 	if image == nil then 
  91. 		--default 
  92. 		image = Cmp_stronghold_images["sh01"] 
  93. 	end 
  94. 	 
  95. 	-- Store our image name to global... 
  96. 	Cmp_image = image 
  97.  
  98. 	--Callback with image... 
  99. 	game_peg_load_with_cb("cmp_common_image_loaded", 1, image) 
  100. 		 
  101. 	Cmp_stronghold_seq[1].type = CMP_SCREEN_TITLE_INDEX 
  102. 	Cmp_stronghold_seq[1].title_string = mission_name 
  103. 	Cmp_stronghold_seq[1].image = image 
  104.  
  105. 	Cmp_stronghold_seq[2].type = CMP_SCREEN_CASH_INDEX 
  106. 	Cmp_stronghold_seq[2].cash_reward = cash_reward 
  107. 	Cmp_stronghold_seq[2].cash_multiplier = cash_multiplier 
  108. 	Cmp_stronghold_seq[2].cash_reward_inc_multiplier = cash_reward_inc_multiplier 
  109. 	 
  110. 	Cmp_stronghold_seq[3].respect_points_old 				= respect_points_old 			 
  111. 	Cmp_stronghold_seq[3].respect_pct_old					= respect_pct_old				 
  112. 	Cmp_stronghold_seq[3].respect_level_old				= respect_level_old			 
  113. 	Cmp_stronghold_seq[3].respect_points_new				= respect_points_new			 
  114. 	Cmp_stronghold_seq[3].respect_pct_new					= respect_pct_new				 
  115. 	Cmp_stronghold_seq[3].respect_level_new				= respect_level_new			 
  116. 	Cmp_stronghold_seq[3].respect_multiplier				= respect_multiplier			 
  117. 	Cmp_stronghold_seq[3].respect_points_multiplier		= respect_points_multiplier	 
  118. 	Cmp_stronghold_seq[3].respect_pct_multiplier			= respect_pct_multiplier		 
  119. 	Cmp_stronghold_seq[3].respect_level_multiplier		= respect_level_multiplier	 
  120.  
  121. 	--Do we show rewards or not? 
  122. 	if unlockables_to_follow > 0 then 
  123. 		Cmp_stronghold_seq[4] = {} 
  124. 		Cmp_stronghold_seq[4].type = CMP_SCREEN_REWARD_INDEX 
  125. 		Cmp_stronghold_seq[4].rewards_count = unlockables_to_follow 
  126. 	else  
  127. 		--Swap out unlockables with Completion... 
  128. 		Cmp_stronghold_seq[4] = table_clone(Cmp_stronghold_seq[5]) 
  129. 		Cmp_stronghold_seq[5] = nil 
  130. 	end 
  131. 	 
  132. end 
  133.  
  134. --Temp Function and variables can be removed once the peg is loaded from C++ 
  135. function cmp_stronghold_image_loaded() 
  136. 	--image is loaded... 
  137. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  138. 	 
  139. 	--replace all 4 images... 
  140. 	for i = 1, 4 do  
  141. 		local screen_image_h = vint_object_find("screen_image_" .. i, 0, Cmp_common_doc) 
  142. 		vint_set_property(screen_image_h, "image", Cmp_image) 
  143. 	end 
  144. end 
  145.  
  146. Cmp_stronghold_seq = { 
  147. 	[1] = { 
  148. 		type 				= CMP_SCREEN_TITLE_INDEX, 
  149. 		title_string 	= "DEATH AT SMILING JACKS", 
  150. 		image				= 0, 
  151. 		on_start			= cmp_stronghold_first_frame, 
  152. 	}, 
  153. 	[2] = { 
  154. 		type = CMP_SCREEN_CASH_INDEX, 
  155. 		cash_reward						= 20000, 
  156. 		cash_multiplier 				= 45, 
  157. 		cash_reward_inc_multiplier = 38000, 
  158. 		on_start = nil, 
  159. 	}, 
  160. 	[3] = { 
  161. 		type = CMP_SCREEN_RESPECT_INDEX, 
  162. 		on_start = nil, 
  163. 		respect_points_old			= 200, 
  164. 		respect_pct_old				= .4, 
  165. 		respect_level_old				=	2, 
  166. 		 
  167. 		respect_points_new			= 2000, 
  168. 		respect_pct_new				= .5, 
  169. 		respect_level_new				= 3, 
  170. 		respect_multiplier			= 40, 
  171. 		 
  172. 		respect_points_multiplier	=	2000,	 
  173. 		respect_pct_multiplier		= 	.5, 
  174. 		respect_level_multiplier	=	5,	 
  175. 	},	 
  176. 	[4] = { 
  177. 		type = CMP_SCREEN_REWARD_INDEX, 
  178. 		rewards_count = 0 
  179. 	}, 
  180. 	[5] = { 
  181. 		type = CMP_SCREEN_COOP_WAIT_INDEX, 
  182. 	}, 
  183. } 
  184.