• 🏆 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 Items Trigger

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2008
Messages
243
So, here's what I'm getting at. I want players to be able to stack potions, but I dont want the stack to exceed 10 charges. Here's how I'm doing.
  • LesserHealingPotion
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to [|cff7777aaLvl 1|r] Lesser Healing Potion
    • 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
              • Or - Any (Conditions) are true
                • Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Equal to 10
            • Then - Actions
              • Do nothing
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
                  • (Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)
                • Then - Actions
                  • Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item being manipulated)))
                  • Item - Remove (Item being manipulated)
                • Else - Actions
 
  • Max10
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Charged
    • 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
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
              • (Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) Less than 10
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Triggering unit) in slot (Integer A)))) Less than or equal to 10
                    • Then - Actions
                      • Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item being manipulated)))
                      • Item - Remove (Item being manipulated)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
Here is the test map: View attachment Max10 Charges.w3x
 
Level 9
Joined
May 22, 2009
Messages
276
correct me if I'm wrong, but I think you have to set max charges to 10 in object editor, then when you buy the item set the charge to one, and have a trigger to stack the items, I remember when I first tried this and add charges to an item with no charges, or even less then the max I wanted it to have it crashed my game

I gonna find my charging trigger and post it here

EDIT: nvm pharaoh beat me to it, DAMN U!!!! j/k
 
Level 7
Joined
Dec 8, 2008
Messages
243
The Pharaoh_ has spoken. *bows*
Thanks, friend. Hopefully I can easily apply to this to work for one single item.

[edit] yup, got it working for singular items. Hats off for you Pharaoh and thanks for taking an interest, Skamigo. :)
 
Status
Not open for further replies.
Top