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.

MemberSection
meetsRequirementsDefining requirements
craftDefining the craft function
InventoryModificationsReturning the result

Define 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.

ParameterDescription
craftingEntryThe content crafting entry.
destroyedInstancedItemsThe list of instance items that would be destroyed if the craft were performed.
playerInventoryA snapshot of the player’s current inventory data.
requestExtYour custom defined proto containing details about the current craft operation.

Define the craft function #

The craft function is used to perform programmatic inventory transformations.

ParameterDescription
craftingEntryThe content crafting entry.
destroyedInstancedItemsThe list of instance items that would be destroyed if the craft were performed.
playerInventoryA snapshot of the player’s current inventory data.
inventoryContentAll inventory content for reference purposes.
requestExtYour custom defined proto containing details about the current craft operation.

Return the result #

The craft function must return a InventoryModifications. This data class can be to used for chaining of additional operations such as granting, updating, or destroying items. Below are the possible item operations:

PropertyTypeDescription
rewardGrantsList<RewardGrant>List of rewards to be granted.
instancedItemServerGrantsList<InstancedItemServerGrant>List of instanced item to be granted.
stackableItemGrantsList<StackableItemGrant>List of stackable item grants to be granted.
serverInstancedItemUpdatesList<ServerInstancedItemUpdate>List of instanced items to be updated.
instancedItemsToDestroyList<InstanceId>List of instanced items to be destroyed.

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.

For full examples, see the Crafting Tutorial.