Jump to content

Better/detailed loot mod


Dr_Cox1911

Recommended Posts

I'm not really satisfied with the way the loot settings within sandbox work in multiplayer.

I would like a system where you can set the loot-chance for specific items yourself (like nails) and for all other not specific defined items of a category a global loot factor would be calculated into the dice roll.

 

My problem: I've never modded something regarding the loot.

There is a Distribution.lua within Server and the ItemPicker.lua within Server/Items is responsible for the rolling. Everything right so far?

My problem: Do I really need to overwrite one/both of them?

Or is there any other change to achieve the above without overwriting?

Link to comment
Share on other sites

I'll test after I've woken up a bit...I can't think of any other functions responsible but I haven't searched through the whole codebase.

My first thought though is if you used the OnGameStart event from the example in that other thread to inject the overrides, that not triggered server-side so wouldn't really work in mp.

Link to comment
Share on other sites

ItemPicker.rollItem does seem to work for MP fine.

Tested on a local server with the following script:

require "Items/ItemPicker"

ItemPicker.rollItem = function(containerDist, container, doItemContainer, character)
    if containerDist ~= nil and container ~= nil then
        for m = 1, containerDist.rolls do
            local item = ItemPicker.tryAddItemToContainer(container, "Base.Axe")
        end
    end
end

Which of course, filled everything with axes.

Link to comment
Share on other sites

Ya I should have used another event in that example in the other thread, but in fairness, I was still new to PZ modding when I wrote that ^_^

The use of events there isn't strictly needed, that was just to ensure some other mod that loaded after his didn't overwrite the file in question.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...