Jump to content

Help needed with overriding specific loot containers.


NightScale5755

Recommended Posts

Hi there. I'm a beginner modder with a question: 
How does one override loot in a specific container at a specific location? I took a look at 

 and well, my zone was registered. Though the containers in question keep using the vanilla loot table. 
Here's my code:

Distributions.lua:
 

Distributions = Distributions or {};

local STPOdistributionTable = {

    policestoragerw = {
        lockerrw = {
            procedural = true,
            procList = {
                {name="StorageOutfitRosewoodSD", min=10, max=99, forceForZones="RosewoodSDL"},
            },
            dontSpawnAmmo = true,
        }
    },
}

table.insert(Distributions, 2, STPOdistributionTable);


PoceduralDistributions.lua:
 

local function preDistributionMerge()
    ProceduralDistributions.list.StorageOutfitRosewoodSD = {
        rolls = 4,
        items = {
            "Bag_DuffelBagTINT", 0.5,
            "Bag_FannyPackFront", 0.8,
            "Bag_Satchel", 0.2,
            "Belt2", 2,
            "Briefcase", 0.2,
            "Disc_Retail", 2,
            "Earbuds", 1,
            "Glasses_Aviators", 1,
            "Hat_CrashHelmet_Police", 1,
            "Hat_EarMuff_Protectors", 1,
            "Headphones", 1,
            "HolsterDouble", 0.5,
            "HolsterSimple", 2,
            "Lunchbox", 1,
            "Lunchbox2", 1,
            "Nightstick", 2,
            "Radio.CDplayer", 2,
            "Radio.WalkieTalkie4", 1,
            "Shoes_Black", 8,
            "Shoes_Brown", 8,
            "Suitcase", 0.2,
            "STPO.Hat_Police_Rosewood", 4,
            "STPO.Jacket_Police_Rosewood", 4,
            "STPO.Shirt_Police_Rosewood", 10,
            "STPO.TShirt_Police_Rosewood", 10,
            "STPO.Trousers_Police_Rosewood", 8,
            "Vest_BulletPolice", 1,
        },
        junk = {
            rolls = 1,
            items = {
            
            }
        }
    }

end
Events.OnPreDistributionMerge.Add(preDistributionMerge);

 

Again, I'm a tad new to the modding scene. The most advanced I've been able to get working has been custom zombie zones. 0 XP with lua before I started modding PZ.

And to recap: I want to override a vanilla police locker room's loot. I'd be ok with vanilla stuff spawning there, I just need my custom items to be area-specific.

 

Thanks for reading, and any help would be greatly appreciated.

 

 

 

Here's the best answer:

  

44 minutes ago, RingoD123 said:

Just checked the building in question, the room that uses the "policestorage" roomdef is 2-3 rooms to the right with multiple types of lockers in them, the room you are in has the roomdef "locker" which does not exist as a roomdef currently in the distributions.lua file so it will pull its loot from the locker definition within the "all" room definition.

 

So in short, if you check the room a few rooms to the right you should be seeing your loot in those lockers, if you want them in the lockers in the room in the pic then create a distribution entry for a "locker" roomdef that points to your proceduraldistribution definition.

 

Edited by NightScale5755
quoting the Answer x2
Link to comment
Share on other sites

On 12/11/2021 at 10:16 PM, NightScale5755 said:

Hi there. I'm a beginner modder with a question: 
How does one override loot in a specific container at a specific location? I took a look at 

 and well, my zone was registered. Though the containers in question keep using the vanilla loot table. 
Here's my code:

Distributions.lua:
 

Distributions = Distributions or {};

local STPOdistributionTable = {

    policestoragerw = {
        lockerrw = {
            procedural = true,
            procList = {
                {name="StorageOutfitRosewoodSD", min=10, max=99, forceForZones="RosewoodSDL"},
            },
            dontSpawnAmmo = true,
        }
    },
}

table.insert(Distributions, 2, STPOdistributionTable);


PoceduralDistributions.lua:
 

