You must be logged in to post messages.
Please login or register

The University
Moderated by Popeychops, Leif Ericson

Hop to:    
Welcome! You are not logged in. Please Login or Register.3 replies
Age of Kings Heaven » Forums » The University » RMS Tutorials: All About Cliffs (Approved)
Bottom
Topic Subject:RMS Tutorials: All About Cliffs (Approved)
Zetnus
Squire
posted 09-15-15 10:24 AM CT (US)         
This article has been approved and can also be read at the University. - Leif Ericson

RMS Tutorials: All About Cliffs

By: Zetnus

************************************************************
Preface

This tutorial assumes that you have some basic understanding of the land_generation and the terrain_generation sections. If you want to brush up on those sections, you might consider looking at my Updated New RMS Guide.

This article assumes that you have absolutely no knowledge about cliffs. If you DO know the basics about cliff_generation, you may want to skim through the first part of this tutorial without actually doing all the exercises.

************************************************************
Introduction

Why cliffs?
cliff_generation is often regarded as one of the least interesting sections of a random map script (after perhaps player_setup). This because there is not that much that you can do to control where you place cliffs, and as a result, many people leave them off their script entirely. My goal is convince you that cliffs are an exciting and useful part of any random map script. Failing that, I at least want to show you that you do have some scope to customize your cliff_generation section to suit your needs.

What are cliffs?
Cliffs are best thought of as a special type of terrain which automatically comes with cliff objects placed on it Ė sort of like forest terrain, which automatically comes with tree objects on it.

Cliffs are generated after lands but before terrains. <--This is very important, as we will soon discover.

The order in which a map is generated is as follows:


<PLAYER_SETUP>
<LAND_GENERATION>
<ELEVATION_GENERATION>
<CLIFF_GENERATION>
<TERRAIN_GENERATION>
<CONNECTION_GENERATION>
<OBJECTS_GENERATION>


The order in which you put them in your script has no effect. However, in my opinion, it is most helpful to put them in the order listed above because that is order if which they are actually used.

************************************************************
The Basics

Grab yourself a text editor (Notepad will do) and create a blank file called cliff_tutorial.rms and place it in your RM script directory in your game folder.

Open up the game and generate that map. You should see a large and utterly uninteresting field of grass, which makes sense, given that the script is blank.

Now add the following:


<CLIFF_GENERATION>


Make sure you have saved the changes to your script. Now if you generate your map, you will notice a few cliffs in your grassy field. This is interesting, because <CLIFF_GENERATION> is the only section of a random map script where typing the section header is enough to achieve something.

Now letís add some basic player lands and objects which will be useful later:


<LAND_GENERATION>
create_player_lands
{
terrain_type DIRT
land_percent 50
}
<CLIFF_GENERATION>

<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


Now letís add the following below the <CLIFF_GENERATION> header:


min_number_of_cliffs 10
max_number_of_cliffs 10


You should now see that there are exactly 10 distinct cliffs in your map. Now try changing it to:


min_number_of_cliffs 9999
max_number_of_cliffs 9999


You will see a large number of cliffs on your map. But there will not be 9999 cliffs, because there isnít room for that many cliffs on your map. You will notice that cliffs avoid the player start areas by default. They would also avoid the centers non-player lands, if we had created any of those. You will also observe that cliffs avoid touching other cliffs. There are always two spaces between different cliffs. This does not have to be the case. Add the following to your script:


min_distance_cliffs 0


Now your map will be absolutely filled with cliffs (except for the centers of the player lands).
Letís make it more manageable by changing it to:


min_distance_cliffs 3


Next we will add the following:


min_length_of_cliff 10
max_length_of_cliff 12


Your cliffs should now be 10, 11 or 12 tiles long. All pretty self-explanatory so far, right?
Next we have:


cliff_curliness 50


This is a % which determines how curly your cliffs are. At 0, cliffs will be very straight, and at 100 they will be extremely twisted.

************************************************************
Scaling to Map Size
What Iíve covered so far is all not to difficult to grasp, and you could have probably worked it out yourself without my help. You may be wondering if you are wasting your time with this tutorial, but I just wanted to cover the basics first to make sure that the rest makes sense.

Change the min and max number of cliffs back to 10. Your script should now look like this:


