with permission from Harfatus:
The following code provides for fully-automated item carry stacking. You are free to redistribute it elsewhere providing credit for this code is stated in bold, on the first line of the post with at least equal font size to the rest of the post.
I recommend binding it to a key that you can access easily as it also acts as a push/pop key. Namely, if you are currently carrying something, it will push it to the stack, if you aren't carrying anything, it will pop whatever is pushed.
You do not need to push every time you pick something up, you are completely free to keep picking stuff up and whatever you are already carrying is pushed to the stack, same applies when dropping items, you can just spam G and watch the bags fly.
Along with this release goes a request to the Overkill devs who no doubt peruse this forum
OVERKILL folks: I understand the modding is getting out of hand, but there are those of us who use the ability to inject lua to improve our own personal game experience without impacting others. I welcome you implementing something to disallow unfettered hacks, but please at least provide an option to host a server that does permit mods so those of us who want to use them can, and those who wish to avoid it may choose to do so.
Code:
if not CarryStackerSetupDone then
CarryStackerSetupDone = true
managers.player.carry_stack = {}
ofuncs = {
managers_player_set_carry = managers.player.set_carry,
managers_player_drop_carry = managers.player.drop_carry,
IntimitateInteractionExt__interact_blocked = IntimitateInteractionExt._interact_blocked,
}
-- pops an item from the stack when the player drops their carried item
function managers.player:drop_carry()
ofuncs.managers_player_drop_carry(self)
if #self.carry_stack > 0 then
local cdata = table.remove(self.carry_stack)
if cdata then
self:set_carry(cdata.carry_id, cdata.value or 100, cdata.dye_initiated, cdata.has_dye_pack, cdata.dye_value_multiplier)
end
end
end
-- saves the current item to the stack if we're already carrying something
function managers.player:set_carry( carry_id, carry_value, dye_initiated, has_dye_pack, dye_value_multiplier )
if self:is_carrying() and self:get_my_carry_data() then
table.insert(self.carry_stack, self:get_my_carry_data())
end
return ofuncs.managers_player_set_carry(self, carry_id, carry_value, dye_initiated, has_dye_pack, dye_value_multiplier)
end
-- new function to discard the currently carried item
function managers.player:carry_discard()
managers.hud:remove_teammate_carry_info( HUDManager.PLAYER_PANEL )
managers.hud:temp_hide_carry_bag()
self:update_removed_synced_carry_to_peers()
if self._current_state == "carry" then
managers.player:set_player_state( "standard" )
end
end
-- overridden to prevent blocking us from picking up a dead body
function IntimitateInteractionExt:_interact_blocked( player )
if self.tweak_data == "corpse_dispose" then
if not managers.player:has_category_upgrade( "player", "corpse_dispose" ) then
return true
end
return not managers.player:can_carry( "person" )
end
return ofuncs.IntimitateInteractionExt__interact_blocked(self, player)
end
-- overridden to always allow us to pick up a carry item
function CarryInteractionExt:_interact_blocked( player )
return not managers.player:can_carry( self._unit:carry_data():carry_id() )
end
-- overridden to always allow us to select a carry item
function CarryInteractionExt:can_select( player )
return CarryInteractionExt.super.can_select( self, player )
end
-- custom function. Pushes a carried item to stack and discards it or pops one if we're not carrying anything.
-- this function is called every time the script gets run.
function managers.player:carry_stacker()
local cdata = self:get_my_carry_data()
if self:is_carrying() and cdata then
table.insert(self.carry_stack, self:get_my_carry_data())
self:carry_discard()
managers.hud:present_mid_text( { title = "Carry Stack", text = cdata.carry_id .. " Pushed", time = 1 } )
elseif #self.carry_stack > 0 then
cdata = table.remove(self.carry_stack)
self:set_carry(cdata.carry_id, cdata.value, cdata.dye_initiated, cdata.has_dye_pack, cdata.dye_value_multiplier)
managers.hud:present_mid_text( { title = "Carry Stack", text = cdata.carry_id .. " Popped", time = 1 } )
else
managers.hud:present_mid_text( { title = "Carry Stack", text = "Empty", time = 1 } )
end
end
end
managers.player:carry_stacker()
Oh and a small mention... if you disconnect from a game, your stacked items are of course lost forever.
Last, but certainly not least, A massive thank you to @v00d00 for his fantastic work in keeping the Lua source updated - so much of the inventive code on here would not exist were it not for his efforts