|
|
#1 |
|
My vision is augmented
MDL & Resource Moderator
|
---
__________________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
![]() Actions
![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)
![]() ![]() ![]() If - Conditions
![]() ![]() ![]() ![]() ((Hero manipulating item) has an item of type Potion of Healing (Non-Runic)) Equal to True
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: 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 = 0Trigger: For each (Integer A) from 1 to 6, do (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: 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. 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 |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
User
Join Date: Feb 2005
Posts: 231
|
I stopped reading after the first half. This seems to be way too complicated triggering for such a simple thing.
|
|
|
|
|
|
#3 |
|
My vision is augmented
MDL & Resource Moderator
|
It's complicated because it covers all eventualities. Obviously you missed that bit.
__________________ |
|
|
|
|
|
#4 |
|
User
Join Date: Feb 2005
Posts: 231
|
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.
|
|
|
|
|
|
#5 |
|
My vision is augmented
MDL & Resource Moderator
|
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.
__________________ |
|
|
|
|
|
#6 | |
|
User
Join Date: Feb 2006
Posts: 46
|
Quote:
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 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. |
|
|
|
|
|
|
#7 |
|
My vision is augmented
MDL & Resource Moderator
|
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. |
|
|
|
|
|
#8 |
|
User
Join Date: Nov 2003
Posts: 4
|
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
|
|
|
|
|
|
#9 |
|
User
Join Date: Mar 2006
Posts: 1
|
I had empty inventory, tried to pick a runic potion, and got the message- "Hero has full health."
|
|
|
|
|
|
#10 |
|
My vision is augmented
MDL & Resource Moderator
|
The "runic" items are supposed to have no ability. You must have forgotten to remove the healing ability.
__________________ |
|
|
|
|
|
#11 |
|
User
Join Date: Feb 2006
Posts: 4
|
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? |
|
|
|
|
|
#12 |
|
My vision is augmented
MDL & Resource Moderator
|
No, not one per player. Just change the event to a generic unit acquires item.
__________________ |
|
|
|
|
|
#13 |
|
Lol I got a custom title!
Join Date: Aug 2004
Posts: 1,231
![]() ![]()
|
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)
__________________ |
|
|
|
|
|
#14 |
|
My vision is augmented
MDL & Resource Moderator
|
Only ttem types that have a trigger will stack; so if he makes a stackable Crown of Kings, that's up to him! :P
__________________ |
|
|
|
|
|
#15 |
|
User
Join Date: Mar 2007
Posts: 9
|
this just makes it more complicated than it needs to be
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |