• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] Detecting 2 or more items of same type carried by unit

Status
Not open for further replies.
Hello, dear Hivers :D

As title says, is there a way to check if hero/unit carries 2 same items in it's invertory, I know it does, I just can't figure it out.

Any ideas how to manage that?

Note:
Using two different variables for two same items, will result as there is only one item of that type in invertory, not as two. (I tried, it doesn't work) Seems WE just takes it as same :<

Thanks!

~Berz
 
You could check for the item you want, remove it and then check for more same items. In the end you can return them all.
 
What I meant was
You check than an item exists. If it does then remove it and set counter=counter+1
Repeat with a loop until the hero has no more items of the same type.
Counter is the number of these items your hero had at start so in the end you can give them all back.
:thumbs_up:
 
  • Actions
    • Set tmp_unit = YOUR UNIT
    • 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 carried by tmp_unit in slot (Integer A)) Not equal to No item
            • (Item-type of (Item carried by tmp_unit in slot (Integer A))) Equal to Tome of Experience
          • Then - Actions
            • Set itemTOME = (itemTOME + 1)
          • Else - Actions
Then if itemTOME is equal to 2 or more the hero has two or more of the tome in his inventory. I think this would work.
 
Hmm... Thanks you two, I'll check it out :D

Edit:

Make it [Solved]

And for those who would like to know more about this...

  • Pendant of Energy
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set Item_Owner = (Triggering unit)
      • Set Item1 = Pendant of Mana
      • Set Item2 = Pendant of Energy
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item_Owner has an item of type Item1) Equal to True
        • Then - Actions
          • Set Item_Counter = (Item_Counter + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_Counter Equal to 2
        • Then - Actions
          • Do your stuff
          • Set Item_Counter = 0
        • Else - Actions
Remember to do this at the end: Set Item_Counter = 0
 
Last edited:
A bit offtopic:
Check item classification is better if you only need a weapon/armor/misc item system(one per type on hero at 1 time)
 
Just because I had some time, I created a trigger that checks for any two of the same items, no need to specify the item type.

  • Untitled Trigger 003 Copy
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set itemOwner = (Hero manipulating item)
      • Set itemType = (Item-type of (Item being manipulated))
      • For each (Integer loopA) from 1 to 5, do (Actions)
        • Loop - Actions
          • For each (Integer loopB) from 2 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 itemOwner in slot loopA)) Equal to (Item-type of (Item carried by itemOwner in slot loopB))
                  • (Item-type of (Item carried by itemOwner in slot loopA)) Equal to itemType
                  • loopA Not equal to loopB
                • Then - Actions
                • Else - Actions
You can break out of the loop by setting loopA = 5 and loopB = 6 at the "Then" branch to save some CPU time, or jump out of the trigger by using "Skip remaining actions".

Maybe it will be useful for someone one day :D
 
Status
Not open for further replies.
Back
Top