# How to add new items

Files & folders needed:

> assets/gameplay/items.json
>
> assets/ui/items/
>
> assets/scripts/p\_game.gd

Inside <mark style="color:green;">**items.json**</mark> we can add new items, from <mark style="color:orange;">**assets/ui/items/**</mark> we can get items icons.

Healing item JSON structure:

```json
"medkit": {
	"name": "itm.medkit.name",
	"caption": "itm.medkit.caption",
	"icon": "assets/ui/items/medkit.png",
	"price": 100,
	"weight": 0.1,
	"type": "usable",
	"on_use": {
		"heal": 25
	}
}
```

Artifact item JSON structure:

```json
"af_fireball": {
	"name": "itm.af.fireball.name",
	"caption": "itm.af.fireball.caption",
	"icon": "assets/ui/items/af_fireball.png",
	"price": 500,
	"weight": 0.5,
	"slot": "belt",
	"type": "equipment",
	"on_use": {
		"armor": 10,
		"weight": -10
	}
}
```

Armor item JSON structure:

```json
"jacket": {
	"name": "itm.jacket.name",
	"caption": "itm.jacket.caption",
	"icon": "assets/ui/items/jacket.png",
	"price": 200,
	"weight": 3,
	"slot": "outfit",
	"type": "equipment",
	"on_use": {
		"armor": 10,
		"rad_resist": 0,
		"anomaly_resist": 10
	}
}
```

Weapon item JSON structure:

```json
"w_pistol": {
        "name": "itm.pistol.name",
        "caption": "itm.pistol.caption",
        "icon": "assets/ui/items/w_pistol.png",
        "price": 0,
        "weight": 0.83,
        "slot": "pistol",
        "type": "weapon",
        "profile": "w_pistol"
}
```

Ammo item JSON structure:

```json
"ammo_ak": {
        "name": "itm.ammo.ak.name",
        "caption": "itm.ammo.ak.caption",
        "icon": "assets/ui/items/ammo_ak.png",
        "price": 60,
        "weight": 0.3,
        "type": "item"
}
```

Custom start-dialogue item JSON structure: (But same feature can be made using event keys)

```json
"radio_first": {
	"name": "itm.radio.name",
	"caption": "itm.radio.caption",
	"icon": "assets/ui/items/hand_radio.png",
	"price": 0,
	"weight": 0,
	"type": "usable",
	"on_use": {},
	"dialogue": {
		"id": "radio_dialogue_first",
		"name": "npc.radio"
	}
}
```

Let's understand keys and what the do in-game:

> "name" : "Name of the item, can be text, or language key from <mark style="color:green;">lang\_\*.json</mark> file"
>
> "caption" : "Item description, can be text, or language key from <mark style="color:green;">lang\_\*.json</mark> 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"
>
> <pre class="language-ini"><code class="lang-ini">[Types]: <a data-footnote-ref href="#user-content-fn-1">usable</a>, <a data-footnote-ref href="#user-content-fn-2">equipment</a>, <a data-footnote-ref href="#user-content-fn-3">weapon</a>, <a data-footnote-ref href="#user-content-fn-4">item</a>
>
> usable = must have on_use
> equipment = must have slot, on_use
> weapon = must have slot, profile | must exclude on_use
> item = must exclude everything above | on_use, slot, profile
> </code></pre>
>
> "on\_use" : "In-game effects that caused by item when used, like healing, armor increasing"
>
> <pre class="language-ini"><code class="lang-ini">[on_use]: <a data-footnote-ref href="#user-content-fn-5">armor</a>, <a data-footnote-ref href="#user-content-fn-6">rad_resist</a>, <a data-footnote-ref href="#user-content-fn-7">anomaly_resist</a>, <a data-footnote-ref href="#user-content-fn-8">max_hp</a>, <a data-footnote-ref href="#user-content-fn-9">weight</a>, <a data-footnote-ref href="#user-content-fn-10">action</a>, <a data-footnote-ref href="#user-content-fn-11">accuracy</a>,
> <a data-footnote-ref href="#user-content-fn-12">heal</a>, <a data-footnote-ref href="#user-content-fn-13">radiation</a>
> </code></pre>
>
> "slot": "where item can be equipped, like <mark style="color:green;">belt</mark>, <mark style="color:green;">outfit</mark>, <mark style="color:green;">rifle</mark>, <mark style="color:green;">pistol</mark>"
>
> "profile" : "ID of the weapon profile from <mark style="color:orange;">assets/gameplay/weapons.json</mark>"
>
> "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.

<figure><img src="/files/iNfXgqHDHIhAojsprpML" alt="" width="353"><figcaption><p>medkit eco structure under original medkit</p></figcaption></figure>

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!&#x20;

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!

<figure><img src="/files/IKAr14551pbamNHFhCNa" alt=""><figcaption><p>Our new item with changed name, caption, price, icon and new effect</p></figcaption></figure>

Now duplicate medkit icon at <mark style="color:orange;">assets/ui/items/</mark> and change it's color in any image editor. I will do it with paint.net.

<figure><img src="/files/xRJ0j2Kfy6ehqJqUBzqp" alt="" width="309"><figcaption><p>Changed medkit icon</p></figcaption></figure>

All done! We create new item! but how we can get this into inventory in game? There are a few ways:

1. Add it by script into inventory from game start
2. Add it to the traders

For now, let's add it from the game start. Open <mark style="color:orange;">assets/scripts/p\_game.gd</mark> file with Visual Studio Code or other editor that will save TAB indentiation in GD script. Find function:

```gdscript
func on_level_changed(level_id):
```

Go inside function to:

```gdscript
match level_id:
```

And look for intro level id string:

```gdscript
"intro":
```

And add new item using <mark style="color:blue;">inventory.</mark>AddItem(<mark style="color:orange;">id</mark>) function. Write it after:

```gdscript
await gui.IntroWindow.hidden
```

It must looks like this:

<pre class="language-gdscript"><code class="lang-gdscript"><strong>"intro":
</strong>    gui.ShowIntroMessageCustom("start.game.info")
    #print("waint until gui intro will be hidden")
    await gui.IntroWindow.hidden
    inventory.AddItem("medkit_eco") # &#x3C;- new item that we created!
    #GM.AddEventKey("intro.cutscene")
</code></pre>

Save files and run new game!

<figure><img src="/files/ee8WXebKVueMFRXZ3rtV" alt=""><figcaption><p>Eco medkit</p></figcaption></figure>

[^1]: Item can be cunsumed

[^2]: Item can be equipped at slot

[^3]: Item can be quipped in slot, used as weapon

[^4]: Non usable item

[^5]: \[int number]: player bulletproof

[^6]: \[int number]: player radiation damage resistance

[^7]: \[int number]: player radiation damage multiplier resistance

[^8]: \[float/int number]: player max hp

[^9]: \[float/int number]: additional player max weight

[^10]: \[string]: call event key, event key process can be created in scripts/p\_game.gd

[^11]: \[int number]: additional player accuracy

[^12]: \[int number]: adds points to health

[^13]: \[boolean]: enable/disable antirad timer effect (100% rad resistance for some time)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://picnic-in-the-oblivion.gitbook.io/assets/modding/how-to-add-new-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
