# Custom Item\_SOs

{% hint style="info" %}
If you are looking for examples of Implementations, check [AppleItem\_SO ](/inventory-pro-add-on-documentation/content/03.-content/03.5-items/appleitem_so.md)and [EnergyDrinkItem\_SO](/inventory-pro-add-on-documentation/content/03.-content/03.5-items/energydrinkitem_so.md).&#x20;
{% endhint %}

`Item_SO` can be extended to create various types of items with custom behaviors and abilities triggered upon use. If your item does not require any custom behavior or is not intended to be used, there's no need to extend `Item_SO`.

For example, [`AppleItem_SO` ](/inventory-pro-add-on-documentation/content/03.-content/03.5-items/appleitem_so.md)heals the player when used. To implement this functionality, it extends `Item_SO` and overrides the `Use` method.

### Create a Custom Item\_SO & Use Behaviour

For this guide, let´s imagine that we´re adding a potion that increases the heal we receive.

{% stepper %}
{% step %}

### Create a New Script

First, we´ll need to create a new script. For organization & clarity purposes, we´ll call this C# script `PotionItem_SO`. Since this script will inherit from `Item_SO`, it´s highly recommended to follow the naming convention: `NameItem_SO`&#x20;

```csharp
using cowsins;
using UnityEngine;

[CreateAssetMenu(fileName = "newPotionInventoryItem", menuName = "COWSINS/Inventory/Showcase Items/New Potion")]
public class AppleItem_SO : Item_SO
{
    public float healMultiplierToAdd = .1f;
}
```

{% hint style="info" %}
You can copy & paste this code, and adjust it to fit your custom Item\_SO.
{% endhint %}

{% hint style="info" %}
Because of the \[CreateAssetMenu] Attribute, you´ll be able to create an instance of this Item\_SO in your Project folder by right clicking > Create > Cowsins > Inventory > Showcase Items > Your Item
{% endhint %}
{% endstep %}

{% step %}

### Implement the Use Method / Behaviour

Now, we´ll need to make a custom Use method, so whenever we use this Item from the Inventory or Fav Pinned Menu, custom behaviour will be run.

For that, we´ll need to override the base Use method.

```csharp
public override void Use(InventoryProManager inventoryProManager, InventorySlot slot)
{
    base.Use(inventoryProManager, slot);
}
```

Notice how you have access to the InventoryProManager and the InventorySlot from which the Item has been used.

For this specific example, we´ll implement the Heal Multiplier logic:

```csharp
public override void Use(InventoryProManager inventoryProManager, InventorySlot slot)
{
   // Access PlayerMultiplier reference
   PlayerMultipliers multiplier = inventoryProManager._WeaponController.GetComponent<PlayerMultipliers>();
   // Increases Heal Multiplier
   multiplier.healMultiplier += healMultiplierToAdd;
   // base.Use ensures the item is consumed.
   base.Use(inventoryProManager, slot);
}
```

{% endstep %}

{% step %}

### Final Script

{% tabs %}
{% tab title="Potion Example" %}

```csharp
using cowsins;
using UnityEngine;

[CreateAssetMenu(fileName = "newPotionInventoryItem", menuName = "COWSINS/Inventory/Showcase Items/New Potion")]
public class AppleItem_SO : Item_SO
{
    public float healMultiplierToAdd = .1f;
    
    public override void Use(InventoryProManager inventoryProManager, InventorySlot slot)
   {
      // Access PlayerMultiplier reference
      PlayerMultipliers multiplier = inventoryProManager._WeaponController.GetComponent<PlayerMultipliers>();
      // Increases Heal Multiplier
      multiplier.healMultiplier += healMultiplierToAdd;
      // base.Use ensures the item is consumed.
      base.Use(inventoryProManager, slot);
   }
}
```

{% endtab %}

{% tab title="Copy & Paste Base Code" %}

```csharp
using cowsins;
using UnityEngine;

[CreateAssetMenu(fileName = "newInventoryItem", menuName = "COWSINS/Inventory/Showcase Items/New Item")]
public class ItemNametem_SO : Item_SO
{
    // Your variables go here.
    
   public override void Use(InventoryProManager inventoryProManager, InventorySlot slot)
   {
      // Custom Use Logic goes here.
      base.Use(inventoryProManager, slot);
   }
}
```

{% endtab %}
{% endtabs %}

{% endstep %}
{% endstepper %}


---

# 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://cowsinss-organization.gitbook.io/inventory-pro-add-on-documentation/how-to-use-and-guides/custom-item_sos.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.
