Tutorial Diablo style stat system

X-maul

AKA: Demtrod
In this tutorial I will teach you how to create a system that will give the player a specified amount of statpoints each level, that the player can use to increase the stats for his hero.
(This system will only work for 1 unit per player)

I asume you have a little bit of expirience with both the data editor and the trigger editor, but I'll try to go forward as slow as possible.

Step 1
To begin with we will need a behavior of the type Veterancy, name it HeroLevel.
(If you already have a veterancy behavior, go to step 2)
When you have created the bahavior, go click the Behavior: Veterancy Levels +, click the green X to add a level. Make the first level be 0 so the hero will start at level 1. Create another one with the minimum expirience at 50. Then just click it and press [Ctrl]+[V], [Ctrl]+[C] and copy as many levels as you want.

Normaly you would want to make the veterancy behavior increase attributes, but in this case, we wont do that.

Step 2
Now we need the attributes, I'll just create 3 attributes for the sake of the tutorial. This is done pretty easily, I'll just make them pretty simple, creating;
  • Stamina
    Increasing Health and health regen.
  • Strength
    Increasing melee and ranged damage
  • Wisdom
    Increases energy and energy regeneration.
Make sure you set the Stats: Max Points to something very high, I'll just set mine to 9999999.
Step 3
Now we need to create a buff that increases the attributes for us.
Make a new behavior of the type Buff, name it Stamina Increaser.
Go to the Behavior: Modification field and go to the Behavior tab, now click the green X under Attribute Changes, and set the new field to Stamina:

You do not want to make it change point to anything but 0, that will be changed later with triggers, we just want it to be associated with the right attribute.
Now create the same buff behavior for each of your attributes, so in my case, I have Stamina Increaser, Strength Increaser and Wisdom Increaser.
Step 4
Now go to your unit and add all the attribute and the buff behaviors;

Step 5
Now we are done with the data part of it. So go to the trigger editor and create a new trigger, and name it Stats System Init. (You can also delete the Melee Initialization)
Now we need some Global Variables;
1 Dialog (Stats Dialog)
5 Dialog Item (Increase Stamina, Increase Strength, Increase Wisdom, Toggle Stats, Stat Points Remaining [16])
4 Integer (Stamina [16], Strength [16], Wisdom [16], Stat Points [16])
1 Boolean (Stats Toggled [16])

