- Joined
- Jun 10, 2007
- Messages
- 780
Buying Abilities
Buying Abilities Through Items
This tutorial will teach you how to make a system allowing the user to buy a skill from a shop (e.g. Avatar) through the purchase of a temporary item that will give you that skill. This can come in handy in games in which you wish for players to customize their heroes. For this tutorial I will use the Infernal and Dark Ritual spells.
The Items
First of all, make a dummy item for each skill you're adding, like this:
Basically, this will be the item the user buys when they want to learn a specific skill. You may modify any of the values to best suite your map. You will need a new item every time you want a different purchasable skill.
Variables
Next, you will need to create a trigger that gives you the spell, but before you create the triggers, you will need this variable:
Check 'array'. The variable stores most of the needed information, and you cannot make this trigger without it. To access the Variable Manager, go to the Trigger Editor and look for a green X, or press CTRL+B.
After creating this variable and the object data, you will be ready to start making the trigger.
One-level skills
Leveling abilities from triggers
For our example of a leveling ability, I will use the Dark Ritual spell.
Again, a dummy item will be used. This item should be very similar to the item used for Infernal - the tooltips, gold cost, icon, etc, should be changed though (If desired).
Second Way
There are lots of ways to do various things within the World Editor (like a cinematic, for example), and there is another way to do this as well. This way is somewhat easier (if you know how to manage variables) and can be more effective as it is more organized. Only continue if you know the World Editor beyond a novice level.
Variable Setup
First of all, we will need a lot of variables, and we will set them all in a single trigger, so right now create a trigger like this which we will use later.
Skills-Ability Array- Size 1-Value None
Description-String Array- Size 1-Value None
Item-Item-Type Array- Size 1-Value None
Now that are variables are properly set, we may continue on. Go to the trigger you set up. Now we will place our variables in that trigger. Go to Action -> New Action -> All -> Set Variable by right clicking Actions.
Keep setting variables for each item, skill, and description in this trigger. Now that this trigger is done and our variables are set, we may continue on.
The Second Way - The Trigger
We want it to make it so when a unit buys the item it will add the ability. Thus, make a new trigger. The event should be as follows:
~Thanks to everyone who helped in this tutorial (Including Purplepoot, myself, and some people who suggested content to be placed here)
Buying Abilities Through Items
This tutorial will teach you how to make a system allowing the user to buy a skill from a shop (e.g. Avatar) through the purchase of a temporary item that will give you that skill. This can come in handy in games in which you wish for players to customize their heroes. For this tutorial I will use the Infernal and Dark Ritual spells.
The Items
First of all, make a dummy item for each skill you're adding, like this:
Basically, this will be the item the user buys when they want to learn a specific skill. You may modify any of the values to best suite your map. You will need a new item every time you want a different purchasable skill.
Variables
Next, you will need to create a trigger that gives you the spell, but before you create the triggers, you will need this variable:
Check 'array'. The variable stores most of the needed information, and you cannot make this trigger without it. To access the Variable Manager, go to the Trigger Editor and look for a green X, or press CTRL+B.
After creating this variable and the object data, you will be ready to start making the trigger.
One-level skills
-
Some Trigger
-
Events
- Unit - A unit Acquires an item
-
Conditions
- (Item-type of (Item being manipulated)) Equal to Summon Infernal
-
Actions
- Set skill[(Player number of (Owner of triggering unit))] = Inferno
- Wait 0.20 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)) Less than 1
-
Then - Actions
- Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
- Game - Display to (Player group((Owner of triggering unit))) for 10.00 seconds the text: You have bought the...
-
Else - Actions
- Game - Display to (Player group((Owner of triggering unit))) for 5.00 seconds the text: You already have th...
- Player - Add 350 to (Owner of triggering unit) Current lumber
-
If - Conditions
-
Events
Leveling abilities from triggers
For our example of a leveling ability, I will use the Dark Ritual spell.
Again, a dummy item will be used. This item should be very similar to the item used for Infernal - the tooltips, gold cost, icon, etc, should be changed though (If desired).
-
Some Trigger
-
Events
- Unit - A unit Acquires an item
-
Conditions
- (Item-type of (Item being manipulated)) Equal to Dark Ritual
-
Actions
- Set skill[(Player number of (Triggering player))] = Dark Ritual
- Wait 0.20 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of skill[(Player number of (Owner of triggering unit))]for (Triggering unit)) Less than 1
-
Then - Actions
- Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
- Game - Display to (All players) for 10.00 seconds the text: Dark Ritual Learned...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)) Less than 3
-
Then - Actions
- Unit - Increase level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)
-
Else - Actions
- Game - Display to (Player group((Owned of triggering unit))) for 5.00 seconds the text: This spell is...
- Player - Add 100 to (Owner of triggering unit) Current lumber
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Events
Second Way
There are lots of ways to do various things within the World Editor (like a cinematic, for example), and there is another way to do this as well. This way is somewhat easier (if you know how to manage variables) and can be more effective as it is more organized. Only continue if you know the World Editor beyond a novice level.
Variable Setup
First of all, we will need a lot of variables, and we will set them all in a single trigger, so right now create a trigger like this which we will use later.
-
Set Variables
-
Events
- Time - Elapsed game time is 0.00 seconds
- Conditions
-
Actions
- -------- We will set our variables here. --------
-
Events
Skills-Ability Array- Size 1-Value None
Description-String Array- Size 1-Value None
Item-Item-Type Array- Size 1-Value None
Now that are variables are properly set, we may continue on. Go to the trigger you set up. Now we will place our variables in that trigger. Go to Action -> New Action -> All -> Set Variable by right clicking Actions.
-
Set Variables
-
Events
- Time - Elapsed game time is 0.00 seconds
- Conditions
-
Actions
- -------- We will set our variables here. --------
- -------- Each number corresponds to only 1 skill. So, the Inferno variable will ALWAYS be 0, and Dark Ritual will ALWAYS have 1. Do not change these up as you will experience glitches. --------
- Set skills[0] = Inferno
- Set skills[1] = Dark Ritual
- Set Items[0] = Summon Infernal
- Set Items[1] = Dark Ritual
- Set Description[0] = <Your info here>
- Set Description[1] = Dark Ritual is a level 1 normal ability with 3 levels.
-
Events
Keep setting variables for each item, skill, and description in this trigger. Now that this trigger is done and our variables are set, we may continue on.
The Second Way - The Trigger
We want it to make it so when a unit buys the item it will add the ability. Thus, make a new trigger. The event should be as follows:
- Unit - A unit Acquires an item
- (Item-class of (Item being manipulated)) Equal to Powerup
-
Actions
-
For each (Integer A) from 0 to <Last array slot you used>, 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))
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer A) from 0 to <Last array slot you used>, do (Actions)
-
(Level of skill[(Player number of (Owner of triggering unit))]for (Triggering unit)) Less than 1
- Then - Actions
- Game - Display to (All players) for 1.00 seconds the text: Spell Learned...
-
Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
- Custom script: exitwhen true
- Else - Actions
- Game - Display to (Player group((Owned of triggering unit))) for 5.00 seconds the text: This spell is...
- Player - Add [Gold Amount] to (Owner of triggering unit) Current lumber
Edits
Edit1: Did what Steel_Cold Suggested.
Edit2: Added more information and used trigger tags.
Edit3: Made it more clear and simple (Will add the second way to do this).
Edit4: Added a second way to do this and 2 mirrors to download the demo.
Edit5: Added another variable screenshot and fixed up way one a tad.
Edit6: Fixed up way one again and added text part to way number 2.
Edit7: Finalized way 2 actions so that it will get approved.
Edit8: Engrish improved from 3 years ago: the tutorial is now better understandable .
Last edited: