Nottud's creations!

Will you be the future designer? Will you be the future ruler? Explore at your own risk!

Random map tutorial

Before we start, you will need to remember that I am only a beginner at random map scripting but I am going to give you a guide to hopefuly create a random map script which will be as good as this from just a basic template!

This guide will start with the very basics and will teach you how to make one yourself!  You may even be able to start making more complex random maps than me and making them as if your doing a scenario!

Please as you read through this guide, go through the processes given here as they are in step by step form!

Task 1 - Creating the start files

Before we start scripting, we need to create the files in the first place!

Open up notepad or any other basic text editor - do not use microsoft word, it tries to run the actual scripts when you open it!
Now save the blank file to a folder in age of mythology called RM2.  This is where your random maps are stored!
When you save the file, save it either by selecting the extension .xml or typing in: yourmapname.xml and press save.
Repeat again and call it exactly the same name but put .xs instead.

-Tips-
If you are struggling, just copy both the xs and xml files from and exsisting random map, open them up and clear them then just save them under a different name which are identical to each other.

Task 2 - Making the .xml script for your map
This file is only a bit of code to tell age of mythology what to display, not the main code!

Copy and paste this template into your xml file:


<?xml version = "1.0" encoding = "UTF-8"?>
<mapinfo details = "" imagepath = "ui/ui map scenario 256x256" displayNameID="" cannotReplace=""/>

This tells age of mythology what to display.  The only thing you need to change pahaps is:

ui/ui map scenario 256x256

This tells age of mythology what picture to display for your map.  There are lots of different ones you can use so try changing the filepath to this one:

ui/ui god kronos 256x256

Remeber to keep the quotation marks on both sides of the filepath.  I don't think I need to go into details on what this is a picture of!

Congratulations! - You have created one of the 2 files needed for age of mythology random map scripting!

Task 3 - Creating your first random map!
Before we start this, I would like to greatly credit Auron_ for using his random map template for this tutorial perpose!

Start by copying and pasting this template into your xs file:



// Main entry point for random map script/


void main(void) {

   // Text
   rmSetStatusText("",0.01);

   // Set size.
   int playerTiles=9000;
   if(cMapSize == 1)
   {
      playerTiles =12000;
      rmEchoInfo("Large map");
   }
   int size=2.0*sqrt(cNumberNonGaiaPlayers*playerTiles/0.9);
   rmEchoInfo("Map size="+size+"m x "+size+"m");
   rmSetMapSize(size, size);

   rmSetStatusText("",0.04);

   // Set up default water.
   rmSetSeaLevel(0.0);

   // Init map.
   rmTerrainInitialize("grassB");
   rmSetLightingSet("default");
   rmSetSeaType("Mediterranean Sea");


//ELEVATION

int id = rmCreateArea("mountain");
rmSetAreaSize(id, 0.1, 0.1);
rmSetAreaLocation(id, 0.5,0.5);
rmSetAreaBaseHeight(id, 15.0);
rmSetAreaHeightBlend(id, 2);
rmSetAreaCoherence(id, 0.50);
rmBuildArea(id);

//  LOADING:

rmSetStatusText("",0.07);

rmSetStatusText("",0.10);

rmSetStatusText("",0.13);

rmSetStatusText("",0.16);

rmSetStatusText("",0.19);

rmSetStatusText("",0.22);

rmSetStatusText("",0.25);

rmSetStatusText("",0.28);

rmSetStatusText("",0.34);

rmSetStatusText("",0.37);

rmSetStatusText("",0.40);

rmSetStatusText("",0.43);

rmSetStatusText("",0.46);

rmSetStatusText("",0.49);

rmSetStatusText("",0.52);

rmSetStatusText("",0.55);

rmSetStatusText("",0.61);

rmSetStatusText("",0.64);

rmSetStatusText("",0.67);

rmSetStatusText("",0.70);

rmSetStatusText("",0.73);

rmSetStatusText("",0.76);

rmSetStatusText("",0.79);

rmSetStatusText("",0.82);

rmSetStatusText("",0.85);

rmSetStatusText("",0.88);

rmSetStatusText("",0.91);

rmSetStatusText("",0.94);

rmSetStatusText("",1.00);

}

Now save it and launch age of mythology, select singleplayer and select your map.  Now launch your new random map!  This will create a giant hill in the centre of the map!

