Clones_m3_doc_handle = -1
local Safe_frame_h = -1
local Pow_grp_h = -1
local Pow_move_grp_h = -1
local Pow_scale_grp_h = -1
local Pow_burst_h = -1
local Pow_txt_h = -1
local Pow_anim_1_h = -1
local Pow_anim_2_h = -1
local Pow_anim_3_h = -1
local Pow_anim_4_h = -1
local Pow_anim_5_h = -1
local Pulse_anim_h = -1
local RANDOM_ANIM = -1
local Prev_anim = -1
local Prev_color = -1
local Prev_text = -1
local Is_paused = -1
local RANDOM_TEXT = {
[1] = "KABLAM!",
[2] = "CLUNK!",
[3] = "CR-R-A-CK!",
[4] = "KAPOW!",
[5] = "KLONK!",
[6] = "SOCK!",
[7] = "SPLA-A-T!",
[8] = "SWOOSH!",
[9] = "THWAPP!",
[10] = "WHAM-ETH!",
[11] = "ZLONK!",
[12] = "POW-EE!",
[13] = "BLAM-O!",
[14] = "URKK!",
[15] = "SPLOOSH!",
[16] = "AAAH-IE!",
[17] = "BLURP!",
[18] = "BIFF!",
[19] = "EE-YOW!",
[20] = "GLIPP!",
[21] = "SWOOMP!",
[22] = "OOMPH!",
[23] = "RIP!",
[24] = "SAACK!",
[25] = "SPLORP!",
[26] = "BAM!",
[27] = "$#%@!",
[28] = "ZOINKS!",
[29] = "BIFF!",
[30] = "GIBS!",
[31] = "ZAP-EHT!",
[32] = "GRUPPP!",
}
local RANDOM_COLOR = {
[1] = {220/255, 200/255, 0/255}, --yellow
[2] = {37/255, 220/255, 0/255}, --green
[3] = {0/255, 148/255, 220/255}, --blue
[4] = {164/255, 0/255, 220/255}, --purple
[5] = {220/255, 91/255, 0/255}, --orange
[6] = {220/255, 0/255, 17/255}, --pink
[7] = {220/255, 37/255, 0/255}, --red
[8] = {220/255, 55/255, 0/255}, --red orange
[9] = {220/255, 146/255, 0/255}, --yellow pink
[10] = {135/255, 220/255, 0/255}, --yellow green
[11] = {0/255, 220/255, 128/255}, --blue green
}
function clones_m3_init()
Clones_m3_doc_handle = vint_document_find("clones_m3")
Safe_frame_h = vint_object_find("safe_frame", 0, Clones_m3_doc_handle)
vint_dataitem_add_subscription("game_paused_item", "update", "clones_m3_game_is_paused") --to check if game is paused..
Pow_grp_h = vint_object_find("pow_grp", 0, Clones_m3_doc_handle)
Pow_move_grp_h = vint_object_find("pow_move_grp", 0, Clones_m3_doc_handle)
Pow_scale_grp_h = vint_object_find("pow_scale_grp", 0, Clones_m3_doc_handle)
Pow_burst_h = vint_object_find("pow_burst", 0, Clones_m3_doc_handle)
Pow_txt_h = vint_object_find("pow_txt", 0, Clones_m3_doc_handle)
Pow_anim_1_h = vint_object_find("pow_anim_1", 0, Clones_m3_doc_handle)
Pow_anim_2_h = vint_object_find("pow_anim_2", 0, Clones_m3_doc_handle)
Pow_anim_3_h = vint_object_find("pow_anim_3", 0, Clones_m3_doc_handle)
Pow_anim_4_h = vint_object_find("pow_anim_4", 0, Clones_m3_doc_handle)
Pow_anim_5_h = vint_object_find("pow_anim_5", 0, Clones_m3_doc_handle)
Pulse_anim_h = vint_object_find("pulse_anim", 0, Clones_m3_doc_handle)
RANDOM_ANIM = {
[1] = Pow_anim_1_h,
[2] = Pow_anim_2_h,
[3] = Pow_anim_3_h,
[4] = Pow_anim_4_h,
[5] = Pow_anim_5_h,
}
vint_set_property(Pow_move_grp_h, "visible", false)
--debug_print("vint", "doc init\n")
lua_play_anim(Pulse_anim_h)
end
function clones_m3_game_is_paused(di_h)
Is_paused = vint_dataitem_get(di_h)
if Is_paused == true then
vint_set_property(Pulse_anim_h, "is_paused", true)
vint_set_property(Pow_move_grp_h, "visible", false)
else
vint_set_property(Pulse_anim_h, "is_paused", false)
end
end
function clones_m3_resize_text()
vint_set_property(Pow_txt_h, "scale", 1,1)
local max_width = 136
local text_width, text_height = element_get_actual_size(Pow_txt_h)
if text_width > max_width then
local text_scale = max_width/text_width
vint_set_property(Pow_txt_h, "scale", text_scale,text_scale)
end
end
function clones_m3_pow(pos_x, pos_y)
local color = RANDOM_COLOR[rand_int(1,11)]
local text = RANDOM_TEXT[rand_int(1,32)]
local scale = rand_float(1,1.5)
local rotation = rand_int(-30,30)
local anim = RANDOM_ANIM[rand_int(1,5)]
--No repeats
while anim == Prev_anim do
anim = RANDOM_ANIM[rand_int(1,5)]
end
while color == Prev_color do
color = RANDOM_COLOR[rand_int(1,11)]
end
while text == Prev_text do
text = RANDOM_TEXT[rand_int(1,32)]
end
Prev_anim = anim
Prev_color = color
Prev_text = text
vint_set_property(Pow_burst_h, "tint", color[1], color[2], color[3])
vint_set_property(Pow_txt_h, "text_tag", text)
vint_set_property(Pow_move_grp_h, "anchor", pos_x, pos_y)
vint_set_property(Pow_scale_grp_h, "scale", scale, scale)
vint_set_property(Pow_move_grp_h, "rotation", rotation * DEG_TO_RAD)
vint_set_property(Pow_move_grp_h, "visible", true)
--stop previous anim before starting new, spamming punches in coop fix
for key, value in pairs(RANDOM_ANIM) do
vint_set_property(value, "is_paused", true)
end
lua_play_anim(anim)
clones_m3_resize_text()
end
function clones_m3_exit()
vint_document_unload(Clones_m3_doc_handle)
end
function clones_m3_cleanup()
end