(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Tutorials > Trigger (GUI) Editor Tutorials

Trigger (GUI) Editor Tutorials Contains tutorials concerning the usage of GUI features.
Read the Rules before posting.

Reply
 
LinkBack Thread Tools Display Modes
Old 05-16-2007, 05:29 PM   #1 (permalink)
 
Tooolbox's Avatar

User
 
Join Date: Jun 2004
Posts: 133

Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)


How To Make Item Recipes

How To Make Item Recipes
In this tutorial I'm gonna go over the various possible recipe styles and how they are accomplished. If you've ever played DotA you'll note that there are 2 kinds of recipes: Manual Combine and Auto Combine. I'll cover both, and even a little extra.

A note on terminology: I will refer to Items that are a part of a recipe as "factors".

Another note: I have never looked at the DotA triggers, so I do not know if my methods are their methods.

Since DotA is such a well-known map, I figured that it would be a good idea to use their recipes as examples, since it is a stable platform that many can relate to.

Manual Combine Theory

The concept of a Manual Combine involves a Recipe Factor and any number of Ingredient Factors. For example, in making the Magic Sword you might have to have the Ingredients Sword and Magic Dust, as well as the Recipe Magic Sword.

Manual Combine is only used when the Recipe actually costs anything. You buy the Sword for 500g, the Magic Dust for 250g and the Magic Sword recipe for 250g, and they all fuse together to create the Magic Sword end result. In a case where the Recipe costs nothing, use Auto-Combine.

sangerecipe.jpg
An example from DotA of a Manual Recipe, with the Factors. 2 Ingredients and the Recipe make the whole: Belt + Axe + Recipe = Sword.

Auto Combine Theory
The idea of Auto Combine uses any number of Ingredient Factors, but no Recipe Factor. As in DotA, it is best to have all Recipe Factors visible in a shop with a description of the ingredients so players can compile them, and this holds true for Auto-Combine recipes, except they should not be purchase-able since they are useless (in DotA they cost wood, which players never get).

Using the same example of the Magic Sword, if it were auto-combine, you need only collect the Factors (Sword and Magic Dust) and they would automatically fuse without a recipe. This means that there is no extra charge beyond the cost of the ingredients. An Auto-Combine item typically forms instantly whenever the Hero is carrying all of the ingredients. If you need to get a Recipe, even if it's free, it's technically not an auto-combiner.

perseverancerecipe.jpg
An example from DotA of an Automatic Recipe, with the Factors. 2 Ingredients combine without an actual Recipe Factor to make the whole. Ring + Pendant = Sphere.

Manual vs. Auto Combine
Combining items can be a serious issue of balance, but luckily there are so very many ways to tweak it. When you combine two or more items together into a single item that holds the same stats, you are essentially freeing up inventory space. This is quite an asset in any type of Hero-based map, such as AoS or RPG. It's up to you to put a price tag on how much the extra inventory space is worth, and make the Recipe Factor cost that much.

There are a number of cases where you don't want to add any extra cost on, such as if the Product Item actually has (somewhat) less stats than the Ingredient Factors put together, or has a different effect. Also, if the number of Ingredients is large (say, 3+) the toll-taking effect of carrying around that many partially-useful items in your inventory might balance it out. Lastly, if some of the Ingredients do nothing on their own (maybe like Magic Dust in our example) you would not add price for the extra inventory slots gained by freeing up the spots where the useless items were. You would only add cost for the bonus given by that item.

(In the example, let's say Sword gives +10 damage and Magic Dust gives nothing. But put together, Magic Sword gives +10 damage and a Poison attack. You don't add anything for the inventory slots "freed" by combo-ing in Magic Dust, simply set the price of the stuff to however much a Poison attack is worth.)

(Just to demo the other end of the spectrum, if Sword gives +10 damage and Magic Dust gives Poison attack, and Magic Sword gives +10 damage and Poison attack...then you make Magic Dust cost the price of Poison attack, and the Magic Sword Recipe cost X gold, where X is the price you determine it's worth to free up an inventory slot by combining the two items.)

Manual Combine Setup
To create a Manual Combine recipe, the items you need are the Ingredient Factors, (once again, Sword and Magic Dust) a Mask Recipe, a Scroll Recipe, (made up terms, use whatever you like) and finally the actual item.

You may have noticed in DotA that in the shops, all of the recipes look like their component items. Yet when they are purchased without the sufficient Factors, they look like Scrolls in your inventory. I call the shop recipe the "Mask" and the inventory recipe the "Scroll". They are actually identical in every respect, including cost, except that one has the icon of the end product item and the other one has a scroll icon.

sangemask.jpg
An example from DotA of the "mask recipe", while in the shop. Looks like the Finished Item so that different recipes in the shop can be distinguished easily, and has a particular gold cost.

sangescroll.jpg
An example from DotA of the "scroll recipe", while in an inventory. Has a Scroll Icon to prevent the carrier for mistaking it for the actual item, and has the same gold cost as the "mask recipe" so that it can be sold back properly, if the owner doesn't end up using it.

The simple way this is triggered is that when you buy the Mask Recipe from the shop, it is instantly replaced with the Scroll Recipe version. The Scroll Recipe version is what is handled and checked for and whatnot in all of your Recipe Triggers. Since the prices of the two are the same, you can sell back the Scroll Recipe just as you would have the Mask Recipe. This method adds more baggage, but is simply more aesthetically pleasing and not confusing, either. (If you make the recipe look just like a Scroll, it will be hard to instantly see what you want in the shop. If you make the recipe look like the item in your inventory, it can confuse you into thinking you have the item.)

Then, when all the ingredients are put together and the Recipe is activated, remove it all and put in the end product item. I did consider simply having the Recipe be the end product and removing it if you did not have all the ingredients, but I realized that the sell-back price of the item would be half of the cost of the Recipe Factor, without taking into account the cost of the Ingredient Factors. So this is the best method.

sangefinished.jpg
An example from DotA of the End Product of the recipe. Note that the gold cost totals the cost of the entire recipe (give or take a tad) so that it can be sold back properly, and you are returned money for all of the ingredients.

Auto Combine Setup
Auto Combine setup is easier, you simply need the Mask Recipe since there's no Scroll Recipe to be had. When they get all the Ingredient Factors in their inventory, remove and add the End Product item, voila.

To make the Mask Recipe un-buyable, your best bet is to make it cost something the player doesn't have. The "cleanest" method is to make it cost (one) wood, but depending on your map that might not be feasible. Alternately, you could make it cost an impractical amount of gold, and if you wanted to be safe, set up a trigger so that whenever someone bought one of the Auto-Combine Mask Recipes, give 'em their money back and remove it.

perseverancemask.jpg
An example from DotA of the mask recipe of an Auto-Combine item, while in the shop. Looks like the Finished Item so that different recipes in the shop can be distinguished easily, and has no cost (they have special methods in DotA to do this, it actually costs lumber but the lumber icon has been toyed with).

perseverancefinished.jpg
An example from DotA of the End Product of an Auto-Combine recipe.

Manual Combine Triggers
Now we're getting to the meat of the matter. How do you actually do it? There are many specific methods and techniques and variations, all depending on what you really want. I'm not going to explore them all-that would take forever. Instead, I'm going to give you an example. This is one way a Manual Combine recipe could be done (and probably the way I would do it).

Mask2Scroll: Replacing the Mask Recipe with the Scroll Recipe.
GoP Mask2Scroll
Events
Unit - A unit Acquires an item
Conditions
(Item-type of (Item being manipulated)) Equal to Gloves of Power (Mask Recipe)
Actions
Item - Remove (Item being manipulated)
Hero - Create Recipe: Gloves of Power and give it to (Hero manipulating item)

Combine: Combining the items.
GoP Combine
Events
Unit - A unit Acquires an item
Conditions
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Gauntlets of Ogre Strength +3
(Item-type of (Item being manipulated)) Equal to Gloves of Haste
(Item-type of (Item being manipulated)) Equal to Recipe: Gloves of Power
((Hero manipulating item) has an item of type Gauntlets of Ogre Strength +3) Equal to True
((Hero manipulating item) has an item of type Gloves of Haste) Equal to True
((Hero manipulating item) has an item of type Recipe: Gloves of Power) Equal to True
Actions
Set Ingredients = 3
Set RecipeFactor[1] = Gauntlets of Ogre Strength +3
Set RecipeFactor[2] = Gloves of Haste
Set RecipeFactor[3] = Recipe: Gloves of Power
For each (Integer A) from 1 to Ingredients, do (Actions)
Loop - Actions
Set FactorCleared[(Integer A)] = False
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
For each (Integer B) from 1 to Ingredients, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to RecipeFactor[(Integer B)]
FactorCleared[(Integer B)] Equal to False
Then - Actions
Item - Remove (Item carried by (Hero manipulating item) in slot (Integer A))
Set FactorCleared[(Integer B)] = True
Else - Actions
Hero - Create Gloves of Power and give it to (Hero manipulating item)

Here we have the Gloves of Power with the Ingredient Factors of Gauntlets of Ogre Strength +3 & Gloves of Haste and a Recipe Factor.

You may note how I did a check for each type of item at the beginning of the trigger. It might be a good idea if you are going to do a lot of these to somehow assign them to array variables instead of checking each one specifically. There are several ways to do this, but that's a variation that's up to you.

Auto Combine Triggers
Auto-Combine in terms of triggers is almost identical to Manual Combine; Auto-Combine just doesn't need the Mask2Scroll trigger. Here is my example of an Auto-Combine trigger:

RoIS Combine
Events
Unit - A unit Acquires an item
Conditions
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Ring of Protection +2
(Item-type of (Item being manipulated)) Equal to Ring of Regeneration
((Hero manipulating item) has an item of type Ring of Protection +2) Equal to True
((Hero manipulating item) has an item of type Ring of Regeneration) Equal to True
Actions
Set Ingredients = 2
Set RecipeFactor[1] = Ring of Protection +2
Set RecipeFactor[2] = Ring of Regeneration
For each (Integer A) from 1 to Ingredients, do (Actions)
Loop - Actions
Set FactorCleared[(Integer A)] = False
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
For each (Integer B) from 1 to Ingredients, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to RecipeFactor[(Integer B)]
FactorCleared[(Integer B)] Equal to False
Then - Actions
Item - Remove (Item carried by (Hero manipulating item) in slot (Integer A))
Set FactorCleared[(Integer B)] = True
Else - Actions
Hero - Create Ring of Inner Strength and give it to (Hero manipulating item)

I reiterate that this is almost identical to the above Manual Combine trigger, it simply has one less ingredient though.

Now that we have a second trigger you can note some contrasts. I use the Ingredients integer variable and the RecipeFactor Item-Type Array variable to go along with For Loops and simply streamline the process and make it more efficient. You can take this to the next level as I mentioned earlier by saving all the data to variables in an Initialization trigger, and simply reading off those for everything, including the Trigger's Conditions.

In closing, I'd like to refer you to Diablo-dk's Recipe System that is here at Hive itself, in case you don't feel like triggering your own unique system.

Even if you use a premade system and don't design your own I hope you at least take away from this tutorial a good concept of the balance issues surrounding Item Recipes.

And for any of those that want to see the Demo Map I created for this tutorial, here it is: Item Recipes.w3x

Quote:
Originally Posted by GST_Nemisis View Post
toolbox describes the theory of item recipies very well but the triggers he shows are bugged and not effective in all situations. i would suggest using these two triggers:

Quote:
Originally Posted by Razorbrain View Post

Combination
Events
Unit - A unit Aquires an item
Conditions
((Triggering unit) has an item of type Item1) equal to True
((Triggering unit) has an item of type Item2) equal to True
((Triggering unit) has an item of type Recipe) equal to True
Actions
Item - Remove (Item carried by (Triggering unit) of type Item1)
Item - Remove (Item carried by (Triggering unit) of type Item2)
Item - Remove (Item carried by (Triggering unit) of type Recipe)
Hero - Create Weapon and give it to (Triggering unit)

this one by razorbrain can be used to automatically create an item when a unit picks up two items of a different type. with this trigger you must also have a recipie item, but if you remove the lines "((Triggering unit) has an item of type Recipe) equal to True" and "Item - Remove (Item carried by (Triggering unit) of type Recipe)" it will do it when the unit automatically when the unit aquires the items.

and:

Quote:
Originally Posted by GST_Nemisis View Post
Untitled Trigger 001
Events
Unit - A unit Acquires an item
Conditions
(Item-type of (Item being manipulated)) Equal to Claws of Attack +15
Actions
For each (Integer A) from 1 to 6, do (If ((Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to Claws of Attack +15) then do (Set ItemAmount = (ItemAmount + 1)) else do (Do nothing))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ItemAmount Equal to 2
Then - Actions
Hero - Drop (Item carried by (Hero manipulating item) of type Claws of Attack +15) from (Hero manipulating item)
Item - Remove (Last dropped item)
Hero - Drop (Item carried by (Hero manipulating item) of type Claws of Attack +15) from (Hero manipulating item)
Item - Remove (Last dropped item)
Hero - Create Crown of Kings +5 and give it to (Hero manipulating item)
Else - Actions
Set ItemAmount = 0
this can be used to turn two items of the same type into another item (for example Claws of Attack +15 + Claws of Attack +15 = Crown of Kings +5). this happens automatically but by adding the condition and action mentioned above you can make it require a recipie item. for this you need the integer variable ItemAmount.

Last edited by Wolverabid; 02-06-2008 at 10:23 PM.
Tooolbox is offline   Reply With Quote
Old 05-17-2007, 09:39 AM   #2 (permalink)
 
paskovich's Avatar

I am ghost
 
Join Date: Jul 2005
Posts: 942

paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)


This can be useful, BUT it does not cover how to make recipies. I mean the trigger part. If you don't want to complicate this tutorial with long triggers, you can attach a link to Diablo-dk's recipie system which is a child's play to implement and use, however, it is written in jass.
http://hiveworkshop.com/resources_new/spells/940/
__________________
Jimmy Eat World - Let It Happen
"I'm the evil one who said.
Gonna let everything just happen
like my chest, my ears are proud
The collision is such an ugly sound."
Vote for the Hive without mercy!
paskovich is offline   Reply With Quote
Old 05-19-2007, 08:31 PM   #3 (permalink)
 
Tooolbox's Avatar

User
 
Join Date: Jun 2004
Posts: 133

Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)


