adding_new_furniture_which_craftes_krapfen

Adding new furniture which craftes Krapfen

In this tutrial we will create a furniture which will be able to craft some krapfen for us (I know the sprite is not a Krapfen, but I know you can get over it).
The whole operation will be divided in steps:

  • Create a Krafpfen Food Item
  • Create a new cooking recipe list, containing the recipe to craft the krapfen
  • Create a new crafting furniture to cook Krapfens, a small krapfen-o-matic-oven which uses the previous recipe list

After having done this we will be able to craft such a furniture in game and use it to craft krapfens! Yum!

In this guide we will introduce two new categories of game entities in Hard Times. They are Furnitures and Recipes. So we will have to edit the mod descriptor file to let it know that we will have to load also them. Edit the mod package descriptor file in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Descriptor.json

And edit it, modifing the file we edited in the last guides, so that it will look like this:

{
  "modName": "MyMod_MODPKG",
  "author": "RadicalFiction",
  "gameVersion": "",
  "langFolder": "Lang",
  "itemsFolder": "Items",
  "shopsFolder": "Shops",
  "spawnersFolder": "Spawners",
  "figuresFolder": "Figure",
  "furnituresFolder": "Furnitures",
  "recipesFolder": "Recipes"
}

Ok, if you followed the previous guides you should be fairly familiar with this operation. First create a FoodItems folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\FoodItem

Copy (save image as) this awesome sprite in the Sprites folder you will create under the FoodItem folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\FoodItem\Sprites

Made this step we will create the FoodItems.json in the FoodItem folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\FoodItem\FoodItems.json

So that it will look just like this:

{
  "archetipusName": "baseItemArchetipus",
  "category": "FoodItem",
  "items": [
	{
	  "itemId": "Modder Krapfen",
	  "itemSpriteName": "krapfen.png",
	  "itemExpiration": 43800,
	  "maxStackable": 1,
	  "itemEffectOnUse": "food_eat_effect",
	  "achievementsOnCraft": "MealCraft",
	  "effectModifiers": [
		{
		  "statId": "playerHunger",
		  "statModifier": 15
		},
		 {
		  "statId": "playerStamina",
		  "statModifier": 0
		},
		{
		  "statId": "playerBowels",
		  "statModifier": -15
		}
	  ]
	}
	  ]
	}
  ]
}

Please refer to the Player Effects Modding Reference for a full reference about all of the properties exposed in this file and to the ADDING A NEW ITEM TO THE GAME for a quick tutorial about the basics of item modding in Hard Times.
Don't forget to create the appropriate lang file for this item category:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\Lang\English\FoodItems.json

(Please note that names are arbitrary, since lang files entries all reside in the same logic level)
Fill it with the following code:

{
  "items": [
	{
	  "key": "Modder Krapfen",
	  "value": "Modder Krapfen"
	},
	{
	  "key": "Modder Krapfen-DESCRIPTION",
	  "value": "I made this awesome Krapfen by following a guide on the official Hard Times wiki! Thake that!"
	}
  ]
}

Please remember that “-DESCRIPTION” is a suffix that the game uses for looking after description of game items. So for every item id entry in the lang file the game expects to exist also a itemId-DESCRIPTION entry. Now that we have a brand new item in game, we can go on and create our crafting recipe list that we will use with the crafting forniture to add a crafting furniture in game.

Now we will tackle with a new concept in Hard Times modding: Crafting Recipes.
They are basically descriptors telling the game how to craft items in game and what is needed to create them (the ingredients). Recipes in Hard Times, are organized in lists or collections. So that any crafting device cam be linked to a proper collection defining what it can and can't craft. So let's create a Recipes folder under our mod package:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Recipes

Let's proceed on creating a brand new recipes list file:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Recipes\KrapfenHovenRecipes.json 

Please note that the name of the file is arbitrary and doesen't matter to the game.
Now we will edit this new file to have it look like this:

{
  "collectionId": "KrapfenHovenRecipes",
  "recipes": [
	{
	  "recipeId": "Modder Krapfen",
	  "duration": 10,
	  "isPublic": true,
	  "result": [
		{
		  "itemId": "Modder Krapfen",
		  "itemType": "FoodItem",
		  "itemQuantity": 1
		}
	  ],
	  "ingredients": [
		{
		  "itemId": "Flour",
		  "itemType": "FoodItem",
		  "itemQuantity": 1
		},
		{
		  "itemId": "Water Bottle",
		  "itemType": "FoodItem",
		  "itemQuantity": 1
		}
	  ]
	}
  ]
}

