How to add new items
Tutorial "How to add new item to the game"
Files & folders needed:
assets/gameplay/items.json
assets/ui/items/
assets/scripts/p_game.gd
Inside items.json we can add new items, from assets/ui/items/ we can get items icons.
Healing item JSON structure:
Artifact item JSON structure:
Armor item JSON structure:
Weapon item JSON structure:
Ammo item JSON structure:
Custom start-dialogue item JSON structure: (But same feature can be made using event keys)
Let's understand keys and what the do in-game:
"name" : "Name of the item, can be text, or language key from lang_*.json file"
"caption" : "Item description, can be text, or language key from lang_*.json file"
"icon" : "Inventory icon image file. Need full path relative to game exe"
"price" : "Item buy/sell price"
"weight" : "Item weight, float value"
"type" : "Item type, this affects how item will be used and it's additional keys"
"on_use" : "In-game effects that caused by item when used, like healing, armor increasing"
"slot": "where item can be equipped, like belt, outfit, rifle, pistol"
"profile" : "ID of the weapon profile from assets/gameplay/weapons.json"
"dialogue" : "if this key exist in usable item, dialogue will be shown, need dialogue ID and NPC name"
Let's add new consumable item, yellow eco medkit!
Duplicate medkit structure and paste it after.
Now rename it. For now we can ignore using langage keys, so we don't need to create keys in lang_* files for now, but for multilanguage it must have!
Change price to 300 and set new icon path (we don't create it for now, but will do it later), make it heal more, 100% of max health and give it new [on_use] effect from antirad!
Now duplicate medkit icon at assets/ui/items/ and change it's color in any image editor. I will do it with paint.net.
All done! We create new item! but how we can get this into inventory in game? There are a few ways:
Add it by script into inventory from game start
Add it to the traders
For now, let's add it from the game start. Open assets/scripts/p_game.gd file with Visual Studio Code or other editor that will save TAB indentiation in GD script. Find function:
Go inside function to:
And look for intro level id string:
And add new item using inventory.AddItem(id) function. Write it after:
It must looks like this:
Save files and run new game!
Last updated