Divergent/mods/Faster Headlamp Toggle/gamedata/scripts/liz_headlamp_animation.script

77 lines
3.2 KiB
Plaintext
Raw Normal View History

-- local originalHTT = actor_effects.Hit_TorchToggle
actor_effects.Hit_TorchToggle = function ()
if (not actor_effects.allow_animation()) or (not item_device.can_toggle_torch()) then return end
actor_effects.torch_anm_state = 1
local weapon_zoomed = axr_main.weapon_is_zoomed and (not (IsPistol(db.actor:active_item(),nil)) or db.actor:active_detector())
local det_active = db.actor:active_detector() or nil
local anm_additive = "liz\\headlamp\\liz_headlamp_toggle_weapon_sway.anm"
local anm_cam = "liz\\headlamp\\liz_headlamp_toggle.anm"
local anm_sec = "liz_headlamp_animation_hud"
-- local anm_name = not det_active and "anm_toggle" or "anm_toggle_no_mix"
local anm_name = "anm_toggle"
local anm_length = game.get_motion_length(anm_sec, anm_name, 1) / 1000
local anm_delay = 0.01
local anm_show_device_length = 0
local anm_use_blending = not det_active
-- if holding weapon and aiming disable ADS
if (db.actor:active_item()) then
if not det_active and weapon_zoomed then
if (get_console():get_bool("wpn_aim_toggle")) then
level.press_action(bind_to_dik(key_bindings.kWPN_ZOOM))
else
level.release_action(bind_to_dik(key_bindings.kWPN_ZOOM))
end
end
end
if det_active then
if weapon_zoomed then
det_active:switch_state(2)
if (get_console():get_bool("wpn_aim_toggle")) then
level.press_action(bind_to_dik(key_bindings.kWPN_ZOOM))
else
level.release_action(bind_to_dik(key_bindings.kWPN_ZOOM))
end
end
local hud_section = SYS_GetParam(0, det_active:section(), "hud")
-- local anm_hide_device_name = "anm_hide_fast_quick" or "anm_hide_fast"
anm_delay = (game.get_motion_length(hud_section, "anm_hide_fast_quick", 1) / 1000) + 0.01
anm_show_device_length = (game.get_motion_length(hud_section, "anm_hide_fast_quick", 1) / 1000) + 0.01
db.actor:hide_detector(true)
end
game.only_allow_movekeys(true)
game.set_actor_allow_ladder(false)
CreateTimeEvent(0, "play_torch_toggle_start", anm_delay, function ()
level.add_cam_effector(anm_cam, 7539, false, "", 0, false)
game.play_hud_anm(anm_additive, 0, 1, 1, false)
game.play_hud_motion(1, anm_sec, anm_name, anm_use_blending, 1)
return true
end)
--0.5333334
CreateTimeEvent(0, "play_torch_toggle_execute", anm_delay + 0.5333334, function ()
local snd_headlamp = sound_object('interface\\inv_torch')
snd_headlamp:play(db.actor, 0, sound_object.s2d)
item_device.toggle_torch()
return true
end)
if det_active then
CreateTimeEvent(0, "play_torch_toggle_show_device", anm_delay + anm_length + 0.01, function ()
if det_active then db.actor:show_detector(true) end
return true
end)
end
CreateTimeEvent(0, "play_torch_toggle_stop", anm_delay + anm_length + anm_show_device_length, function ()
game.only_allow_movekeys(false)
game.set_actor_allow_ladder(true)
actor_effects.torch_anm_state = 0
return true
end)
end