--Enums for events
RM_FIRE_TRAP = 1
RM_ELECTRIC_TRAP = 2
RM_FIRE_TRAP_KILL = 3
RM_ELECTRIC_TRAP_KILL = 4
RM_PRESENT_AWARDED = 5
RM_PRESENT_SPAWN = 6
RM_PRESENT_EXPLODED = 7
RM_PRESENT_WARNING = 8
RM_MULTI_5X = 9
RM_HUNTER_SPAWN = 10
RM_HUNTER_KILLED = 11
RM_HUNTER_KILL_PLAYER = 12
RM_ENEMY_TRAP = 13
RM_HUMAN_SHIELD = 14
RM_TARGET_ETHICAL = 15
RM_TARGET_UNETHICAL = 16
RM_TARGET_MONEY = 17
RM_TARGET_TIME_BONUS = 18
RM_TARGET_HEALTH = 19
RM_HEAD_SHOT = 20
RM_NUT_SHOT = 21
RM_TIME_LOW = 22
RM_EXIT_SPAWN = 23
RM_START_MATCH = 24
RM_GENKI_TARGET_CORRECT = 25
RM_GENKI_TARGET_INCORRECT = 26
RM_TARGET_ETHICAL_CLASSIC = 27
RM_TARGET_UNETHICAL_CLASSIC = 28
RM_SHARK = 29
RM_TARGET_ETHICAL_XMAS = 30
RM_TARGET_UNETHICAL_XMAS = 31
RM_TARGET_COMBO = 32
RM_TARGET_COMBO_SUPER = 33
Data = {
[RM_FIRE_TRAP] = {
animation = "fire_anim",
tween = "end_event_twn",
grps = {"fire_grp"},
sfx = "RM_HUD_Fire_Trap"
},
[RM_ELECTRIC_TRAP] = {
animation = "trap_electric_anim",
tween = "end_event_twn",
grps = { "trap_electric_grp" },
sfx = "RM_HUD_Electricity_Trap",
},
[RM_FIRE_TRAP_KILL] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Killed_by_Fire_Trap",
},
[RM_ELECTRIC_TRAP_KILL] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Killed_by_Fire_Trap",
},
[RM_PRESENT_AWARDED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Gets_Present",
},
[RM_PRESENT_SPAWN] = {
animation = "present_anim",
tween = "end_event_twn",
grps = { "present_grp" },
sfx = "RM_Present_Spawned",
},
[RM_PRESENT_EXPLODED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Player_Damaged_by_Present",
},
[RM_PRESENT_WARNING] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Present_About_to_Explode",
},
[RM_MULTI_5X] = {
animation = "5x_anim",
tween = "end_event_twn",
grps = { "fan_grp", "multiplier_grp" },
sfx = "RM_5X_Multiplier",
},
[RM_HUNTER_SPAWN] = {
animation = "hunter_anim",
tween = "end_event_twn",
grps = { "hunter_grp" },
sfx = "RM_Hunters_Spawned",
},
[RM_HUNTER_KILLED] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Kills_Hunter",
},
[RM_HUNTER_KILL_PLAYER] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Killed_by_Hunter",
},
[RM_ENEMY_TRAP] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Kill_Enemy_With_Trap",
},
[RM_HUMAN_SHIELD] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Take_Human_Shield",
},
[RM_TARGET_ETHICAL] = {
animation = "ethical_anim",
tween = "end_event_twn",
grps = { "ethical_grp" },
sfx = "RM_HUD_Ethical",
},
[RM_TARGET_UNETHICAL] = {
animation = "unethical_anim",
tween = "end_event_twn",
grps = { "unethical_grp" },
sfx = "RM_HUD_Unethical",
},
[RM_TARGET_MONEY] = {
animation = "money_shot_anim",
tween = "end_event_twn",
grps = { "money_shot_grp" },
sfx = "RM_Shoot_Money_Target",
},
[RM_TARGET_TIME_BONUS] = {
animation = "time_bonus_anim",
tween = "end_event_twn",
grps = { "time_bonus_grp", "genki_head_grp" },
sfx = "RM_HUD_Time_Bonus",
},
[RM_TARGET_HEALTH] = {
animation = "health_anim",
tween = "end_event_twn",
grps = { "health_grp" },
sfx = "RM_HUD_Health",
},
[RM_HEAD_SHOT] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Headshot",
},
[RM_NUT_SHOT] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Nutshot",
},
[RM_TIME_LOW] = {
animation = "time_low_anim",
tween = "end_event_twn",
grps = { "timer_grp", "fan_grp", "genki_head_grp" },
sfx = "RM_HUD_Timer",
},
[RM_EXIT_SPAWN] = {
animation = "exit_spawn_anim",
tween = "end_event_twn",
grps = { "exit_spawned_grp" },
sfx = "RM_Exiting",
},
[RM_START_MATCH] = {
animation = "do_nothing_anim",
tween = "end_event_twn",
grps = { "do_nothing_grp" },
sfx = "RM_Start_Match",
},
[RM_GENKI_TARGET_CORRECT] = {
animation = "ethical_anim",
tween = "end_event_twn",
grps = { "ethical_grp" },
sfx = "RM_HUD_Ethical",
},
[RM_GENKI_TARGET_INCORRECT] = {
animation = "unethical_anim",
tween = "end_event_twn",
grps = { "unethical_grp" },
sfx = "RM_HUD_Unethical",
},
[RM_TARGET_ETHICAL_CLASSIC] = {
animation = "ethical_classic_anim",
tween = "end_event_twn",
grps = { "ethical_classic_grp" },
sfx = "RM_HUD_Ethical",
},
[RM_TARGET_UNETHICAL_CLASSIC] = {
animation = "unethical_classic_anim",
tween = "end_event_twn",
grps = { "unethical_classic_grp" },
sfx = "RM_HUD_Unethical",
},
[RM_SHARK] = {
animation = "shark_anim",
tween = "end_event_twn",
grps = { "shark_grp" },
sfx = "Jungle_HUD_Water_Bear",
no_switch_sfx = true,
},
[RM_TARGET_ETHICAL_XMAS] = {
animation = "ethical_xmas_anim",
tween = "end_event_twn",
grps = { "ethical_xmas_grp" },
sfx = "Genki_Holiday_Orthodox",
},
[RM_TARGET_UNETHICAL_XMAS] = {
animation = "unethical_xmas_anim",
tween = "end_event_twn",
grps = { "unethical_xmas_grp" },
sfx = "Genki_Holiday_Unorthodox",
},
[RM_TARGET_COMBO] = {
animation = "combo_anim",
tween = "end_event_twn",
grps = { "combo_grp" },
sfx = "Genki_Holiday_Combo_01",
},
[RM_TARGET_COMBO_SUPER] = {
animation = "combo_super_anim",
tween = "end_event_twn",
grps = { "combo_super_grp" },
sfx = "Genki_Holiday_Combo_2x",
},
}
Hud_running_man_doc_handle = -1
local Event_played = -1
local Timer_audio = 0
local Event_is_playing = false
local Running_man_peg_loaded = false
local Panda_is_sad = false
local Rm_hud_event_audio_id = -1
function hud_running_man_init()
Hud_running_man_doc_handle = vint_document_find("hud_running_man")
for key, event in pairs(Data) do
local anim_h = vint_object_find(event.animation)
local tween_h = vint_object_find(event.tween, anim_h)
vint_set_property(tween_h, "end_event", "end_event_anim")
vint_apply_start_values(anim_h)
for key2, group_name in pairs (event.grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", false)
end
end
-- Set up looping tweens
local unethical_classic_anim = Vdo_anim_object:new("unethical_classic_anim", 0, Hud_running_man_doc_handle)
local trap_electric_anim = Vdo_anim_object:new("trap_eletric_anim", 0, Hud_running_man_doc_handle)
local health_anim = Vdo_anim_object:new("health_anim", 0, Hud_running_man_doc_handle)
local money_shot_anim = Vdo_anim_object:new("money_shot_anim", 0, Hud_running_man_doc_handle)
local panda_shock_twn = Vdo_tween_object:new("panda_shock_twn", trap_electric_anim.handle)
panda_shock_twn:set_end_event("hud_running_man_switch_panda")
local panda_twn = Vdo_tween_object:new("panda_twn", unethical_classic_anim.handle)
panda_twn:set_end_event("hud_running_man_switch_panda")
thread_new( "hud_running_man_load_complete" )
end
function hud_running_man_load_complete()
if (mission_is_active("mol_jg_01") == true) then
pause_map_dump( true )
game_peg_load_with_cb("hud_running_man_peg_loaded", 2, "ui_bms_rm", "ui_bms_genki_run")
elseif(mission_is_active("DLC2_A_GH_NE_01") == true) or (mission_is_active("DLC2_A_GH_NW_01") == true) or (mission_is_active("DLC2_A_GH_DT_01") == true) then
game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_genki_fly")
else
game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_genki_escort")
end
end
function hud_running_man_peg_loaded()
Running_man_peg_loaded = true
hud_running_man_event_update(RM_START_MATCH)
end
function hud_running_man_event_update(event_idx, timer)
-- check if we're using the time low event
if event_idx == RM_TIME_LOW then
hud_running_man_play_time_low(event_idx, timer)
return
end
if Running_man_peg_loaded == false then
return
end
--Always interrupt an existing event to play something newer
if Event_is_playing then
end_event_anim()
end
-- DEBUG TEXT MESSAGE
-- local do_nothing_txt = Vdo_base_object:new("do_nothing_txt", 0, Hud_running_man_doc_handle)
-- do_nothing_txt:set_text("Event "..event_idx.." fired")
for key, group_name in pairs(Data[event_idx].grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", true)
end
local anim_h = vint_object_find(Data[event_idx].animation)
lua_play_anim(anim_h)
if Data[event_idx].sfx ~= nil then
if Data[event_idx].no_switch_sfx then
Rm_hud_event_audio_id = audio_object_post_event(Data[event_idx].sfx)
else
Rm_hud_event_audio_id = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man",Data[event_idx].sfx})
end
end
Event_is_playing = true
Event_played = event_idx
end
function end_event_anim()
-- hide grps that were used and stop animation
for key, group_name in pairs(Data[Event_played].grps) do
local group_h = vint_object_find(group_name)
vint_set_property(group_h, "visible", false)
end
-- stop animation
vint_set_property(vint_object_find(Data[Event_played].animation),"is_paused", true)
-- Mark it ended
Event_is_playing = false
end
function hud_running_man_unload()
if (mission_is_active("mol_jg_01") == true) then
game_peg_unload_wait("ui_bms_rm")
game_peg_unload_wait("ui_bms_genki_run")
pause_map_restore()
elseif(mission_is_active("DLC2_A_GH_NE_01") == true) or (mission_is_active("DLC2_A_GH_NW_01") == true) or (mission_is_active("DLC2_A_GH_DT_01") == true) then
game_peg_unload_wait("ui_bms_genki_fly")
else
game_peg_unload_wait("ui_bms_genki_escort")
end
--pop_screen( "running_man_hud" )
end
function hud_running_man_cleanup()
end
function hud_running_man_switch_panda(twn_handle)
local anim_h = vint_object_parent(twn_handle)
local unethical_classic_anim_h = vint_object_find("unethical_classic_anim")
local trap_electric_anim_h = vint_object_find("trap_electric_anim")
local panda_img
if anim_h == unethical_classic_anim_h then
panda_img = Vdo_base_object:new("panda_img", 0, Hud_running_man_doc_handle)
if Panda_is_sad then
panda_img:set_image("ui_rm_nuetral_panda")
Panda_is_sad = false
else
panda_img:set_image("ui_rm_sad_panda")
Panda_is_sad = true
end
elseif anim_h == trap_electric_anim_h then
panda_img = Vdo_base_object:new("panda_shocked", 0, Hud_running_man_doc_handle)
if Panda_is_sad then
panda_img:set_image("ui_rm_panda_shocked")
Panda_is_sad = false
else
panda_img:set_image("ui_rm_panda_skeleton")
Panda_is_sad = true
end
end
end
function hud_running_man_play_time_low(event_idx, timer)
local timer_grp = Vdo_base_object:new("timer_grp", 0, Hud_running_man_doc_handle)
local genki_head_grp = Vdo_base_object:new("genki_head_grp", 0, Hud_running_man_doc_handle)
local anim_h = vint_object_find("time_low_anim")
local timer_txt = Vdo_base_object:new("timer_txt", 0, Hud_running_man_doc_handle)
if Event_is_playing == false and timer > -1 then
timer_txt:set_text(format_time(timer/1000, false, false))
lua_play_anim(anim_h)
Timer_audio = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man","RM_HUD_Timer"})
timer_grp:set_visible(true)
genki_head_grp:set_visible(true)
Event_is_playing = true
elseif timer > -1 then
timer_txt:set_text(format_time(timer/1000, false, false))
if timer <= 0 then
if Timer_audio > 0 then
audio_stop(Timer_audio)
Timer_audio = 0
end
end
elseif timer == -1 then
timer_grp:set_visible(false)
genki_head_grp:set_visible(true)
vint_set_property(anim_h, "is_paused", true)
if Timer_audio > 0 then
audio_stop(Timer_audio)
Timer_audio = 0
end
Event_is_playing = false
end
end