- Joined
- Jan 31, 2010
- Messages
- 3,552
Abilities
Purchases & Upgrades with Items
This tutorial will teach you on how to purchase and upgrade abilities from shops, via items. This is heavily (ab)used in "Custom Hero" maps, where you can completely customize your Hero's spells. This system is fully MUI and MPI - all players can use it with unlimited count of different, or same, units.
Suggested readings are at the bottom of the page.
Content of tutorial:
I - Setting the DataII - Variables
III - Buy & Upgrade Trigger
I - Setting the Data
First of all, before we go with the Triggers, we will need to declare some Object Data. If you already have your Abilities and purchasable Items, I still recommend you to read through this.
Okay, what we will need first are some skills. Go ahead and create few. In this tutorial, I will be using 4 skills - Barrage, Command Aura, Chain Lightning and a custom one, Death Gaze. I guess you already set your number of levels, mana cost, effects and other. That was easy enough, right? Make sure to check the requirements, since some Ladder abilities, such as Barrage, require certain upgrades to be used.
Hint: You don't need to set the Learn tooltips! These abilities can only be upgraded via triggers. Also, use Auto Fill option (Right Click on a field, -Auto Fill Levels-) to make everything faster and easier! |
Now, let's create some items. The items should carry the icon and description of the skill, and they should also mention what is upgraded with each level. Only one item per one skill is allowed. It is advised to not put any stock cooldown, and to remove the model of the item; because you don't want those small lost particles lingering around.
Hint: Create items with the Classification of "Power Up"! Power up items can be picked even if your inventory is full, like Tomes or Runes, thus allowing you to upgrade skills even if your inventory is full. Be careful to remove the model - Power Up items leave those ugly particles. |
II - Variables
Now when we have our Abilities and Items, we need to set the Variables. Go to the Trigger Editor, enter the Variables, and then create five new variables, named "Skills", "MaxLevel", "Items", "TempUnit" and "TempPlayer". Last two will be used later.
Skills' type is Ability, Initial value of None, Array is True, and size is 1.
MaxLevel's type is Integer, Initial value of None, Array is True, and size is 1.
Items' type is Item-Type, Initial value of None, Array is True, and Size is 1.
TempUnit's type is Unit, Initial value of None, Array is False.
TempPlayer's type is Player, Initial value of None, Array is False.
Okay, now create a new trigger with an event at Map Initialization. The triggering part is easy now - you will just set the Variables that suit your needs, like I did in there.
-
Variables
-
Events
- Map initialization
- Conditions
-
Actions
- Set Skills[0] = Barrage
- Set Items[0] = Barrage
- Set MaxLevel[0] = 12
- Set Skills[1] = Command Aura
- Set Items[1] = Command Aura
- Set MaxLevel[1] = 20
- Set Skills[2] = Chain Lightning
- Set Items[2] = Chain Lightning
- Set MaxLevel[2] = 6
- Set Skills[3] = Death Gaze
- Set Items[3] = Death Gaze
- Set MaxLevel[3] = 3
-
Events
Hint: You can even add a Description variable, which will inform the user about the spell's increments per level. To do this, simply write down everything in a String type of variable, and display it by following the guide I provided bellow. |
III - Buy & Upgrade Trigger
Great. Now, when we stored the variables, we need a new trigger to check when an item is bought, and to increase the level of the ability. We will also check if the ability is at maximum level, and return the cost to player, as well as displaying proper messages. Here we use the TempUnit and TempPlayer variables to avoid leaks.
-
Buy and Upgrade Skills
-
Events
- Unit - A unit Acquires an item
-
Conditions
- (Item-class of (Item being manipulated)) Equal to Powerup
-
Actions
- Set TempUnit = (Triggering Unit)
- Set TempPlayer = (Owner of (Triggering Unit))
-
For each (Integer A) from 0 to 3, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Items[(Integer A)] Equal to (Item-type of (Item being manipulated))
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of Skills[(Integer A)] for TempUnit Less than 1
-
Then - Actions
- Game - Display to TempPlayer for 1.00 seconds the text: TempPlayer + ( bought + (Name of (Item being manipulated))))
- Unit - Add Skills[(Integer A)] to TempUnit
- Skip remaining actions
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of Skills[(Integer A)] for TempUnit) Less than MaxLevel[(IntegerA)]
-
Then - Actions
- Game - Display to TempPlayer for 1.00 seconds the text: TempPlayer + ( upgraded + (Name of (Item being manipulated))))
- Unit - Set level of Skills[(Integer A)] for TempUnit to ((Level of Skills[(Integer A)] for TempUnit) + 1)
- Skip remaining actions
-
Else - Actions
- Game - Display to TempPlayer for 2.00 seconds the text: Skill is at maximum level!
- Player - Add 50 to TempPlayer Current lumber
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Events
We are finished! You will need to add variables for each ability, along with corresponding item, maximum level and the description, if you decide to go with it.
I hope that this tutorial helped you in acomplishing your goal, and I am looking forward to see your maps soon!
Suggested Readings:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/array-tutorial-17789/
http://www.hiveworkshop.com/forums/...quick-tutorial-common-triggering-tips-190802/
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/complete-list-things-leak-126761/
My Stuff:
Current project: http://www.hiveworkshop.com/forums/map-development-202/legendary-war-apheraz-181100/
Back to the Top
Last edited: