| 02-04-2006, 12:39 PM | #1 |
Can someone tell me an easy way to check what unit within 500 (or something) is nearest the caster? I know this has been asked before but I dont have time to search it up. |
| 02-04-2006, 12:56 PM | #2 |
Get the unit whose distance to the caster is the minimum of all the distances you get |
| 02-04-2006, 06:07 PM | #3 |
So.. how would I do that in trigger? would I have to loop it like first 10, 20, 30, 40 etc. or is there any easier way? |
| 02-04-2006, 06:10 PM | #4 |
Pick every unit in 500 of caster, and calculate their distance to the caster. Whoever has the shortest distance is your unit. |
| 02-04-2006, 06:13 PM | #5 |
Well I dont get how to do the check, I'll need a variable right? This works? Trigger: Unit Group - Pick every unit in (Units within 1000.00 of (Position of Peasant 0000 <gen>) matching (((Matching unit) Not equal to Peasant 0000 <gen>) and (((Matching unit) is dead) Equal to False))) and do (Actions)and YES I know it leaks alot. EDIT: Well it works sometimes :S EDIT2: Ok its fixed, had to check if the picked unit was dead or not, thx for the help. |
| 02-04-2006, 06:26 PM | #6 |
That seems like it would work to me. When exactly does it work and not work? Opps. Posted before your edit2. Nevermind. :P |