So far I have covered the theory of Recipes, I do plan on covering the triggers with my own set, given both as examples and in a map.

I may mention Diablo's recipe system as well, though.

Edit: Props to Wolverabid for showing me the ATTACH tag!

Bump: Triggers and map added. Would appreciate feedback or suggestions for more content. If there are none, this tutorial is done.
__________________
Clan TrCh @ US West

Completed, Near Complete, Or-At-Least-Playable Projects
Ninja Clans - Chain of Command - Unholy Frenzy

Want help with your GUI Triggers? (I'm still learning JASS slowly.) PM me! Rep is appreciated.
Tooolbox is offline   Reply With Quote
Old 05-20-2007, 11:14 AM   #4 (permalink)
 
paskovich's Avatar

I am ghost
 
Join Date: Jul 2005
Posts: 942

paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)paskovich has a spectacular aura about (124)


Perfect! ;) Good job!

Only one thing:
Quote:
In closing, I'd like to refer you to Diablo-dk's Recipe System ... in case you don't feel like doing your own recipes.
This may be confusing.. You CAN make your own recipes with that system. Perhaps, you should put a "trigger" or "system" word after "your own recipes".
-> "in case you don't feel like doing your own recipe triggers".
__________________
Jimmy Eat World - Let It Happen
"I'm the evil one who said.
Gonna let everything just happen
like my chest, my ears are proud
The collision is such an ugly sound."
Vote for the Hive without mercy!
paskovich is offline   Reply With Quote
Old 05-21-2007, 05:39 AM   #5 (permalink)
 
