• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Picking Destructables in range

Status
Not open for further replies.
I don't know how to get destructables in range, but I do have a way of picking destructables in a rect, meaning that a rect is moved to some coordinates to get the destructables inside it.

Ex:
JASS:
library KillTreesInRect requires DestructableLib
    globals    
        private rect TempRect = Rect(0,0,0,0)
    endglobals
    
    private function KillTrees takes nothing returns boolean
        // Note, use GetFilterDestructable since we're doing it inside a boolexpr.
        if IsDestructableTree(GetFilterDestructable()) and not IsDestructableDead(GetFilterDestructable()) then
            call KillDestructable(GetFilterDestructable())
        endif
        return false
    endfunction
    
    function KillTreesInRect takes real x, real y, real radius returns nothing
        call SetRect(TempRect,x-radius,y-radius,x+radius,y+radius)
        call EnumDestructablesInRect(TempRect,Filter(function KillTrees),null)
    endfunction
endlibrary
You would call KillTreesInRect on some coords (x,y) which would kill trees in a rect with an area of radius squared, if I'm doing my calculations correctly.
You should pay attention to SetRect.

Of course, this isn't as accurate as getting them in actual range.

Library Used:
DestructableLib
 
Status
Not open for further replies.
Top