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