(I set the init for Stat Points to 5 so we have 5 stat points from the start)
Go to your Stats System Init trigger, and create an action that creates a dialog of the size 250, 270 relative to center, and set the variable Stats Dialog to the last created dialog. Now make an action that hides the last created dialog (This is so that it's not shown in the start of the game).
By now your trigger should look like this:
Code:
Stats System Init
    Events
        Game - Map initialization
    Local Variables
    Conditions
    Actions
        Dialog - Create a Modal dialog of size (250, 270) at (0, 0) relative to Center of screen
        Dialog - Hide (Last created dialog) for (All players)
        Variable - Set Stat Dialog = (Last created dialog)
Now add an action to create a dialog item of the type button, and set the Increase Stamina variable to last create dialog item, do this for each attribute.

Also we want to display the remaining stat points, so create a local variable of type Integer, name it X.
Now create a For each Integer action and make it go from 1 - 12.
Add an action that adds a dialog label to display the remaining stat points, and set the Stat Points Remaining variable to the last created dialog item, and the array to X.

You trigger should look something like this by now;
Code:
Stats System Init
    Events
        Game - Map initialization
    Local Variables
        X = 0 <Integer>
    Conditions
    Actions
        Dialog - Create a Modal dialog of size (250, 270) at (0, 0) relative to Center of screen
        Dialog - Hide (Last created dialog) for (All players)
        Variable - Set Stat Dialog = (Last created dialog)
        Dialog - Create a button for dialog (Last created dialog) with the dimensions (200, 50) anchored to Top with an offset of (0, 100) setting the tooltip to "" with button text "Stamina" and the hover image set to ""
        Variable - Set Increase Stamina = (Last created dialog item)
        Dialog - Create a button for dialog (Last created dialog) with the dimensions (200, 50) anchored to Top with an offset of (0, 150) setting the tooltip to "" with button text "Strength" and the hover image set to ""
        Variable - Set Increase Strength = (Last created dialog item)
        Dialog - Create a button for dialog (Last created dialog) with the dimensions (200, 50) anchored to Top with an offset of (0, 200) setting the tooltip to "" with button text "Strength" and the hover image set to ""
        Variable - Set Increase Wisdom = (Last created dialog item)
        General - For each integer X from 1 to 12 with increment 1, do (Actions)
            Actions
                Dialog - Create a label for dialog (Last created dialog) with the dimensions (200, 50) anchored to Top Left with an offset of (50, 50) with the text ("Stat Points Remaining: " + (Text(Stat Points[X]))) color set to White text writeout set to False with a writeout duration of 2.0
                Dialog - Hide (Last created dialog item) for (All players)
                Dialog - Show (Last created dialog item) for (Player group(X))
                Variable - Set Stat Points Remaining[X] = (Last created dialog item)
Step 6
Now we need to make the buttons actually do something.
Create a new trigger and name it Stat Dialog Buttons.
Make your new trigger have the event;
Code:
        Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Now create a new action of the type Switch, and make it depend on Used Dialog Item.
Add a new case with the if set to Stamina Increaser, now create an If Then Else action and set the condition to Stat Points == 0. Now in in the Then field add an action that sets the Stamina variable to Stamina + 1.
Now add an action of the type Catalog Field Value Set. Set the Catalog to Behavior, the Entry to Stamina Increaser and the Field Path to;

Set the string in the end to Convert Integer to String, and set the integer to your Stamina variable.
Now create an action that decreases the Stat Points with 1.
Set all the array fields to Triggering Player.
Create an action that sets the text for the Stat Points Remaining to the updated value.

Do this for the 3 attribute buttons, your trigger should look something like this;
Code:
Stat Dialog Buttons
    Events
        Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
    Local Variables
    Conditions
    Actions
        General - Switch (Actions) depending on (Used dialog item)
            Cases
                General - If (Increase Stamina)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                Stat Points[(Triggering player)] == 0
                            Then
                            Else
                                Variable - Set Stamina[(Triggering player)] = (Stamina[(Triggering player)] + 1)
                                Catalog - Set value of Behaviors StaminaIncreaser Modification.AttributeChangeArray[0].Points for player (Triggering player) to (String(Stamina[(Triggering player)]))
                                Variable - Set Stat Points[(Triggering player)] = (Stat Points[(Triggering player)] - 1)
                                Dialog - Set Stat Points Remaining[(Triggering player)] text to ("Stat Points Remaining: " + (Text(Stat Points[(Triggering player)]))) for (All players)
                General - If (Increase Strength)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                Stat Points[(Triggering player)] == 0
                            Then
                            Else
                                Variable - Set Strength[(Triggering player)] = (Strength[(Triggering player)] + 1)
                                Catalog - Set value of Behaviors StrengthIncreaser Modification.AttributeChangeArray[0].Points for player (Triggering player) to (String(Strength[(Triggering player)]))
                                Variable - Set Stat Points[(Triggering player)] = (Stat Points[(Triggering player)] - 1)
                                Dialog - Set Stat Points Remaining[(Triggering player)] text to ("Stat Points Remaining: " + (Text(Stat Points[(Triggering player)]))) for (All players)
                General - If (Increase Wisdom)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                Stat Points[(Triggering player)] == 0
                            Then
                            Else
                                Variable - Set Wisdom[(Triggering player)] = (Wisdom[(Triggering player)] + 1)
                                Catalog - Set value of Behaviors WisdomIncreaser Modification.AttributeChangeArray[0].Points for player (Triggering player) to (String(Wisdom[(Triggering player)]))
                                Variable - Set Stat Points[(Triggering player)] = (Stat Points[(Triggering player)] - 1)
                                Dialog - Set Stat Points Remaining[(Triggering player)] text to ("Stat Points Remaining: " + (Text(Stat Points[(Triggering player)]))) for (All players)
            Default
Step 7

Now we only need to create a button that toggles the Dialog;
Create a new dialog with a button, and set the variables;
Code:
Stat Toggle Init
    Events
        Game - Map initialization
    Local Variables
    Conditions
    Actions
        Dialog - Create a Modal dialog of size (200, 200) at (0, 0) relative to Left of screen
        Dialog - Show (Last created dialog) for (All players)
        Variable - Set Toggle Dialog = (Last created dialog)
        Dialog - Create a button for dialog (Last created dialog) with the dimensions (180, 180) anchored to Center with an offset of (0, 0) setting the tooltip to "" with button text "Stats" and the hover image set to ""
        Variable - Set Toggle Stats = (Last created dialog item)
Step 8
Now we need to make the toggle button do something, so make a trigger that reacts to dialog item is used, and make the condition check if it's the Toggle Stats dialog item

Now make a If then else actions that checks if the Stats Toggled is true or false, and make the one that is true hide the dialog, and set the Stats Toggled variable to False. Now copy the If then else and move it into the then field and change the true to false, and false to true. It should look like this:
Code:
Stat Toggle Button
    Events
        Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
    Local Variables
    Conditions
        (Used dialog item) == Toggle Stats
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                Stats Toggled[(Triggering player)] == True
            Then
                Dialog - Hide Stat Dialog for (Player group((Triggering player)))
                Variable - Set Stats Toggled[(Triggering player)] = False
            Else
                General - If (Conditions) then do (Actions) else do (Actions)
                    If
                        Stats Toggled[(Triggering player)] == False
                    Then
                        Dialog - Show Stat Dialog for (Player group((Triggering player)))
                        Variable - Set Stats Toggled[(Triggering player)] = True
                    Else
Step 9

Last but not least, we need to make the stat points remaining increase when leveling.
Just increase the Stat Points variable, and update the dialog text:
Code:
Level Up
    Events
        Unit - Any Unit gains an experience level
    Local Variables
    Conditions
    Actions
        Variable - Set Stat Points[(Owner of (Triggering unit))] = (Stat Points[(Owner of (Triggering unit))] + 5)
        Dialog - Set Stat Points Remaining[(Triggering player)] text to ("Stat Points Remaining: " + (Text(Stat Points[(Triggering player)]))) for (All players)
_____________________________________________________________________

Hopefully you were able to make sense of my tutorial, please give me some feedback, as this is my first tutorial.
 

Attachments

General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is online though at night
  • The Helper The Helper:
    You would probably have to take a loan to get the Rice cert it is like 14l
  • The Helper The Helper:
    I was hoping you were going to say you wanted to be a cook and wished to open up a Food Truck there are so many opportunities for that here
  • The Helper The Helper:
    you can only open the bar if you sell food and a food truck in the parking lot counts
  • The Helper The Helper:
    here in houston
  • The Helper The Helper:
    most bars are struggling to build food prep and even some I know are doing there own food trucks
  • The Helper The Helper:
    but yeah man you should come to Houston there is so much more opportunity here than San Antonio. Just look at all the homeless people on the Riverwalk and downtown there you cannot even walk down the street without getting mobbed them
  • The Helper The Helper:
    check out this place apparently it is the best roommate site out there roommates.com lol
  • Varine Varine:
    The homeless people reminded me of New York
  • Varine Varine:
    I'll check it out, my lease expires in like a few months so I need to figure something out.
  • Varine Varine:
    I tried to open a food truck in Sandpoint a few years ago but the city said no, then like two years later they passed new laws to encourage it and gave them all fucking tax breaks and shit. And at that point I didn't have enough money to go buy one so I was way too late to the game once other cities realized they could just bring their existing truck there, or sell their brick and mortar.
  • Varine Varine:
    I do like food trucks though, they're way more fun than restaurants and usually I also get some of that tip money there.
  • Varine Varine:
    Restaurants are really hard if you don't have a back up source of income to fund them sometimes, in my experience most owners either got really really lucky, had existing money that allowed them to buy an already successful one, or they have family money to fall back on for loans. It's few and far between to see very inspiring success stories where the person actually got it through hard work and perseverance. I thought about opening one lots and I always just end up not thinking it'll work. I would much rather just find someone that has that money and go work for them
  • The Helper The Helper:
    i am not talking about opening a brick and mortar I am talking about food trucks though I have seen some brick and mortar mexican places open up during covid that are doing good because there food is awesome!
  • The Helper The Helper:
    Food trucks are killing out here because Bars cannot open unless they sell food and the governor ok'd the use of a food truck in front as serving food
  • The Helper The Helper:
    Just not enough food trucks
  • The Helper The Helper:
    a buddy of mine just opened up a food truck and he is killing it but he is a great cook and has awesome food right in the middle of the pandemic too food trucks are immune to pandemic because they are take out in Texas you will always be able to get take out or delivery
  • The Helper The Helper:
    He is in the different food facebook groups in houston and posts videos of him making his food
  • The Helper The Helper:
    he is killing it
  • jonas jonas:
    @Varine with the restaurants, there surely is a lot of luck and hard work but most restaurants fail because they suck. Flair isn't right, economics not well thought through, food is mediocre or sucks, location is bad, etc. If you're thinking about opening one, make sure you're looking at the stories of those that would be playing at your level, don't let your hopes be dragged down by all the subpar restaurants out there.
  • jonas jonas:
    I'm a bit worried about the future of data science, there's an influx of incompetent people hired by incompetent managers, that can't last. But I'm sure smart data scientists will always be useful and hireable. Same as smart security people.
  • jonas jonas:
    My sister in law worked in a vegan food truck, the owners were also making a killing, added several trucks and opened two restaurants over 5 years
  • Ghan Ghan:
    The CompTIA stuff is pretty much crap unfortunately. The places that ask for those low-level certs aren't likely places you want to work. For IT you really want a degree, but in the meantime you need to figure out some way to learn the skills. Cybersecurity is really hot right now so competition is fierce.
  • tom_mai78101 tom_mai78101:
    I realized I don't have anything much to say, other than "Good luck!". Compared to other places, I'm just very lucky we didn't have a lot of surges of cases coming in.

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top