Warcraft III resources & community, 2003–2006 · archived

GetRandomLocInRectOfCliffHeight

not rated
Submitted by AltSubmitterFunctions0 downloads
This is just like getting a random point in a region, except it makes sure that it's of a certain cliff height. Just be sure that there is some point of that cliff height in the region, or it'll get in an infinite recursion and crash. It is possible to test for every point in the region to make sure there's at least one of the appropriate cliff height, but I suspect that would be INCREDIBLY slow, especially if done for the entire map area.

Source

//WARNING: Gets in an infinite loop if there is no place of that cliffheight in region
function GetRandomLocInRectOfCliffHeight takes integer cliffheight, rect whichRegion returns location
    local location temp_point = GetRandomLocInRect(whichRegion)

    //If cliff height matches, return
    if (GetTerrainCliffLevelBJ(temp_point) == cliffheight) then
        return temp_point
    endif

    //Otherwise try again
    return GetRandomLocInRectOfCliffHeight(cliffheight, whichRegion)
endfunction

Comments

0

No comments.