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

How to hide and unhide units in an area?

Status
Not open for further replies.
This works fine:

  • Hide
    • Events
      • Player - Player 1 (Red) types a chat message containing hide as An exact match
    • Conditions
    • Actions
      • Set HideGroup = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in HideGroup and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
  • Unhide
    • Events
      • Player - Player 1 (Red) types a chat message containing unhide as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HideGroup and do (Actions)
        • Loop - Actions
          • Unit - Unhide (Picked unit)
Hidden units are omitted from many triggers, which is probably the reason you are facing some difficulties.
 
Level 8
Joined
Aug 13, 2018
Messages
338
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing hide as An exact match
    • Conditions
    • Actions
      • Set hg = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in hg and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
          • Wait 5.00 seconds
          • Trigger - Run Untitled Trigger 001 Copy <gen> (checking conditions)
  • Untitled Trigger 001 Copy
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in hg and do (Actions)
        • Loop - Actions
          • Unit - Unhide (Picked unit)
 
Not sure why that doesn't work but do this instead, it works fine and does what you need:

  • Hide
    • Events
      • Player - Player 1 (Red) types a chat message containing hide as An exact match
    • Conditions
    • Actions
      • Set HideGroup = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in HideGroup and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
          • Countdown Timer - Start UnhideTimer as a One-shot timer that will expire in 5.00 seconds
  • Unhide
    • Events
      • Time - UnhideTimer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HideGroup and do (Actions)
        • Loop - Actions
          • Unit - Unhide (Picked unit)
 
Level 18
Joined
Oct 17, 2012
Messages
822
@matin45 The reason the units do not get hidden is because waits do not work in the loops from "pick all units" and "pick all players". Actions that come after the wait will never happen.

Another solution would have been to run a trigger inside the loops. Then the trigger will call the wait and the other actions after it.

  • Hide
    • Events
      • Player - Player 1 (Red) types a chat message containing hide as An exact match
    • Conditions
    • Actions
      • Set HideGroup = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in HideGroup and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
          • Trigger - Run UnHide <gen> (not checking conditions)
  • UnHide
    • Events
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Unit - Unhide (Picked unit)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,028
No need to start a timer or a wait for each unit in the group... just do what matin tried but with the wait and trigger execution outside the loop....

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing hide as An exact match
    • Conditions
    • Actions
      • Set hg = (Units in Region 000 <gen>)
      • Unit Group - Pick every unit in hg and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
      • Wait 5.00 seconds
      • Trigger - Run Untitled Trigger 001 Copy <gen> (checking conditions)
  • Untitled Trigger 001 Copy
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in hg and do (Actions)
        • Loop - Actions
          • Unit - Unhide (Picked unit)
 
Status
Not open for further replies.
Top