Dr_Cox1911 Posted January 5, 2018 Share Posted January 5, 2018 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 More sharing options...
Fenris_Wolf Posted January 5, 2018 Share Posted January 5, 2018 Ya thats right. You could just overwrite the functions in question without overwriting the whole files, specifically ItemPicker.rollItem() and ItemPicker.rollContainerItem(). Can probably just leave everything in the Distribution.lua alone. Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted January 5, 2018 Author Share Posted January 5, 2018 How do I overwrite single functions? Only did this with whole files. Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted January 5, 2018 Share Posted January 5, 2018 https://theindiestone.com/forums/index.php?/topic/22996-resolved-change-only-1-function-from-original/ Dr_Cox1911 1 Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted January 6, 2018 Author Share Posted January 6, 2018 Thanks Fenris_Wolf! Works like a charm, only need to do some more testing, then I can release it. Fenris_Wolf 1 Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted January 6, 2018 Author Share Posted January 6, 2018 Looks like i spoke to soon, it's working in SP just fine, but with multiplayer there seems to be another function which is used to spawn the loot. Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted January 6, 2018 Share Posted January 6, 2018 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 More sharing options...
Fenris_Wolf Posted January 6, 2018 Share Posted January 6, 2018 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 More sharing options...
Dr_Cox1911 Posted January 7, 2018 Author Share Posted January 7, 2018 (edited) Thanks for testing, will have to dig some more I guess. Must be something wrong on my end then. EDIT: It works, only problem was OnGameStart, needs to be OnGameBoot for MP dedicated server. Edited January 7, 2018 by Dr_Cox1911 Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted January 7, 2018 Share Posted January 7, 2018 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 More sharing options...
FinestHops Posted January 18, 2018 Share Posted January 18, 2018 I would be interesting in testing this out on our servers as well once you finish it. We are always looking different mods to change various aspects such as loot spawn. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now