I'm very proud and happy to present you the first easy-to-set, modifiable and restartable terrain generator!!!
But before you cry (because you are happy), you must understand how it works.
So, before we start, I must thanks IliIilI for giving me his map 'populous', which gives me the basic lines to set my variable and do other cool stuff like that. At the bottom of the page, I've put the link to see this map.
I also want to say that the reason why I have described all my library is because my generator is still incomplete and imperfect and I wish that the community will help me to improve it with new actions. If this part is doesn't interest you, skip the 'function' and 'fundamental' part of my tutorial.
Now, Let's get starting with the interesting part. In my map, there is several things you must understand in the trigger panel to have an interesting final product like: Action definition, dimensional variables with index, etc. If you are not safe with this, don't lose your time and get tutorials about that. So, I strongly recommand you to open my map and check this tutorial at the same time with the library, because my titles in this page are the same as in my trigger panel.
- Linear Moutain
For more flexability, I have a variable that calls my record and in my record, I have my datas about terrain. As you can see, My world variable have 2 dimensions and I use this 2 dimensions to set the X and Y coordinates (you can always see your coordinates in the map at the bottom-left of the terrain window). For example, if I want to create a 8 height mountain at the coordinates "50,50", My action definition will set the world variable .Height = 8. Notice that I have set my arrays at the maximum of 135 of each. Why? It is simple, The more arrays you have, heavier the variable will be.So, if your map's size are 128X128, I recommand you to set the arrays to like 135-140. I also recommand to set your map's bounds at left and bottom to 16 minimum, because variable can't have negative arrays and if you spawn a mountain at 0,0, the program will try to put action in the negative part of the map, which is impossible.
In short, The height sub-variable is to set and get the new height of the terrain and the actor sub-variable is to verify if there is an actor at a specific coordinate to avoid actor stacking, the thing that will cause heavy lag.
The 2 functions are the only things that I have copied from Populous. The "If" function is simply the classic if,then,else function without the else and the "String To Actor" function is to convert a string to an actor name, in the data panel. While I'm in the data panel, if you open it, you can see in the actor tab that I have created strange actors, like TD 1_0. You will see the reason why later in the fundamental folder, but be reassured, if you want to put my library in your map, you only need to copy too the actors in your map's data panel (if you don't do it, the generator will not work).
This is the part that could give you a headache. To be as simple as possible, all of my generator primary works with 2 actions definitions, "Creating Deformer Smooth" which creates the actor and the other "Around Deformer Smooth" which checks the 4 points (X+1,X-1,Y+1,Y-1) around my first actor. Notice that the only difference between "Creating Deformer Smooth 1" and "Creating Deformer Smooth 2" is the final slope of the mountain. You can also notice that all my actions definitions have always the same 'template' parameter, otherwise I always begin with the X coordinate, after the Y and finally with the Height, which it is sometimes a H.
So, I will start with "Creating Deformer Smooth 1".
As you can see, I begin with a temporary variable to set my coordinates and after, I create an actor at this coordinates. Maybe you're asking yourself: Why does he places a temporary variable here? The reason is simple: The big big advantage is that I can put this action definition as 'create thread', which costs less memory (an independant action definition). The 2 last actions are only for setting my world variable, as I said above (Height for the height of the terrain and actor to confirm there is an actor here).
Now, I will focus on my action that creates the actor. This is how it works: I use my function "String To Actor" and after, I combine multiple strings together (notice that the order of the entered strings is very important). I start with the word "TD" and for the next string, I set this number equal to the height of my parameter and I conclude with "_0". If you go to the actor tab in the data panel, you will see my actor TD from 0 to 20. For example, If you select the actor TD 10_0, you will see that the 'height delta' slot is set to 2.5. Actually, the real height of the terrain with that actor will be of 2.5, but in my trigger, I will be 10. Why? It is simple. I cannot name an actor TD 2.5_0, because the editor cannot take characters like . or , so I place integers and I multiply by 4 to get more smoothness. One last thing, DON'T PUT A SPACE AFTER THE WORD TD IN THE FUNCTION, because when you are getting a name in the data panel, the editor will take the ID of the actor, not its name. For example, my trigger will get the actor ID "TD10_0", not the actor name "TD 10_0".
Finally, the "Around Deformer Smooth 1".
First of all, I set 2 temporary variables with the offset coordinates (X+1,X-1,Y+1,Y-1) of my first created actor. After it is done, I start an if function to verify if there is an actor at the 4 offset points and if it returns false, I simply get back my "Creating Deformer Smooth 1", but with my height - 1. For example, I create the actor TD 10_0 at the point 100,100. My trigger will verify after if there is an actor at the 4 coordinates (101,100 ; 99,100 ; 100,101; 100,99) and if they are all empty, my trigger create 4 actors TD 9_0 at the 4 points. But the magic is here: after the first actor TD 9_0 is created, it will run again the action "Around Deformer Smooth 1",but at the coordinates of this new actor!
In short, All actors that are created are verified 4 times.
Now, what happen if there is an actor at an offset point? It is easy but with some challenge. First of all, my trigger destroy the actor in place and after it verify the height at this point. Here is the challenge part: The trigger checks the higher AND the lowest height between the offset and the origin coordinates and after it subtracts to get the difference between this 2 height. If this value is higher than 4, the trigger will create and actor at the average height between the offset and the origin AT THE PLACE OF THE OFFSET. if it is lower than 4, it simply create an actor AT THE OFFSET COORDINATES with the (HEIGHT OF THE ORIGIN - 1).Why I put this complicated? See my example below.
My generator creates an actor of height 10 at the points 100,100 and 2 seconds after, it creates and actor of height 15 at the point 101,100. When the action "Around Deformer Smooth 1" will start for the second actor, my trigger will see that there is already an actor of height 10 at the point 100,100. So, as I said above, my library will take the height of 15 and 10 and will get the average height of it, 12.5. Notice that it is a decimal number, so I will create an actor of height rounded at 13.
To conclude, my generator is simply a loop between 2 actions that breaks only when the height = 0 or the height is enough averaged.
The Noise actions can be only used on wide flat terrain. It is not recommanded for now until I fix it.
The last action is "Creating Top Deformer", it is the same action than "Creating Deformer Smooth", but without starting the loop between my 2 actions.
Now the painful job is done, here is the funny part. I have primary 3 actions, Deformer with 1X1, 3X3 or 5X5. Notice that this size will be the size of the top of the mountain. As you can see in my trigger example, you only have to place this action in your trigger and set the X,Y and height of the desired mountain. Notice that there is also a folder in this folder, which create high height mountain. If you want to have tall mountains, take this actions, or else the program will create too much actors at the same time and the trigger will crash. If you open my action "Creating 3X3 Deformer", you will see that it creates 1 Top deformer at the origin coordinates and it will already creates 8 offset actors around the origin. I made this actions only to save time in the trigger part.
I personnally think that it is the most interesting part of my generator. This action let you create a mountain with the length that you want! But I need to explain this further.
This action have 6 parameters, the 3 basics (X,Y,Height) and 3 news; angle, length and top size. For example, if you enter "Linear Mountain Smooth" with this parameters "100,100,8,0,20,3" , my trigger will create a mountain with origin coordinates at 100,100 of height 8 at angle 0 of length 20 with a 3X3 flat top. Notice the "angle" parameter with the number 0. if you open my action definition, you will see that I multiple this number by 45, to get the actual degrees of the mountain. Otherwise, linear mountain can only go in 8 directions, from 0 to 360 degrees at multiple of 45. Another example, if I create a mountain with angle 3, the real angle will be 135 degrees, so all the Y points will be negative from the origin and all the X points will be positive. It is a bit complicated, so I recommand to make some tests with this action for a better comprehension.
Notice that "Noise" action refers to the noise pallet in the terrain editor, which means that it creates mini steepy mountains.
This part is not finished for now, so you can only use it on wide, wide flat terrain. For example, I have a 10X10 flat top mountain at height of 10. I can noise this to break the flatness of the mountain with this action with this parameter : X,Y,10. It is very important to put the same height between the terrain and the noise action, or else it will create too many actors and the trigger will crash.
For the visual programmers, I have put 2 example triggers, 1 for the starting map generator and 1 with the psi storm ability, which deforms the terrain. These examples are only to show you a part of the possibilities of my library. Notice that I create a templar at each end of the generator period, to see if my generator have crashed or not. At the end of all, I reveal the map to see the new terrain, but this action creates heavy lag (it is normal because you almost see like 128^2 actor in same time).
Finally, I'm thinking since 2 weeks on a way to create cliff via trigger panel. I think that I will base this on blocker and revealer, but I'm still in the imagination part, so this update will be not be for tomorrow. I also want to say that I'm still considering myself as a noobie in trigger, so if someone got an idea or want to improve my library, it is sure that I will listen you.
Here is the link for populous : http://www.sc2mapster.com/maps/populous/
P.S: I suggest you to go to my other libraries to leave comments and suggestions and I have finally done a wish list on the official forum of Starcraft 2. My only demand is that people who see, like and use my libraries could go on the battle.net forum and like my comments about the improvement for the editor. It's not an obligation, but It would me make very happy! Here is the link for the forum : http://us.battle.net/sc2/en/forum/topic/6307501153?page=6#110
Thank you. you are a life saver to us noobs. i've been trying to learn how to dose this for yonk's. keep up the great work and also thanks to IliIilI for his hard work as well.
all i need now is a room Generator and im set to go. just one question how would i go about saving the terrain generated ?
You're welcome and hmmm... great question...
I made my generator primary for my RTS map, so I don't need to save my map once it is generated. I kept in mind that a player never now what kind of terrain will expect him. Maybe I could save all my datas on another world variable that can be called later with a specific action. Could you explain more about saving the terrain? Is it for another linked map or to get the beginning terrain later in the game?
If I may make a suggestion: Perhaps a random seed for your generator would help cut down on the number of variables you would need for saving the terrain.
Malum Ruina: SC2Mapster
Eternal Exile: SC2Mapster
Spine Crawler Madness: SC2Mapster
Xeno Crisis: SC2Mapster
did read that Ahli634 dungon generator map uses untis xp,life and all that to store data of the dungon layout. so would it not be possible to do it here ? plus the other bouns would be the amont of data needed to be stored would be alot less. just an idea.....not a good idea i think never mind.
Can you explain more about the random seed generator? I think that my world variable is the best because, in the future, I will add foliage and regions depending on the height of the terrain to the record. For example, if the terrain is higher that 15, it will creates a region that gives a behavior to any units that reduce the sight radius.
I have yet to program one myself, but wikipedia may give you more insight.
I added something new with my map, an earthquake event! Open my map, start the game and press a when you are ready. You can press multiple time to see how it reacts.
How can you use it? Easy. You have 4 parameters : the 2 first are for the start X and Y coordinates, the third is for the height of the crack (multiply this number by 2 to have the total height) and the last is the strength of the earthquake (I use the power 2 of a number, so if you put 5, you will get a crack of 50 cases, 25 point in x,y and 25 points in -x,-y).
cmon, post some screens of the terrain your generator generated
I know that my earthquake crack is a little bit square, but as my variable is set for integer in the map (like x=1,y=1 or x=102,y=64), I cannot have decimal coordinates.
You must login to post a comment. Don't have an account? Register to get one!