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

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Ok - the plan is: A dialog shown up - player 1 can choose a mode.

If he choose a certain mode - the terrain should be changed.

I simply think to "pick" a terrain type and change this "picked" terrain type to another. But I can't find something like that.
After I tried to CREATE the terrain - but only possible way (i see) is - to create a rect on the map and in this rect I can create terrain.
(Environment - Change terrain type at (Center of (Playable map area)) to Lordaeron Summer - Dirt using variation -1 in an area of size 1 and shape Circle)
But I need to create full ways with terrain.

So maybe someone can help me and find a useful and not an imba hard omg way for changing terrain ~ thanks =)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

WoW - that you can create this in a short time is really nice!!

But my problem is a little different.

It's TD. The ground texture is "gras". Over this I painted a way in Ice. And I painted another way with lava.

Now the creeps have 2 possible ways to walk.

At map start, the host can choose "Option A - Creeps walks only on Ice" or "Option B - Creeps walks only on lava".

If he picks "Option A - all lava should be changed into gras" and if he pick "Option B - all ice should be changed into gras".

(Lol if I read that what I'm typing - my english sux dude or? =D - but hope you understand^^)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

O M G

For this you needed ~20 mins <-- dude are you crazy? :week: :wthumbsup:
(Joke)

That you can do this - is really omg - that you did this in this short time is wtf omg.
(I want give you +5rep for this (can you tell me how I can give directly 5 plz))


Think is: I want understand this. Can you tell me in 1 or 2 sentence what you done plz? =)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Well, I had the terrain change thingy mostly done a while ago. I just added the dialog part :)

The trigger calculates the amount of tiles in playable map area, finds the tile in the lower left corner of the map, and goes through every tile's center points starting from there, and checks the terrain type. If the terrain type mathces the terrain type in Terrain_Type[1], it changes it to Terrain_Type[2].

You can define those terrain types in the dialog trigger.

Is there anything else you need to know?

You can't give more than 1 rep, since your own rep and post count are too low.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Hmm I think I understand the idea behind it - but I will check if sometimes that I'm ok with it =)

Bad thing: only can give you +1rep - but you can be sure - you earned +10rep for this help (If I think my try to change the terrain - and if I look your triggers now --- I have much to learn --- very very much)

So dude - THANKS! for ever
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
wow, quite the necro....

I don't know if maker is still active, but he wrote how he did it:

Well, I had the terrain change thingy mostly done a while ago. I just added the dialog part :)

The trigger calculates the amount of tiles in playable map area, finds the tile in the lower left corner of the map, and goes through every tile's center points starting from there, and checks the terrain type. If the terrain type mathces the terrain type in Terrain_Type[1], it changes it to Terrain_Type[2].

You can define those terrain types in the dialog trigger.

Is there anything else you need to know?

You can't give more than 1 rep, since your own rep and post count are too low.
 
