Есть способ для каждого юнита в группе получить координаты по X и Y, и потом взять минимум X и Y?
Принятый ответ
Функции дистанции
function GetDistancePoints takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction
return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction
function GetDistanceUnitPoint takes unit u, real x, real y returns real
local real dx = GetUnitX(u) - x
local real dy = GetUnitY(u) - y
return SquareRoot(dx * dx + dy * dy)
endfunction
local real dx = GetUnitX(u) - x
local real dy = GetUnitY(u) - y
return SquareRoot(dx * dx + dy * dy)
endfunction
function GetDistanceUnits takes unit u1, unit u2 returns real
local real dx = GetUnitX(u1) - GetUnitX(u2)
local real dy = GetUnitY(u1) - GetUnitY(u2)
return SquareRoot(dx * dx + dy * dy)
endfunction
local real dx = GetUnitX(u1) - GetUnitX(u2)
local real dy = GetUnitY(u1) - GetUnitY(u2)
return SquareRoot(dx * dx + dy * dy)
endfunction
Узнать ближайшего юнита к (x, y)
globals
real X
real Y
unit ClosestUnit
real Distance
endglobals
function FindClosestToXYCallback takes nothing returns nothing
local real d = GetDistanceUnitPoint(GetEnumUnit(), X, Y)
if d <= Distance then
set Distance = d
set ClosestUnit = GetEnumUnit()
endif
endfunction
function FindClosestToXY takes group g, real x, real y returns unit
set X = x
set Y = y
set ClosestUnit = null
set Distance = 999999.
call ForGroup(g, function FindClosestToXYCallback)
return ClosestUnit
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Ред. biridius
Ред. biridius
а на джассе ForGroup(g, function f) перебирает отряд g и запускает для каждого юнита по очереди функцию f