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

[Trigger] Checking if region has non-hero units owned by player

Status
Not open for further replies.
Level 9
Joined
Dec 12, 2007
Messages
489
try this:

  • check
    • Events
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((((Triggering unit) is A Hero) Equal to False) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Greater than 0
        • Then - Actions
          • -------- add your action here --------
        • Else - Actions
it requires a Unit Group variable, currently it checks only for Player 1 (red), specified region can be changed, initially set as Playable Map Area.
trigger event is emptied so add your own event, whether it check periodically or certain circumstance.
trigger not optimized to be leak free, do it yourself
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
^ Uh.. Not quite.

You're going to want to use a loop.
I don't have WE. but just look over this pseudo and try to implement it.
  • For Each TempInteger from 1 to 12
  • Set TempPlayer == Player(TempInteger)
  • Set TempGroup == Units in yourRegion matching condition (Matching Unit is not a Hero) and (Matching Unit is owned by TempPlayer)
  • Pick every unit in TempGroup and do actions
  • --Do what you'd like to do them--such as move them, give them HP, whatever.
  • custom script: call DestroyGroup(udg_TempGroup)
TempGroup == Unit Group Variable
TempPlayer == Player
TempInteger == Integer

yourRegion is either a preplaced Region or one that you created during gameplay. If each player has a specific region you're checking, you should save the regions like this:

  • PlayerRegions[1] == NameofPlayer1Region <gen>
  • PlayerRegions[2] == NameofPlayer2Region <gen>
The event is for you to decide for whenever or under what circumstances you'd like this to fire.
 
Level 9
Joined
Dec 12, 2007
Messages
489
^ Uh.. Not quite.

You're going to want to use a loop.
I don't have WE. but just look over this pseudo and try to implement it.
  • For Each TempInteger from 1 to 12
  • Set TempPlayer == Player(TempInteger)
  • Set TempGroup == Units in yourRegion matching condition (Matching Unit is not a Hero) and (Matching Unit is owned by TempPlayer)
  • Pick every unit in TempGroup and do actions
  • --Do what you'd like to do them--such as move them, give them HP, whatever.
  • custom script: call DestroyGroup(udg_TempGroup)
TempGroup == Unit Group Variable
TempPlayer == Player
TempInteger == Integer
what your trigger does is doing action with all units in certain region owned by all players by looping on each player. it doesn't check if the unitgroup is empty or in other words there is no units owned by that certain player in the region which is different than what the question is.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
The question is "Checking if region has non-hero units owned by player"

I take this to mean the OP's asking to check if there are non-hero units in a region for whichever player, do X, Y, and Z. If there are not any units in that region, none of the actions will happen. There is no need to check if the group is empty.

I believe the OP was having difficulty with creating the unit group to then sort through and do actions with, not with checking for units within that group.
 
Status
Not open for further replies.
Top