Search Unity

Question Where to get started on a tier-based stat system?

Discussion in 'Scripting' started by theoharisalexander, Jul 8, 2021.

  1. theoharisalexander

    theoharisalexander

    Joined:
    Jun 21, 2021
    Posts:
    8
    I'm currently trying to develop a jrpg as a learning project, but I'm attempting to differ from the well-trodden paths and make my own modifications to the various systems so as to better challenge myself. It takes longer, but I find I learn more this way.

    The reason I mention this is that I'm currently attempting to develop my character stat system, and am not quite sure how to translate my current game design idea into proper code.

    My idea is to have various stats be modifiable by Player actions, going up and down depending on what items or characters they interact with. However, to keep this from fluctuating too heavily, I want to institute a 'Tier' system, where each stat has a certain range--for example 1-10--that it can operate within but upon the player exceeding that range--hitting 11-- they can no longer decrease the stat further. They will have gotten to the second tier of this stat--11-20--and can fluctuate within *this* range now.

    I've researched some tutorials on stat systems already, but am still having trouble figuring out where to start. I'm not quite sure how to move from the simpler systems I've seen in Brackey's or similar videos to something this complex. As such, does anyone have any suggestions on what resources I should look into to pursue this?

    I apologize if this is the wrong forum for this post, but I'm unaware of a better location to ask about this.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    If you wanna set yourself up for big success on this, obviously a lot of "define what you wanna do" has to happen.

    To help you in this, the best plan I find is to iterate.

    Set up a UI scene that has a few buttons on it to trigger the things you want, such as :

    - increase tier
    - increase stat1
    - increase stat2

    And have text to display what is going on. The above should be enough to start to reason about the logic.

    Now start defining some objects to handle this. For now just have some hard-coded variables and logic that you increment and see how they go, imagine how the game would play if you implemented such a thing.

    For instance, what happens with your above example if my stat is at 10 and I go to tier 2... does my stat automatically bounce up to 11? Or only bounce up when I next increase it? Or do the stat ranges overlap a few numbers? Or are they merely upper ceilings?

    Ultimately once the sequencing and leveling flows right, you can start to decide how things are going to work, what will be explicitly updated and what will be looked up from your tables, you can start to structure your data.

    ScriptableObject-derived objects are a great way to make preset data like this. You might make a Tier object, or a Stat object, or a TierRange object, something that is very generic and gives a range of possible values for a particular stat.
     
  3. theoharisalexander

    theoharisalexander

    Joined:
    Jun 21, 2021
    Posts:
    8
    This is very helpful, thank you!
    Iteration seems like a very useful concept that I'm honestly shocked I didn't think of doing. Though, this explanation does leave me with a couple of questions.

    First, when you say tables, do you mean a system I develop to handle various parts of stat allocation or some unity/c# concept I've yet to run into?

    Secondly, for the idea of scriptableObject-derived objects, I just want to confirm I understand your explanation. You're describing a system where I have various empty objects in the scene that I assign scripts to related to various aspects of the stat system and refer back to these scripts from a larger, separate, script?

    Edit: I've now realized a major part of what I was looking for, mainly due to a thought that arose from your post. I didn't phrase it properly, but I was looking for some math and logic for RPG stat/combat systems since I knew my idea wasn't something I'd considered enough. I've now found several resources related to the subject.
     
    Last edited: Jul 9, 2021
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    You're welcome!

    Keep in mind that to engineer anything you have to break it down to the tiniest part.

    At the end of the day, stats are just numbers.

    You label them to show onscreen : Strength, Intelligence, etc.

    That label means nothing to the game.

    In the game, when a melee attack happens, you need code to take the value contained in Strength and see how it goes into computations to decide how much damage to deal to an enemy.

    Other things that go into that might be weapon modifiers, enemy armor, surprise attack, any other perks, etc.

    You will NEVER get all this working in one shot. Iterate, iterate, iterate. Get each single thing going, save it. I recommend using source control to guard your hard-earned work.

    Also, for the poster-boy of "how did I learn game programming" watch this guy's six-minute video. That is good iteration, layer after layer after layer, NEVER moving forward until everything works.

    It's like building a house: you don't just furiously start hammering and sawing and pouring concrete and stop when it is done. First architect, then choose location, then make foundation, wait for it to dry, etc.

    Imphenzia: How Did I Learn To Make Games:

     
  5. theoharisalexander

    theoharisalexander

    Joined:
    Jun 21, 2021
    Posts:
    8
    All very helpful advice here, and that video is fantastic! Thanks for your assistance. I think I know where to start now.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    Whatever you do I hope you have a great time at it and that it feels rewarding. That's what makes game-making special... GO!

    Here's one more handy mental tool for organizing all this stuff you're cramming into your brain:

    When you are working, identify the knowledge into three different buckets:

    - syntax of C# (very similar to Java, but different)
    - the .NET API (all the tools that come with C#: lists, dictionaries, file io, etc)
    - the Unity API (everything in the
    using UnityEngine;
    namespace)

    Or as I call it, API buckets:

    https://forum.unity.com/threads/beginner-trying-to-understand.1044361/#post-6758320