X-maul
AKA: Demtrod
- Reaction score
- 201
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;
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:
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;
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;
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;
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;
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:
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:
_____________________________________________________________________
Hopefully you were able to make sense of my tutorial, please give me some feedback, as this is my first tutorial.
(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.
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)
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)
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
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
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)
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
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
-
23.7 KB Views: 572