breezeblocks Posted April 2, 2022 Share Posted April 2, 2022 I'm creating a custom character who has unique crafting recipes that use diamonds. Is it possible to add a low-chance diamond drop to boulders that already exist in a game? Moon rocks, to be more specific. I wasn't able to find a single tutorial on that matter. Long story short, i want moon rocks to drop my custom gem. Is that possible to implement? Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/ Share on other sites More sharing options...
Bumber64 Posted April 2, 2022 Share Posted April 2, 2022 (edited) local LT = GLOBAL.LootTables AddPrefabPostInit("rock_moon", function(inst) table.insert(LT["rock_moon"], {"diamond", 0.5}) end) AddPrefabPostInit("rock_moon_shell", function(inst) table.insert(LT["rock_moon_shell"], {"diamond", 0.5}) end) Where "diamond" is your diamond prefab and 0.5 is 50% drop chance. Edited April 2, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1554660 Share on other sites More sharing options...
breezeblocks Posted April 2, 2022 Author Share Posted April 2, 2022 58 minutes ago, Bumber64 said: local LT = GLOBAL.LootTables AddPrefabPostInit("rock_moon", function(inst) table.insert(LT["rock_moon"], {"diamond", 0.5}) end) AddPrefabPostInit("rock_moon_shell", function(inst) table.insert(LT["rock_moon_shell"], {"diamond", 0.5}) end) Where "diamond" is your diamond prefab and 0.5 is 50% drop chance. Oh, it's actually not that complicated. Thank you so much, i think i'll be able to figure out the rest! Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1554669 Share on other sites More sharing options...
ScrewdriverLad Posted April 11, 2022 Share Posted April 11, 2022 On 4/2/2022 at 12:44 AM, Bumber64 said: local LT = GLOBAL.LootTables AddPrefabPostInit("rock_moon", function(inst) table.insert(LT["rock_moon"], {"diamond", 0.5}) end) AddPrefabPostInit("rock_moon_shell", function(inst) table.insert(LT["rock_moon_shell"], {"diamond", 0.5}) end) Where "diamond" is your diamond prefab and 0.5 is 50% drop chance. I'm working on adding coffee to my mod, and while I figure out how to add new bushes, could I recycle this for berry bushes & coffee? So I would replace rock_moon with the berry bush prefab, and diamond with the Coffee Bean prefab? Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1556944 Share on other sites More sharing options...
Bumber64 Posted April 12, 2022 Share Posted April 12, 2022 19 hours ago, ScrewdriverLad said: I'm working on adding coffee to my mod, and while I figure out how to add new bushes, could I recycle this for berry bushes & coffee? So I would replace rock_moon with the berry bush prefab, and diamond with the Coffee Bean prefab? Sure. Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1557180 Share on other sites More sharing options...
ScrewdriverLad Posted May 4, 2022 Share Posted May 4, 2022 On 4/12/2022 at 12:57 PM, Bumber64 said: Sure. And how would I then publish the mod? would I include the Berry bush prefab in the mod's folder, or should I do something else? Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1566813 Share on other sites More sharing options...
Bumber64 Posted May 4, 2022 Share Posted May 4, 2022 (edited) 16 hours ago, ScrewdriverLad said: And how would I then publish the mod? would I include the Berry bush prefab in the mod's folder, or should I do something else? If you're reusing Klei's berry bush, you don't need to include the prefab. However, there's some additional work to be done since berry bushes use the "pickable" component instead of a loot table. Something like this should work: AddPrefabPostInit("berrybush", function(inst) inst.components.pickable.use_lootdropper_for_product = true inst.components.lootdropper:SetLoot({"berries"}) inst.components.lootdropper:AddChanceLoot("coffee_bean", 0.5) end) AddPrefabPostInit("berrybush2", function(inst) inst.components.pickable.use_lootdropper_for_product = true inst.components.lootdropper:SetLoot({"berries"}) inst.components.lootdropper:AddChanceLoot("coffee_bean", 0.5) end) AddPrefabPostInit("berrybush_juicy", function(inst) inst.components.pickable.use_lootdropper_for_product = true inst.components.lootdropper:SetLoot({"berries_juicy", "berries_juicy", "berries_juicy"}) inst.components.lootdropper:AddChanceLoot("coffee_bean", 0.5) end) This will drop the standard berries for each berry bush, as well as add a 50% chance to drop a "coffee_bean". There's more that could be done to protect loot added by other mods, but this is fine for a temporary solution. Edited May 4, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1567226 Share on other sites More sharing options...
ScrewdriverLad Posted May 16, 2022 Share Posted May 16, 2022 thank you so much! where exactly would I put this, though? Would it go into modmain.lua, or would it go somewhere else? Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1570737 Share on other sites More sharing options...
Bumber64 Posted May 16, 2022 Share Posted May 16, 2022 11 hours ago, ScrewdriverLad said: thank you so much! where exactly would I put this, though? Would it go into modmain.lua, or would it go somewhere else? Yes, modmain. Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1570829 Share on other sites More sharing options...
ScrewdriverLad Posted May 21, 2022 Share Posted May 21, 2022 On 5/16/2022 at 8:44 AM, Bumber64 said: Yes, modmain. Thanks!! Link to comment https://forums.kleientertainment.com/forums/topic/138808-is-it-possible-to-create-a-custom-drop-from-an-already-existing-structure/#findComment-1572155 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