• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Destroy units in area

Status
Not open for further replies.
Level 3
Joined
Jun 1, 2013
Messages
47
When any Player uses Last Hope, all enemy units in the area "Rot <gen>" shall explode.

This is my try, I have not figured out how to make it for all players at once, so I just did it for red. But the trigger kills all units including Red and allied units instead of just enemies.

  • Spieler 1 uses LAST HOPE
    • Ereignisse
      • Einheit - |cFF008080Rebels Keep |r 0016 <gen> Vollendet Forschung
    • Bedingungen
      • (Researched tech-type) Gleich |cFF008080Last Hope|r
    • Aktionen
      • Set PlayerAlive[1] = False
      • Einheitengruppe - Pick every unit in (Units in Rot <gen> matching ((Owner of (Picked unit)) Ungleich Spieler 1 (Rot))) and do (Actions)
        • Schleifen - Aktionen
          • Einheit - Explode (Picked unit)
      • Spiel - Display to (All players) the text: ((Name of (Triggering player)) + has used last hope!)
 
Wrong forum. This should be in Triggers & Scripts.


You shouldn't use Matching Unit to filter out your unit groups, when you have over 3+ checks, it becomes extremely ugly and hard to read. Here's a solution to your problem + a better way to filter them out.
  • Set caster = (Triggering unit)
  • Set playerVariable = (Owner of caster)
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in Rot <gen>) and do (Actions)
    • Loop - Actions
      • Set tempUnit = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempUnit belongs to an enemy of player) Equal to True
          • -------- you can add other filters like magic immune, not a structure, is alive, etc--------
        • Then - Actions
          • -------- unit passed filters; explode picked unit --------
        • Else - Actions
          • -------- unit did not pass filters; do nothing --------
 
Well, the problem he has is that he has a region named Red, so I assume there is a region for each player. So what he must do is use a region array and set each player's region to the array using the player number as the array index.

Oh woops. I misunderstood his question. Thank you.


You will need to make a region variable with an array element that is the same as their player number.
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set regionVariable[1] = Player Red's region
      • Set regionVariable[2] = Player Blue's region
      • Set regionVariable[3] = Player Teal's region
      • -------- continue for all players --------

Then when they cast the spell, this is exactly how it will look like.
  • Set caster = (Triggering unit)
  • Set playerVariable = (Owner of caster)
  • Set intVariable = (Player number of playerVariable)
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in regionVariable[intVariable]) and do (Actions)
    • Loop - Actions
      • Set tempUnit = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempUnit belongs to an enemy of playerVariable) Equal to True
          • -------- you can add other filters like magic immune, not a structure, is alive, etc--------
        • Then - Actions
          • -------- unit passed filters; explode picked unit --------
        • Else - Actions
          • -------- unit did not pass filters; do nothing --------
 
Wrong forum. This should be in Triggers & Scripts.


You shouldn't use Matching Unit to filter out your unit groups, when you have over 3+ checks, it becomes extremely ugly and hard to read. Here's a solution to your problem + a better way to filter them out.
  • Set caster = (Triggering unit)
  • Set playerVariable = (Owner of caster)
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in Rot <gen>) and do (Actions)
    • Loop - Actions
      • Set tempUnit = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempUnit belongs to an enemy of player) Equal to True
          • -------- you can add other filters like magic immune, not a structure, is alive, etc--------
        • Then - Actions
          • -------- unit passed filters; explode picked unit --------
        • Else - Actions
          • -------- unit did not pass filters; do nothing --------

I know your way is easier to read but is it easier for the game?
I have a create group for my missile trigger to detect units in range matching conditions. Would it always be adding units to a group that don't need to be in the group or does it not really matter?
 
Filters work almost exactly the same as an If/Then/Else.
It may or may not create a new thread for each iteration but it will run for each individual unit ofcourse.

@Bribe:
It's a matter of opening 1 thread per unit versus opening 1 thread and another one for each unit that passes the filter per unit. (If the filter creates a new thread at least.)
 
Status
Not open for further replies.
Back
Top