- Joined
- Jun 1, 2007
- Messages
- 98
ITEM STACKING TUTORIAL
There have been so many questions regarding the combining and/or stacking of items so i decided to make a tutorial!
1] Start
- Create a blank map
- Make a hero inside it
- Make 3 (or more) of the same item near the hero.
2] Stacking Items
- The triggers used for this are not complex. In fact, it is easier than most things.
Basically, what you have to do is to check if the player has an item in his inventory that is the same as the item he picked up. If he does then it stacks the item, otherwise it just.. does nothing and gives the item as normal.
-
Stack
-
Events
- Unit - A unit Acquires an item
-
Conditions
- ((Hero manipulating item) has an item of type (Item-type of (Item being manipulated))) Equal to True
- (Item being manipulated) Not equal to (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))
-
Actions
- Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
- Hero - Drop (Item being manipulated) from (Hero manipulating item)
- Item - Remove (Item being manipulated)
-
Events
-
Events
- Unit - A unit Acquires an item
-
Conditions
- ((Hero manipulating item) has an item of type (Item-type of (Item being manipulated))) Equal to True
- (Item being manipulated) Not equal to (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))
-
Actions
- Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
- Hero - Drop (Item being manipulated) from (Hero manipulating item)
- Item - Remove (Item being manipulated)
The second line makes the hero drop the item he just picked up and the third one removes it!
And you're finished! Now any items you pick up will be automatically stacked.
The only problem is if you want to unstack the items.
How would you do that?
Well, you could, for example make a trigger which takes half the charges in the chosen slot and drops that many. The problem is that it can become odd numbers and you can't have half an item... The WE automatically rounds it down so you lose 1 charge.
-
Unstack
-
Events
- Player - Player 1 (Red) types a chat message containing -unstack as A substring
- Player - Player 2 (Blue) types a chat message containing -unstack as A substring
- Player - Player 3 (Teal) types a chat message containing -unstack as A substring
- Player - Player 4 (Purple) types a chat message containing -unstack as A substring
- Player - Player 5 (Yellow) types a chat message containing -unstack as A substring
- Player - Player 6 (Orange) types a chat message containing -unstack as A substring
- Player - Player 7 (Green) types a chat message containing -unstack as A substring
- Player - Player 8 (Pink) types a chat message containing -unstack as A substring
- Player - Player 9 (Gray) types a chat message containing -unstack as A substring
- Player - Player 10 (Light Blue) types a chat message containing -unstack as A substring
- Player - Player 11 (Dark Green) types a chat message containing -unstack as A substring
- Player - Player 12 (Brown) types a chat message containing -unstack as A substring
- Conditions
-
Actions
- Set HeroPos = (Position of Hero[(Player number of (Triggering player))])
- Set Slot = (Integer((Substring((Entered chat string), 10, 10))))
- Set Charges = ((Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot Slot)) / 2)
- Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot Slot) to Charges
- Item - Create (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot Slot)) at HeroPos
- Item - Set charges remaining in (Last created item) to Charges
- Custom script: call RemoveLocation(udg_HeroPos)
-
Events
Example map:
Attachments
Last edited: