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

Change Terrain (Not Working Well)

Status
Not open for further replies.
Level 7
Joined
Sep 11, 2013
Messages
220
Hey guys, I want to change the terrain into different ones through triggers.
  • Harvest Moon (3D).w3x
  • function RT2 takes real X, real Y, integer T returns nothing
    • call SetTerrainType(X, Y, T, -1, 1, 1)
    • endfunction
    • function RT1 takes real MinX, real MaxX, real Y, integer OldTerrain, integer Terrain returns nothing
      • loop
        • exitwhen MinX > MaxX
          • if GetTerrainType(MinX, Y) == OldTerrain then
            • call RT2 (MinX, Y, Terrain)
          • endif
        • set MinX = MinX + 128
      • endloop
    • endfunction
    • function ReplaceTerrainTypeEx takes integer OldTerrain, integer NewTerrain, rect WhichRect returns nothing
      • local real MinX = GetRectMinX(WhichRect)
      • local real MaxX = GetRectMaxX(WhichRect)
      • local real MinY = GetRectMinY(WhichRect)
      • local real MaxY = GetRectMaxY(WhichRect)
      • loop
        • exitwhen MinY > MaxY
          • call RT1 (MinX, MaxX, MinY, OldTerrain, NewTerrain)
        • set MinY = MinY + 128
      • endloop
    • endfunction
    • function ReplaceGlobalTerrain takes integer OldTerrain, integer NewTerrain returns nothing
      • call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    • endfunction
    • function ReplaceGlobalTerrainReversed takes integer NewTerrain, integer OldTerrain returns nothing
      • call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    • endfunction
Then I use this which activates when I press ESC.
  • SET when Player press ESC
  • call ReplaceGlobalTerrain ('Agrs', 'Lgrs')
  • call ReplaceGlobalTerrain ('Adrg', 'Ldrg')
The 1st is (Ashenvale Grass to Lordaeron Grass)
The 2nd is (Ashenvale Grassy Dirt to Lordaeron Grassy Dirt)

But it only changes the 1st and the 2nd does not happen.
And it does not change in the ENTIRE MAP. my map size is (192 x 192) can someone help me?? xO
 
JASS:
function ReplaceTerrainTypeId takes integer OldTerrain, integer NewTerrain, rect WhichRect returns nothing
    local real MinX = GetRectMinX(WhichRect)
    local real MaxX = GetRectMaxX(WhichRect)
    local real MinY = GetRectMinY(WhichRect)
    local real MaxY = GetRectMaxY(WhichRect)
    loop
        loop
            if GetTerrainType(MinX, MinY) == OldTerrainId then
                call SetTerrainType(MinX, MinY, NewTerrain, -1, 1, 1)
            endif
            
            exitwhen MinX >= MaxX
            set MinX = MinX + 128
        endloop
        
        exitwhen MinY >= MaxY
        set MinY = MinY + 128
    endloop
endfunction

This function replaces a specific Terrain Type with another within a rect.

If you call it properly it should work(haven't tested).


It's also more recommended to make the coordinates of the region yourself.
JASS:
function ReplaceTerrainTypeId takes integer OldTerrain, integer NewTerrain, real MinX, real MaxX, real MinY, real MaxY returns nothing
    loop
        loop
            if GetTerrainType(MinX, MinY) == OldTerrainId then
                call SetTerrainType(MinX, MinY, NewTerrain, -1, 1, 1)
            endif
            
            exitwhen MinX >= MaxX
            set MinX = MinX + 128
        endloop
        
        exitwhen MinY >= MaxY
        set MinY = MinY + 128
    endloop
endfunction

Oh yes and remember to paste your jass code here with the jass tags [code=jass][/code].
 
Status
Not open for further replies.
Top