System Terrain Generator

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Hate creating terrain? Want to have great terrain without the work? Well, this system is for you! It will create completely random, good-looking terrain when the game starts.

Pros

You can specify up to 5 different terrain types

You can also have 5 different destructable-types that will be randomly generated.

No more wasting time on terrain!

The Generation Seed allows you to specify how much generation there is!

You can specify a specific region to be modified.

If a region is specified, it will not be a perfect square.

Works on any size map. Even 256x256!


Cons

The larger the map, the longer the generation takes.

The new terrain does not show up on the minimap.

If a region is specified, it will not be a perfect square.


Here are some screenshots of the randomly generated terrain. This was created from a blank, flat 64 x 64 dirt map:

TerrainGenerator-1.jpg


TerrainGenerator2-1.jpg


TerrainGenerator3-1.jpg




Just download the map, open it, and hit the test button to see it in action!

Improvement suggestions and critiques are welcome.

Yes, I know the code is a little bit of a mess. But it works. :p

Code:
Terrain Generator
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        For each (Integer Loop) from 1 to (Integer(((Width of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to (Integer(((Height of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
                    Loop - Actions
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Terrain type at TempPoint) Equal to Lordaeron Summer - Dirt
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Change terrain type at TempPoint to TerrainTypes[(Random integer number between 1 and 5)] using variation -1 in an area of size (Random integer number between 1 and 5) and shape Circle
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (-1.00 x (Real(GeneratorSeed)))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Terrain type at TempPoint) Equal to Lordaeron Summer - Dirt
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Change terrain type at TempPoint to TerrainTypes[(Random integer number between 1 and 5)] using variation -1 in an area of size (Random integer number between 1 and 5) and shape Circle
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (-1.00 x (Real(GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Terrain type at TempPoint) Equal to Lordaeron Summer - Dirt
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Change terrain type at TempPoint to TerrainTypes[(Random integer number between 1 and 5)] using variation -1 in an area of size (Random integer number between 1 and 5) and shape Circle
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (-1.00 x (Real(GeneratorSeed)))), ((Real((Integer A))) x (-1.00 x (Real(GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Terrain type at TempPoint) Equal to Lordaeron Summer - Dirt
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Change terrain type at TempPoint to TerrainTypes[(Random integer number between 1 and 5)] using variation -1 in an area of size (Random integer number between 1 and 5) and shape Circle
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)

Code:
Destructable Generator
    Events
        Time - Elapsed game time is 1.25 seconds
    Conditions
    Actions
        For each (Integer Loop) from 1 to (Integer(((Width of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to (Integer(((Height of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
                    Loop - Actions
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random integer number between 1 and 100) Less than or equal to 15
                            Then - Actions
                                Set TempGroup = (Units within 400.00 of TempPoint)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in TempGroup) Equal to 0
                                        (Terrain type at TempPoint) Not equal to Lordaeron Summer - Rock
                                        (AffectedRegion contains TempPoint) Equal to True
                                    Then - Actions
                                        Destructible - Create a Destructables[(Random integer number between 1 and 5)] at TempPoint facing (Random angle) with scale 1.00 and variation 0
                                    Else - Actions
                                Custom script:   call DestroyGroup(udg_TempGroup)
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (-1.00 x (Real(GeneratorSeed)))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random integer number between 1 and 100) Less than or equal to 15
                            Then - Actions
                                Set TempGroup = (Units within 400.00 of TempPoint)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in TempGroup) Equal to 0
                                        (Terrain type at TempPoint) Not equal to Lordaeron Summer - Rock
                                        (AffectedRegion contains TempPoint) Equal to True
                                    Then - Actions
                                        Destructible - Create a Destructables[(Random integer number between 1 and 5)] at TempPoint facing (Random angle) with scale 1.00 and variation 0
                                    Else - Actions
                                Custom script:   call DestroyGroup(udg_TempGroup)
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (-1.00 x (Real(GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random integer number between 1 and 100) Less than or equal to 15
                            Then - Actions
                                Set TempGroup = (Units within 400.00 of TempPoint)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in TempGroup) Equal to 0
                                        (Terrain type at TempPoint) Not equal to Lordaeron Summer - Rock
                                        (AffectedRegion contains TempPoint) Equal to True
                                    Then - Actions
                                        Destructible - Create a Destructables[(Random integer number between 1 and 5)] at TempPoint facing (Random angle) with scale 1.00 and variation 0
                                    Else - Actions
                                Custom script:   call DestroyGroup(udg_TempGroup)
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (-1.00 x (Real(GeneratorSeed)))), ((Real((Integer A))) x (-1.00 x (Real(GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random integer number between 1 and 100) Less than or equal to 15
                            Then - Actions
                                Set TempGroup = (Units within 400.00 of TempPoint)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in TempGroup) Equal to 0
                                        (Terrain type at TempPoint) Not equal to Lordaeron Summer - Rock
                                        (AffectedRegion contains TempPoint) Equal to True
                                    Then - Actions
                                        Destructible - Create a Destructables[(Random integer number between 1 and 5)] at TempPoint facing (Random angle) with scale 1.00 and variation 0
                                    Else - Actions
                                Custom script:   call DestroyGroup(udg_TempGroup)
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)

Code:
Terrain Generator Height
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        For each (Integer Loop) from 1 to (Integer(((Width of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to (Integer(((Height of (Playable map area)) / (Real(GeneratorSeed))))), do (Actions)
                    Loop - Actions
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Create a 0.10 second Permanent crater deformation at TempPoint with radius (Random real number between 64.00 and 512.00) and depth (-1.00 x (Random real number between -32.00 and 32.00))
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (Real((-1 x GeneratorSeed)))), ((Real((Integer A))) x (Real(GeneratorSeed)))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Create a 0.10 second Permanent crater deformation at TempPoint with radius (Random real number between 64.00 and 512.00) and depth (-1.00 x (Random real number between -32.00 and 32.00))
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (Real(GeneratorSeed))), ((Real((Integer A))) x (Real((-1 x GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Create a 0.10 second Permanent crater deformation at TempPoint with radius (Random real number between 64.00 and 512.00) and depth (-1.00 x (Random real number between -32.00 and 32.00))
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
                        Set TempPoint = (Point(((Real(Loop)) x (Real((-1 x GeneratorSeed)))), ((Real((Integer A))) x (Real((-1 x GeneratorSeed))))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (AffectedRegion contains TempPoint) Equal to True
                            Then - Actions
                                Environment - Create a 0.10 second Permanent crater deformation at TempPoint with radius (Random real number between 64.00 and 512.00) and depth (-1.00 x (Random real number between -32.00 and 32.00))
                            Else - Actions
                        Custom script:   call RemoveLocation(udg_TempPoint)
 

Attachments

  • Terrain Generator.w3x
    24.3 KB · Views: 1,149

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Please post the code here

Done. Didn't think it was needed since the map is there. :rolleyes:
 

elmstfreddie

The Finglonger
Reaction score
203
It's completely random! You might as well randomly place 4 types of terrain on the ground, lol.
Besides, wouldn't a better system make the terrain based on factors like terrain height differences, position of trees, etc ;)
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> It's completely random!

That's the idea. :p Replayability in the extreme. What terrain will it be THIS time? You can specify the types that are available, though.

> Besides, wouldn't a better system make the terrain based on factors like terrain height differences, position of trees, etc

IT makes the trees and height. :p
 

elmstfreddie

The Finglonger
Reaction score
203
> Besides, wouldn't a better system make the terrain based on factors like terrain height differences, position of trees, etc

IT makes the trees and height. :p

So :p
That makes it easier to change the terrain at hill sides/trees now doesn't it ;)

BTW: Random trees is completely evil idea. I couldn't think of a map that would work very well with random tree placement anywhere O_O
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> That makes it easier to change the terrain at hill sides/trees now doesn't it

Hmm. Not really sure what you mean there....

> Random trees is completely evil idea. I couldn't think of a map that would work very well with random tree placement anywhere

Then don't add trees in the destructable variable. :p
 

elmstfreddie

The Finglonger
Reaction score
203
> That makes it easier to change the terrain at hill sides/trees now doesn't it

Lets say you have an ashenvale tileset. I like to place the leaves tile underneath trees, it looks good :p. Also steep hills should have more rock terrain on them then lower plains, which should have grass.
 

Newbwc3

Sephiroth_VII
Reaction score
157
Terrain thats COMPLETLY random. yep. I wouldn't use it because it make bad terrain in my opinion, and im not that lazy..but I'm sure it could be usefull to a very lazy person. :D
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Lets say you have an ashenvale tileset. I like to place the leaves tile underneath trees, it looks good . Also steep hills should have more rock terrain on them then lower plains, which should have grass.

Ok, got it. No, it won't do that. :p Though, now I think about it, I could make it do that....

> I wouldn't use it because it make bad terrain in my opinion

I have some screenshots. It looks pretty good to me. :(
 

Newbwc3

Sephiroth_VII
Reaction score
157
On the unbuildable rock you could make it place rock doodads that would look nice.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> On the unbuildable rock you could make it place rock doodads that would look nice.

I can only do destructables, unfortunately. There is a rock destructable, but it's that selectable one that you can destroy.
 

Newbwc3

Sephiroth_VII
Reaction score
157
yea WE needs more functions that deal with doodads. create, remove, move,ect..
Need help! few posts below cameras...
 

U are a noob

Mega Super Ultra Cool Member
Reaction score
152
You have no if then else actions to check whether trees make a full circle around a certain point. Trees can be in the way of things like maybe shops. Add the option where you can make only a certain part of the map is random or a certain part isn't random. Make it so trees aren't made on rocks because that is un-real. Also you should have actions that make path ways instead of pure random tiles.
 

Tinki3

Special Member
Reaction score
418
>I have some screenshots. It looks pretty good to me :(

I think I'd have to agree with you Ghan. Not too bad.
Does need a bit of work though.
Title requires a *WIP* tag :p

>This is horrible
>This system needs a full overhaul

Any positive stuff you'd like to add? :rolleyes:
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
To all of you flamers, bah!

Nice system Ghan_04, in bigger map, where terrain matters it might not be the wisest thing to use it, but when playing mini-games this could be quite useful.

Also, add something that will not randomize terrain if there is a pre-placed one there already.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Ok, got a major update. It won't put trees on rocks anymore, though they may be right up on the edge. Also, it won't produce destructables near units. And last, you can give it a specific region to be generated, but it will not be a perfect square. Might be a plus, actually. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top