local function preDistributionMerge()
    ProceduralDistributions.list.StorageOutfitRosewoodSD = {
        rolls = 4,
        items = {
            "Bag_DuffelBagTINT", 0.5,
            "Bag_FannyPackFront", 0.8,
            "Bag_Satchel", 0.2,
            "Belt2", 2,
            "Briefcase", 0.2,
            "Disc_Retail", 2,
            "Earbuds", 1,
            "Glasses_Aviators", 1,
            "Hat_CrashHelmet_Police", 1,
            "Hat_EarMuff_Protectors", 1,
            "Headphones", 1,
            "HolsterDouble", 0.5,
            "HolsterSimple", 2,
            "Lunchbox", 1,
            "Lunchbox2", 1,
            "Nightstick", 2,
            "Radio.CDplayer", 2,
            "Radio.WalkieTalkie4", 1,
            "Shoes_Black", 8,
            "Shoes_Brown", 8,
            "Suitcase", 0.2,
            "STPO.Hat_Police_Rosewood", 4,
            "STPO.Jacket_Police_Rosewood", 4,
            "STPO.Shirt_Police_Rosewood", 10,
            "STPO.TShirt_Police_Rosewood", 10,
            "STPO.Trousers_Police_Rosewood", 8,
            "Vest_BulletPolice", 1,
        },
        junk = {
            rolls = 1,
            items = {
            
            }
        }
    }

end
Events.OnPreDistributionMerge.Add(preDistributionMerge);

 

Again, I'm a tad new to the modding scene. The most advanced I've been able to get working has been custom zombie zones. 0 XP with lua before I started modding PZ.

And to recap: I want to override a vanilla police locker room's loot. I'd be ok with vanilla stuff spawning there, I just need my custom items to be area-specific.

 

Thanks for reading, and any help would be greatly appreciated.

 

If you are trying to overwrite the loot in a vanilla location then you will be unable to set a custom zone as this needs done in worldEd before the map is exported.

Your best bet would be to recreate the cell or add a new cell, and then add your new custom zone over the area you want to contain your new loot. Your above code should then work.

Link to comment
Share on other sites

Oh? So using the new-ish objects.lua feature in the maps/MODNAME folder won't work? During my tests, when using Debug mode's ChunkDebugger, I found the zone was registered, albeit at the bottom of the list?
Either way, How would I recreate this cell? You got any tutorials???

Thanks for the info.

Link to comment
Share on other sites

16 minutes ago, NightScale5755 said:

Oh? So using the new-ish objects.lua feature in the maps/MODNAME folder won't work? During my tests, when using Debug mode's ChunkDebugger, I found the zone was registered, albeit at the bottom of the list?
Either way, How would I recreate this cell? You got any tutorials???

Thanks for the info.

At the moment the best way to recreate a vanilla cell is to use this guide:

 

along with the online map to use as a reference:

https://map.projectzomboid.com/

 

Although you might find it easier to choose a cell around the town that has less buildings etc that need recreated.

Link to comment
Share on other sites

Mmm. Seems like an excessive amount of work to overwrite one container...
You sure I can't just define the loot zone with Maps/MODNAME/objects.lua? There's got to be an easier way...... Well, thanks for the info, guess I'll stick with the items in question spawning in vanilla loot zones. 
Sorry to have been a bother.

Link to comment
Share on other sites

41 minutes ago, NightScale5755 said:

Mmm. Seems like an excessive amount of work to overwrite one container...
You sure I can't just define the loot zone with Maps/MODNAME/objects.lua? There's got to be an easier way...... Well, thanks for the info, guess I'll stick with the items in question spawning in vanilla loot zones. 
Sorry to have been a bother.

Try with this in your distributions.lua instead:

 

Distributions = Distributions or {};

local STPOdistributionTable = {

    policestorage = {
        locker = {
            procedural = true,
            procList = {
                {name="PoliceStorageGuns", min=0, max=99, forceForTiles="furniture_storage_02_8;furniture_storage_02_9;furniture_storage_02_10;furniture_storage_02_11"},
                {name="PoliceStorageOutfit", min=0, max=99, forceForTiles="furniture_storage_02_4;furniture_storage_02_5;furniture_storage_02_6;furniture_storage_02_7"},
        {name="StorageOutfitRosewoodSD", min=10, max=99, forceForZones="RosewoodSDL"},
            },
            dontSpawnAmmo = true,
        },
        metal_shelves = {
            procedural = true,
            procList = {
                {name="PoliceStorageGuns", min=0, max=99, weightChance=100},
            },
            dontSpawnAmmo = true,
        }
    },
}

