wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > Trigger (GUI)/ AI editor Tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-11-2006, 11:08 AM   #1
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default RDZ's Item Stacking System of Doom

---
RDZ's Item Stacking System
---

Item stacking is a nasty business. And since I've been grappling with it recently for my All-In-One Micro Map, I thought it good to pass on my findings in the form of a pleasant little tutorial.

What you need:
- Basic triggering knowledge
- Basic item editing knowledge

For your stacking item, you need two items - a "runic" one (Stats - Use Automatically When Acquired = True) and a "non-runic" one (Stats - Use Automatically When Acquired = False). Now, the player will be interacting with both of these in slightly different ways, so the same name is probably essential. However, the Item Editor lacks an "Editor - Suffix" field, so to avoid confusion give both versions different names and change them back when you're finished. Why? Well, with a runic item, even when your inventory is full, you'll still be able to stack.

Now, you can create a very simple item stacking system thus:


Trigger:
Stacking HealPotion
Collapse Events
Unit - A unit owned by Player 1 (Red) Acquires an item
Collapse Conditions
(Item-type of (Last created item)) Equal to Potion of Healing (Runic)
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Hero manipulating item) has an item of type Potion of Healing (Non-Runic)) Equal to True
Collapse Then - Actions
Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Potion of Healing (Non_Runic)) to ((Charges remaining in (Item carried by (Hero manipulating item) of type Potion of Healing(Non-Runic))) + 1)
Collapse Else - Actions
Hero - Create Potion of Healing (Non-Runic) and give it to (Hero manipulating item)

For those of you unable to read triggers outside the editor (like me), this fires when the hero picks the rune (which handily disappears), then checks to see if the hero has the inventory (non-runic) version of the potion. If he/she/it does have the non-runic potion, then add one charge to it, if not, then create a non-runic potion. Done. If you can't be bothered catering for acquisition of the non-runic version, the buck stops here. If you want a totally fool-proof system, keep reading.

So, what if the player has a full inventory and no non-runic potion to add to? We get a nice non-runic potion deposited on the ground. Oh oh. In the heat of battle, the hero might pick up the runic version somewhere else after dropping something, and later go back to that initially dropped non-runic potion - argh, we've got two stacks! This can be very nasty if you've dropped a large stack in a stash or backpack and forgotten about it, then built up a new stack. Maybe two heroes have two different stacks, and one wants to give its stack to the other - again, two large stacks. This might not happen too often, but it's an inconvenience for the poor player.

So we need something a little more complex. Note that in a multiplayer, or even multihero environment, you may need to resort to local variables and jass and all that madness. But we don't like that, so I'll stick to the easy version.

