Add quickloot

This commit is contained in:
2025-03-31 00:36:27 +02:00
parent 4150516dc6
commit 0e35890f41
3 changed files with 49 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ MyModGlobal = {
UNLOAD = Keys.E, UNLOAD = Keys.E,
RELOAD = Keys.R, RELOAD = Keys.R,
STACK_TO_CURSOR = Keys.G, STACK_TO_CURSOR = Keys.G,
LOOT = Keys.L,
NESTED_CONTAINERS = true, NESTED_CONTAINERS = true,
DEBUG_MODE = true, DEBUG_MODE = true,
}, },
@@ -61,6 +62,7 @@ local hotkeyrepair = require("Cyka.hotkeyrepair")
local cursormacroer = require("Cyka.cursormacroer") local cursormacroer = require("Cyka.cursormacroer")
local quickunload = require("Cyka.quickunload") local quickunload = require("Cyka.quickunload")
local quickreload= require("Cyka.quickreload") local quickreload= require("Cyka.quickreload")
local quickloot = require("Cyka.quickloot")
require("Cyka.xpticker") require("Cyka.xpticker")
require("Cyka.zoom") require("Cyka.zoom")
@@ -137,3 +139,8 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.RELOAD) then return end if not PlayerInput.KeyHit(MyModGlobal.CONFIG.RELOAD) then return end
quickreload.tryReloadCursorItem(PlayerInput.IsShiftDown()) quickreload.tryReloadCursorItem(PlayerInput.IsShiftDown())
end, Hook.HookMethodType.After) end, Hook.HookMethodType.After)
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.LOOT) then return end
quickloot.tryLoot()
end, Hook.HookMethodType.After)

View File

@@ -0,0 +1,41 @@
-- luacheck: globals Character MyModGlobal
local dump = require("Cyka.dump")
local utils = require("Cyka.utils")
local quickstack = require("Cyka.quickstack")
local function tryLoot()
MyModGlobal.debugPrint("Trying to loot dead creatures")
local character = Character.Controlled
if not character then
MyModGlobal.debugPrint("No character found")
return
end
local itemTree, err = quickstack.tryBuildCharacterItemTree(character)
if err then
MyModGlobal.debugPrint(string.format("Failed to build item tree: %s", err))
return
end
local items = {}
for _, itcharacter in pairs(Character.CharacterList) do
if itcharacter.IsDead and itcharacter.Inventory then
MyModGlobal.debugPrint(string.format("Enqueuing inventory for %s", itcharacter.Name))
local before = #items
utils.enqueueInventory(itcharacter.Inventory, items)
MyModGlobal.debugPrint(string.format("Enqueued %d items for %s", #items - before, itcharacter.Name))
end
end
local errors = quickstack.tryMoveItems(items, itemTree, true)
if #errors > 0 then
MyModGlobal.debugPrint(string.format("Failed to move %d items", #errors))
for _, err in pairs(errors) do
MyModGlobal.debugPrint(err)
end
end
end
return {
tryLoot = tryLoot,
}

View File

@@ -79,7 +79,7 @@ Hook.HookMethod("Barotrauma.Character", "ControlLocalPlayer", function(_, ptable
gzsUpd = true gzsUpd = true
end end
end end
if PlayerInput.KeyDown(zKey) then if PlayerInput.KeyDown(zKey) or PlayerInput.Mouse5ButtonClicked() then
if isToggle then if isToggle then
if not zHeld then if not zHeld then
zoomOn = not zoomOn zoomOn = not zoomOn