- Joined
- Aug 13, 2007
- Messages
- 309
Which is faster?
My script:
OR
My script:
UnitGetNearest
- Unit Get Nearest
- Options: Action
- Return Type: Unit
- Parameters
- Unit = No Unit <Unit>
- Group = (Empty unit group) <Unit Group>
- Grammar Text: Unit Get Nearest(Unit, Group)
- Hint Text: Makes the units seek out enemy units and attack them.
- Custom Script Code
- Local Variables
- Actions
- General - Custom Script: unit lv_u;...
JASS:unit lv_u; unit lv_u2; point lv_pt = UnitGetPosition(lp_unit); point lv_pt2; fixed lv_distance; fixed lv_distance2 = 10000.0; UnitGroupLoopBegin(lp_group); while (!UnitGroupLoopDone()) { lv_u = UnitGroupLoopCurrent(); lv_pt2 = UnitGetPosition(lv_u); lv_distance = DistanceBetweenPoints(lv_pt, lv_pt2); if (lv_distance < lv_distance2) { lv_distance2 = lv_distance; lv_u2 = lv_u; } UnitGroupLoopStep(); } UnitGroupLoopEnd(); return lv_u2;
JASS:
UnitGroupClosestToPoint(Unit Group, Point);