Overview
There was never any question that Crea would have a crafting system and from day one I knew what I wanted out of it. The goal was to make discovery a key component and not have players be dependent on a wiki. Since then it has been a matter of how will it work. For a long time I thought I knew exactly how it would; however, after implementing it and facing several design issues I decided to step back and redesign.
Before being able to craft an item you must first learn what materials are needed. This can be done two ways. The simpler but less common way is to acquire a recipe/schematic that reveals all materials needed to craft the item. These recipes will be rare and only found as dungeon or boss loot. The usual route to learning an item’s recipe is through researching.
As we have always planned, researching is done through the Researcher NPC. When you talk to the Researcher you are presented with the simple research dialog.
There is one item slot where you can drop a material in and click “Research”. By doing so you research the capabilities of that material. This is not free though and does consume one of the material. The result is that a single recipe is revealed. However, if the recipe has multiple materials then all must be researched before the entire recipe is available.
The “Materials” button opens a window that shows the progress of each material so you know when you’ve fully researched a material.
Once a item recipe is available you can easily craft it by opening your craft window, selecting the item and clicking “Craft”.
Modding
Both the crafting and researching systems are fully implemented in Python and consequently are completely moddable. Since these systems are hundreds of lines long I’ll forgo including them in this post, but they can easily be found and edited with the game. However, the majority of modding regarding these system will be done with creating item recipes.
An item recipe is always defined with the item and can be as simple as the following:
craft = Craft(category='Armor', subcategory='Chest', level=4, experience=30, service='Anvil')
craft.material('mods/base/item/recipes/smelting/copper_ingot.ce', 6)
add(craft)
Recipes can be much more involved with several additional attributes.
craft = Craft(category='Basics', subcategory='Essentials', level=1, experience=15)
# Any number of materials can be listed.
# craft.material('path/to/content.ce, quantity)
craft.material('mods/base/item/materials/wood.ce', 1)
# Recipes can have multiple results based on the quality of the craft.
# result(quantity, quality) - This is a short hand.
# Here the player will receive 4 of this item always since quality is always 0+.
craft.result(4, 0)
# and here the player receives one additional quantity if quality is 50+.
craft.result(5, 50)
# Results can also be created long hand.
# By doing this it is possible to expand on the yielded items and their quantity.
# This result occurs at quality of 100+ and will yield 5 lumber and even another item!
result = CraftResult()
result.quality = 100
result.items.append(InventoryItem("mods/base/item/basics/essential/lumber.ce", 5))
result.items.append(InventoryItem("mods/base/item/basics/essential/super_lumber.ce", 1))
craft.results.append(result)
# Sets if a recipe can be learned through research. Defaults to True.
craft.isResearchable = False
add(craft)