Crafting / Crafting Recipes

How to Create Crafting Recipes Video

How to Create New Crafting Recipes
How to Create New Crafting Recipes — 6:09

What are Crafting Recipes?

A Recipe defines which items are consumed and which items are produced when crafting. You can optionally specify requirements for learning and/or using the recipe, and set chances for failure (ingredients consumed, no yield) or bonus (extra yield quantity) per recipe.

Create a Recipe

We create our recipes in the DT_Recipes data table found in the Blueprints/Variables/DataTables/ folder. Each recipe consists of the following variables:

Title The text title for the recipe, shown to the player in the recipe window.
Description The text that appears under the title when selected in the recipe window.
FlavorText The gold text that appears under the description when selected in the recipe window. Flavor text is often used for injecting lore, typically about the item or the previous owner.
Contexts is how we define where this recipe can be crafted. You can create a new crafting context by right clicking in the content browser, select Miscellaneous then select Data Asset. Select DA_CraftingContext from the list then name your context. Open the context to set the variables related to it.
Ingredients are the items, and quantity of each, that will be consumed to produce the Yield. OverrideData is not used as requirements for ingredients.
Yield are the items, and quantity of each, that are produced on a successful craft of this recipe. OverrideData is used for Yield, and can be applied to the item produced.
Requirements let us define the conditions that must be met to obtain and use the recipe. Details about each variable inside this structure can be found below.
CraftTimeSeconds the number of seconds required to produce one of this recipe.
FailChance the chance the recipe fails to produce the yield. Ingredients are consumed on failure and nothing is produced.
BonusChance the chance the recipe has a great success, producing a higher quantity yield than normal.
BonusYieldMultiplier the multiplier applied to the yield quantity when a bonus occurs.

Recipe Requirements

Each recipe in our data table has a requirements structure, here is a breakdown of those variables and how to use them.

AutoUnlock? True if the player is automatically given permission to use this recipe. If false you will need to call the unlockRecipe function on the player’s AC_Inventory_Crafting component to grant access to this recipe.
UnlockHelperText If you want to provide a clue to the player as to how this is obtained you can enter that text here. This will show at the top of the crafting window while the quest is locked.
CustomRequirements Add additional custom requirements by adding the BPI_Crafting_CustomRequirements blueprint interface to your player controller and implement the interfaced function checkCustomRequirement to validate your custom requirements. Each key value pair you enter here will be sent to that function when the recipe list is loaded and before a recipe is crafted. From there you would return true or false depending on if the requirement was met on your side for that player.
WorkstationToolRequirements The dynamic data key that must be found within the equipped workstation tools, and each tool's minimum level (the value) that must be met to craft this recipe. For example our meat_cooked recipe requires a cooking.grill of at least level 1. Our meat_feast recipe requires a cooking.pot of at least level 3 and a cooking.grill of at least level 1. On our workstation tool items we would define the same dynamic keys, and set our value for the level. In the demo world you can craft the level 3 cooking.pot from the player crafting window, or purchase it from the wandering vendor.

It is worth noting that while the text that appears on the crafting recipe information for custom requirements looks similar to the dynamic data definitions used on the Item Tooltips, it does not include the full capabilities of the dynamic data system. It only offers the very basics, meaning the key will be translated and the value will be added through the format strings. Using them in this part of the system does not offer the advanced value variables such as for max value and percentages. It also does not include the custom syntax object method.

These features did not seem necessary for recipes, but if you have a good reason to use them please reach out and let me know and maybe I can work them into a future minor version release (if there is enough interest).

Locked Recipes

This version of the system introduces locked recipes, which are recipes that must first be unlocked before they can be used.

By default all recipes are unlocked. To make a recipe locked, set AutoUnlock? to false under the Requirements section of the recipe (it is true by default). Then when you are ready to unlock the recipe for the specific player, call the unlockRecipe function on that player’s AC_Inventory_Crafting component (attached to the player controller).

When a recipe is unlocked is entirely up to you. I’ve included two examples in the demo world to help get you started. There is a button near the campfire that when pressed will unlock the Meat Feast campfire recipe. There is also a usable item that will unlock the Vial of Fire player crafted recipe.

It is important to note that even if the recipe is part of a workstation, you would still call the unlockRecipe function on the player’s crafting component, and not on the workstation. Calling unlockRecipe on a workstation’s component will not do anything.