• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Stacking item problems

Status
Not open for further replies.
Level 4
Joined
Aug 12, 2004
Messages
76
umm can someone tell me why this trigger won't work? It's for stacking items.

The life of item will be the max charge.
If the charge of item + item in inventory < life, add them together
If they are greater and item in inventory < life, set item in inventory to life, and subtract the difference of two from item being manipulated.
If not, do nothing.

However, it just removes the item being manipulated.

  • Stacking
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Charged
    • Actions
      • For each (Integer Item_Cycle[(Player number of (Owner of (Hero manipulating item)))]) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • ((Hero manipulating item) has (Item being manipulated)) Equal to True
                  • (Item being manipulated) Equal to (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))])
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))])) + (Charges remaining in (Item being manipulated))) Less than or equal to (Integer((Current life of (Item being manipulated))))
                • Then - Actions
                  • Item - Set charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))]) to ((Charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))])) + (Charges remaining in (Item being manipulated)))
                  • Item - Remove (Item being manipulated)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))])) Less than (Integer((Current life of (Item being manipulated))))
                    • Then - Actions
                      • Item - Set charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of (Hero manipulating item)))]) to (Integer((Current life of (Item being manipulated))))
                      • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) - ((Integer((Current life of (Item being manipulated)))) - (Charges remaining in (Item carried by Hero_Type[(Player number of (Owner of (Hero manipulating item)))] in slot Item_Cycle[(Player number of (Owner of
                    • Else - Actions
                      • Do nothing
            • Else - Actions
              • Do nothing
 
Last edited by a moderator:
Level 4
Joined
Aug 12, 2004
Messages
76
well i only added the array loop since my Hero_type variable is also array. Which I think means that I would have to make the cycle an array too... to make thing pick the right hero.

Well, yeah it won't even go in my inventory, even when i have nothing in my inventory, it just disappears.
 
Level 10
Joined
Sep 21, 2007
Messages
517
man, item stacking is extremely easy, you are making it way more complicated than it is, i mean i just posted a thread which had a item stacking system that i did almost two months ago but i told mods to delete it since i didnt think anybody needed an item stacking system( how convinient :D), ok this is how you should do it, btw this also works if you pick an item, just do it this way:
  • Events
    • Unit - A unit Acquires an item
  • Conditions
    • (Charges remaining in (Item being manipulated)) Not equal to 0
  • Actions
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))) Greater than 0
            • (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))) Less than MaxStack
            • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
            • (Item carried by (Hero manipulating item) in slot (Integer A)) Not equal to (Item being manipulated)
          • Then - Actions
            • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A)) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))) + Charges Remaining in Item Being Manipulated)
            • Item - Remove (Item being manipulated)
          • Else - Actions
            • Do nothing
MaxStack is the maximum amount of charges you want that an item can have, i suggest you make all your charged item types, have one charge so you can avoid any bugs by item charges surpassing the limit, i can make a method of debugging items but that would require setting the costs of each item in a variable array, well i gotta go later !
 
Level 4
Joined
Aug 12, 2004
Messages
76
well, the only problem is that in my map, there is going to be items with multiple charges so i can't use yours. Thank you though.

Edit: But, thanks to your trigger I found out what the mistake was! Thank you very much! ^^
 
Last edited:
Status
Not open for further replies.
Top