• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Stacking of items?

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
Wondering if this is an already premade function of some sort or if it requires triggering.

I've got an item that sends out little shards that does damage to nearby units and structures.

With more than 2 of these tops it does too much damage to the enemy your fighting. So I need to cap it at 2 max.

My ideal solution is to allow the purchase of 2+ of these items, but somehow remove the ability from the extra same item bought.

Like

1 has ability
2nd has ability
3rd doesnt
4th doesnt
etc

Is this simple or require triggering?

If it requires triggering how should I go about this, right now in my mind all I can think is

Detect if ring item is bought, add it to a variable. Check if unit has more than 2 rings via variable, and if he drops the item remove from variable, if he picks it up add to the variable, if he sells remove from the variable.

And if the variable has more than 2, I somehow remove the ability from one or more of the items. This just seems messy, I know it will be. Is there a better way to go about this?
 
Level 13
Joined
Oct 12, 2016
Messages
769
It'll require triggering. The easiest way to do this is to make 2 versions of the same item:
1 with the ability, 1 without.
As for triggers, you will need 2 separate triggers, 1 for acquiring the item:
  • Acquired Item Limit
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Apple
    • Actions
      • Set TempInt = 0
      • 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 Apple
            • Then - Actions
              • Set TempInt = (TempInt + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Greater than or equal to 3
        • Then - Actions
          • Item - Remove (Item being manipulated)
          • Hero - Create Bananas and give it to (Triggering unit)
        • Else - Actions
And 1 for losing/selling the item:
  • Lose Limited Item
    • Events
      • Unit - A unit Loses an item
      • Unit - A unit Pawns an item (to shop)
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Apple
    • Actions
      • Set TempInt = 0
      • ...
 
Last edited:
Level 12
Joined
Dec 2, 2016
Messages
733
Ok I gotcha, but when losing the item. Set TempInt should be TempInt = TempInt - 1 and not set to 0 right? What if he had 5 of the item. Loses 1 it gets set to 0, he picks it up again and has 5. The "greater than or equal to 3 will be wrong right?
 
Level 13
Joined
Oct 12, 2016
Messages
769
Losing an item is where it gets tricky. What if it's one of the dummy items?
You will still have to count each item (TempInt = TempInt +1), but also consider the number of dummy items and real items.

Let's say you have 2 "Apples" and 1 "Banana", but then you drop an "Apple." You'll need to count the number of both of these, then remove a "Banana" to add another "Apple."
 
Level 12
Joined
Dec 2, 2016
Messages
733
Ok so I've got my acquires ring.
  • Ring
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Item-type of (Item being manipulated)) Equal to Ring of the Hell Lords) or ((Item-type of (Item being manipulated)) Equal to Fake Ring)
    • Actions
      • Set TempInt = 0
      • 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 Ring of the Hell Lords
            • Then - Actions
              • Set TempInt = (TempInt + 1)
            • Else - 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
              • TempInt Greater than or equal to 3
            • Then - Actions
              • Item - Remove (Item being manipulated)
              • Hero - Create Fake Ring and give it to (Triggering unit)
            • Else - Actions
And then loses ring

  • Losing Ring
    • Events
      • Unit - A unit Loses an item
      • Unit - A unit Pawns an item (to shop)
    • Conditions
    • Actions
      • Set RingInt = 0
      • Set LoseRingInt = 0
      • 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 Ring of the Hell Lords
            • Then - Actions
              • Set RingInt = (RingInt + 1)
              • Game - Display to (All players) the text: (String(RingInt))
            • Else - 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 Fake Ring
            • Then - Actions
              • Set LoseRingInt = (LoseRingInt + 1)
              • Game - Display to (All players) the text: (String(LoseRingInt))
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (RingInt Equal to 1) and (LoseRingInt Greater than or equal to 1)
        • Then - 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 Fake Ring
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                  • Game - Display to (All players) the text: Giving
                  • Hero - Create Ring of the Hell Lords and give it to (Triggering unit)
                • Else - Actions
        • Else - Actions

No matter what I do, for some reason it only replaces the fake ring when I have only 1 fake ring in inventory and drop it.

I've got two variables. When it detects only 1 real ring it adds +1 to that variable. If it detects 1 fake ring or more it adds to that variable. Then it checks if the real ring variable = '1' and the fake ring variable >= 1. Go through the inventory remove the fake ring and add a real ring. But doesn't work, I can't figure out why. Would you be able to assist me? Thanks.
 
Status
Not open for further replies.
Top