Please refer to the Crafting Recipes Reference page for a full explaination of all the properties exposed in this file.
In this file you can note a “collectionId” value, which indicates a uniquie id to refer this collection. After that we just have a list of available recipes. Each one has a recipeId, a duration expressed in minutes game time, a “isPublic” flag, indicating if the recipe will be readily accessible to the player as the game starts or if it will be locked until a proper book has been read to unlock it. In that case we will need to add or edit a proper book item.
As you can see each recipe has also one or more result items, each one with a quantity property to indicate how many of the items to spawn. Also we have a “ingredients” list containing the required ingredients for the recipe to be succesful.
Please note that the quality of the resulting item will be equal the average quality of all of the ingredients and the quality of the crafting device used. Now we have a new FoodItem and a recipe to create it. Next step we will create a furniture to implement this Recipes collection and to make in game crafting possible.

Ok, now that we prepared the proper item and crafting recipe we will go on to create a furniture hoven that will craft for us many tasteful krapfens, given that we have all of the required crafting ingredients.
First step of this process is to create the Furnitures folder under our new mod package:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Furnitures

As you should be used to by now, under this folder we will create a Sprites folder containing all of the furnitures sprites used in the vanilla game. Just save in that folder this new fantastic sprite representing a hoven: So that it will end up like this:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Furnitures\Sprites\krapfen_hoven.png

Now lets create the furniture file in the Furnitures folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Furnitures\krapfen_hoven.json

The contents of the file will be like this:

{
  "furnitureId": "Krapfen Hoven",
  "furnitureType": "CraftingStationFurniture",
  "boxedItemAncestorName": "krapfen_hoven_boxed",
  "boxedItemAncestorType": "BoxedFurnituresItem",
  "furnitureArchetipusName": "FurnitureArchetipus",
  "furnitureSpriteName": "krapfen_hoven.png",
  "furnitureColliderRadius": 0.7,
  "isPackable": true,
  "freezePosition": true,  
  "achievementsOnUse": "",
  "mass": 20,
  "positionRestrictions": [],
  "extras": [
	{
	  "key": "recipesCollection",
	  "stringValue": "KrapfenHovenRecipes"
	},
	{
	  "key": "panelTitle",
	  "stringValue": "Base Krapfen Hoven"
	},
	{
	  "key": "panelDescription",
	  "stringValue": "Base Krapfen Hoven Description"
	},
	{
	  "key": "craftingPaletteModule",
	  "stringValue": "FloatingCraftingPanel"
	},
	{
	  "key": "craftingSound",
	  "stringValue": "cooking"
	}
  ]
}

For a full explanation of all of the furnitures properties please refer to the Crafting Furnitures Reference.
Note how we referenced the proper recipes collection in the recipesCollection extra property.
The craftingPaletteModule should remain as it is since it's not meant to be changed.
For this guide's sake we will note also that we have linked the furniture to a “BoxedFurnituresItem” as a boxed item ancestor. This is important since in Hard Times each furniture must have a BoxedFurnituresItem counterpart. This will represent the furniture while it is boxed and unmounted. In fact what we will spawn or craft is this item, so we will now go on and create the folder and the file in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\BoxedFurnituresItem\BoxedFurnituresItem.json

to be exacly like this:

{
  "archetipusName": "baseItemArchetipus",
  "category": "BoxedFurnituresItem",
  "items": [
	{
	  "itemRootPath": "",
	  "itemId": "krapfen_hoven_boxed",
	  "itemSpriteName": "boxed_furniture.png",
	  "itemProxySprite": "boxed_furniture.png",
	  "achievementsOnCraft": "",
	  "itemExpiration": 0,
	  "maxStackable": 1,
	  "extras":[
		{
			"key":"linkedFurnitureId",
			"stringValue": "Krapfen Hoven"
		}
	  ]
	}
  ]
}

