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

Hiding and Unhiding Units

Status
Not open for further replies.
Do a periodic event in which you enumerate all units within the group of hidden units, check each unit against the unit you want to test the range for, then unhide the picked unit if it is within range and remove it from the group.
Add this unit to a group containing all visible units and do the same periodic checks for those in reverse (if range > 400, hide and add to hidden group again).

Try it on your own! It's not hard to do and you'll learn a few things.
 
You can use these 3 triggers:
trigger 1. This will set the peasant as our unit to be hidden and unhidden.
  • set
  • Events
    • Time-Elapsed game time is 0.01 seconds
  • Conditions
  • Actions
    • Set unit_X=Peasant 000<gen>
    • Unit - Hide unit_X
Trigger 2. This will unhide our unit when a triggering unit comes within 250.00 to the peasant.
  • unhide
  • Events
    • Unit - A unit comes within 250.00 of Peasant 000<gen>
  • Conditions
    • (Triggering unit) Equal to Archmage 0002<gen>
  • Actions
    • Unit - Unhide unit_X
Trigger 3. We convert a point with size to region with reference to our peasant so when a triggering unit leaves there, our peasant will be hidden.
  • hide
  • Events
    • Unit - A unit leaves (Region centered at (Position of Peasant 0000<gen>) with size (300.00, 300.00))
  • Conditions
    • (Triggering unit) Equal to Archmage 0002<gen>
  • Actions
    • Unit - Hide unit_X
 
The problem is that picking units in range does not detect hidden units. You have to manually add the hidden units to a group, then cycle through the group of hidden units to evaluate if they get unhidden or not.
Hm, I think that's not true. Hidden units also should be picked up with the function "PickAllUnitsInRange". So it might save you some work here.
Trigger 3. We convert a point with size to region with reference to our peasant so when a triggering unit leaves there, our peasant will be hidden.
  • hide
  • Events
    • Unit - A unit leaves (Region centered at (Position of Peasant 0000<gen>) with size (300.00, 300.00))
  • Conditions
    • (Triggering unit) Equal to Archmage 0002<gen>
  • Actions
    • Unit - Hide unit_X
That's static. If the peasant moves it won't work anymore and might cause bugs I think. Me would go with periodic checks as Zwiebelchen suggested.
 
Status
Not open for further replies.
Top