table.insert(Distributions, 2, STPOdistributionTable);

 

 

If your zone is being added to the vanilla world then the above code should work for you, all it is doing is adding your custom procedural definition into the existing roomdef (policestorage) and tiledef (locker) and stating it will only work inside a zone named RosewoodSDL so should only take effect where your zone is placed. In your original example you were using a custom roomdef (policestoragerw) and a custom tiledef (lockerrw) which wont work unless you have created a building with that roomdef and placed it on the map and added a new tile with that name.

Link to comment
Share on other sites

42 minutes ago, RingoD123 said:

Try with this in your distributions.lua instead:

 

Distributions = Distributions or {};

local STPOdistributionTable = {

    policestorage = {
        locker = {
            procedural = true,
            procList = {
                {name="PoliceStorageGuns", min=0, max=99, forceForTiles="furniture_storage_02_8;furniture_storage_02_9;furniture_storage_02_10;furniture_storage_02_11"},
                {name="PoliceStorageOutfit", min=0, max=99, forceForTiles="furniture_storage_02_4;furniture_storage_02_5;furniture_storage_02_6;furniture_storage_02_7"},
        {name="StorageOutfitRosewoodSD", min=10, max=99, forceForZones="RosewoodSDL"},
            },
            dontSpawnAmmo = true,
        },
        metal_shelves = {
            procedural = true,
            procList = {
                {name="PoliceStorageGuns", min=0, max=99, weightChance=100},
            },
            dontSpawnAmmo = true,
        }
    },
}

table.insert(Distributions, 2, STPOdistributionTable);

 

 

If your zone is being added to the vanilla world then the above code should work for you, all it is doing is adding your custom procedural definition into the existing roomdef (policestorage) and tiledef (locker) and stating it will only work inside a zone named RosewoodSDL so should only take effect where your zone is placed. In your original example you were using a custom roomdef (policestoragerw) and a custom tiledef (lockerrw) which wont work unless you have created a building with that roomdef and placed it on the map and added a new tile with that name.

Oh??? I'll do some tests right now. Thanks man.


EDIT: Does this zone in question need to be a LootZone??? It keeps using the vanilla loot tables?
 

20211213142216_1.jpg

Edited by NightScale5755
Avoiding multi-posts
Link to comment
Share on other sites

Just checked the building in question, the room that uses the "policestorage" roomdef is 2-3 rooms to the right with multiple types of lockers in them, the room you are in has the roomdef "locker" which does not exist as a roomdef currently in the distributions.lua file so it will pull its loot from the locker definition within the "all" room definition.

 

So in short, if you check the room a few rooms to the right you should be seeing your loot in those lockers, if you want them in the lockers in the room in the pic then create a distribution entry for a "locker" roomdef that points to your proceduraldistribution definition.

Link to comment
Share on other sites

42 minutes ago, RingoD123 said:

Just checked the building in question, the room that uses the "policestorage" roomdef is 2-3 rooms to the right with multiple types of lockers in them, the room you are in has the roomdef "locker" which does not exist as a roomdef currently in the distributions.lua file so it will pull its loot from the locker definition within the "all" room definition.

 

So in short, if you check the room a few rooms to the right you should be seeing your loot in those lockers, if you want them in the lockers in the room in the pic then create a distribution entry for a "locker" roomdef that points to your proceduraldistribution definition.

Ahhhh. So I just confirmed the bit about the armory, my loot's spawning in there. I do want it to spawn in the locker rooms though. So I'll fart with it more, and I'll get back to you if I make it work or not. Thanks so much, my guy!

Edit: Huzzah!!! I figured it out!! Thank you so much!!! I'll make sure to credit you in the mod description.

Edited by NightScale5755
Avoiding multi-posts
Link to comment
Share on other sites

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...