> For the complete documentation index, see [llms.txt](https://october-studio.gitbook.io/monster-survivors-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://october-studio.gitbook.io/monster-survivors-documentation/abilities/add-abilities.md).

# Add Abilities

{% stepper %}
{% step %}

### Preparation

To add a new ability you would need to create at least three new classes - one for ability data, ability level and ability behavior. Depending on the type of the new ability we recomend using one of these two folders:&#x20;

<img src="/files/lqyvBnmqc6Zdc30OC16g" alt="" data-size="line"> <img src="/files/M2LhAbBnpeffSU1uKUa5" alt="" data-size="line">
{% endstep %}

{% step %}

### Ability Type Enum

Open the AbilityType.cs script located at Path: <img src="/files/6WIeBJAWGbEbyExOIzEu" alt="" data-size="line">

Add a new value to the AbilityType enum that will represent the new ability.&#x20;
{% endstep %}

{% step %}

### Ability Level class

Create an ability level class. It should have \[System.Serializable] attribute and inherit from AbilityLevel. Add fields to this class that will change with the progression of the ability.

```csharp
[System.Serializable]
public class NewAbilityLevel : AbilityLevel
{
    [SerializeField] int someUpgradableValue = 5;
    public int SomeUpgradableValue => someUpgradableValue ;
}
```

{% endstep %}

{% step %}

### Ability Data class

Create an ability data class. It should inherit from GenericAbilityData\<NewAbilityLevel>. All necessary functionality is inside this parent class. If you have a need for an additional fields that does not change with the progression of the ability, add them here. Also, create Awake and OnValidate methods and assign the type field inside them to prevent accidentally changing the type of created asset.

```csharp
[CreateAssetMenu(fileName = "New Ability Data")]
public class NewAbilityData : GenericAbilityData<NewAbilityLevel>
{
    private void Awake()
    {
        type = AbilityType.NewAbilityType;
    }

    private void OnValidate()
    {
        type = AbilityType.NewAbilityTypedgame;
    }
}
```

{% endstep %}

{% step %}

### Ability Behavior class

Create an Ability Behavior Class. Implement the custom behavior of the new ability here. The game object with this class assigned will be instantiated when the player selects this ability for the first time. After evolution or the end of the game this game object will be destroyed.

```csharp
public class NewAbilityBehavior : AbilityBehavior<HealEndgameAbilityData, HealEndgameAbilityLevel>
{
    // Gets called when the ability is selected for the first time
    public override void Init(AbilityData data, int levelId)
    {
        base.Init(data, levelId);
    }
    
    // Gets called when the ability is selected for the first time
    protected override void SetData(HealEndgameAbilityData data)
    {
        base.SetData(data);
    }
    
    // Gets called when the ability is selected for the first time and after every upgrade
    protected override void SetAbilityLevel(int levelId)
    {
        base.SetAbilityLevel(levelId);
    }
    
    // Gets called every time the ability get's upgraded.
    // Dose not get called when the ability is selected for the first time
    protected override void OnAbilityUpgraded(int levelId)
    {
        base.OnAbilityUpgraded(levelId);
    }
    
    // Calls when the ability is removed due to evolution or due to the end of the game
    // Clear pools, projectiles, spawned game objects here
    public override void Clear()
    {
        base.Clear();
    }
}
```

{% endstep %}

{% step %}

### Prefab

Create a new empty prefab We recomend using this folder <img src="/files/sVWxqIRP6lqg4qDhN1xP" alt="" data-size="original">

Assign created ability behavior script to it's root object.
{% endstep %}

{% step %}

### Scriptable Object

Create scriptable object of the ability data class, using context menu (Select the name from the \[CreateAssetMenu] attribute). We recomend using <img src="/files/iaaZW63IfYAhT97xRv2m" alt="" data-size="line"> folder.

&#x20;Fill it's fields. Use tooltips if you get confused. Assign the prefab from the previous step to the "prefab" field.

Add the scriptable object to the Abilities Database, located here:<img src="/files/C7zLBXTlgoTV28e6mXmV" alt="" data-size="line">.&#x20;

You're good to go!
{% endstep %}

{% step %}

### Testing ability

To quickly test the new ability, locate "Testing Preset" asset, add the ability to the abilities list, then assing this "Testing Preset" to the corresponding field of the "Stage Controller" script. It is attached to the "Game Management" gameObject in the "Game" scene.

Don't forget to remove the preset when you're done
{% endstep %}
{% endstepper %}


---

# 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 dynamically by asking a question.

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

```
GET https://october-studio.gitbook.io/monster-survivors-documentation/abilities/add-abilities.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