F4talWr4th's Avatar

The creator of LOGA!!!!!!
 
Join Date: Aug 2006
Posts: 129

F4talWr4th has little to show at this moment (15)F4talWr4th has little to show at this moment (15)


Yes, useful but some people don't want their recipes to be combined automatically and it is possible by using an ability bar of course.
__________________


I LOVE CLANNAD!!! "Plays Death Metal Music!!"
F4talWr4th is offline   Reply With Quote
Old 05-21-2007, 05:28 PM   #6 (permalink)
 
Tooolbox's Avatar

User
 
Join Date: Jun 2004
Posts: 133

Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)Tooolbox has little to show at this moment (22)


@ Paskovich, Thanks! :) I fixed the wording in regards to Diablo-dk's system.

@ FatalWrath, People don't want their recipes to be combined automatically? I went over both Manual Combine and Auto-Combine. Are you referring to something I'm going to dub Ability-Combine, such as having all the ingredients and then using an ability to fuse them? If you think it's really that important I may insert a how-to in that department, but it would be good if you could be more specific as to what you mean.
__________________
Clan TrCh @ US West

Completed, Near Complete, Or-At-Least-Playable Projects
Ninja Clans - Chain of Command - Unholy Frenzy

Want help with your GUI Triggers? (I'm still learning JASS slowly.) PM me! Rep is appreciated.
Tooolbox is offline   Reply With Quote
Old 05-23-2007, 11:15 AM   #7 (permalink)
 
Diablo-dk's Avatar

Shifting voidwalker!
 
Join Date: Nov 2004
Posts: 452

Diablo-dk has a spectacular aura about (128)Diablo-dk has a spectacular aura about (128)Diablo-dk has a spectacular aura about (128)Diablo-dk has a spectacular aura about (128)


For the best RPG recipe system use http://www.wc3campaigns.net/showthread.php?t=87309 though this does require the newest version of CSCache(Requires jasshelper)

Also, you may want to fix this:
when you create a recipe with 2 or more of the same item type it will bug.
__________________
Need an easy Recipe System for your map?
Wonder what is inside the Spellbook?
Check my Cinematic!

Vote for the hive, the most friendly wc3 website.
Diablo-dk is offline   Reply With Quote
Old 06-09-2007, 03:15 PM   #8 (permalink)
 
Razorbrain's Avatar

Awaiting WAR
 
Join Date: Aug 2006
Posts: 1,108

Razorbrain is on a distinguished road (65)Razorbrain is on a distinguished road (65)


maybe just like this?

Combination
Events
Unit - A unit Aquires an item
Conditions
((Triggering unit) has an item of type Item1) equal to True
((Triggering unit) has an item of type Item2) equal to True
((Triggering unit) has an item of type Recipe) equal to True
Actions
Item - Remove (Item carried by (Triggering unit) of type Item1)
Item - Remove (Item carried by (Triggering unit) of type Item2)
Item - Remove (Item carried by (Triggering unit) of type Recipe)
Hero - Create Weapon and give it to (Triggering unit)
__________________
Current Project : War of the Factions 3.0
http://www.hiveworkshop.com/forums/s...ad.php?t=43670
Sig Updated : October 17th
Total Progress : 100%
Razorbrain is offline   Reply With Quote
Old 09-10-2007, 04:14 PM   #9 (permalink)