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,146

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
156
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
156
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
156
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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top