Various Changes; Updated and Added Mods

This commit is contained in:
2024-03-27 00:55:00 -04:00
parent 8abddf23c7
commit 46265b6fcc
2193 changed files with 23397 additions and 56583 deletions
@@ -2,6 +2,9 @@ local fov_manager = outfit_animations_fov_manager
local mcm_memory_enable = outfit_animations_mcm.get_config("memory")
local mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
local enable_animations = false
local ruck_last_outfit = -1
local originalPIF = actor_effects.play_item_fx
function actor_effects.play_item_fx(name)
@@ -13,6 +16,9 @@ end
function on_game_start()
RegisterScriptCallback("on_option_change", on_option_change)
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
RegisterScriptCallback("actor_item_to_slot", on_item_to_slot)
RegisterScriptCallback("actor_item_to_ruck", on_item_to_ruck)
RegisterScriptCallback("actor_on_item_drop", on_item_to_ruck)
end
@@ -24,8 +30,41 @@ end
function actor_on_first_update()
local sec = db.actor:item_in_slot(7) and db.actor:item_in_slot(7)
if sec then remember_outfit(sec) end
CreateTimeEvent("outfit_animations", "enable_animation_delay_te", 3, function()
ruck_last_outfit = db.actor:item_in_slot(7) and db.actor:item_in_slot(7):id() or -1
local sec = db.actor:item_in_slot(7)
if sec then remember_outfit(sec) end
enable_animations = true
return true
end)
end
function on_item_to_ruck(obj)
if IsOutfit(obj) and obj:id() == ruck_last_outfit then
ruck_last_outfit = -1
if not db.actor:alive() then return end
if not enable_animations then return end
if has_alife_info("BAR_ARENA_FIGHT") then return end
play_animation(obj)
end
end
function on_item_to_slot(obj)
if IsOutfit(obj) and obj:id() ~= ruck_last_outfit then
ruck_last_outfit = obj:id()
if not db.actor:alive() then return end
if not enable_animations then return end
if has_alife_info("BAR_ARENA_FIGHT") then return end
play_animation(obj)
end
end
@@ -33,49 +72,91 @@ end
-- main
------------------------------------------------------------------------------
local anm_info = nil --it's here cuz of stalke engine magic that I don't know
local cur_slot
local det_active
function play_animation_delayed(obj, callback)
--prepare
Invoke("play_animation_te3", 0.01, function ()
hide_hud_inventory()
cur_slot = db.actor:active_slot()
det_active = db.actor:active_detector() or nil
if det_active then det_active:switch_state(2) end
db.actor:activate_slot(0)
if headgear_animations then headgear_animations.enable_animations = false end
end)
wait_for_free_hands(function()
--play
fov_manager.restore_fov()
if mcm_allow_movement then game.only_allow_movekeys(true) else level.disable_input() end
callback() -- perform inventory ui action
anm_info = select_animation(obj)
local delay = 0.25
local length = 0
length = length + game.get_motion_length(anm_info.section_name, anm_info.anm, 1) / 1000
Invoke("play_outfti_inspect_animation_te", delay, function()
xr_effects.play_snd(db.actor, nil, {[1] = anm_info.snd})
level.add_cam_effector(anm_info.cam, 1300, false, "")
game.play_hud_motion(2, anm_info.section_name, anm_info.anm, false, 1)
end)
function play_animation(obj)
--prepare for anim
anm_info = select_animation()
local activeSlot = db.actor:active_slot()
local activeWpn = db.actor:active_item()
local activeDetector = db.actor:active_detector()
local activeWpnId
local activeDetectorId
CreateTimeEvent("outfit_animations", "unequip_weapon_te", 0.1, function()
if activeWpn or activeDetector then
if activeWpn then
db.actor:move_to_ruck(activeWpn)
activeWpnId = activeWpn:id()
end
if activeDetector then
db.actor:move_to_ruck(activeDetector)
activeDetectorId = activeDetector:id()
end
end
return true
end)
--restore
Invoke("restore_after_animtion_play_te", delay + length + 0.25, function()
if mcm_allow_movement then game.only_allow_movekeys(false) else level.enable_input() end
if headgear_animations then headgear_animations.enable_animations = true end
-- db.actor:activate_slot(cur_slot or 0)
-- if det_active then det_active:switch_state(1) end
hide_hud_inventory()
if headgear_animations then headgear_animations.enable_animations = false end
--trying to kill backpack animation (kinda afterid that it might cause busy hands bug. Need some testing)
if enhanced_animations and ui_mcm.get("EA_settings/enable_backpack_addon") then
CreateTimeEvent("outfit_animations", "stop_animation", 0.05, function()
game.stop_hud_motion()
fov_manager.restore_fov()
if mcm_allow_movement then game.only_allow_movekeys(true) else level.disable_input() end
return true
end)
end
--play
anm_info = select_animation(obj)
local delay = 0.25
local length = 0
length = length + game.get_motion_length(anm_info.section_name, anm_info.anm, 1) / 1000
Invoke("play_outfti_inspect_animation_te", delay, function()
xr_effects.play_snd(db.actor, nil, {[1] = anm_info.snd})
level.add_cam_effector(anm_info.cam, 1300, false, "")
game.play_hud_motion(2, anm_info.section_name, anm_info.anm, false, 1)
end)
--restore
Invoke("restore_after_animtion_play_te", delay + length + 0.25, function()
-- Restore weapons if had
if activeWpnId or activeDetectorId then
if activeWpnId then
local obj = level.object_by_id(activeWpnId)
if obj then
db.actor:move_to_slot(obj, activeSlot)
CreateTimeEvent("outfit_animations", "restore_active_weapon_te", 0.05, function()
db.actor:activate_slot(activeSlot)
return true
end)
-- nextTick(function()
-- db.actor:activate_slot(activeSlot)
-- return true
-- end, 2)
end
end
if activeDetectorId then
local obj = level.object_by_id(activeDetectorId)
if obj then
db.actor:move_to_slot(obj, 9)
-- Time event for proper animation play
CreateTimeEvent("outfit_animations", "restore_active_detector_te", 0.5, function()
obj:switch_state(1)
return true
end)
end
end
end
if mcm_allow_movement then game.only_allow_movekeys(false) else level.enable_input() end
if headgear_animations then headgear_animations.enable_animations = true end
end)
end
function select_animation(obj)
--temp solution
--todo: choose animation base on armor type
local m_section = "outfit_animation_hud"
if mcm_memory_enable then
@@ -101,19 +182,6 @@ function select_animation(obj)
end
function wait_for_free_hands(action_to_perform)
local force_timer = 0
CreateTimeEvent("outfit_animations", "wait_for_free_hands_te0", 0.1, function()
if (db.actor:active_slot() == 0 and not db.actor:active_detector() and not enhanced_animations.used_item) or (force_timer > 5) then
Invoke("wait_for_free_hands_te1", 0, action_to_perform) --i don understan y this works (ノへ ̄、)
return true
end
force_timer = force_timer + (device().time_delta/1000)
return false
end)
end
function Invoke(name, time, action)
CreateTimeEvent("outfit_animations", name, time, function()
action()