Sacco Posted September 28, 2024 Share Posted September 28, 2024 Hi, i was trying to change trees' loot table, but somehow this change sometimes crashes/corrupts the world to the point where some things just don't spawn at all. I don't know why this happens, can anybody help? THANKS! if GLOBAL.TheNet:GetIsClient() then return end local custom_loot_table = { short = { guaranteed = { }, random = { { "bee", 0.5 }, { "twigs", 0.5 }, { "log", 1 } } }, normal = { guaranteed = { "log" }, random = { { "bird_egg", 0.1 }, { "log", 1 } } }, tall = { guaranteed = { "log", "log", "log", "pinecone" }, random = { { "bird_egg", 0.5 }, { "rottenegg", 0.5 }, { "crow", 0.5 }, { "pinecone", 1 } } }, old = { guaranteed = { "twigs", "pinecone", "pinecone" }, random = { { "rottenegg", 0.1 }, { "pinecone", 1 } } }, burnt = { guaranteed = { "coal" }, random = { { "coal", 1 }, { "coal", 0.5 }, { "feather_crow", 0.5 } } }, haunted = { guaranteed = { "terrorbeak" }, random = {} } } local function SetRandomLoot(self, random) self.inst.components.lootdropper:SetLootSetupFn(function(lootdropper) for i = 1, #random do lootdropper:AddRandomLoot(random[1], random[2]) end lootdropper.numrandomloot = 1 end) end local SetLootOld local function SetLoot(self, loots) local names = { "short", "normal", "tall", "old" } local random = {} if (self.inst:HasTag("burnt")) then random = custom_loot_table["burnt"].random loots = custom_loot_table["burnt"].guaranteed elseif (self.inst:HasTag("haunted")) then random = custom_loot_table["haunted"].random loots = custom_loot_table["haunted"].guaranteed else random = custom_loot_table[names[self.inst.components.growable.stage]].random loots = custom_loot_table[names[self.inst.components.growable.stage]].guaranteed end SetRandomLoot(self, random) SetLootOld(self, loots) end AddPrefabPostInit("evergreen", function(inst) if not GLOBAL.TheWorld.ismastersim then return end SetLootOld = inst.components.lootdropper.SetLoot inst.components.lootdropper.SetLoot = SetLoot end) Link to comment https://forums.kleientertainment.com/forums/topic/159990-weird-world-corruptions-with-tree-loot-table-changes/ 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