Task 4 - going through on how this random map works!

I am now going to run through the steps on how this map works going through all the steps:
// Set size.
   int playerTiles=9000;
   if(cMapSize == 1)
   {
      playerTiles =12000;
      rmEchoInfo("Large map");
   }
   int size=2.0*sqrt(cNumberNonGaiaPlayers*playerTiles/0.9);
   rmEchoInfo("Map size="+size+"m x "+size+"m");
   rmSetMapSize(size, size);

   rmSetStatusText("",0.04);

   // Set up default water.
   rmSetSeaLevel(0.0);

   // Init map.
   rmTerrainInitialize("grassB");
   rmSetLightingSet("default");
   rmSetSeaType("Mediterranean Sea");

This is the first part of the script and this gives you all the settings of the actual random map.


// Set size.
   int playerTiles=9000;
   if(cMapSize == 1)
   {
      playerTiles =12000;
      rmEchoInfo("Large map");
   }
   int size=2.0*sqrt(cNumberNonGaiaPlayers*playerTiles/0.9);
   rmEchoInfo("Map size="+size+"m x "+size+"m");
   rmSetMapSize(size, size);

This is to tell the game what size you want the random map to be.  I myself actually prefer the set size option rather than doing it the tiles way.  This will make the map size adjust accoding to the number of players.

int playerTiles=9000;
   if(cMapSize == 1)
   {
      playerTiles =12000;
      rmEchoInfo("Large map");
   }
[/code]</tt></font>

Try changing the map size by changing the "playertiles" value.  The larger the number, the larger the map.

// Set up default water.
   rmSetSeaLevel(0.0);

   // Init map.
   rmTerrainInitialize("grassB");
   rmSetLightingSet("default");
   rmSetSeaType("Mediterranean Sea");

The next part of the script is very obvious

The first part tells you the sea level of the map.  This is currently set to zero but try changing the sea height to 10.  Here is the code below if you get stuck:

rmSetSeaLevel(10.0);

The second part tells you default settings of the map.
rmTerrainInitialize("grassB");  tells you what the default terrain of the map is.  This can be changed to any terrain type you like!
rmSetLightingSet("default");  this tells you the lighting of the map.  This also can be changed to what you like.
rmSetSeaType("Mediterranean Sea");  this tells you that if there is any water there this will be the water type the map can be.  This can be changed into any watertype you like.

Now for the main bit of the script!:
(1)int id = rmCreateArea("mountain");
(2)rmSetAreaSize(id, 0.1, 0.1);
(3)rmSetAreaLocation(id, 0.5,0.5);
(4)rmSetAreaBaseHeight(id, 15.0);
(5)rmSetAreaHeightBlend(id, 2);
(6)rmSetAreaCoherence(id, 0.50);
(7)rmBuildArea(id);

I have numbered each section which I am now going to go through:

(1)Tells you the area main name and script name.
(2)This tells you the size of the area out of 1 being the entire map
(3)tells you where is it - 0.5,0.5 is the centre of the map
(4)tells you the height of the area, in this case it is the hill.
(5)This tells you how much you want the land to blend in into the surroundings.  0 is not blend.  1 is a little blend.  2 or more blends it in really well.
(6)This is my favorite bit which I am going to let you try out yourself!  I want to on the main script to change this value to the amounts listed below and save it.  Then open age of mythology and open the script.  Here are the values I want you to try:

1
0
-1
-10
-100

What do you notice?

You will notice that 1 creates a perfect round hill, 0 makes it less of a circular shape and more random.  Keep going down in value and the hill gets more and more out of shape intill you get the hill going all over the map creating cool landscapes at really low values!

(7)Not sure - I think this tells the script to place the actual area.  You will have to ask more experienced scripters than me!


You map find that the script has these dotted around the script, especially at the end in this script template:

rmSetStatusText("",0.79);

This tells you what the position the loading bar should be when launching you map.  (That big green bar you get when you launch your map to show it is loading!)

There are some other symbols and things in the script but now is not the time to worry about them!

 


*Construction should hopefuly continue soon, it will tell you how to:

Creating mutiple areas of your own.
Creating forsts, cliffs and water.
Creating 2 features or more to appear at random
Creating objects for the map
Creating triggers for your map*

 

 

    Want your own free site like this? Try Freewebs.com