• 🏆 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!

Need help with rects/regions with jass

Status
Not open for further replies.
Level 3
Joined
Jan 15, 2010
Messages
47
Hey all :)

Does there happen to be a good tutorial on rects or regions with jass? I have been looking at all the main sites and can't find any :/

Or perhaps someone could help me figure out what it is i need to be doing with my code. I don't exactly know how to use rects/regions with Jass. I am trying to add all the units with certain raw codes into a group but i'm not sure how to do this :/

Any tips/advice would be greatly appreciated :)

Thanks!
-saeyne
 
Level 7
Joined
Oct 14, 2008
Messages
340
Does this help?
JASS:
globals
    region reg
endglobals

function filter takes nohthing returns boolean
    local real x = GetUnitX(GetFilterUnit())
    local real y = GetUnitY(GetFilterUnit())
    return IsPointInRect(reg, x, y) and GetUnitTypeId(GetFilterUnit()) == 'h000'
endfunction

function SomeFunction takes this returns that
    local rect array rct
    local group g = CreateGroup()
    set reg = CreateRegion()
    set rct[0] = YourRect
    call RegionAddRect(reg, rct[0])
    set rct[1] = YourOtherRect
    call RegionAddRect(reg, rct[1])
    call GroupEnumUnitsInRect(g, GetPlayableMapRect(), Condition(function filter))
    //insert group actions here
endfunction
 
Status
Not open for further replies.
Top