For this you will need two variables. These will hold the number of non-runic potions you have (I'll get to that later) and one to hold the number of charges in the newly acquired item. For this example: Item_TempPotionCount and Item_TempChargeCount.

First of all, the trigger must respond to an item being acquired. The item must be either of the two versions of the stackable item.

Trigger:
Potion Stacking Heal
Collapse Events
Unit - A unit owned by Player 1 (Red) Acquires an item
Collapse Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
(Item-type of (Item being manipulated)) Equal to Potion of Healing (Runic)
(Item-type of (Item being manipulated)) Equal to Potion of Healing (Non-Runic)
Actions
Now, we get down to the hard-core bit.
We must make sure our temporary variables are reset to avoid spillage from previous trigger executions. At this stage, you'd be initialising your local variables.
Trigger:
Set Item_TempPotionCount = 0
Set Item_TempChargeCount = 0
Now, we must discover how many non-runic potions we have to decide what sort of stacking to do. This loop checks every inventory slot the hero has (NOTE: you can use "1 to Unit - Size of Inventory" for the loop condition if you're messing with many different heroes with different inventory sizes) for Potions of Healing that are Non-Runic. If it finds one, it adds 1 to the counter.

Trigger:
For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to Potion of Healing
Collapse Then - Actions
Set Item_TempPotionCount = (Item_TempPotionCount + 1)
Else - Actions

So we know how many non-runic potions we have. This means we know what the hero has just acquired and what he/she/it already has. If we currently have 2 non-runic potions, then the hero has a stack and has picked up another one. So we take the number of charges in the new stack and remove it.

Trigger:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Item_TempPotionCount Equal to 2
Collapse Then - Actions
Set Item_TempChargeCount = (Charges remaining in (Item being manipulated))
Item - Remove (Item being manipulated)
Else - Actions
Simple. Now, in that "else" section we must add another IF - if we have only one runic potion (the else section here houses what happens when we have 0 non-runic potions). And within this IF we need another one. Because here there is ambiguity - did the Hero acquire a rune and have a stack already, or did the hero have nothing and pick up a stack? Just check if he picked up a runic potion. If this is true, then set the number of charges. Leave this "else" section blank, because if you've just picked up a stack it's got all its charges.
And finally, if TempPotionCount is not 2 and it's not 1 either, it's 0. So we create a non-runic potion for the hero, and again leave TempChargeCount at 0.

Trigger:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Item_TempPotionCount Equal to 1
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of (Item being manipulated)) Equal to Potion of Healing
Collapse Then - Actions
Set Item_TempChargeCount = (Charges remaining in (Item being manipulated))
Else - Actions
Collapse Else - Actions
Hero - Create Potion of Healing and give it to (Hero manipulating item)

And our last action is to add on the charges to the item we have. If you have just been given a new item or picked a stack, then TempChargeCount is 0; so 0 charges will be added to the item's default.

Trigger:
Item - Set charges remaining in (Item carried by (Hero manipulating item) of type Potion of Healing) to ((Charges remaining in (Item carried by (Hero manipulating item) of type Potion of Healing)) + Item_TempChargeCount)

So there you go. A simpler-than-it-looks way of stacking items that accounts for all eventualities. Just in case all that passed you by, here's a simple algorithm anybody should be able to understand without my rambling:

0. Initialise variables: TempPotionCount and TempChargeCount to 0.
1. Establish how many non-runic potions we have in the hero's inventory.
2. If we have 2, we've picked a stack while we have a stack - set charges and remove the picked item.
3. If we have 1,
4. If we picked a rune while we have a stack - set charges.
5. Else we picked a stack off the ground - do nothing.
6. If we have 0, we've picked a rune while we have no stack - create a non-runic potion.
7. Add the number of charges onto the non-runic potion in the inventory.

Thank you, and good night.

RDZ
__________________
Rao Dao Zao is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-13-2006, 04:36 AM   #2
MercyfulJester
User
 
Join Date: Feb 2005
Posts: 231

MercyfulJester is on a distinguished road (20)

Default

I stopped reading after the first half. This seems to be way too complicated triggering for such a simple thing.
MercyfulJester is offline   Reply With Quote
Old 02-13-2006, 10:40 AM   #3
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

It's complicated because it covers all eventualities. Obviously you missed that bit.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 02-13-2006, 07:31 PM   #4
MercyfulJester
User
 
Join Date: Feb 2005
Posts: 231

MercyfulJester is on a distinguished road (20)

Default

Well, I don't see any point in making two separate items, except that you can pick up those power ups even with a full inventory. But you still can't pick up those "actual" items, making the system seem a bit odd to those playing the map without any clue about the triggers and the system.
MercyfulJester is offline   Reply With Quote
Old 02-14-2006, 10:24 AM   #5
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Covers all eventualities. The chances of a stack hitting the ground should be very low, but it is still necessary to take account of the possibility. Nine times out of ten, the player will be acquiring the runic version and will suspect nothing.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 02-14-2006, 11:28 AM   #6
Erdrik
User
 
Join Date: Feb 2006
Posts: 46

Erdrik has little to show at this moment (5)

Default

Quote:
Rao Dao Zao
Note that in a multiplayer, or even multihero environment, you may need to resort to local variables and jass and all that madness. But we don't like that, so I'll stick to the easy version.

For this you will need two variables. These will hold the number of non-runic potions you have (I'll get to that later) and one to hold the number of charges in the newly acquired item. For this example: Item_TempPotionCount and Item_TempChargeCount.

mmm You can do this in a multiplayer environment without jass.
Just make Item_TempPotionCount and Item_TempChargeCount arrays with a size of 12. Then :
Code:
Item_TempChargeCount[(Player Number of (Owner of Unit(Hero Manipulating Item)))]
Item_TempChargeCount[(Player Number of (Owner of Unit(Buying Unit)))]
This will make a slot in the array for each player that should never be messed with due to other players manipulating items at the same (or near same) time.
This won't acount for when a player has more than one hero, but the odds of a single player manipulating items with two different heros at the same time are pretty slim.

Just thought I'd add that in. If you find a flaw in my thought please tell me as I'd rather be wrong and correct my mistakes than live in ignorance.
Also... how did you do the trigger tags?

Last edited by Erdrik : 02-14-2006 at 11:31 AM.
Erdrik is offline   Reply With Quote
Old 02-14-2006, 12:19 PM   #7
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Hmm, good point on the variables.

Trigger tags are just [*trigger] and [*/trigger] (without *s). They don't seem to be anywhere on the interface, though. Just wrap those around any text.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 02-24-2006, 06:27 PM   #8
Doctor-Pepper
User
 
Join Date: Nov 2003
Posts: 4

Doctor-Pepper has little to show at this moment (0)

Default

Hmm, once i created a simular inventory system but with unlimited item combine system and 3 pages of inventory = 15 inventory slots. Everything with gui and all u needed to do to import it was to created the equeled named variabels. Maybe ill import it one day
Doctor-Pepper is offline   Reply With Quote
Old 03-02-2006, 05:58 PM   #9
asdfghjkl
User
 
Join Date: Mar 2006
Posts: 1

asdfghjkl has little to show at this moment (0)

Default

I had empty inventory, tried to pick a runic potion, and got the message- "Hero has full health."
asdfghjkl is offline   Reply With Quote
Old 03-02-2006, 06:19 PM   #10
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

The "runic" items are supposed to have no ability. You must have forgotten to remove the healing ability.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 04-28-2006, 08:25 PM   #11
Ryuu
User
 
Join Date: Feb 2006
Posts: 4

Ryuu has little to show at this moment (0)

Default

You mean that I need to make one of trigger for each item and each player that acquires this item?
Doesn't that seem quite...much?
Ryuu is offline   Reply With Quote
Old 04-28-2006, 09:00 PM   #12
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

No, not one per player. Just change the event to a generic unit acquires item.
__________________
Rao Dao Zao is offline   Reply With Quote
Old 05-02-2006, 02:44 PM   #13
Thunder_Eye
Lol I got a custom title!
 
Thunder_Eye's Avatar
 
Join Date: Aug 2004
Posts: 1,231

Thunder_Eye has a spectacular aura about (88)Thunder_Eye has a spectacular aura about (88)Thunder_Eye has a spectacular aura about (88)

Default

He'll also have to add a check if the item is consumable or not (you cant stack non-consumable ones like crown of kings)
__________________
Thunder_Eye is offline   Reply With Quote
Old 05-02-2006, 05:35 PM   #14
Rao Dao Zao
www.raodaozao.net
 
Rao Dao Zao's Avatar


MDL & Resource Moderator
 
Join Date: Aug 2003
Posts: 2,441

Submissions (27)

Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)Rao Dao Zao has a brilliant future (817)

Approved Map: When the Freedom Slips Away

Send a message via MSN to Rao Dao Zao
Default

Only ttem types that have a trigger will stack; so if he makes a stackable Crown of Kings, that's up to him! :P
__________________
Rao Dao Zao is offline   Reply With Quote
Old 08-08-2007, 06:56 PM   #15
darkchaos11
User
 
darkchaos11's Avatar
 
Join Date: Mar 2007
Posts: 9

darkchaos11 has little to show at this moment (0)

Default

this just makes it more complicated than it needs to be
darkchaos11 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:24 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services