• 🏆 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] SetRectTerrainType

This isn't much, but I felt wc3 was lacking this function. It basically changes the terrain inside a rect to whatever you want. Here's the code:
JASS:
function SetRectTerrainType takes rect r, integer terrainType, integer variation returns nothing
    local real minx = GetRectMinX(r)
    local real miny = GetRectMinY(r)
    local real maxx = GetRectMaxX(r)
    local real maxy = GetRectMaxY(r)
    local real x = minx
    local real y = miny
    loop
        exitwhen y >= maxy
        loop
            exitwhen x >= maxx
            call SetTerrainType(x, y, terrainType, variation, 1, 1)
            set x = x + 128.0
        endloop
        set y = y + 128.0
        set x = minx
    endloop
endfunction
I don't know why, but this function doesn't work after TriggerSleepAction is called, but I'm sure there are ways round that, such as using a timer, though I haven't tested any.
 
Last edited:
I tested it by doing:
JASS:
call SetRectTerrainType(gg_rct_test1, 'Lgrs', -1)
call SetRectTerrainType(gg_rct_test2, 'Lgrs', -1)
call SetRectTerrainType(gg_rct_test3, 'Lgrs', -1)
call SetRectTerrainType(gg_rct_test4, 'Lgrs', -1)
call SetRectTerrainType(gg_rct_test5, 'Lgrs', -1)
and it all worked until I put call TriggerSleepAction(0.5) after every call, then it just worked in the first rect, but didn't do anything to the others...
 
Top