How to create random item chest

1) To create a random Item Chest you will need to write costume code. Feel free to use the "ItemInfoProbabilityTable" class which is very easy to use. Once set up it can give you a list of random amounts of items. You feed it a list of itemAmounts where the higher the amount the higher the probabilty of getting that item is. Check the "RandomItemDropper" class to see an example of setting up the "ItemInfoProbabilityTable".

Once you have a list of random items you may create your custom chest around it. It's up to you to decide how your chest work. Do not feel constrained to use our "Chest" class, you can create one from scratch to better suit your needs.

2)Unfortunatly the crafting system does not send an event when an item was crafted yet. I just took the time to add that event now but since we are not planning to make an update very soon I'll send you the the file I changed, you must follow the instructions below to make sure it compiles and works.

First in the EventNames.cs file add those two event names:

Code:
//This event is executed when a item is crafted.
public const string c_InventoryGameObject_OnCraft_CraftingRecipe_CraftingResult = "InventoryGameObject_OnCraft_CraftingRecipe_CraftingResult";
//This events executes when a CanCraft call is executed.
public const string c_InventoryGameObject_OnCanCraft_CraftingRecipe_Bool = "InventoryGameObject_OnCanCraft_CraftingRecipe_Bool";

Then download the file attached and replace the CraftingProcessor.cs file


You should then be able to listen to the "c_InventoryGameObject_OnCraft_CraftingRecipe_CraftingResult" event to know if the crafting succeeded or not. The CraftingResult gives you a boolean "success" to know whether or not you succeeded to craft the item.

Read this page if you are unfamiliar with our event system: https://opsive.com/support/documentation/ultimate-inventory-system/events/

If you need more guidance let me know and I'll write an example.


Note that another solution to your problem is to write a custom CraftingProcessor, Crafter and/or CraftingMenu. It is up to you to choose the option that suits your needs best
 

Attachments

  • CraftingProcessor.cs
    7.5 KB · Views: 2
Top