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

Unit comes within range of a unit type

Status
Not open for further replies.
Level 4
Joined
Jul 11, 2007
Messages
82
I need an event for GUI or JASS that detects when a unit comes within range of any unit of a particular type (or any unit in a unit group).

I need something like:

Event - A unit comes within 100 of *a barracks*
Conditions - Trigger unit is equal to footman
Actions
....

The other option would be if a unit comes within 100 of any unit within a "barracks" unit group, which contains all the barracks on the map. Or, I could maybe detect when a unit gets a "barracks aura" and then I know its close to a barracks.

Any thoughts?
 
Level 4
Joined
Jul 24, 2008
Messages
108
So the problem i assume your having is that using the "Event - A unit comes within 100 of ______" where u cannot use variables or anything except for preplaced units in the blank. I had that problem a while ago, and the way around it is to have the action Trigger - add event to trigger.

  • Trigger - Add to (This trigger) the event (Unit - A unit comes within 256.00 of (Picked unit))
replace the this trigger and picked units, this is the only way in GUI that i know how to use this event on nonpregenerated units
 
Level 4
Joined
Jul 11, 2007
Messages
82
That is helpful for a possible work-around, but my issue is that I can't use a "unit of type". The trigger is set up so I can only use single units.
 
Level 4
Joined
Jul 24, 2008
Messages
108
That is helpful for a possible work-around, but my issue is that I can't use a "unit of type". The trigger is set up so I can only use single units.


I was thinking you could add that event to the barracks that were being made, then have a condition already on the trigger ur adding the action to of something like this
  • (Unit-type of (Entering unit)) Equal to Footman
So when the footman gets within xxx of the building, not the building gets within xxx of the footman
 
Level 4
Joined
May 3, 2008
Messages
51
I think there is no way to do it, or maybe there is one in JASS, but I don't know JASS, but you can do it like that: And add 1 more action for every unit:

  • Events:
  • Time - Every 0.10 seconds of game time
  • Actions:
  • Unit Group - Pick every unit in (Units within 100.00 of (Position of Your Unit) Matching Unit Type of Picked Unit Equal to YOUR UNIT) and do (Actions)
    • Loop - Actions
      • Your Actions
I didn't try this out, but maybe it works!
 
Level 4
Joined
Jul 24, 2008
Messages
108
I think there is no way to do it, or maybe there is one in JASS, but I don't know JASS, but you can do it like that: And add 1 more action for every unit:

  • Events:
  • Time - Every 0.10 seconds of game time
  • Actions:
  • Unit Group - Pick every unit in (Units within 100.00 of (Position of Your Unit) Matching Unit Type of Picked Unit Equal to YOUR UNIT) and do (Actions)
    • Loop - Actions
      • Your Actions
I didn't try this out, but maybe it works!

That will work, however a new problem is caused with leaks and having a trigger execute 600 times a minute will probably cause much lag. I would keep looking for an alternate way before resorting to this. I know i experienced this with a fps type map that changed camera every .10 seconds when more than 4 people were in the game.. Just a thought
 
Status
Not open for further replies.
Top