Crafting / Player Crafting

What is player crafting?

Player crafting is a new feature introduced in this version that allows the crafting of recipes to occur directly from the player, without the need of a workstation.

Linking Recipes to the Player

We assign recipes to the player using the Recipe’s Contexts. The context lets us define where the recipe can be crafted. Open up the DT_Recipes data table in the Blueprints/Variables/DataTables/ folder and select the recipe you want to assign to the player. Then under the Contexts array add and then select the DA_CC_Player data asset, the default context for the player.

Changing contexts that are linked to the Player

For the player you can change and add the contexts that are linked to the player using the PlayerCraftingContexts array found in the Crafting configuration section of the AC_InventorySystem component you added to your player controller.

For everything else (like workstations) you would set the Contexts in the ContextTypes array on the AC_Inventory_Crafting instance.

Showing recipes from multiple Contexts

You can set multiple contexts to a single component using the methods above, and if you do, the recipe list in the crafting window UI will group recipes into each context, and the context’s label (set inside the data asset) will appear as the grouping header.

Toggle Player Crafting Window

The default keybinding for toggling the player crafting window is [ V ]. The input action for this is IA_InventorySystem_TogglePlayerCrafting, and is part of the IMC_InventoryV4_KBM_Crafting input mapping context. Both can be found in the Blueprints/Input/KeyboardMouse/ folder.

If for some reason the key binding is not working you will want to verify that you have player crafting enabled. Make sure that both enableCrafting? and enableCraftingFromPlayer? booleans are set to True in the Crafting configuration section on the AC_InventorySystem component you added to the player controller.

If that is not an issue then you most likely have something consuming the keybinding. If it is an enhanced input key you can use the console command ShowDebug EnhancedInput and then press the keybinding. You should see an input action on the debug light up. If it is not the TogglePlayerCraftingWindow one then that input has the priority.

Customizing the Player Crafting Window

For the player crafting window you can customize the Window Title Text, Icon, Open and Close Sounds using the variables found in the Configure / Crafting / Crafting Window section of the AC_InventorySystem component you added to your player controller.

View the Sounds chapter to learn how to customize the sounds that play when you craft something.

Disabling Player Crafting

You can disable crafting from the player by setting the enableCraftingFromPlayer? to false in the Crafting configuration section on the AC_InventorySystem component you added to the player controller.

Crafting will still be possible from workstations, the only difference is the UI for player crafting will not occur.

Requiring Tools on the Player

Keep in mind by default Tools are a feature of the Workstation system. If however you want to require tools on the player you can manually implement the BPI_Crafting_Workstation blueprint interface on your player controller then respond to the implemented haveRequiredCraftingTools? function.

On workstations this function gets the combined tool data from the workstation component.

To use on the player you would need to come up with the logic to respond to this function based on your own criteria.

The data for the inputs provided with this function come from the WorkstationToolRequirements under the Requirements structure for the recipe in the DT_Recipes data table. Each element in this WorkstationToolRequirement has a key and a value. The key will be sent through Tool, and the value through ToolLevel. You will want to evaluate that the key exists in the dynamic data of your tool on the player, and that the value for that dynamic data key on your item is greater than or equal to the value provided in the ToolLevel variable.

For output there are two booleans, Handled? signifies to the system that you are responding to the request. This should always be true since you are responding to the request using this function. The other boolean HaveTool? is the one where you respond with true or false depending on if the player has the tool.

For multiplayer games you will need to make sure you are responding to this function from both the server and the client. The server is where the work is handled, but the client does use this function to display a validator to the player in the crafting window based on the status of the tool.

Awarding the player experience from crafting

Implement the BPI_Crafting_Awards blueprint interface into your player controller, and when crafting occurs (success or fail) in both player crafting and workstation crafting this craftedRecipe function will be called. It will provide the following details:

RecipeRowName is the recipe that was crafted.
YieldMultiplier is the yield multiplier that was applied, such as from tool and bonuses.
isBonus? True if the crafting was of great success, resulting in a bonus.
isFail? True if crafting was a failure, resulting in lost items.
PlayerID Used by the workstation to redirect the request to the correct player controller (the one receiving this call).