• 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.

[Solved] How to select all the hero units controlled by all players?

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
This is probably what you're looking for. Claws of Attack is just whatever Item you're looking for. I assumed you wanted to give it to them if they don't have it. That's the purpose of the Boolean and the If

EDIT:


  • Actions
    • Do Multiple ActionsFor each (Integer TempInteger) from 1 to 12, do (Actions)
      • Loop - Actions
        • Set TempBoolean = False
        • Set TempPlayer = (Player(TempInteger))
        • Set TempGroup = (Units owned by TempPlayer matching ((((Matching unit) is A Hero) Equal to (==) True) and (((Matching unit) has an item of type Claws of Attack +15) Equal to (==) True)))
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempGroup is empty) Equal to (==) True
            • Then - Actions
              • Set TempBoolean = True
            • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempBoolean Equal to (==) True
            • Then - Actions
            • Else - Actions
              • Set TempUnit = (Random unit from TempGroup)
              • Hero - Create Claws of Attack +15 and give it to TempUnit
        • Custom script: call DestroyGroup(udg_TempGroup)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Using this, all units with the item are in the unit group.
  • Untitled Trigger 112
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Custom script: if GetHandleId(GetTriggerEventId()) == 49 then
      • Unit Group - Add (Triggering unit) to group
      • Custom script: else
      • Unit Group - Remove (Triggering unit) from group
      • Custom script: endif

Dead units can have items...
 
Level 11
Joined
Oct 11, 2012
Messages
711
This is probably what you're looking for. Claws of Attack is just whatever Item you're looking for. I assumed you wanted to give it to them if they don't have it. That's the purpose of the Boolean and the If

EDIT:


  • Actions
    • Do Multiple ActionsFor each (Integer TempInteger) from 1 to 12, do (Actions)
      • Loop - Actions
        • Set TempBoolean = False
        • Set TempPlayer = (Player(TempInteger))
        • Set TempGroup = (Units owned by TempPlayer matching ((((Matching unit) is A Hero) Equal to (==) True) and (((Matching unit) has an item of type Claws of Attack +15) Equal to (==) True)))
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempGroup is empty) Equal to (==) True
            • Then - Actions
              • Set TempBoolean = True
            • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempBoolean Equal to (==) True
            • Then - Actions
            • Else - Actions
              • Set TempUnit = (Random unit from TempGroup)
              • Hero - Create Claws of Attack +15 and give it to TempUnit
        • Custom script: call DestroyGroup(udg_TempGroup)
Thanks, that helped. :)

Using this, all units with the item are in the unit group.
  • Untitled Trigger 112
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Custom script: if GetHandleId(GetTriggerEventId()) == 49 then
      • Unit Group - Add (Triggering unit) to group
      • Custom script: else
      • Unit Group - Remove (Triggering unit) from group
      • Custom script: endif

Dead units can have items...
Thanks a lot. This is better than the method I am using right now, which is to check all the units within a certain range. LOL

Edit:
@Maker, after further looked into your code I got a question: is the first custom script an unfinished line? Why use "GetHandleId(...) ==49"? Does it point to the first event ---> a unit acquiring an item?
 
Status
Not open for further replies.
Top