> For the complete documentation index, see [llms.txt](https://roogame.gitbook.io/roogame/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roogame.gitbook.io/roogame/survivors-roguelike-kit/adding-a-new-attack-skill.md).

# Adding a New Attack Skill

### **Step 1: Create Skill Configuration**

#### **Option A: Duplicate Existing Skill**

<figure><img src="/files/kjJ8HkJc7QzN0DsWXrFA" alt=""><figcaption></figcaption></figure>

1. Navigate to:\
   `Assets/RGame/RoguelikeKit/ScriptableObjects/DataSO/Skill/AttackSkill/BothSideSkill.asset`
2. Right-click an existing skill → **Duplicate**
3. Rename (e.g., `FireWhirlwind_Skill.asset`)

#### **Option B: Create New Skill**

1. Right-click in folder → **Create → RGame → RoguelikeKit → Skill → BothSideSkill**
2. Name it with clear convention (e.g., `IceSpear_Skill.asset`)

***

### **Step 2: Configure Skill Parameters**

Open the new skill config in **Inspector** and modify:

| Parameter                | Description                                       |
| ------------------------ | ------------------------------------------------- |
| **SkillType**            | Attack/Attribute                                  |
| **SkillIcon**            | UI display icon                                   |
| **Key**                  | Unique identifier                                 |
| **MixAttributeSkillKey** | Required attribute skill for super-weapon upgrade |
| **SkillPrefab**          |                                                   |
| **Velocity**             | Movement speed                                    |
| **Duration**             | Active time (seconds)                             |
| **CD**                   | Cooldown time                                     |
| **Damage**               | Base damage value                                 |
| **Amount**               | Initial projectiles                               |
| **Area**                 | Effect size/scale                                 |
| **UpgradeAttribute**     | Enhanced stat per level                           |

<figure><img src="/files/QxMqqWt70ZwSvBFU9F1n" alt=""><figcaption></figcaption></figure>

### Step 3: Add **Motion/Visual Effects of Attack Skills**

Since it's difficult to modify the attack mode of the skill without writing code. Then, I will teach you how to quickly write different attack modes with the help of AI. I believe that even if you have no coding experience, you can quickly create the motion effects you want.

All you need to do is copy the following paragraph and specify the motion effect you want to write.  As well as the names of the two scripts, it is best to name one ending in SkillCast and the other in Skill.

```
Here's the skill launcher that's already available, 
and the script for the skill itself, which I'd like you to modify to get a 
different motion effectusing. I hope you can give me the full code and tell 
me how to use it.

UnityEngine;

namespace RGame.RoguelikeKit
{
    public class CircularAttackSkillCast : SkillCast
    {
        [SerializeField] private float _midAngle;
        private float _angle = -45;
        
        public override void Cast(SkillDataSO skillData)
        {
            base.Cast(skillData);
            
            int amount = _stat.GetValue("Amount") + skillData.Amount;
            int damage = (int)(_stat.GetValue("Might") * skillData.Damage * 0.01f) + 1;
            float velocity = skillData.Velocity * _stat.GetValue("SkillSpeed") * 0.01f;
            float duration = skillData.Duration * _stat.GetValue("Duration") * 0.01f;

            if (skillData.CurrentState is SkillCurrentState.Mixed)
            {
                for (int i = 0; i < 16; i++)
                {
                    var go = _pool.Request(Key);
                    var skill = go.GetComponent<CircularAttackSkill>();
                
                    skill.transform.position = _globalConfig.GlobalPlayer.transform.position;
                    skill.transform.localScale = skill.transform.localScale * (_stat.GetValue("Area") + skillData.Area) * 0.01f * 2f;
                    _angle += 22.5f;
                    var rad = _angle * Mathf.Deg2Rad;
                    Vector2 dir = new Vector2(Mathf.Cos(rad), -Mathf.Sin(rad));
                
                    skill.OnDeath += HandleSkillDeath;
                    skill.Init(velocity,damage, duration, dir.normalized);
                }
            }
            else
            {
                for (int i = 0; i < amount; i++)
                {
                    var go = _pool.Request(Key);
                    var skill = go.GetComponent<CircularAttackSkill>();
                
                    skill.transform.position = _globalConfig.GlobalPlayer.transform.position;
                    skill.transform.localScale = skill.transform.localScale * (_stat.GetValue("Area") + skillData.Area) * 0.01f;
                    _angle += 45;
                    var rad = _angle * Mathf.Deg2Rad;
                    Vector2 dir = new Vector2(Mathf.Cos(rad), -Mathf.Sin(rad));
                
                    skill.OnDeath += HandleSkillDeath;
                    skill.Init(velocity,damage, duration, dir.normalized);
                }
            }
        }
    }
}

using UnityEngine;

namespace RGame.RoguelikeKit
{
    public class CircularAttackSkill : SkillBase
    {
        private float _velocity;
        private int _damage;
        private float _duration = 1;
        private float _timer;
        private Vector3 _dir;
        
        private void FixedUpdate()
        {
            _timer += Time.fixedDeltaTime;

            if (_timer >= _duration)
            {
                _timer = 0;
                OnDeath?.Invoke(this);
            }
            
            transform.position += _dir * (_velocity * Time.fixedDeltaTime);
        }

        public void Init(float velocity, int damage, float duration, Vector3 dir)
        {
            _velocity = velocity;
            _damage = damage;
            _duration = duration;
            _dir = dir;
        }
        
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.CompareTag("EnemyHit"))
            {
                other.GetComponent<EnemyHit>().Hit(_damage);
            }
        }
    }
}

```

You will then get two scripts, one with SkillCast named at the end and the other with Skill named at the end.

#### **Step 1: Generate Skill Scripts with AI**

1. Copy the provided `CircularAttackSkillCast` and `CircularAttackSkill` scripts
2. Ask your AI assistant to:
   * "Modify these scripts to create a \[describe your desired motion effect] pattern"
   * Example requests:
     * "Make projectiles spiral outward"
     * "Create a boomerang return effect"
     * "Make skills orbit around the player"

#### **Step 2: Implement the Scripts**

1. **Create New Components**:
   * In Unity, navigate to:

     ```
     Assets/RGame/RoguelikeKit/Scripts/
     ```
   * Create two new C# scripts named:
     * `[YourEffectName]SkillCast.cs` (e.g. `SpiralSkillCast.cs`)
     * `[YourEffectName]Skill.cs` (e.g. `SpiralSkill.cs`)
2. **Paste AI-Generated Code**:
   * Replace all content in both files with the AI-modified versions `RGame.RoguelikeKit` (e.g. `SpiralSkillCast.cs SpiralSkill.cs`)

#### **Step 3: Attach to Game Objects**

1. Open the gameplay scene:

<figure><img src="/files/njtxfH8MTtZhivqgEZhB" alt=""><figcaption></figcaption></figure>

```
Assets/RGame/RoguelikeKit/Scenes/Managers/GamePlay.unity
```

1. Set up Skill Manager:

   * Right-click `SkillManager` → Create Empty
   * Name it (e.g. "SpiralAttack\_Manager")
   * Drag your `[YourEffectName]SkillCast` script onto it
   * Key is the logo name of your customized skill Other configurations are the same as the picture below
   *

   ```
   <figure><img src="/files/XlGwfVBrvRSwhmTROvRV" alt=""><figcaption></figcaption></figure>
   ```
2. Configure Prefab:
   * Locate your skill prefab
   * Remove any existing skill script
   * Add your `[YourEffectName]Skill` component

#### **Step 4: Final Configuration**

1. Link components:

   * Assign your prefab to the `SkillPrefab` field in your SkillConfigSO
   * Add the SkillConfigSO to `SkillManager`'s `SkillData` array

2. Set identifiers:
   * Ensure the `Key` field matches in:
     * SkillConfigSO
     * SkillCast component
     * ObjectPool settings

### **Testing & Iteration**

1. Enter Play Mode to test
2. Common adjustments via AI:
   * "Increase projectile spread by 30%"
   * "Add gradual size scaling"
   * "Make projectiles accelerate over time"

***

**Troubleshooting Tips**:

* If skills don't appear:
  * Verify all `Key` fields match exactly
  * Check SkillManager's `SkillData` array has your config
* If movement behaves oddly:
  * Ask AI to "debug velocity calculation in \[script name]"

**Pro Tip**: Use these exact phrases for AI modifications:

* "Make the projectiles home toward enemies"
* "Add wave pattern to movement"
* "Create 8-way directional attack"
