Crafting #
Crafting systems range from a simple exchange of materials for gear, to complex, nested, pseudo-random rolled item grant and upgrade systems. Pragma Engine is designed to enable simple workflows powered entirely by content and configuration, and rich workflows with custom game logic defined in plugins.
To learn more about how crafting fits into our larger content systems, as well as how to access crafting content catalogs in Portal, visit the Content Data services page.
Crafting Plugin #
The Crafting Plugin is used to define custom crafting behavior and enable programmatic inventory transformations. In the following sections, we’ll take a look at the different components that make up the Crafting Plugin’s interface.
Member | Section |
---|---|
meetsRequirements | Defining requirements |
craft | Defining the craft function |
CraftResult | Returning the result |
Defining requirements #
When the Crafting Plugin is called, the meetsRequirements
function is the first to be executed. This function is used to create custom requirements for a craft request. If the requirements are not met, meetsRequirements
returns an error message and the craft
function is not performed.
Parameter | Description |
---|---|
craftingEntry | The content crafting entry. |
destroyedInstancedItems | The list of instance items that would be destroyed if the craft were performed. |
playerInventory | A snapshot of the player’s current inventory data. |
requestExt | Your custom defined proto containing details about the current craft operation. |
Defining the craft function #
The craft
function is used to perform programmatic inventory transformations.
Parameter | Description |
---|---|
craftingEntry | The content crafting entry. |
destroyedInstancedItems | The list of instance items that would be destroyed if the craft were performed. |
playerInventory | A snapshot of the player’s current inventory data. |
inventoryContent | All inventory content for reference purposes. |
requestExt | Your custom defined proto containing details about the current craft operation. |
Returning the result #
The craft
function must return a CraftResult
. The CraftResult
data class contains information on the relevant instanced item, stackable item, and/or reward grants to be given to a player upon a successful craft request.
Parameter | Description |
---|---|
instancedItemServerGrants | A list of instanced item grants to apply to the player inventory. |
stackableItemGrants | A list of stackable item grants to apply to the player inventory. |
rewardGrants | A list of reward grants to give to the player. |
Basic Crafting #
The Store system works in a pinch to support basic crafting systems as well. This means crafting can be implemented directly through content and configuration.
It can be helpful to think of the store system as a simple crafting system. You can define as many store catalogs as needed, and the in-game UI could be anything from an NPC shopkeeper to a workbench to an in-game menu.
Advanced Crafting #
Some games have more involved crafting systems with custom requirements or initialization logic. The Craft system provides a very powerful, flexible API through the Craft
plugin.
Time-Based Crafting #
Many games require time-based crafting where players wait in real time for an operation to complete.
This can be quickly implemented by creating a workflow out of existing systems:
- A store catalog is defined to allow players to exchange crafting materials for a crafting token.
- The crafting token includes a timestamp (set by the platform) that specifies when the item will be ready to be redeemed.
- Another store entry exchanges the crafting token for the actual item after a simple plugin check to confirm the wait time has completed.
For full examples, see the Crafting Tutorial and the Crafting: Time Based Tutorial.