Dynamic Skill/Ability System

I am trying to make an ability system that allows the player to customize the skills. I want to be able to dynamically alter the values within the skills such as the element of the skill when a “rune” is equipped.
I’m currently am able to do this with my current code but I feel there is a better and less messy way of going about this.

Here are my scripts:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

public abstract class Skill : ScriptableObject{

    public string skillName;
    public string skillDesc;

    public int cooldown;

    public enum Element
    {
        None,
        Fire,
        Water,
        Earth,
        Electic,
        Wind,
        Dark,
        Holy
    }
    public Element element;

    public abstract void UseSkill();

    public SkillRune[] levelRunes;
    private SkillRune currentLevelRune;

    public void setLevelRune(SkillRune rune)
    {
        currentLevelRune = rune;
        if (currentLevelRune.skillMods.Contains(SkillRune.SkillModifiers.DamageElement))
        {
            element = currentLevelRune.element;
        }
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;



[CreateAssetMenu(menuName = "Skills/CombatSkill")]
public class CombatSkill : Skill {

    public override void UseSkill()
    {
        setLevelRune(levelRunes[0]);

        Debug.Log(skillName + "\nDecription: " + skillDesc + "\nCooldown: " + cooldown + "\nElement: " + element);
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Skills/Rune")]
public class SkillRune : ScriptableObject {

    public enum SkillModifiers
    {
        Cooldown,
        DamageElement
    }
    public SkillModifiers[] skillMods;

    public Skill.Element element;
}

Put this on a gameobject

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkillTest : MonoBehaviour {

    //public Skill worldSkill;
    public Skill combatSkill;
    //public Skill fieldSkill;

    //private Skill worldSkillEdit;
    private Skill combatSkillEdit;
    //private Skill fieldSkillEdit;
    // Use this for initialization
    void Start () {
        InstanceSkills();

        //worldSkillEdit.UseSkill();
        combatSkillEdit.UseSkill();
        //fieldSkillEdit.UseSkill();
    }

    private void InstanceSkills()
    {
        //worldSkillEdit = ScriptableObject.Instantiate(combatSkill);
        combatSkillEdit = ScriptableObject.Instantiate(combatSkill);
        //fieldSkillEdit = ScriptableObject.Instantiate(combatSkill);
    }
}

As a good rule to follow: If it works move on, if you have a better idea then work that out. The community isn’t going to be able to really help with this as its really down to a design decision. Your code looks fine, not too messy really. Skill systems are never going to be easy.

One of the things we need to understand about game development is that, the first iteration of your code probably isn’t going to be the best. As the project evolves the code changes to suit game mechanics, so its a good idea to not spend too much time trying to refine something that might not even be there in the end. Once a mechanic is finalized THEN you refine it.

1 Like

True, but coming from the perspective of someone still learning how to program and design games, this kind of information is invaluable.