131 lines
4.1 KiB
Plaintext
131 lines
4.1 KiB
Plaintext
--TODO:
|
|
-- -make fix for people who don't use "crouch toggle" control option
|
|
-- -add mcm options for crouch, weapon lower
|
|
|
|
-- local is_crouch_togglable = false
|
|
is_looting = false
|
|
local is_crouching = false
|
|
local is_weapon_lowered = false
|
|
local is_shift_pressed = false
|
|
|
|
local originalUIS = ui_inventory.start
|
|
ui_inventory.start = function(mode, obj)
|
|
if mode == "loot" and not is_shift_pressed then
|
|
local search_hand = pick_hand()
|
|
|
|
--if both hands occupied don't do anything
|
|
if search_hand == 3 then return end
|
|
|
|
-- printf("#liz. body search start called")
|
|
|
|
--if not stalker open as usual
|
|
if not IsStalker(obj) then
|
|
originalUIS(mode, obj)
|
|
return
|
|
end
|
|
|
|
--if is companion open as usual
|
|
local is_companion = obj and IsStalker(obj) and obj:alive() and obj:has_info("npcx_is_companion") and true or false
|
|
if is_companion then
|
|
originalUIS(mode, obj)
|
|
return
|
|
end
|
|
|
|
--crouch
|
|
-- local is_crouch_togglable = get_console_cmd(1, "g_crouch_toggle")
|
|
-- get_console():execute("g_crouch_toggle 1")
|
|
if is_looting then return end
|
|
is_looting = true
|
|
is_crouching = IsMoveState('mcCrouch')
|
|
if not is_crouching then
|
|
level.press_action(bind_to_dik(key_bindings.kCROUCH))
|
|
level.release_action(bind_to_dik(key_bindings.kCROUCH))
|
|
end
|
|
|
|
--look at body
|
|
local pm = obj:bone_position('bip01_spine1')
|
|
pm.y = pm.y + 0.3
|
|
db.actor:actor_look_at_point(pm)
|
|
|
|
--lower weapon. wonder if it will look more natural
|
|
is_weapon_lowered = game.actor_weapon_lowered()
|
|
if not is_weapon_lowered then game.actor_lower_weapon(true) end
|
|
|
|
--play start search animation (1 or 2 handed)
|
|
local length = game.get_motion_length("liz_body_search_animation", "anm_start", 1) / 1000
|
|
game.play_hud_motion(search_hand, "liz_body_search_animation", "anm_start", true, 1)
|
|
|
|
CreateTimeEvent("liz_body_search_animation", "start_looting_anm_delay", length, function()
|
|
--then play search idle animation (1 or 2 handed)
|
|
game.play_hud_motion(search_hand, "liz_body_search_animation", "anm_idle", true, 1)
|
|
return true
|
|
end)
|
|
|
|
CreateTimeEvent("liz_body_search_animation", "start_looting_delay", length + 0.42, function()
|
|
--and open inventory ui
|
|
originalUIS(mode, obj)
|
|
RegisterScriptCallback("GUI_on_hide", stop_search)
|
|
return true
|
|
end)
|
|
else
|
|
originalUIS(mode, obj)
|
|
end
|
|
end
|
|
|
|
|
|
function stop_search()
|
|
is_looting = false
|
|
--if wans't crouched stand up
|
|
if not is_crouching then
|
|
level.press_action(bind_to_dik(key_bindings.kCROUCH))
|
|
level.release_action(bind_to_dik(key_bindings.kCROUCH))
|
|
end
|
|
|
|
--stop looking at the body
|
|
if db.actor.actor_stop_look_at_point then db.actor:actor_stop_look_at_point() end --took from dynamic dialog ui
|
|
|
|
--rise weapon
|
|
if not is_weapon_lowered then game.actor_lower_weapon(false) end
|
|
|
|
--pla stop aniamtion
|
|
local search_hand = pick_hand()
|
|
game.stop_hud_motion()
|
|
game.play_hud_motion(search_hand, "liz_body_search_animation", "anm_end", true, 1)
|
|
|
|
--play stop search animation (maybe possible pick up animation?)
|
|
UnregisterScriptCallback("GUI_on_hide", stop_search)
|
|
end
|
|
|
|
|
|
function pick_hand()
|
|
wpn = db.actor:active_item()
|
|
detector = db.actor:active_detector()
|
|
|
|
if wpn and detector then
|
|
return 3
|
|
elseif wpn and not detector then
|
|
return 1
|
|
elseif detector and not wpn then
|
|
return 0
|
|
else
|
|
return 2
|
|
end
|
|
end
|
|
|
|
|
|
function on_key_press(key)
|
|
if (key == DIK_keys.DIK_LSHIFT) or (key == DIK_keys.DIK_RSHIFT) then
|
|
is_shift_pressed = true
|
|
end
|
|
end
|
|
|
|
function on_key_release(key)
|
|
if (key == DIK_keys.DIK_LSHIFT) or (key == DIK_keys.DIK_RSHIFT) then
|
|
is_shift_pressed = false
|
|
end
|
|
end
|
|
|
|
function on_game_start()
|
|
RegisterScriptCallback("on_key_press", on_key_press)
|
|
RegisterScriptCallback("on_key_release", on_key_release)
|
|
end |