In the linkedFurnitureId extra parameter we referenced the linked furnitureId.
We will have also to create the proper Sprites folder under the BoxedFurnituresItem folder:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\BoxedFurnituresItem\Sprites

in which we will put our beloved boxed furniture sprite as it is referenced in the json file: so that it will end like this:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Items\BoxedFurnituresItem\Sprites\boxed_furniture.png


The boxed item newly created will also need its own entries in the proper lang file:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\Lang\English\BoxedFurnituresItems.json

The content of the file to be like:

{
  "items": [
	{
	  "key": "krapfen_hoven_boxed",
	  "value": "A Krapfen Hoven"
	},
	{
	  "key": "krapfen_hoven_boxed-DESCRIPTION",
	  "value": "A beautiful Krapfen Hoven made thanks to the modding guides in the official Hard Times wiki!"
	}
  ]
}

Lastly to have access to the newly created furniture we will put it on sale in the same Metro Shop we used for a previous guide. We can also create a proper crafting recipe for it and place it in some existing crafting recipes collection (such as the one of the workbench for example).
For this guide's sake we will limit ourselves to edit that shop file, located in:

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\Shops\metro_shop.json

Just add our boxed item to the items for sale list as follows:

{
  "shopId": "Metro Shop",
  "shopSpriteName": "shop.png",
  "shopType": "Shop",
  "openHour": 00,
  "openMinute": 00,
  "closeHour": 23,
  "closeMinute": 59,
  "refillIntervalMins": 30,
  "robberyDuration": 5,
  "robberyRecoveryMins": 480,
  "effectNeededToRob": "crowbar_effect",
  "shoppables": [
	{
	  "itemId": "Metro Ticket",
	  "itemType": "BaseItem",
	  "price": 2,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "food_coffee",
	  "itemType": "FoodItem",
	  "price": 2.5,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "Water Bottle",
	  "itemType": "FoodItem",
	  "price": 1.5,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "Light the Bob Stout",
	  "itemType": "FoodItem",
	  "price": 3.5,
	  "minQuality": 3,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "Old Goat liquor",
	  "itemType": "FoodItem",
	  "price": 10,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "Smoking Papers",
	  "itemType": "BaseItem",
	  "price": 2.5,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 1
	},
	{
	  "itemId": "Cigarette pack",
	  "itemType": "ContainerItem",
	  "price": 6,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 2,
	  "itemsContainedIfBought": "Cigarette|DrugItem*20"
	},
	{
	  "itemId": "Modder Shirt",
	  "itemType": "ClothingItem",
	  "price": 1.5,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 2
	},
	{
	  "itemId": "krapfen_hoven_boxed",
	  "itemType": "BoxedFurnituresItem",
	  "price": 1,
	  "minQuality": 2,
	  "maxQuality": 4,
	  "minQuantity": 1,
	  "maxQuantity": 2
	}
	
  ]
}

Note that we put it for sale for only one euro. It's cheap so that it will be easy for you to buy it a test it. Then you could come back here and raise the price as you wish.

If everything went well you should now be able to start again the game with no errors(!). Be sure you have your new mod active and start a new game.
Just enter any metro stations and look in the Metro Shop for the Krapfen hoven for sale. Please keep in mind that you are not guaranteed to find it at first try. Items in shop cycle randomly and you may not find what you are looking for at first.

Damn it! What a shame, now that it was going so well. Ok let's edit the proper file to add the Furniture description (note that when a label is missing in Hard Times you just are presented the label itself in the UI):

C:\Users\{YOUR USERNAME}\AppData\LocalLow\RadicalFiction\HARDTIMES\Mods\MyMod_MODPKG\Lang\English\Furnitures.json

just make it look like this:

{
  "items": [
	{
	  "key": "Base Krapfen Hoven",
	  "value": "Krapfen Hoven"
	},
	{
	  "key": "Base Krapfen Hoven-DESCRIPTION",
	  "value": "Just your average super awesome Krapfen hoven"
	}
  ]
}

Please note that we used the panelTitle of the furniture as a key. Now all is in place, and your average zombie cop looks satisfied as well!

If you have problems or find errors in this guide please get in touch at info@tempi-duri.net.

You could leave a comment if you were logged in.
  • adding_new_furniture_which_craftes_krapfen.txt
  • Last modified: 2019/02/11 11:09
  • by thorfinio