Perk Scripting Like in Skyrim

Hi all! I am currently following burgzerg arcade hack and slash tutorials for unity scripting in c#… I was just wondering if someone could point me in the right direction as to how one would make a perk/skill system like in skyrim,
Thanks in advance! :slight_smile:

Whew, that is a tough one. I would say try to make some objects to make your life easier. Like make a public “Perks” class and inside that class, have a list of each perk you want. So like maybe:

public class Perks
{
    public static float lightArmor = 15.0f;
    public static float heavyArmor = 15.0f;
    //Etc... Add any more needed variables

    public static void NewStat (float newStat, float statToChange)
    {
        statToChange = newStat;
    }
}

And then in a “MonoBehaviour” class that would increase any stat, do this:

public class Increaser : MonoBehaviour
{
    void Update ()
    {
        if (player.LeveledUp()) //LeveledUp() would be a bool method/function
        (
            Perks.NewStat (Perks.lightArmor + 10.0f, Perks.lightArmor);
        )
    }
}

I know this is not EXACTLY like Skyrim, but it was supposed to lead in the right direction. It will take a while to make a system like Skyrim.

PS: I did this post on my iPhone so if there are spelling errors I didn’t catch, sorry!

Thanks for the help thats very helpful! Im watching burgzerg and his way of going about it seems to be confusing to me, he makes a list of enums for his skills instead of making them variables wich just seems confusing to me.

Enums could work better as they are sort of lists of variables but both should work just fine.

When looking for a good answer I found this, hopefully it will help you.

Yea, but im still confused about how to set actual values to the enums, so for example i would make

public enum Skills{ Kick, Punch, Slap }

i cant say
Kick = 24; // example kick skill is level 24

am i missing some kind of trick to doing this? im totally confused what enums go

I’m not too good when it comes to explaining about enums, but they are not used like the example you used above and enums are just names given to values.

enums make your program more readable and help you todon’t set integer values incorrectly. remembering easy is easier than remembering 0 or 1.” - Quote from the link I sent you earlier

So in your example kick would be 0, punch 1 and slap 2.

You could also check this C# reference, hopefully it will explain this better.
http://msdn.microsoft.com/en-us/library/sbbt4032(v=vs.80).aspx

I also found this youtube video for you,

If you still don’t understand how they work, wait for someone who can explain them better than me or stick with variables.

Alright, I think I kinda understand enums a bit better right now. Thanks for the replies, very helpful! :smile:

1 Like