Level 19
Joined
Feb 27, 2019
Messages
590
Here is a system I use. I dont remember who the author is :(

I have only used the global terrain part but I guess there is a function for any rect aswell.

I dont think any global variables needs to be created.

JASS:
/*--------------------
 RT2
----------------------*/
function RT2 takes real X, real Y, integer T returns nothing
        call SetTerrainType(X, Y, T, -1, 1, 1)
    endfunction
/*--------------------
 RT1
----------------------*/   
    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
/*--------------------
 Replace Terrain Type Ex
----------------------*/      
    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
/*--------------------
 ReplaceGlobalTerrain
----------------------*/
    function ReplaceGlobalTerrain takes integer OldTerrain, integer NewTerrain returns nothing
        call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    endfunction
/*--------------------
 ReplaceGlobalTerrainReversed
----------------------*/   
    function ReplaceGlobalTerrainReversed takes integer NewTerrain, integer OldTerrain returns nothing
        call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    endfunction

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-= List of Terrain Types =-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

// Lordaeron Summer
'Ldrt' = Lordaeron Summer - Dirt
'Ldro' = Lordaeron Summer - Rough Dirt
'Ldrg' = ordaeron Summer - Grassy Dirt
'Lrok' = Lordaeron Summer - Rock
'Lgrs' = Lordaeron Summer - Grass
'Lgrd' = Lordaeron Summer - Dark Grass

// Lordaeron Fall
'Fdrt' = Lordaeron Fall - Dirt
'Fdro' = Lordaeron Fall - Rough Dirt
'Fdrg' = Lordaeron Fall - Grassy Dirt
'Frok' = Lordaeron Fall - Rock
'Fgrs' = Lordaeron Fall - Grass
'Fgrd' = Lordaeron Fall - Dark Grass

// Lordaeron Winter
'Wdrt' = Lordaeron Winter - Dirt
'Wdro' = Lordaeron Winter - Rough Dirt
'Wsng' = Lordaeron Winter - Grassy Snow
'Wrok' = Lordaeron Winter - Rock
'Wgrs' = Lordaeron Winter - Grass
'Wsnw' = Lordaeron Winter - Snow

// Barrens
'Bdrt' = Barrens - Dirt
'Bdrh' = Barrens - Rough Dirt
'Bdrr' = Barrens – Pebbles
'Bdrg' = Barrens - Grassy Dirt
'Bdsr' = Barrens - Desert
'Bdsd' = Barrens - Dark Desert
'Bflr' = Barrens - Rock
'Bgrr' = Barrens - Grass

// Ashenvale
'Adrt' = Ashenvale - Dirt
'Adrd' = Ashenvale - Rough Dirt
'Agrs' = Ashenvale - Grass
'Arck' = Ashenvale - Rock
'Agrd' = Ashenvale - Lumpy Grass
'Avin' = Ashenvale - Vines
'Adrg' = Ashenvale - Grassy Dirt
'Alvd' = Ashenvale - Leaves

// Felwood
'Cdrt' = Felwood - Dirt
'Cdrd' = Felwood - Rough Dirt
'Cpos' = Felwood - Poison
'Crck' = Felwood - Rock
'Cvin' = Felwood - Vines
'Cgrs' = Felwood - Grass
'Clvg' = Felwood - Leaves

// Northrend
'Ndrt' = Northrend - Dirt
'Ndrd' = Northrend - Dark Dirt
'Nrck' = Northrend - Rock
'Ngrs' = Northrend - Grass
'Nice' = Northrend - Ice
'Nsnw' = Northrend - Snow
'Nsnr' = Northrend - Rocky Snow

// Cityscape
'Ydrt' = Cityscape - Dirt
'Ydtr' = Cityscape - Rough Dirt
'Yblm' = Cityscape - Black Marble
'Ybtl' = Cityscape - Brick
'Ysqd' = Cityscape - Square Tiles
'Yrtl' = Cityscape - Round Tiles
'Ygsb' = Cityscape - Grass
'Yhdg' = Cityscape -

Example:
  • Custom script: call ReplaceGlobalTerrain ('Lgrd', 'Wgrs')
 
Level 4
Joined
Dec 21, 2019
Messages
51
Here is a system I use. I dont remember who the author is :(

I have only used the global terrain part but I guess there is a function for any rect aswell.

I dont think any global variables needs to be created.

JASS:
/*--------------------
 RT2
----------------------*/
function RT2 takes real X, real Y, integer T returns nothing
        call SetTerrainType(X, Y, T, -1, 1, 1)
    endfunction
/*--------------------
 RT1
----------------------*/ 
    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
/*--------------------
 Replace Terrain Type Ex
----------------------*/    
    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
/*--------------------
 ReplaceGlobalTerrain
----------------------*/
    function ReplaceGlobalTerrain takes integer OldTerrain, integer NewTerrain returns nothing
        call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    endfunction
/*--------------------
 ReplaceGlobalTerrainReversed
----------------------*/ 
    function ReplaceGlobalTerrainReversed takes integer NewTerrain, integer OldTerrain returns nothing
        call ReplaceTerrainTypeEx(OldTerrain, NewTerrain, GetWorldBounds())
    endfunction

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-= List of Terrain Types =-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

// Lordaeron Summer
'Ldrt' = Lordaeron Summer - Dirt
'Ldro' = Lordaeron Summer - Rough Dirt
'Ldrg' = ordaeron Summer - Grassy Dirt
'Lrok' = Lordaeron Summer - Rock
'Lgrs' = Lordaeron Summer - Grass
'Lgrd' = Lordaeron Summer - Dark Grass

// Lordaeron Fall
'Fdrt' = Lordaeron Fall - Dirt
'Fdro' = Lordaeron Fall - Rough Dirt
'Fdrg' = Lordaeron Fall - Grassy Dirt
'Frok' = Lordaeron Fall - Rock
'Fgrs' = Lordaeron Fall - Grass
'Fgrd' = Lordaeron Fall - Dark Grass

// Lordaeron Winter
'Wdrt' = Lordaeron Winter - Dirt
'Wdro' = Lordaeron Winter - Rough Dirt
'Wsng' = Lordaeron Winter - Grassy Snow
'Wrok' = Lordaeron Winter - Rock
'Wgrs' = Lordaeron Winter - Grass
'Wsnw' = Lordaeron Winter - Snow

// Barrens
'Bdrt' = Barrens - Dirt
'Bdrh' = Barrens - Rough Dirt
'Bdrr' = Barrens – Pebbles
'Bdrg' = Barrens - Grassy Dirt
'Bdsr' = Barrens - Desert
'Bdsd' = Barrens - Dark Desert
'Bflr' = Barrens - Rock
'Bgrr' = Barrens - Grass

// Ashenvale
'Adrt' = Ashenvale - Dirt
'Adrd' = Ashenvale - Rough Dirt
'Agrs' = Ashenvale - Grass
'Arck' = Ashenvale - Rock
'Agrd' = Ashenvale - Lumpy Grass
'Avin' = Ashenvale - Vines
'Adrg' = Ashenvale - Grassy Dirt
'Alvd' = Ashenvale - Leaves

// Felwood
'Cdrt' = Felwood - Dirt
'Cdrd' = Felwood - Rough Dirt
'Cpos' = Felwood - Poison
'Crck' = Felwood - Rock
'Cvin' = Felwood - Vines
'Cgrs' = Felwood - Grass
'Clvg' = Felwood - Leaves

// Northrend
'Ndrt' = Northrend - Dirt
'Ndrd' = Northrend - Dark Dirt
'Nrck' = Northrend - Rock
'Ngrs' = Northrend - Grass
'Nice' = Northrend - Ice
'Nsnw' = Northrend - Snow
'Nsnr' = Northrend - Rocky Snow

// Cityscape
'Ydrt' = Cityscape - Dirt
'Ydtr' = Cityscape - Rough Dirt
'Yblm' = Cityscape - Black Marble
'Ybtl' = Cityscape - Brick
'Ysqd' = Cityscape - Square Tiles
'Yrtl' = Cityscape - Round Tiles
'Ygsb' = Cityscape - Grass
'Yhdg' = Cityscape -

Example:
  • Custom script: call ReplaceGlobalTerrain ('Lgrd', 'Wgrs')
Hello @[db]east , thanks for your response!

I want the tiles to change with the day/night time
from winterLordaeron tileset(day) to Northrend tileset(night) and vice versa.

would it be an issue to you if you integrate it for me real quick? you seem to be easy with Jass!
You would make my day! :)
 
Last edited:
Level 19
Joined
Feb 27, 2019
Messages
590
Id rather attempt to explain it to you, hope that works as well!

To be clear I have not created my own scripts with jass but I have a basic understanding of it.

However.. GUI is jass aswell!

You can make a copy of a trigger and convert it to custom text to see how this is true. Select Trigger > Edit > Convert To Custom Text > OK

You will se something like function InitTrig that will run at Init. I dont know why it automatically runs at Initialization, something hardcoded with the name Init probably.. It basically creates the trigger, adds event and adds the functions.

However we do not need to create a new trigger to make use of functions. We can call for functions using GUI. This is mostly what GUI does all the time, calls functions. These functions are mostly hidden from view and are built into the game. With jass we get a little better understanding of these built in functions.

Moving on from that and now to add the script I posted to your map and then use the functions within it!

From my understanding there are lots of useful systems and ways to add code, however I only understand the most basic way, which is to add the code to at the top of the Trigger Editor under the map name, there will be a space with the headline Custom Script Code. You can create any functions here and call for them using GUI which is similar to "Run Trigger". This is were you copy the entire Jass code that I posted. Whenever // is used in a line of code, that code will be ignored. That is why every comment in the script begins with // or /* hello / which ignores everyt hing inbetween the / and */. Comments are great to keep order in the code. Copy the jass code here now.

There you go! Now you have the entire script ready to be called.

Before we can replace a tile with another tile those tiles must exist in in the tileset within the map > Advanced > Modify tileset
If the tile does not exist there it cannot be used within the game. Cliff Base Tiles are usually cheaper and you have to bargain for tiles since there is a limit to how many tiles can be used. The tile furthest to the right will have priority over tiles to the left, simply what it means is that tiles line up to each other differently depending on their priority.

Now you can create a trigger with the event time becomes equal to.... (BE CAREFUL, using time becomes equal to = something may cause a crash! If this happens or to avoid this, I believe one adds a small wait of 0.1s or eventually less before any other actions) 18:00.

Then add the actions, first wait 0.1s then custom script: call ReplaceGlobalTerrain('Wdrt', 'Ndrt')
More function calls will be needed for the other tiles.

But why ('Wdrt', 'Ndrt') ??
If we look at the function we will find the answer!
function ReplaceGlobalTerrain takes integer OldTerrain, integer NewTerrain returns nothing
The function takes 2 things. These are the things that we use in ('Wdrt', 'Ndrt') the things are split up by ,
If the function instead says it takes nothing, returns nothing one would instead use call ReplaceGlobalTerrain() but that would not work for this function...

Also to find the code for each tile look at my older post.

GOOD LUCK
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Be aware that the 16 tile limit still applies to dynamically loaded terrain types. If you already use 16 tile types then you will not be able to dynamically load any more with triggers. Once a tile type is dynamically loaded it counts towards this limit meaning that there will always be at most 16 tile types on the map and that tile types cannot be swapped out.
 
Status
Not open for further replies.
Top