> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs.md).

# ItemAttribute.cs

v4.0

`ItemAttribute` is a Scriptable Object which is intended to augment an `ItemObject`, providing more details about it, perhaps describing it. Beyond simply being a thing that changes an `ItemObject`, the `ItemAttribute` can also affect Stat objects, so that a "*Fire Sword*" can do something because of the "*Fire*" (an `ItemAttribute`) beyond simply having a cool name.

{% hint style="info" %}
A `GameItemAttribute`, the runtime version of `ItemAttribute`, can also be added to any other object and used in various ways. It can affect the `Stats` of an `IHaveStats` object, even if it is not in a `GameItemAttributeList`, or attached to a `GameItemObject`.
{% endhint %}

{% code title="ItemAttribute.cs" %}

```csharp
public string ObjectName
public string ObjectType

// ItemAttributes can change the FullName() of a GameItemObject they are attached to
public int nameOrder = 0;
public string humanName = "";
```

{% endcode %}

## Setup

The `objectType` of an **Item Attribute** is the name of the folder the Scriptable Object is in. Create one named as you'd like, and right-click inside to select the menu option:

`/Create/Game Modules/Items/Item Attribute`

This will create an `ItemAttribute` Scriptable Object in your project. Select that and view the Inspector to begin setting up your data. The name of the Scriptable Object is saved as the `objectName` value.

{% hint style="warning" %}
Note that names of **Item Attributes** must be unique. The console will provide a warning if there are multiple **Item Atrributes** with the same name.
{% endhint %}

## Inspector <a href="#inspector" id="inspector"></a>

Select your new object and view it in the Inspector. Here is where you can manage all the details about this **Item Attribute**. Note there are multiple tabs, each of which provide access to specific, and optional, information.

![As with all Game Module objects, the ObjectType is the name of the folder the Scriptable Object is in, "Character Race" in this example from the Party Based RPG demo game.](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FgC5gHyybemwjM4dezqSP%2FScreenshot%202023-06-16%20at%206.47.42%20PM.png?alt=media\&token=8071e8e2-7674-4509-ba1e-b033bed00fae)

{% tabs %}
{% tab title="Settings" %}
![](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FjZWcCT9XdkQj7dUWwE52%2FScreenshot%202023-06-16%20at%206.47.46%20PM.png?alt=media\&token=cedb87ad-06d5-4487-9abb-5dd813375003)

The **Settings** tab allows you to specify how the `ItemAttribute` effects other things, how it may change the name of `GameItemObjects` it's attached to, and which other `ItemAttributes` it either requires, or is incompatible with.

{% content-ref url="/pages/OL6ArnlIGlcBYZC9I3xx" %}
[General Settings](/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs/general-settings.md)
{% endcontent-ref %}

{% content-ref url="/pages/a3CpxLSldjWlt9DWhzPv" %}
[Name Settings](/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs/name-settings.md)
{% endcontent-ref %}

{% content-ref url="/pages/2HAr2IPYFkxUk5o2Kr2m" %}
[Requisite Attributes](/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs/requisite-attributes.md)
{% endcontent-ref %}
{% endtab %}

{% tab title="Stat Effects" %}
![This example shows the Stat effects that the Character Race "Elf" would have on an Actor.](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FDDOB76mrxolJpJQ0zMuA%2FScreenshot%202023-06-16%20at%206.52.10%20PM.png?alt=media\&token=df4dd042-6d64-42be-9db6-eaa508dbd9cd)

Once you have **Stats** set up, you can set how this **Item Attribute** will affect them here. The math is all handled automatically once you have your data set up at runtime, so that any **Item Attributes** you choose can affect the **Stats** of a player or other object which has **Stats**.

{% hint style="info" %}
`ItemAttributes` can affect the stats of an `IHaveStats` object, or they can affect the stats of the `GameItemObject` they are attached to. This can be set up in the [**General Settings**](/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs/general-settings.md) panel, and it may change the scale of the impact the `ItemAttribute` has.

For example, if the `Stat` effect is on the Proficiency of a `Stat`, then the value of the stat is going to be multiplied -- a larger stat value would mean the `ItemAttribute` has a larger impact. Affecting the `GameItemObject` often means it has an impact, but one that is limited to the overall impact of the `GameItemObject`.
{% endhint %}

See more details of the how this panel works on "Stat Effects" tabs of the [**Item Objects**](/magic-pig-games/game-modules-4/module-documentation/items/itemobject.cs.md) page.

#### Example

In the example above, stats Hit Points Max and Magic Points Max are given a 20 and 25 point increase resepctively. The proficiency of Wisdom and Accuracy are both increased by 0.2, while Might and Stamina are decreased by -0.2.

This means that if the stat value is 20, the "Final Stat" of Wisdom and Accuracy would be 20 \* 1.2, or 24, while the "Final Stat" of Might and Stamina would be 20 \* 0.8, or 16. Proficiency on the Actor may be affected by other things as well, such as the Character Class, or equipped items, or [Conditions](/magic-pig-games/game-modules-4/module-documentation/conditions.md).

The Magic Points Max value is also affected by the "Level" of the `IHaveStats` object which owns this `ItemAttribute`. In the example above, we add 3 \* Level \* the value of "Magic Points Souce" in a Lookup Table called "Stat Bonus".

In the **Party Based RPG demo game**, "Magic Points Source" is a "Hidden Stat", which is directly affected by Wisdom and Personality, two "Main Stats" in the game. In the demo, classes which use magic deterimine their Magic Points Source either through the value of their Wisdom or Personality stat. For Druid and Ranger classes, the magic points are determined by the average of the two, as seen here in the "Druid" `ItemAttribute`.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2F02ao88hxenaT5Uxkwy6H%2FScreenshot%202023-06-16%20at%207.04.06%20PM.png?alt=media&amp;token=df399484-5235-47bd-b114-403bf4ddf26a" alt=""><figcaption></figcaption></figure>

Among with other `Stat` effects, the "Magic Point Source" stat has 0.5 \* the Final Stat of Wisdom, and 0.5 \* the Final Stat of Personality added to it.&#x20;

This technique allows all magic users to have a common method of calculating final Magic Point Max stats, but with different sources.
{% endtab %}

{% tab title="Dictionaries" %}
![Dictionaries can be used to store all kinds of custom data, which you can use any way you'd like!](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FG2XKwyFqXrQwQZUXzNui%2FScreenshot%202023-06-16%20at%207.07.35%20PM.png?alt=media\&token=cf13f002-5bb2-45f2-9a7e-c7d5958743d1)

Here you can manage the values on the various [**Dictionaries**](/magic-pig-games/game-modules-4/module-documentation/dictionaries.md) key set up. Each one is a `List` and you can add and re-order the entires as you'd like. You can also have multiple "type" of data on each key.

{% hint style="success" %}
To add keys to individual `ItemAttributes`, you will need click the "Manage Item Attributes" button at the top of the Inspector. **Dictionaries** keys are the same for all **Item Attributes** of the same `objectType`. On the "Manage Item Attributes" panel you can set up Keys, and optionally choose to display `strings` in those keys as a `textbox`.
{% endhint %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/items/itemattribute.cs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
