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

Help with "all units in region" function - related to "remove units" action

Status
Not open for further replies.
Level 4
Joined
Apr 29, 2020
Messages
59
this function does not seem to exist within the parameters of the "remove unit" action..... I'm trying to do what would be extremely simple in sc1 editor but im running into all kinds of hell with wc3 editor trigger functions. all i want is this: <E: specific unit enters region 1. C: none. A: remove all units owned by player 1 from region 2.> (this action would include all trained units that are not present at map initialization so i cant just pick the units i want removed as they dont exist yet.... which brings me to a reoccurring problem that i keep wanting to use trigger functions for units that dont currently exist but will be created by other triggers or actions and there doesn't seem to be any way to do this without an "all units in region" function).... i tried looking into unit groups as that does have a "units in region" function but i cannot apply that function to removing units. in fact, i cant seem to apply that function to units changing owner, moving(non-issued command) or just about any non-issue-command action that i find useful for the map im making. i do not understand how to create a variable but that's my next guess as to what im supposed to do. can any of y'all point me in the right direction to figuring this one out?
 
Here's your trigger:
  • Remove all p1 units in region
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Region 001 <gen> owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
And here's an example which shows how to make a more advanced version of your trigger. This method gives you a lot more control in filtering which units you want to manipulate. So as you can see I'm removing all Undead Heroes owned by Player 1 that are in the playable map area.
  • Remove all units advanced
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 1 (Red)
              • ((Picked unit) is A Hero) Equal to True
              • ((Picked unit) is Undead) Equal to True
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
            • Else - Actions

Variables are a way to store information that you can reference throughout your triggers. By default a Variable can only be set to one thing at a time.

Here's an example of keeping track of a player's Hero using a Unit variable. After training a hero we store the trained unit as a variable called Hero. We can reference this variable at any time in any of our triggers.
  • Train A Hero
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Trained unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Hero = (Trained unit)
Now we can reference Hero in another trigger. This trigger kills Hero whenever Player 1 types "-kill".
  • Kill My Hero
    • Events
      • Player - Player 1 (Red) types a chat message containing -kill as An exact match
    • Conditions
    • Actions
      • Unit - Kill Hero
Keep in mind that if you type "-kill" before the Hero variable has been set (so you haven't trained a Hero yet) nothing will happen. The trigger will still run ALL of it's Actions, but the Action "Unit - Kill Hero" will do nothing, as the variable Hero is set to No Unit by default.
 

Attachments

Last edited:
Holy crap. thank you so much! i finally found "pick unit" - which took me a while because i was looking for "select unit" XD but everything you just gave me will be extremely helpful :) much appreciated.
 
Status
Not open for further replies.
Back
Top