Добавлен EviLInside
reforged. Может ли кто-то поделиться подобной функцией для поиска ближайшего destructable?
Принятый ответ
ну типа как-то так, не уверен в работоспособности потому что не проверял
раскрыть
globals
destructable bj_lastFilterDestructable = null
destructable nearDestructable = null
real g_distance
real g_x
real g_y
endglobals
function NearDestructable takes nothing returns nothing
local real x
local real y
local real d
set bj_lastFilterDestructable = GetEnumDestructable( )
set x = GetDestructableX( bj_lastFilterDestructable )
set y = GetDestructableY( bj_lastFilterDestructable )
set d = SquareRoot( ( g_x - x ) * ( g_x - x ) + ( g_y - y ) * ( g_y - y ) )
if d < g_distance then
set g_distance = d
set nearDestructable = bj_lastFilterDestructable
endif
endfunction
function GetNearDestructable takes real x, real y, real radius, boolexpr b returns destructable
local rect r = Rect( x - radius, y - radius, x + radius, y + radius )
set nearDestructable = null
set g_distance = radius
set g_x = x
set g_y = y
call EnumDestructablesInRect( r, b, function NearDestructable )
call RemoveRect( r )
set r = null
return nearDestructable
endfunction
в булекспр можешь кинуть любое условие для фильтрации деструктов, т.е. например
function MyCond takes nothing returns boolean
return GetDestructableTypeId( GetFilterDestructable( ) ) == '4sdfsd' or GetDestructableTypeId( GetFilterDestructable( ) ) == 's'fsf'
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован rsfghd
Отредактирован Clamp