<LAND_GENERATION>
create_player_lands
{
terrain_type DIRT
land_percent 50
}
<CLIFF_GENERATION>
min_number_of_cliffs 10
max_number_of_cliffs 10
min_distance_cliffs 3
min_length_of_cliff 10
max_length_of_cliff 12
cliff_curliness 50

<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


Now, I want you to generate a TINY map and count the number of cliffs. It should be 10. Now generate a GIGANTIC map and count the number of cliffs. It will still be 10. This is a problem.

Cliffs do not scale to map size automatically. You have to do it manually using conditional statements based on map size. Letís take a quick look at the scaling table:


Size Tiles on Sides Total Tiles Area ratio to 100x100 map

Tiny 120x120 14400 1.4
Small 144x144 20736 2.1
Medium 168x168 28224 2.8
Large 200x200 40000 4.0
Huge 220x220 48400 4.8
Gigantic 240x240 57600 5.8
LudiKRIS 480x480 230400 23.0


If we think that a medium map looks good with roughly 10 cliffs, then we should execute some scaling which could look roughly like this:


if TINY_MAP
min_number_of_cliffs 5
max_number_of_cliffs 5
elseif SMALL_MAP
min_number_of_cliffs 7
max_number_of_cliffs 7
elseif MEDIUM_MAP
min_number_of_cliffs 10
max_number_of_cliffs 10
elseif LARGE_MAP
min_number_of_cliffs 14
max_number_of_cliffs 14
elseif HUGE_MAP
min_number_of_cliffs 17
max_number_of_cliffs 17
elseif GIGANTIC_MAP
min_number_of_cliffs 21
max_number_of_cliffs 21
elseif LUDIKRIS_MAP
min_number_of_cliffs 82
max_number_of_cliffs 82
endif


************************************************************
Controlled Cliff Placement: Wonderful Water

This is where things actually get interesting and new possibilities open up.
Change the base_terrain to WATER and change the min and max number of cliffs back to 9999 (ie. get rid of the conditional scaling again). Also change the min_distance_cliffs to 1.
Your script should look like this:


<LAND_GENERATION>
base_terrain WATER
create_player_lands
{
terrain_type DIRT
land_percent 50
}
<CLIFF_GENERATION>
min_number_of_cliffs 9999
max_number_of_cliffs 9999
min_distance_cliffs 1
min_length_of_cliff 10
max_length_of_cliff 12
cliff_curliness 50

<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


You will see that cliffs are not placed on the WATER. Cliffs avoid water by default (this includes all types of water including shallows and ice). The default avoidance distance is 2. The distance that cliffs stay away from water can be modified as follows:


min_terrain_distance 4


Cliffs will now stay 4 tiles away from the nearest body of water. If you change it to 0, cliffs will go all the way to the beaches.

I mentioned earlier that it was important to know that cliffs are generated after lands but before terrain and you will now see why. Change your script to match this:


<LAND_GENERATION>
base_terrain GRASS
create_player_lands
{
terrain_type DIRT
land_percent 50
}
<CLIFF_GENERATION>
min_number_of_cliffs 9999
max_number_of_cliffs 9999
min_distance_cliffs 1
min_length_of_cliff 10
max_length_of_cliff 12
cliff_curliness 50
min_terrain_distance 0
<TERRAIN_GENERATION>
create_terrain WATER
{
base_terrain GRASS
land_percent 100
number_of_clumps 99999
}
<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


You will see that you ocean is now completely filled with cliffs. This is because the WATER is now being produced in the terrain_generation section rather than land_generation. This means that the water is being created after the cliffs have already been placed down. Similarly cliffs can be on connections made of water because connection_generation also comes after cliffs.

Using water for your lands can let you achieve all kinds of interesting effects. For example, try the following:


<LAND_GENERATION>
base_terrain WATER
create_player_lands
{
terrain_type MED_WATER
land_percent 50
}
create_land
{
terrain_type DESERT
land_percent 25
}
<CLIFF_GENERATION>
min_number_of_cliffs 9999
max_number_of_cliffs 9999
min_distance_cliffs 1
min_length_of_cliff 10
max_length_of_cliff 12
cliff_curliness 50
min_terrain_distance 0
<TERRAIN_GENERATION>
create_terrain GRASS
{
base_terrain WATER
land_percent 100
number_of_clumps 99999
}
create_terrain DIRT
{
base_terrain MED_WATER
land_percent 100
number_of_clumps 99999
}
<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


