HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Counting Items

03-19-2006, 01:47 AM#1
Pheonix-IV
What i'm after is a trigger that checks every hero's inventory for certain items, then does certain things depending on what items it finds. Now thats all fine and dandy, but for some reason the trigger seems to be doing the action too many times.

What i have atm is this:

Code:
For each (Integer A) from 1 to 6, do (Actions)
    Loop - Actions
        Unit Group - Pick every unit in Heroes and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) has an item of type Ariafrost) in slot (Interger A)
                    Then - Actions
                        Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 25.00)
                    Else - Actions
                        Do nothing

And this works, sort of, it seems to do that action once for every hero in the group, So if theres 5 heros, and one of them is holding Ariafrost, he gets +125 Mana instead of just 25.

So i need another way to count the number of items of a certain type that a hero is holding and then do something based on that number. I've done it before, and its really annoying me that i can't remember how i did it last time, so any help would be appriciated.
03-19-2006, 01:53 AM#2
Vexorian
I think you should reverse the order:
Trigger:
Unit Group - Pick every unit in Heroes and do (Actions)
Collapse Loop - Actions
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) has an item of type Ariafrost) in slot (Interger A)
Collapse Then - Actions
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 25.00)
Collapse Else - Actions
Do nothing
03-19-2006, 02:01 AM#3
Pheonix-IV
That appears to work, thanks Vex. Guess i got the order mixed up.