• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

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?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
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

  • Basic Trigger Example.w3m
    18.4 KB · Views: 18
Last edited:
Level 4
Joined
Apr 29, 2020
Messages
59
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.
Top