Этот код не работает.
Нужна функция, где я буду указывать Х,У,Радиус - и в этом АОЕ ломаются деревья.
(Для всяких способностей со взрывами итд.)
Что я делаю не так?

Написал общую функцию EnumDestructablesInRange.
раскрыть
globals
    real TrasmittedX
    real TrasmittedY
    real TrasmittedRange
endglobals

function GetDistancePoints takes real x1, real y1, real x2, real y2 returns real
    return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction

function FilterFunc takes nothing returns boolean
    return TrasmittedRange >= GetDistancePoints(TrasmittedX, TrasmittedY,/*
        */ GetDestructableX(GetFilterDestructable()), GetDestructableY(GetFilterDestructable()))
endfunction

function EnumDestructablesInRange takes real x, real y, real range, code callback returns nothing
    set TrasmittedX = x
    set TrasmittedY = y
    set TrasmittedRange = range
    call EnumDestructablesInRect(GetWorldBounds(), Filter(function FilterFunc), callback)
endfunction

function KillDestructiblesInRangeCallback takes nothing returns boolean
    call KillDestructable(GetEnumDestructable())
endfunction

function KillDestructiblesInRange takes real x, real y, real range returns boolean
    call EnumDestructablesInRange(x, y, range, function KillDestructiblesInRangeCallback)
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...

Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
29
В качестве ректа игровая карта, внутри функции DestructableKill проверку удалённости этого декора от центра
Кодом скинь, покажу
19
function DestructibleKill takes nothing returns nothing
KillDestructable(GetEnumDestructable())
endfunction
function KillDest takes real x,real y,real rad returns nothing
rect r=Rect(x-rad,y-rad,x+rad,y+rad)
EnumDestructablesInRect(r,null,function DestructibleKill)
RemoveRect(r)
set r=null
endfunction
Удаленности от центра игровой карты? Мне нужен конкретный ХУ... -.-
Короче, без глобалок не обойтись походу?
29
globals
    x = //твой х
    y = //твой y
    rad = //твой радиус
endglobals
function DestructibleKill takes nothing returns nothing
if SquareRoot((x1-GetDestructableX(GetEnumDestructable()))*(x1-GetDestructableX(GetEnumDestructable())) + (y1-GetDestructableY(GetEnumDestructable())*y1-GetDestructableY(GetEnumDestructable())) <= rad
KillDestructable(GetEnumDestructable())
endif
endfunction
function KillDest takes real x,real y,real rad returns nothing
EnumDestructablesInRect(GetPlayableMapRect(),null,function DestructibleKill)
endfunction
28
Написал общую функцию EnumDestructablesInRange.
раскрыть
globals
    real TrasmittedX
    real TrasmittedY
    real TrasmittedRange
endglobals

function GetDistancePoints takes real x1, real y1, real x2, real y2 returns real
    return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction

function FilterFunc takes nothing returns boolean
    return TrasmittedRange >= GetDistancePoints(TrasmittedX, TrasmittedY,/*
        */ GetDestructableX(GetFilterDestructable()), GetDestructableY(GetFilterDestructable()))
endfunction

function EnumDestructablesInRange takes real x, real y, real range, code callback returns nothing
    set TrasmittedX = x
    set TrasmittedY = y
    set TrasmittedRange = range
    call EnumDestructablesInRect(GetWorldBounds(), Filter(function FilterFunc), callback)
endfunction

function KillDestructiblesInRangeCallback takes nothing returns boolean
    call KillDestructable(GetEnumDestructable())
endfunction

function KillDestructiblesInRange takes real x, real y, real range returns boolean
    call EnumDestructablesInRange(x, y, range, function KillDestructiblesInRangeCallback)
endfunction
Принятый ответ
29
PT153, Спасибо, показательный пример красивого кода
Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.