| 11-30-2003, 01:04 AM | #1 |
I want to build a trigger that gets the closest enemy unit within a range of 1000. The only w Any way to make Hero units priority in this would be good too-- as in, a hero at 700 range will be chosen over a normal unit at 400 range. Thanks in advance. |
| 11-30-2003, 01:17 AM | #2 |
There's a few ways to do this; most obvious of which would be to pick all units in the thousand radius and check their distances.. However.. You might be able to create a dummy unit that has 1000 range and 1-1 damage. Whenever you want to do your little comparison, spawn the dummy unit at the center of the checking circle.. Have another trigger that has an event; "A unit is attacked." Condition: Attacking unit type = dummy unit Action: set NearestUnitVariable = attacked unit.. or something. For the hero thing, you might be able to just pump up his priority so he's attacked naturally by anything that can see him. This method is a bit off the wall and would require tweaking; but in concept it works. |
| 11-30-2003, 02:11 AM | #3 |
Is there any short, easy way to get the lowest number out of a bunch of values? only "minimum out of.." function only seems to be able to hold 2 distinct numbers. |
| 11-30-2003, 04:56 PM | #4 | |
Quote:
Just make a loop where you continually compare the lowestdistancesofar with the new distance. Something like this Set variable lowest_dist = 99999999999999999999999999 Unit Group - Pick Every Unit on map and do - Set curr_dist = distance between Picked unit and Triggering Unit - if curr_dist is less than lowest_dist then - - Set lowest_dist = curr_dist - - Set closest_unit = Picked unit |
