Various Changes; Updated and Added Mods
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
local originalPIF = actor_effects.play_item_fx
|
||||
actor_effects.play_item_fx = function(name)
|
||||
if name == "disguise_tear_patch" then return end
|
||||
originalPIF(name)
|
||||
end
|
||||
|
||||
local originalMPA = gameplay_disguise.menu_patch_action
|
||||
gameplay_disguise.menu_patch_action = function(obj)
|
||||
|
||||
local section = obj:section()
|
||||
local comm = ini_sys:r_string_ex(section, "community")
|
||||
if comm and (comm ~= "") and gameplay_disguise.possible_factions[comm] then
|
||||
local id = obj:id()
|
||||
local obj_patch = gameplay_disguise.get_patch(comm)
|
||||
local state = se_load_var(id, obj:name(), "unpatched")
|
||||
|
||||
local current_outfit_id = db.actor:item_in_slot(7) and db.actor:item_in_slot(7):id() or -1
|
||||
local is_equipped_outfit = id == current_outfit_id and true or false
|
||||
|
||||
if state and obj_patch then
|
||||
|
||||
if is_equipped_outfit then
|
||||
outfit_animations_patches.play_animation_apply_patch(comm)
|
||||
else
|
||||
outfit_animations_patches.play_animation_apply_patch_inventory(comm)
|
||||
end
|
||||
|
||||
elseif (state == nil) then
|
||||
|
||||
if is_equipped_outfit then
|
||||
outfit_animations_patches.play_animation_remove_patch(comm)
|
||||
else
|
||||
outfit_animations_patches.play_animation_remove_patch_inventory(comm)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
originalMPA(obj)
|
||||
end
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
local fov_manager = outfit_animations_fov_manager
|
||||
local mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
|
||||
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("on_option_change", on_option_change)
|
||||
end
|
||||
|
||||
|
||||
function on_option_change()
|
||||
mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
end
|
||||
------------------------------------------------------------------------------
|
||||
-- main
|
||||
------------------------------------------------------------------------------
|
||||
local anm_info = nil --it's he cuz of stalke engine magic that I don't know
|
||||
local cur_slot
|
||||
local det_active
|
||||
function play_animation_delayed(obj, is_equip, callback)
|
||||
|
||||
--prepare
|
||||
Invoke("play_backpack_animation_te0", 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
|
||||
|
||||
local anm_info = select_animation(obj, is_equip)
|
||||
local delay = 0.25
|
||||
local length = 0
|
||||
length = length + game.get_motion_length(anm_info.section_name, anm_info.anm, 1) / 1000
|
||||
Invoke("play_backpack_animation_te1", 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("play_backpack_animation_te2", delay + length + 0.25, function()
|
||||
callback() -- perform inventory ui action
|
||||
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
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function select_animation(obj, is_equip)
|
||||
--select backpack texture based on faction, like in fdda
|
||||
local faction = character_community(db.actor):sub(7)
|
||||
local m_section = is_equip and "outfit_animation_backpack_equip" or "outfit_animation_backpack_unequip"
|
||||
m_section = m_section .. "_" .. faction .. "_hud"
|
||||
local m_animation = "anm_use"
|
||||
|
||||
return {
|
||||
section_name = m_section,
|
||||
anm = m_animation,
|
||||
cam = ini_sys:r_string_ex(m_section, "cam"),
|
||||
snd = ini_sys:r_string_ex(m_section, "snd")
|
||||
}
|
||||
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 on 1.5.1 (ノへ ̄、)
|
||||
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()
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
local fov_manager = outfit_animations_fov_manager
|
||||
local mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
|
||||
local enable_animations = false
|
||||
local ruck_last_backpack = -1
|
||||
|
||||
local is_animation_playing = false
|
||||
local item_to_equip = nil
|
||||
local item_to_unequip = nil
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
function on_option_change()
|
||||
mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
end
|
||||
|
||||
|
||||
function actor_on_first_update()
|
||||
CreateTimeEvent("outfit_animations_backpack", "enable_backpack_animation_delay_te", 3, function()
|
||||
ruck_last_backpack = db.actor:item_in_slot(13) and db.actor:item_in_slot(13):id() or -1
|
||||
|
||||
enable_animations = true
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function on_item_to_ruck(obj)
|
||||
if IsItem("backpack", nil, obj) and obj:id() == ruck_last_backpack then
|
||||
ruck_last_backpack = -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
|
||||
|
||||
item_to_unequip = get_section_name("outfit_animation_backpack_unequip")
|
||||
if not is_animation_playing then
|
||||
is_animation_playing = true
|
||||
play_animation_enter()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function on_item_to_slot(obj)
|
||||
if IsItem("backpack", nil, obj) and obj:id() ~= ruck_last_backpack then
|
||||
ruck_last_backpack = 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
|
||||
|
||||
item_to_equip = get_section_name("outfit_animation_backpack_equip")
|
||||
if not is_animation_playing then
|
||||
is_animation_playing = true
|
||||
play_animation_enter()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- main
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- prepare before animation
|
||||
function play_animation_enter()
|
||||
hide_hud_inventory()
|
||||
if headgear_animations then headgear_animations.enable_animations = false end
|
||||
-- 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)
|
||||
|
||||
wait_for_free_hands(play_animation_execute)
|
||||
end
|
||||
|
||||
|
||||
function play_animation_execute()
|
||||
if mcm_allow_movement then game.only_allow_movekeys(true) else level.disable_input() end
|
||||
fov_manager.restore_fov()
|
||||
|
||||
if item_to_unequip and item_to_equip then
|
||||
swap()
|
||||
elseif item_to_unequip and not item_to_equip then
|
||||
unequip()
|
||||
elseif not item_to_unequip and item_to_equip then
|
||||
equip()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- restore after animation
|
||||
function play_animation_exit()
|
||||
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
|
||||
item_to_equip = nil
|
||||
item_to_unequip = nil
|
||||
is_animation_playing = false
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function equip()
|
||||
local anm = "anm_use"
|
||||
local cam = ini_sys:r_string_ex(item_to_equip, "cam")
|
||||
local snd = ini_sys:r_string_ex(item_to_equip, "snd")
|
||||
local length = game.get_motion_length(item_to_equip, anm, 1) / 1000
|
||||
xr_effects.play_snd(db.actor, nil, { [1] = snd })
|
||||
level.add_cam_effector(cam, 1301, false, "")
|
||||
game.play_hud_motion(2, item_to_equip, anm, false, 1)
|
||||
Invoke("restore_after_animation_te", length + 0.25, play_animation_exit)
|
||||
end
|
||||
|
||||
|
||||
function unequip()
|
||||
local anm = "anm_use"
|
||||
local cam = ini_sys:r_string_ex(item_to_unequip, "cam")
|
||||
local snd = ini_sys:r_string_ex(item_to_unequip, "snd")
|
||||
local length = game.get_motion_length(item_to_unequip, anm, 1) / 1000
|
||||
xr_effects.play_snd(db.actor, nil, { [1] = snd })
|
||||
level.add_cam_effector(cam, 1302, false, "")
|
||||
game.play_hud_motion(2, item_to_unequip, anm, false, 1)
|
||||
Invoke("restore_after_animation_te", length + 0.25, play_animation_exit)
|
||||
end
|
||||
|
||||
|
||||
function swap()
|
||||
local anm = "anm_use"
|
||||
local cam_unequip = ini_sys:r_string_ex(item_to_unequip, "cam")
|
||||
local snd_unequip = ini_sys:r_string_ex(item_to_unequip, "snd")
|
||||
local cam_equip = ini_sys:r_string_ex(item_to_equip, "cam")
|
||||
local snd_equip = ini_sys:r_string_ex(item_to_equip, "snd")
|
||||
local length_unequip = game.get_motion_length(item_to_unequip, anm, 1) / 1000
|
||||
local length_equip = game.get_motion_length(item_to_equip, anm, 1) / 1000
|
||||
|
||||
xr_effects.play_snd(db.actor, nil, { [1] = snd_unequip })
|
||||
level.add_cam_effector(cam_unequip, 1303, false, "")
|
||||
game.play_hud_motion(2, item_to_unequip, anm, false, 1)
|
||||
Invoke("play_equip_animation_after_unequip_te", length_unequip, function ()
|
||||
xr_effects.play_snd(db.actor, nil, { [1] = snd_equip })
|
||||
level.add_cam_effector(cam_equip, 1300, false, "")
|
||||
game.play_hud_motion(2, item_to_equip, anm, false, 1)
|
||||
Invoke("restore_after_animation_te", length_equip + 0.25, play_animation_exit)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- utils
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function get_section_name(section)
|
||||
local faction = character_community(db.actor):sub(7)
|
||||
return section .. "_" .. faction .. "_hud"
|
||||
end
|
||||
|
||||
|
||||
function wait_for_free_hands(action_to_perform)
|
||||
local force_timer = 0
|
||||
CreateTimeEvent("outfit_animations_backpack", "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.1, 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_backpack", name, time, function()
|
||||
action()
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
local fov_manager = outfit_animations_fov_manager
|
||||
local mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
|
||||
local
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("on_option_change", on_option_change)
|
||||
end
|
||||
|
||||
function on_option_change()
|
||||
mcm_allow_movement = outfit_animations_mcm.get_config("allow_movement")
|
||||
end
|
||||
|
||||
|
||||
function play_animation_apply_patch(faction)
|
||||
local section_name = get_animation_section_name("outfit_animation_patch_apply", faction)
|
||||
play_animation(section_name)
|
||||
end
|
||||
|
||||
function play_animation_remove_patch(faction)
|
||||
local section_name = get_animation_section_name("outfit_animation_patch_remove", faction)
|
||||
play_animation(section_name)
|
||||
end
|
||||
|
||||
function play_animation_apply_patch_inventory(faction)
|
||||
local section_name = get_animation_section_name("outfit_animation_patch_apply_inventory", faction)
|
||||
play_animation(section_name)
|
||||
end
|
||||
|
||||
function play_animation_remove_patch_inventory(faction)
|
||||
local section_name = get_animation_section_name("outfit_animation_patch_remove_inventory", faction)
|
||||
play_animation(section_name)
|
||||
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(section_name)
|
||||
--prepare
|
||||
Invoke("play_patch_animation_prepare_te", 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
|
||||
|
||||
-- anm_info = select_animation(faction, is_apply_patch, is_equipped)
|
||||
local delay = 0.25
|
||||
local length = 0
|
||||
local anm = "anm_use"
|
||||
local cam = ini_sys:r_string_ex(section_name, "cam")
|
||||
local snd = ini_sys:r_string_ex(section_name, "snd")
|
||||
length = length + game.get_motion_length(section_name, anm, 1) / 1000
|
||||
Invoke("play_patch_animation_te", delay, function()
|
||||
xr_effects.play_snd(db.actor, nil, { [1] = snd })
|
||||
level.add_cam_effector(cam, 1300, false, "")
|
||||
game.play_hud_motion(2, section_name, anm, false, 1)
|
||||
end)
|
||||
|
||||
--restore
|
||||
Invoke("play_patch_animation_restore_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
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function get_animation_section_name(section_name, faction)
|
||||
return section_name .. "_" .. faction .. "_hud"
|
||||
end
|
||||
|
||||
|
||||
function wait_for_free_hands(action_to_perform)
|
||||
local force_timer = 0
|
||||
CreateTimeEvent("outfit_animations_patch", "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_patch", name, time, function()
|
||||
action()
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
local OriginalPAD = outfit_animations.play_animation_delayed
|
||||
function outfit_animations.play_animation_delayed(obj, callback)
|
||||
local enable_animations = ui_options.get("video/player/animations")
|
||||
if not enable_animations then
|
||||
callback()
|
||||
return
|
||||
end
|
||||
|
||||
OriginalPAD(obj, callback)
|
||||
end
|
||||
|
||||
|
||||
local OriginalBPAD = backpack_animations.play_animation_delayed
|
||||
function backpack_animations.play_animation_delayed(obj, is_equip, callback)
|
||||
local enable_animations = ui_options.get("video/player/animations")
|
||||
if not enable_animations then
|
||||
callback()
|
||||
return
|
||||
end
|
||||
|
||||
OriginalBPAD(obj, is_equip, callback)
|
||||
end
|
||||
@@ -1,212 +0,0 @@
|
||||
local play_animation_delayed = outfit_animations.play_animation_delayed
|
||||
local play_backpack_animation_delayed = backpack_animations.play_animation_delayed
|
||||
|
||||
------------------------------------------------------------------
|
||||
-- ui inventory overrides
|
||||
------------------------------------------------------------------
|
||||
local snd_item_to_slot = sound_object([[interface\inv_slot]])
|
||||
local snd_item_to_belt = sound_object([[interface\inv_belt]])
|
||||
local snd_item_to_ruck = sound_object([[interface\inv_ruck]])
|
||||
local snd_drop_item = sound_object([[interface\inv_drop]])
|
||||
|
||||
local originalUIIOCCDD = ui_inventory.UIInventory.On_CC_DragDrop
|
||||
function ui_inventory.UIInventory:On_CC_DragDrop(bag_from, idx_from)
|
||||
local obj_from = self.CC[bag_from]:GetObj(idx_from)
|
||||
if (not obj_from) then return end
|
||||
if self.mode == "trade" then return end
|
||||
|
||||
if IsOutfit(obj_from) or IsBackpack(obj_from) then
|
||||
-- When interacting with item picker, get parent cell bag and index
|
||||
bag_from, idx_from = self:Picker_Ownership(bag_from, idx_from, obj_from)
|
||||
-- Throw items outside
|
||||
if self.trash:IsShown() and self.trash:IsCursorOverWindow() then
|
||||
if self:Item_On_Mode("drop", bag_from) and self:Cond_NotQuest(obj_from, bag_from) then
|
||||
self:Action_Drop(obj_from, bag_from)
|
||||
return
|
||||
end
|
||||
else
|
||||
-- Get hovered container and cell
|
||||
local bag_to, idx_to, obj_to
|
||||
for name, cc in pairs(self.CC) do
|
||||
bag_to, idx_to, obj_to = cc:GetCell_Focused()
|
||||
if bag_to then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- When interacting with item picker, get parent cell bag and index
|
||||
if obj_to then
|
||||
bag_to, idx_to = self:Picker_Ownership(bag_to, idx_to, obj_to)
|
||||
end
|
||||
|
||||
-- Ruck/Slot to Slot
|
||||
if (bag_to == "actor_equ") and (self:Cond_Equip(obj_from, bag_from) or bag_from == "actor_equ") and (not IsArtefact(obj_from)) then
|
||||
local slot = (SYS_GetParam(2, obj_from:section(), "slot") or -1) + 1
|
||||
local cslots = self.slot_cell[slot] or {}
|
||||
for i = 1, #cslots do
|
||||
if (cslots[i] == idx_to) then
|
||||
-- that code hurts my soul
|
||||
if IsOutfit(obj_from) then
|
||||
play_animation_delayed(obj_from, function()
|
||||
if obj_to then
|
||||
db.actor:move_to_ruck(obj_to)
|
||||
end
|
||||
db.actor:move_to_slot(obj_from, idx_to)
|
||||
end)
|
||||
else
|
||||
play_backpack_animation_delayed(obj_from, true, function()
|
||||
if obj_to then db.actor:move_to_ruck(obj_to) end
|
||||
db.actor:move_to_slot(obj_from, idx_to)
|
||||
end)
|
||||
end
|
||||
|
||||
self:PlaySND(snd_item_to_slot)
|
||||
self:On_Item_Update()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
originalUIIOCCDD(self, bag_from, idx_from)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local originalUIIAE = ui_inventory.UIInventory.Action_Equip
|
||||
function ui_inventory.UIInventory:Action_Equip(obj, bag)
|
||||
obj = self:CheckItem(obj, "Action_Equip")
|
||||
|
||||
if IsOutfit(obj) or IsBackpack(obj) then
|
||||
-- Gather free compatible slots
|
||||
local slot = (SYS_GetParam(2, obj:section(), "slot") or -1) + 1
|
||||
local cc = self.CC["actor_equ"]
|
||||
local free_slots = {}
|
||||
local cslots = self.slot_cell[slot] or {}
|
||||
for i = 1, #cslots do
|
||||
local ci = cc.cell[cslots[i]]
|
||||
if ci and (not ci:IsShown()) then
|
||||
table.insert(free_slots, cslots[i])
|
||||
end
|
||||
end
|
||||
|
||||
if is_empty(free_slots) then
|
||||
if IsOutfit(obj) then
|
||||
play_animation_delayed(obj, function() db.actor:make_item_active(obj) end)
|
||||
elseif IsBackpack(obj) then
|
||||
play_backpack_animation_delayed(obj, true, function() db.actor:make_item_active(obj) end)
|
||||
end
|
||||
else
|
||||
local slot_new = free_slots[1]
|
||||
local obj_in = cc:GetObj(slot_new)
|
||||
if obj_in then db.actor:move_to_ruck(obj_in) end
|
||||
|
||||
if IsOutfit(obj) then
|
||||
play_animation_delayed(obj, function() db.actor:move_to_slot(obj, slot_new) end)
|
||||
elseif IsBackpack(obj) then
|
||||
play_backpack_animation_delayed(obj, true, function() db.actor:move_to_slot(obj, slot_new) end)
|
||||
end
|
||||
end
|
||||
|
||||
self:PlaySND(snd_item_to_slot)
|
||||
self:On_Item_Update()
|
||||
return
|
||||
end
|
||||
|
||||
originalUIIAE(self, obj, bag)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local originalUIIAUE = ui_inventory.UIInventory.Action_UnEquip
|
||||
function ui_inventory.UIInventory:Action_UnEquip(obj, bag)
|
||||
obj = self:CheckItem(obj, "Action_UnEquip")
|
||||
|
||||
if IsOutfit(obj) then
|
||||
play_animation_delayed(nil, function() db.actor:move_to_ruck(obj) end)
|
||||
self:PlaySND(snd_item_to_ruck)
|
||||
self:On_Item_Update()
|
||||
return
|
||||
elseif IsBackpack(obj) then
|
||||
play_backpack_animation_delayed(nil, false, function() db.actor:move_to_ruck(obj) end)
|
||||
self:PlaySND(snd_item_to_ruck)
|
||||
self:On_Item_Update()
|
||||
return
|
||||
end
|
||||
|
||||
originalUIIAUE(self, obj, bag)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local originalUIIAD = ui_inventory.UIInventory.Action_Drop
|
||||
function ui_inventory.UIInventory:Action_Drop(obj, bag)
|
||||
if bag == "actor_equ" then
|
||||
obj = self:CheckItem(obj, "Action_Drop")
|
||||
if IsOutfit(obj) then
|
||||
play_animation_delayed(nil, function() db.actor:drop_item(obj) end)
|
||||
self:PlaySND(snd_drop_item)
|
||||
return
|
||||
elseif IsBackpack(obj) then
|
||||
play_backpack_animation_delayed(nil, false, function() db.actor:drop_item(obj) end)
|
||||
self:PlaySND(snd_drop_item)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
originalUIIAD(self, obj, bag)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local originalUIIAM = ui_inventory.UIInventory.Action_Move
|
||||
function ui_inventory.UIInventory:Action_Move(obj, bag)
|
||||
|
||||
if (self.mode == "loot") then
|
||||
if (bag == "actor_equ") then
|
||||
obj = self:CheckItem(obj, "Action_Move")
|
||||
|
||||
if IsOutfit(obj) then
|
||||
local npc = self.npc_id and get_object_by_id(self.npc_id)
|
||||
if (not npc) then
|
||||
return
|
||||
end
|
||||
|
||||
play_animation_delayed(nil, function()
|
||||
self:On_Item_Exchange(db.actor, npc, obj)
|
||||
end)
|
||||
|
||||
SendScriptCallback("ActorMenu_on_item_after_move", self.npc_id, obj, self.mode, self.bag_id[bag])
|
||||
self:On_Item_Update()
|
||||
return
|
||||
elseif IsBackpack(obj) then
|
||||
local npc = self.npc_id and get_object_by_id(self.npc_id)
|
||||
if (not npc) then
|
||||
return
|
||||
end
|
||||
|
||||
play_backpack_animation_delayed(nil, false, function()
|
||||
self:On_Item_Exchange(db.actor, npc, obj)
|
||||
end)
|
||||
|
||||
SendScriptCallback("ActorMenu_on_item_after_move", self.npc_id, obj, self.mode, self.bag_id[bag])
|
||||
self:On_Item_Update()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
originalUIIAM(self, obj, bag)
|
||||
end
|
||||
|
||||
|
||||
-------------------------
|
||||
-- utils
|
||||
-------------------------
|
||||
function IsBackpack(obj)
|
||||
if IsItem("backpack", nil, obj) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
Reference in New Issue
Block a user