Even though there is almost no water in your final map, the cliffs placement has been restricted to a certain part of the map (the desert) by virtue of creating watery lands and then replacing all the terrains.

************************************************************
Controlled Cliff Placement Continued: Cliffs as a Terrain

I mentioned earlier that cliffs are sort of like a specialized terrain. Let me illustrate why by going back to a very basic setup:


<LAND_GENERATION>
base_terrain DESERT
create_player_lands
{
terrain_type DIRT
land_percent 5
}
<CLIFF_GENERATION>
min_number_of_cliffs 10
max_number_of_cliffs 10
<TERRAIN_GENERATION>

<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


Now, letís add some stuff the in the terrain_generation section:


<LAND_GENERATION>
base_terrain DESERT
create_player_lands
{
terrain_type DIRT
land_percent 5
}
<CLIFF_GENERATION>
min_number_of_cliffs 10
max_number_of_cliffs 10
<TERRAIN_GENERATION>
create_terrain BAMBOO
{
base_terrain DESERT
land_percent 100
number_of_clumps 99999
spacing_to_other_terrain_types 5
}
<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
set_place_for_every_player
max_distance_to_players 0
}


What you should see is that the massive bamboo forest stays 5 tiles away from other terrains (ie. the player lands made of DIRT). What is interesting is that that it also stays 5 tiles away from all the cliffs. This is because cliffs automatically come with terrain underneath them. This terrain is #16 and looks exactly like GRASS. You may sometimes have noticed it peeking out beneath the cliffs when the surrounding terrain isnít GRASS. If you donít like the way this looks, it can be replaced with a different terrain. First you need to define this terrain using a #const statement because it doesnít come with predefined name. Once youíve done that, you can place or replace terrain 16.
Add this to the bottom of your terrain_generation section:


#const GRASS_CLIFFS 16
create_terrain ICE
{
base_terrain GRASS_CLIFFS
land_percent 100
number_of_clumps 99999
spacing_to_other_terrain_types 0
}


You should now see tiny patches of ICE under parts of your cliffs. Iíve chosen ICE to make it easy to see, but if you want to make it impossible to see then you should replace terrain 16 with the surrounding terrain Ė in this case DESERT.

************************************************************
Conclusion

That pretty much wraps up this tutorial on cliffs. You should now understand almost everything there is to know about cliffs when it comes to random map scripting. You know that cliffs donít scale to map size and you understand why they avoid land water but not terrain water. You also understand why terrains you place will avoid cliffs just like they avoid other terrains.

Using everything youíve learned, you can harness the power of controlled cliff placement to generate some unusual map designs. For some examples, take a look at my Cliffscape. Itís a collection of maps that focus specifically on controlled cliff placement.

Let me know if you have any questions or find any mistakes. I hope this was useful!

......../\
......./ / / \ Check out my Blacksmith submissions as well as my stuff in the Steam Workshop.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Updated New RMS Guide <<<version 2.0 is out<<< and the Random Map Scripting Links and FAQ thread.
..../_____\\\ \
....\\\\\\\\\\\\\/ (unknowingly) the submitter of the 12000th item to the Blacksmith.

[This message has been edited by Leif Ericson (edited 02-19-2017 @ 05:06 PM).]

AuthorReplies:
HockeySam18
Dķnadan
posted 09-15-15 01:27 PM CT (US)     1 / 3       
Nice article, very informative! I've never given RM scripting a go before, but I'll be sure to check this out when that day comes

Storm on the Steppe | Galderton Hill RP | Proud member of Stormwind Studios

"Cattle die, kindred die, every man is mortal:
But the good name never dies of one who has done well." - HŠvamŠl

"Hockey is the only sport left for true men." - ax_man1
HenkDeSuperNerd
Squire
posted 08-25-18 08:04 PM CT (US)     2 / 3       
There seems to be a minimum distance to lands, where cliffs generation is hindered. This distance seems to be roughly 25tiles (from the center of the land).

Is there any code known that can change this distance to (player)lands??
Zetnus
Squire
posted 09-20-18 02:55 PM CT (US)     3 / 3       
As far as I know, there is no way to change or affect that distance.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my stuff in the Steam Workshop.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Updated New RMS Guide <<<version 2.0 is out<<< and the Random Map Scripting Links and FAQ thread.
..../_____\\\ \
....\\\\\\\\\\\\\/ (unknowingly) the submitter of the 12000th item to the Blacksmith.
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Kings Heaven | HeavenGames