./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. function cmp_stronghold_populate(unlockables_to_follow, mission_name, layout, cash_reward, cash_multiplier, cash_reward_inc_multiplier, mission_internal_name) 
  49. --[[ 
  50. 	debug_print("vint", "unlockable# = " 						.. var_to_string(unlockables_to_follow).."\n") 
  51. 	debug_print("vint", "mission name = " 					.. var_to_string(mission_name).."\n") 
  52. 	debug_print("vint", "layout number = " 					.. var_to_string(layout).."\n") 
  53. 	debug_print("vint", "cash_reward" 							.. var_to_string(cash_reward).."\n") 
  54. 	debug_print("vint", "cash_multiplier = " 					.. var_to_string(cash_multiplier).."\n") 
  55. 	debug_print("vint", "cash_reward_inc_multiplier = " 	.. var_to_string(cash_reward_inc_multiplier).."\n") 
  56. ]] 
  57. 	local image = nil 
  58. 	if mission_internal_name ~= nil and mission_internal_name ~= "" then 
  59. 		image = Cmp_stronghold_images[mission_internal_name] 
  60. 	end 
  61.  
  62. 	-- DAD - 4/8/11 - In the event you do get a mission_internal name, but theres no matching image in the table for it: 
  63. 	if image == nil then 
  64. 		--default 
  65. 		image = Cmp_stronghold_images["sh01"] 
  66. 	end 
  67. 	 
  68. 	-- Store our image name to global... 
  69. 	Cmp_image = image 
  70.  
  71. 	--Callback with image... 
  72. 	game_peg_load_with_cb("cmp_common_image_loaded", 1, image) 
  73. 		 
  74. 	Cmp_stronghold_seq[1].type = CMP_SCREEN_TITLE_INDEX 
  75. 	Cmp_stronghold_seq[1].title_string = mission_name 
  76. 	Cmp_stronghold_seq[1].image = image 
  77.  
  78. 	Cmp_stronghold_seq[2].type = CMP_SCREEN_CASH_INDEX 
  79. 	Cmp_stronghold_seq[2].cash_reward = cash_reward 
  80. 	Cmp_stronghold_seq[2].cash_multiplier = cash_multiplier 
  81. 	Cmp_stronghold_seq[2].cash_reward_inc_multiplier = cash_reward_inc_multiplier 
  82.  
  83. 	--Do we show rewards or not? 
  84. 	if unlockables_to_follow > 0 then 
  85. 		Cmp_stronghold_seq[3] = {} 
  86. 		Cmp_stronghold_seq[3].type = CMP_SCREEN_REWARD_INDEX 
  87. 		Cmp_stronghold_seq[3].rewards_count = unlockables_to_follow 
  88. 	else  
  89. 		--Swap out unlockables with Completion... 
  90. 		Cmp_stronghold_seq[3] = table_clone(Cmp_stronghold_seq[4]) 
  91. 		Cmp_stronghold_seq[4] = nil 
  92. 	end 
  93. end 
  94.  
  95. --Temp Function and variables can be removed once the peg is loaded from C++ 
  96. function cmp_stronghold_image_loaded() 
  97. 	--image is loaded... 
  98. 	local img_grp_h = vint_object_find("img_grp", 0, Cmp_common_doc) 
  99. 	 
  100. 	--replace all 4 images... 
  101. 	for i = 1, 4 do  
  102. 		local screen_image_h = vint_object_find("screen_image_" .. i, 0, Cmp_common_doc) 
  103. 		vint_set_property(screen_image_h, "image", Cmp_image) 
  104. 	end 
  105. end 
  106.  
  107. Cmp_stronghold_seq = { 
  108. 	[1] = { 
  109. 		type 				= CMP_SCREEN_TITLE_INDEX, 
  110. 		title_string 	= "DEATH AT SMILING JACKS", 
  111. 		image				= 0, 
  112. 		on_start			= cmp_stronghold_first_frame, 
  113. 	}, 
  114. 	[2] = { 
  115. 		type = CMP_SCREEN_CASH_INDEX, 
  116. 		cash_reward						= 20000, 
  117. 		cash_multiplier 				= 45, 
  118. 		cash_reward_inc_multiplier = 38000, 
  119. 		on_start = nil, 
  120. 	}, 
  121. 	[3] = { 
  122. 		type = CMP_SCREEN_REWARD_INDEX, 
  123. 		rewards_count = 0 
  124. 	}, 
  125. 	[4] = { 
  126. 		type = CMP_SCREEN_COOP_WAIT_INDEX, 
  127. 	}, 
  128. } 
  129.