JadeKnightblazer Posted May 17, 2022 Share Posted May 17, 2022 Looking for a way to adjust a custom item, when murdered, dropping a custom loot table. Seems the game auto injects recipe materials (50%) then allows you to add extra loot when adjusting inst.components.lootdropper:SetLoot({}) Any ideas? My recipe for said item: local visceralharvesterr1dormatrecipe = AddRecipe( "visceralharvesterr1dormat", {Ingredient("nightsword", 1),Ingredient("deerclops_eyeball", 1),Ingredient("reviver", 1),Ingredient("boneshard", 12)}, RECIPETABS.MAGIC, TECH.MAGIC_THREE, nil,nil, nil, 1, nil, "images/inventoryimages/visceralharvesterr1dormat.xml", "visceralharvesterr1dormat.tex" ) What I want to drop when item is murdered: {"deerclops_eyeball", "boneshard"} what on murder gives me: {"deerclops_eyeball" x 2, "boneshard" x 7, "reviver" x 1 } I don't see any functions to remove items from the loot pool Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted May 18, 2022 Author Share Posted May 18, 2022 At this point... would it be better to make an "On Use" function, destroy the item and reward the player with loots? Link to comment Share on other sites More sharing options...
zaptrap Posted May 19, 2022 Share Posted May 19, 2022 I think you might be able to replace the lootdropper.GetRecipeLoot function with function() return {} end (a function that returns an empty table), I haven't tested this yet so hopefully this helps Link to comment Share on other sites More sharing options...
Ziro2k Posted May 21, 2022 Share Posted May 21, 2022 @JadeKnightblazer So what's happening is that when LootDropper:GenerateLoot() is called, it automatically checks the AllRecipes table for the prefab and gets loot based off of the recipe ingredients: local recipe = AllRecipes[self.inst.prefab] if recipe then local recipeloot = self:GetRecipeLoot(recipe) for k,v in ipairs(recipeloot) do table.insert(loots, v) end end Avoiding this is actually rather simple. LootDropper looks up the recipe based on the item's prefab, but the name of the crafting recipe doesn't actually have to be the prefab name. When you declare your recipes, you can give it a custom name and then set the product to your prefab. That way, the recipe key isn't the prefab itself and thus LootDropper won't return a valid recipe with the above code. So something like this: local visceralharvesterr1dormatrecipe = AddRecipe( "visceralharvesterr1dormat_builder", --custom recipe name {Ingredient("nightsword", 1),Ingredient("deerclops_eyeball", 1),Ingredient("reviver", 1),Ingredient("boneshard", 12)}, RECIPETABS.MAGIC, TECH.MAGIC_THREE, nil,nil, nil, 1, nil, "images/inventoryimages/visceralharvesterr1dormat.xml", "visceralharvesterr1dormat.tex", nil, "visceralharvesterr1dormat" --product prefab name ) Also as a side note, you should really try to use AddRecipe2 now after the crafting UI update because AddRecipe has been deprecated. It's actually a lot easier to read because you don't have to worry about all of those ridiculous nils (all of those options are passed in a config table where the keys are the option names): local visceralharvesterr1dormatrecipe = AddRecipe2("visceralharvesterr1dormat_builder", {Ingredient("nightsword", 1), Ingredient("deerclops_eyeball", 1), Ingredient("reviver", 1), Ingredient("boneshard", 12)}, TECH.MAGIC_THREE, { atlas = "images/inventoryimages/visceralharvesterr1dormat.xml", image = "visceralharvesterr1dormat.tex" product = "visceralharvesterr1dormat" }, {"MAGIC"}) 1 Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted May 21, 2022 Author Share Posted May 21, 2022 TY very much for this info. 100% switching to AddRecipe2. I kinda glad up on /murder and instead made it so dragging the Razor over kills off the item. /Salute Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted May 22, 2022 Author Share Posted May 22, 2022 (edited) Oddly enough when trying Add recipe2 I get time seg errors. However thank you for posting some interesting information. Got it to work after a bit of editing. local visceralharvesterr1dormatrecipe = AddRecipe2("visceralharvesterr1dormat", {Ingredient("nightsword", 1),Ingredient("deerclops_eyeball", 1),Ingredient("reviver", 1),Ingredient("boneshard", 12)}, TECH.MAGIC_THREE, {numtogive = 1, atlas = "images/inventoryimages/visceralharvesterr1dormat.xml", image = "visceralharvesterr1dormat.tex" }, {"MAGIC"}) Even tho I didn't add the _Builder, I do understand it. Edited May 22, 2022 by JadeKnightblazer 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