• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Picking Destructables in range

Status
Not open for further replies.
Level 14
Joined
Nov 18, 2007
Messages
1,084
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