Random Map Help File Document
Age of Mythology™
© 2002, Microsoft Corporation. All rights reserved.
Important: Age of Mythology allows you to create your own random map scripts. You may share these custom random map scripts for the purposes of gameplay, but you may not sell or make other commercial uses of the custom random map scripts. Microsoft® reserves all other rights to the editors and files.
1) How to Script
The Random Map scripts are more like an actual programming language than were the RM scripts from Age of Kings: The Conquerors. This gives the AoM RM scripts a great deal of power, but also a potentially steeper learning curve. However, users with any familiarity with programming should have an easier time because many of the conventions are similar.
Some conventions to keep in mind:
· The script is case-sensitive.
· All variables (such as integers and floats) must be defined the first time they are used. If they are redefined after that, you must leave out the “int” of “float”.
Original: int numGoats = 0;
Subsequent: numGoats = 2;
· There are many shortcuts for making scripts, and some are shown at the end of this file. Conditional statements can make use of “if”, “else” and “if else”. Do loops can run through a list of commands multiple times, and is particularly useful for duplicating areas or objects for each player.
· Comments can be specified by inserting // at the beginning of a line or enclosing text in /* and */. Comments can remind you (and anyone else reading your map) what each section is trying to do, and commenting out sections of a map script can help in debugging problems.
2) Script Order
Order of the scripts is important. You must build land before you can place objects on it. Objects will only respect the constraints of areas and objects that are already placed. You can’t use a variable that you haven’t defined.
3) Map Grid
Maps are oriented along an X, Z grid. Y is elevation. The origin of the grid, 0,0, is located at the bottom of the screen. When using fractions, 0.5, 0.5 is the middle of the map, and 1, 1 is the top of the map, at 12 o’clock. The grid uses 2m square tiles. A 4-player map is probably about 400 m along one side. Small buildings occupy 2m and small units occupy 1m of space.
4) Unit names
All object names refer to a protounit name. What’s the difference between a unit and a protounit? Unit names in the game are a friendlier version of the protounit name. For example, the protounit name for “Laborer” is “Villager Egyptian”. The protounit name for “Town Center” is “Settlement Level 1.”
5) XML files
Map scripts use the file extension RMS but are text files and can be edited with any text editor. However, in order to play on a new map, you must also create an XML file with the same name as your RMS. XML is a markup language similar to HTML used by Web pages. Most Web browsers can view XML files, but you may need to open the file in another application, such as an XML editor or even a text editor. The only things you need in your XML file are shown below in bold: the map’s name and description, plus a screenshot icon if you want. XML files for random maps look like this:
· <?xml version = "1.0" encoding = "UTF-8"?>
· <mapinfo details = "Goatunheim: Fight your way through evil Goats to reach the enemy player" imagepath = "ui\ui map goatunheim 256x256" displayNameID="Goatunheim" cannotReplace=""/>
6) How to get help
Some ways to get help:
· Look at Ensemble Studios official RM scripts to learn conventions and shortcuts. An annotated version of Mediterranean is included below.
· Use the XS debugger. If you put debugRandomMaps into your user.cfg or +debugRandomMaps on the command line, it will enable the XS debugger to pop up when an error is detected.
· Using the console, you can get help for any command by typing: help(“command”)”.
· Look online. Fan sites are often a great source of information on random map scripting.
· Keep it simple. If something in your script seems to be breaking, try and isolate the problem.
rmEchoInfo( string echoString, int level ): Random map echo.
Use this to spit out information while debugging a script. It is not shown to the player.
rmRandFloat(float min, float max): Returns a random float between min and max.
This is a random number generator useful for determining random events. Because it is a float, it can handle decimals.
rmRandInt(int min, int max): Returns a random integer between min and max.
This is a random number generator useful for determining random events. Because it is a integer, it cannot handle decimals, but that makes it useful for placing down numbers of objects.
rmSetMapSize( int x, int z ): Sets the size of the map.
X and Z are in meters. They do not need to be the same if you want to create a rectangular map. All ES maps scale map size by number of players.
rmSetSeaLevel(): Sets the sea level for the map.
rmGetSeaLevel(): Gets the sea level for the map.
rmSetSeaType(string name): Sets the sea type for the map. This is used if terrain is initialized to water.
You must use this command before you place water on a map. The sea type must be a valid water type from the random map editor.
rmAreaFractionToTiles(float fraction): Converts an area from fraction of the map to tile count.
Fractions are relative to map size, so sometimes you may want to use them.
rmAreaTilesToFraction(int tiles): Converts area tile count to fraction of map.
rmXFractionToTiles(float fraction): Converts an fraction of the map in the x direction to tile count.
rmXTilesToFraction(int tiles): Converts tile count in the x direction to fraction of map.
rmZFractionToTiles(float fraction): Converts an fraction of the map in the z direction to tile count.
rmZTilesToFraction(int tiles): Converts tile count in the z direction to fraction of map.
rmMetersToTiles(float meters): Converts a distance in meters to a number of tiles.
rmTilesToMeters(int tiles): Converts a number of tiles to a distance in meters.
rmXMetersToFraction(float meters): Converts meters into a fraction of the map in the x direction.
rmZMetersToFraction(float meters): Converts meters into a fraction of the map in the z direction.
rmXFractionToMeters(float meters): Converts a fraction of the map in the x direction to meters.
rmZFractionToMeters(float meters): Converts meters a fraction of the map in the z direction to meters.
Fractions are relative to map size, so sometimes you may want to use them instead of distances in meters.
rmDegreesToRadians(float degrees): Converts an angle in degrees to radians.
Particularly useful when players are placed in a circle.
rmTerrainInitialize( string baseTerrain, float height ): Initializes the terrain to the base type and height.
Specifies the base terrain to use for a map. If set to water, sea type needs to be defined. Initial terrain is usually grass, sand, snow or water.
rmSetLightingSet(string name) : Sets a lighting set
You can specify a lighting set from the scenario editor to be used for your RMS. This command must be placed after terrain is initialized.
rmSetGaiaCiv(long civ) : Sets Gaia's civilization
This is only useful if you place Gaia objects that vary by culture, such as many buildings.
rmSetStatusText(status, progress) : Sets the friendly cool loading screen text.
This text will be seen by players while the map is generating. If you do not at least specify percentages in the progress parameter, the “loading bar” will not advance during map generation.
rmDefineConstant(string name, int value)
2) Players
Player locations need to be determined so that objects and area can be placed “by player.” Player areas must still be created as individual areas.
rmGetPlayerCiv(int playerID): Gets the civilization the specified player is on.
rmGetPlayerCulture(int playerID): Gets the culture the specified player is on.
Civilization is the same as major god, e.g., Thor or Isis. Culture is Norse, Greek, or Egyptian. These commands are useful for placing specific objects (such as Dwarves for Thor) or varying starting resources. They are also useful for triggers that fire or prohibit specific improvements.
rmGetNumberPlayersOnTeam(int teamID): Gets the number of players on the given team.
Useful for scaling area or resources in a team area based on number of players on that team.
rmSetTeamSpacingModifier(float modifier): Sets the team spacing modifier.
Normally, all players are placed equidistant. This command allows you to force team members closer together. Values of 0.3-0.5 return the best results. Values less than 0.25 may not provide enough space for starting resources.
rmPlacePlayersCircular(float minFraction, float maxFraction, float angleVariation): Makes a circle of player locations.
Places players in a circle. Variation is determined by the difference between the min and max. Angle variation determines whether players are equidistant or can be slightly closer or farther apart. Circular placement is generally the most versatile, but will not work on all map types, such as non-square maps.
rmPlacePlayersSquare(float dist, float distVariation, float spacingVariationfloat): Makes a square of player locations.
Places players in a square, which automatically adjusts to a rectangle for rectangular maps. Unlike the circle, variance here is determined by a plus or minus (the distVariation) off of the mean distance. SpacingVariation determines whether players are equidistant or can be slightly closer or farther apart.
rmPlacePlayersLine(float x1, float z1, float x2, float z2, float distVariation, float spacingVariation): Makes a line of player locations.
Sometimes you will want players to be placed in a line. Anatolia places each time in a line, while Vinlandsaga places all players in a line. Using a line placement is not easy because there may not be enough room for player areas or resources. X and Z determine the starting and ending locations of the line. DistVariation determines how far from the line player areas can vary, and spacingVariation determines how much space there is among points along the line where players are placed.
rmSetPlacementSection(float fromPercent, float toPercent)
When placing players in a circle or square, this command allows you to skip part of the circle or square, in essence removing a slice from the pie (maybe you want to fit an ocean in there like in Sea of Worms). The default for fromPercent is 0, and the default for toPercent is 1. That means use the whole circle or square. You can pass in something like 0.25 and 0.50 to have the players placed from 25% in to 50% in along the circle or square. For circular placement, 0 is at 9:00, 0.25 is at 12:00, 0.5 is at 3:00, and 0.75 is at 6:00. For square placement (think of the square as a line that follows a square), 0 is at 6:00, 0.25 is at 9:00, 0.5 is at 12:00, and 0.75 is at 3:00.
rmSetPlacementTeam(long teamID): Sets the team to place.
Use this before calling the various rmPlacePlayers functions, and only players on the specified team will get placed. The first team is number 0, the second is number 1, etc. Pass in -1 for the teamID to place all teams (or actually all players that haven't been placed yet).
rmPlacePlayer(int playerID, float xFraction, float zFraction): Sets one player location.
You can use this to place players anywhere. Once a player is placed, it won't be repositioned by any future calls to the various rmPlacePlayers functions. This can be tricky since you often do not know how many players will be placed on the map, since from 2-12 players can play any map.
Here are a few examples of things you can do:
Put the first team in the center of the map and all other teams around the outside:
· rmSetPlacementTeam(0);
· rmSetPlayerPlacementArea(0.3, 0.3, 0.7, 0.7);
· rmPlacePlayersCircular(0.4,0.3,rmDegreesToRadians(5.0));
· rmSetPlacementTeam(-1);
· rmSetPlayerPlacementArea(0, 0, 1, 1);
Put player one in the bottom corner, player two in the right corner, and the rest of the players in a line from the left corner to the top corner (9:00 to 12:00):
· rmPlacePlayer(1, 0.2, 0.2);
· rmPlacePlayer(2, 0.8, 0.2);
· rmPlacePlayersLine(0.2, 0.8, 0.8, 0.8, 20, 10);
rmSetPlayerPlacementArea(float minX, float minZ, float maxX, float maxZ): Sets the area of the map to use for player placement.
Use this command if, for example, you want to place players in one quadrant of a map.
rmSetPlayerArea(int playerID, int areaID): Sets a player's 'official' area.
rmSetTeamArea(int teamID, int areaID): Sets a team's 'official' area.
When you want an area to belong to a player (i.e. this is the location from which you will place player resources) assign it to a player. Teams work the same way. Usually you want to iterate through number of players using for(i=1; <cNumberPlayers).
rmPlayerLocXFraction(int playerID): Gets a player's start location x fraction.
rmPlayerLocZFraction(int playerID): Gets a player's start location z fraction.
Use these commands when you don’t know where a player’s starting location is and you need the values to place other areas or resources.
3) Areas
Areas are regions on a...
deichman5