./clones_m3.lua

  1. Clones_m3_doc_handle = -1 
  2. local Safe_frame_h = -1 
  3.  
  4. local Pow_grp_h = -1 
  5. local Pow_move_grp_h = -1 
  6. local Pow_scale_grp_h = -1 
  7. local Pow_burst_h = -1 
  8. local Pow_txt_h = -1 
  9. local Pow_anim_1_h = -1 
  10. local Pow_anim_2_h = -1 
  11. local Pow_anim_3_h = -1 
  12. local Pow_anim_4_h = -1 
  13. local Pow_anim_5_h = -1 
  14. local Pulse_anim_h = -1 
  15.  
  16. local RANDOM_ANIM = -1 
  17.  
  18. local Prev_anim = -1 
  19. local Prev_color = -1 
  20. local Prev_text = -1 
  21.  
  22. local Is_paused = -1 
  23.  
  24. local RANDOM_TEXT = { 
  25. 	[1] = "KABLAM!", 
  26. 	[2] = "CLUNK!", 
  27. 	[3] = "CR-R-A-CK!", 
  28. 	[4] = "KAPOW!", 
  29. 	[5] = "KLONK!", 
  30. 	[6] = "SOCK!", 
  31. 	[7] = "SPLA-A-T!", 
  32. 	[8] = "SWOOSH!", 
  33. 	[9] = "THWAPP!", 
  34. 	[10] = "WHAM-ETH!", 
  35. 	[11] = "ZLONK!", 
  36. 	[12] = "POW-EE!", 
  37. 	[13] = "BLAM-O!", 
  38. 	[14] = "URKK!", 
  39. 	[15] = "SPLOOSH!", 
  40. 	[16] = "AAAH-IE!", 
  41. 	[17] = "BLURP!", 
  42. 	[18] = "BIFF!", 
  43. 	[19] = "EE-YOW!", 
  44. 	[20] = "GLIPP!", 
  45. 	[21] = "SWOOMP!", 
  46. 	[22] = "OOMPH!", 
  47. 	[23] = "RIP!", 
  48. 	[24] = "SAACK!", 
  49. 	[25] = "SPLORP!", 
  50. 	[26] = "BAM!", 
  51. 	[27] = "$#%@!", 
  52. 	[28] = "ZOINKS!", 
  53. 	[29] = "BIFF!", 
  54. 	[30] = "GIBS!", 
  55. 	[31] = "ZAP-EHT!", 
  56. 	[32] = "GRUPPP!", 
  57. } 
  58.  
  59. local RANDOM_COLOR = { 
  60. 	[1] = {220/255, 200/255, 0/255}, 	--yellow 
  61. 	[2] = {37/255, 220/255, 0/255},		--green 
  62. 	[3] = {0/255, 148/255, 220/255}, 	--blue 
  63. 	[4] = {164/255, 0/255, 220/255}, 	--purple 
  64. 	[5] = {220/255, 91/255, 0/255}, 		--orange 
  65. 	[6] = {220/255, 0/255, 17/255}, 		--pink 
  66. 	[7] = {220/255, 37/255, 0/255},		--red 
  67. 	[8] = {220/255, 55/255, 0/255}, 		--red orange 
  68. 	[9] = {220/255, 146/255, 0/255}, 	--yellow pink 
  69. 	[10] = {135/255, 220/255, 0/255}, 	--yellow green 
  70. 	[11] = {0/255, 220/255, 128/255}, 	--blue green 
  71. } 
  72.  
  73. function clones_m3_init() 
  74. 	 
  75. 	Clones_m3_doc_handle = vint_document_find("clones_m3") 
  76. 	 
  77. 	Safe_frame_h = vint_object_find("safe_frame", 0, Clones_m3_doc_handle) 
  78. 	 
  79. 	vint_dataitem_add_subscription("game_paused_item", "update", "clones_m3_game_is_paused") --to check if game is paused..  
  80. 	 
  81. 	Pow_grp_h = vint_object_find("pow_grp", 0, Clones_m3_doc_handle) 
  82. 	Pow_move_grp_h = vint_object_find("pow_move_grp", 0, Clones_m3_doc_handle) 
  83. 	Pow_scale_grp_h = vint_object_find("pow_scale_grp", 0, Clones_m3_doc_handle) 
  84. 	Pow_burst_h = vint_object_find("pow_burst", 0, Clones_m3_doc_handle) 
  85. 	Pow_txt_h = vint_object_find("pow_txt", 0, Clones_m3_doc_handle) 
  86. 	 
  87. 	Pow_anim_1_h = vint_object_find("pow_anim_1", 0, Clones_m3_doc_handle) 
  88. 	Pow_anim_2_h = vint_object_find("pow_anim_2", 0, Clones_m3_doc_handle) 
  89. 	Pow_anim_3_h = vint_object_find("pow_anim_3", 0, Clones_m3_doc_handle) 
  90. 	Pow_anim_4_h = vint_object_find("pow_anim_4", 0, Clones_m3_doc_handle) 
  91. 	Pow_anim_5_h = vint_object_find("pow_anim_5", 0, Clones_m3_doc_handle) 
  92. 	Pulse_anim_h = vint_object_find("pulse_anim", 0, Clones_m3_doc_handle) 
  93.  
  94.  
  95. 	RANDOM_ANIM = { 
  96. 		[1] = Pow_anim_1_h, 
  97. 		[2] = Pow_anim_2_h, 
  98. 		[3] = Pow_anim_3_h, 
  99. 		[4] = Pow_anim_4_h, 
  100. 		[5] = Pow_anim_5_h, 
  101. 	}	 
  102. 	 
  103. 	vint_set_property(Pow_move_grp_h, "visible", false) 
  104. 	--debug_print("vint", "doc init\n") 
  105. 	lua_play_anim(Pulse_anim_h) 
  106.  
  107. end 
  108.  
  109. function clones_m3_game_is_paused(di_h) 
  110. 	Is_paused = vint_dataitem_get(di_h) 
  111. 	if Is_paused == true then 
  112. 		vint_set_property(Pulse_anim_h, "is_paused", true) 
  113. 		vint_set_property(Pow_move_grp_h, "visible", false) 
  114. 	else  
  115. 		vint_set_property(Pulse_anim_h, "is_paused", false) 
  116. 		 
  117. 	end	 
  118. end  
  119.  
  120. function clones_m3_resize_text() 
  121.  
  122. 	vint_set_property(Pow_txt_h, "scale", 1,1) 
  123. 	local max_width = 136  
  124. 	local text_width, text_height = element_get_actual_size(Pow_txt_h) 
  125.  
  126. 	if text_width > max_width then 
  127. 		local text_scale = max_width/text_width 
  128. 		vint_set_property(Pow_txt_h, "scale", text_scale,text_scale) 
  129. 	end 
  130.  
  131. end 
  132. 	 
  133. function clones_m3_pow(pos_x, pos_y) 
  134. 	 
  135. 	local color = RANDOM_COLOR[rand_int(1,11)] 
  136. 	local text = RANDOM_TEXT[rand_int(1,32)] 
  137. 	local scale = rand_float(1,1.5) 
  138. 	local rotation = rand_int(-30,30) 
  139. 	local anim = RANDOM_ANIM[rand_int(1,5)] 
  140. 	 
  141. 	--No repeats 
  142. 	while anim == Prev_anim do 
  143. 		anim = RANDOM_ANIM[rand_int(1,5)] 
  144. 	end 
  145. 	 
  146. 	while color == Prev_color do 
  147. 		color = RANDOM_COLOR[rand_int(1,11)] 
  148. 	end 
  149. 	 
  150. 	while text == Prev_text do 
  151. 		text = RANDOM_TEXT[rand_int(1,32)] 
  152. 	end 
  153. 	 
  154. 	Prev_anim = anim 
  155. 	Prev_color = color 
  156. 	Prev_text = text 
  157. 	 
  158. 	vint_set_property(Pow_burst_h, "tint", color[1], color[2], color[3]) 
  159. 	vint_set_property(Pow_txt_h, "text_tag", text) 
  160. 	vint_set_property(Pow_move_grp_h, "anchor", pos_x, pos_y) 
  161. 	vint_set_property(Pow_scale_grp_h, "scale", scale, scale) 
  162. 	vint_set_property(Pow_move_grp_h, "rotation", rotation * DEG_TO_RAD) 
  163. 		 
  164. 	 
  165. 	vint_set_property(Pow_move_grp_h, "visible", true) 
  166. 	 
  167. 	--stop previous anim before starting new, spamming punches in coop fix 
  168. 	for key, value in pairs(RANDOM_ANIM) do 
  169. 		vint_set_property(value, "is_paused", true) 
  170. 	end 
  171. 	 
  172. 	lua_play_anim(anim) 
  173. 	 
  174. 	clones_m3_resize_text() 
  175. end 
  176.  
  177.  
  178.  
  179. function clones_m3_exit() 
  180. 	vint_document_unload(Clones_m3_doc_handle) 
  181. end 
  182.  
  183. function clones_m3_cleanup() 
  184. 	 
  185. end 
  186.