TWiki Home Tharsis . Website . UsingTheAreaEngine (r1.9) Tharsis webs:
Design | Guilds | Combat | Website
Website . { Home | Changes | Index | Search | Go }

The Area Engine


The Area Engine is a "device" that allows builders to make areas in an easier fashion - at least that is the idea. Down the track it should even have a graphical interface!

Essentially it is a single "controller" that creates the rooms for you based on an area file. As a builder you write the area file and the area generates itself - no more creating rooms. At this time the area file only controls the rooms, their exits and descriptions, and the placement of externally created objects/monsters. It will soon provide the ability to define objects and monsters. After that, I'm open to suggestions.

File Format

The area file is a normal text file - you can edit the file in notepad, under windows, and using ed inside the mud.

The file is broken into a series of sections, each section having a heading and some content. Headings have the form [heading-name], and a section is all the content from its heading until the heading for the next section. Section headings have to be on a single line of their own.

The following shows you the outline of the file. A complete area file will probably include the sections shown here as well as having lots of content inside each section


# This section defines the layout of your area

# This section defines special exits - doors/blocking/etc

# This section defines what your rooms look like
# and defines the external rooms (links to other areas)

# This section manages hand-coded objects like monsters
# and treasures


You can put comments anywhere in the area file. Comments are notes that are completely ignored by the Area Engine. Comments are lines beginning with a #

# I am a comment
I am not a comment.

# I am another comment
# that goes over multiple lines
I am not a comment

The [general] section

This section is used to define some global variables: constants and rules that apply across the whola area.

Supported constants at this time are:

Name Purpose
domain The numeric id for your domain - ask a wiz. This makes all rooms be in this domain
startroom The roomkey for the room which the player will start in by default

Each constant goes on a line of its own and is assigned a value using the = operator.

For example:

# Define 'domain' to be 123

#define 'startroom' to be 'hallway'

The [map] section

The map section is used to define all the rooms in the area and the exits between them.

This section does not define the contents of rooms, nor the room descriptions, just the exits/links between rooms.

Each room is defined on a single line. The line has the format:

room_key : exit = destination , exit = destination ....
So each room has a room_key, which is a unique name for this room. It might be a word, as in the following example, or it might just be a number - maybe you just number your rooms from 1 to 100.

After the ":" are the exits for the room, separated with commas. Each exit is a direction, an "=" sign, and the room_key for the destination.

So - the following map is used to describe a 2 story house with several rooms:

# Make people start in the lounge

# This comment is just describing the layout below, 
#   the area creator ignores it completely
# The ground floor map looks like:

# kitchen   -  dining  
#    |      \     |
# hallway    lounge - outside
#    |
# hallway - bedroom
#    |
# hallway - bedroom
#    <

# The second story looks like

# bedroom - onsuite
#   |
# landing
#   >

# The "outside" room is not in this area, it's the room for entering this area

# Below here are the actual rooms with their exits
kitchen: e=dining,s=hallway1,se=lounge
dining: w=kitchen,s=lounge
lounge: nw=kitchen,n=dining,frontdoor=outside
hallway1: n=kitchen,s=hallway2
hallway2: n=hallway1,s=hallway3,e=bedroom1
hallway3: n=hallway2,e=bedroom2,u=landing
bedroom1: w=hallway1
bedroom2: w=hallway2
landing: d=hallway3,n=masterbedroom
masterbedroom: s=landing,e=onsuite

Note that there is no room with a room_key = "outside". This is because the room is specially coded - it is either a hand-coded room which you want to connect with, or it is a room managed by a different area engine.

The [exits] section

The [exits] section is sort of optional.

In this section you define the details of exits. Details include things like

So, for example, in the map above there are exits described as "e", "w" and so on. By default this means the exits in the rooms will be exactly that: "e" and "w", not "east" and "west".

More interestingly the definition for room "lounge" has an exit called "frontdoor", which leads to the outside. It seems unlikely that we want the player to see that - rather we want them to see an "east" exit, and for it to be a wooden door.

The following shows the configuration for the "frontdoor" exit

# define the frontdoor as a normal east exit.  In the
# future we might define this as an actual door which opens
# and closes
exit: frontdoor
direction: east
  ToDo: Describe how to define a door.  something like
  type: door {
     adj: wooden
     long: A large wooden door.
     locked: 0
     key: front_door_key

The [rooms] section

The [rooms] section defines the appearance of rooms - the description, items, light levels, etc. This section DOES NOT define the exits/connections between rooms - that is done in the [map] section.

The [rooms] section is broken up into a series of individual room descriptions. Each room description can apply to one or more of the rooms which are defined in the [map] section. This is deliberately done to allow you to use a generic room description for multiple rooms in your area.

The [rooms] section also identifies rooms that are outside your area, or have been specially hand-coded by a wizard. You need to identify these rooms and tell the Area Engine how to find them so that your rooms can link to the rest of the mud.

Rooms that are part of your area

Each such room description starts with a line that begins with room: All subsequent lines until the next room: (or external ) are considered to be part of the room description.

# this is the first room description
# and so is this

# this is the description for the next room

Rooms that are outside your area or are hand coded

In our example map above the "outside" room is such an example. It is not to be created by the area engine, but we want the "lounge" to be able to connect to it.

Each external room description starts with a line that begins with external: . All subsequent lines until the next room: or external are considered to be part of identification of the external room.

# this is the first room description
# and so is this

external: outside
# this is the 'outside' room and is a room that is probably a room in an adjoining area.
# The Area Engine will expect to be told where to find the file/map for the external room.

# this is the description for the next room

Understanding how room descriptions are allocated

The Area Engine uses room descriptions whenever it needs to create a room - it does not use this process when linking to external rooms.

Putting a room in the [rooms] section doesn't cause the room to be created, the actual rooms that get created are controlled by the [map] section. The Area Engine examines the [map] section to work out which rooms should exist.

When a room is to be created the Area Engine will:

  1. check to see if there is an external definition in the [rooms] and if so then use that external room.
  2. assuming no external room can be found then it will get the entire set of room descriptions from the [rooms],
  3. determine the subset of the descriptions that are possibilities for this room, and
  4. randomly choose one of these.

The important thing to understand is how the Area Engine performs the third step - the process of working out which room descriptions can apply to a given room. It is possible for you to create an area with a single room description which can apply to all rooms, it is also possible to create an area in which each room has only a single applicable room description (in which case you have as many room descriptions as you do rooms in your [map]), and anywhere in-between.

The Area Engine works out which room descriptions can be applied to a room using the room: line.

The room: line has the form:

room: room_key_pattern,room_key_pattern,room_key_pattern,etc

The room_key_pattern is a string which indicates which of the room_keys from the [map] the room description can apply to. The pattern can include an "*" to match any characters. As shown it is possible to specify multiple patterns by separating them with commas.

A special circumstance applies if you specify NO room_key_patterns. Rooms descriptions with no room_key_patterns may be used for rooms which match no other room descriptions.

For example, presuming we have the map of the house from above we can use the following descriptions:

# This description applies to only the kitchen
room: kitchen
short: The kitchen
long: This is the kitchen, it is full of cooking stuff.

# This description can apply to any bedroom.
# Note that there are other descriptions below which have the 
# room_key_patterns that match the bedrooms, and thus the
# Area Engine will randomly choose one of these when assigning
# a description to each bedroom
room: *bedroom*
short: A bedroom
long: A room with a messy bed in it, someone has slept here recently.

# This description can apply to any bedroom, but is specified
# using commas instead of a * wildcard.
room: bedroom1, bedroom2, masterbedroom
short: A bedroom
long: A room with a very neat and tidy bed in it.

# This description will apply to any room that does not match
# any of the other descriptions (IE all non-bedrooms and non-kitchens)
short: A room
long: This room is completely bare.

# This description can also apply to any room that does not
# match the other definitions with room_key_patterns.  
# Thus the Area Engine will randomly choose either this description 
# or the one immediately above when describing all non-bedroom
# and non-kitchen rooms.
short: A room
long: This room is tastefully furnished.

# This tells the Area Engine where to find the 'outside' room.
# It tells it that it is the 'street1' room in the 'town' domain.
external: outside
domain: DOM_TOWN
file: street1

What can go in a room description block


What can go into an external room identification block

ToDo? * domain * file

The [specialobjects] section

The [specialobjects] section is used to manage the placement of objects that are not defined within the area file; like hand-coded, or specially-coded monsters and treasures, perhaps created with the Blob.

The [specialobjects] section is is broken up into a series of individual objectdefinitions. Each description starts with a line that begins with object:

All subsequent lines until the next object: are considered to be part of the same object definition.

object: rabbit
# this is the definition for the 'rabbit' monster
# and so is this

object: table
# this is the definition for the 'table' treasure

Each object: line has the format:

object: object_key

The object_key is a unique keyword used to identify the object in other parts of the area file. You can use any keyword you like.

What can go in a object description block

Each object description block is a series of lines which have the form
keyword: value

Possible keywords, and their meanings are:

file yes This is the name of the hand-coded file for the object

For example: file: monsters/big_bag_guy

placement yes This controls the placement of the object within the area - which room or rooms the object can be placed in.

At least one room_key must be specified. The room_key can include wildcards. Multiple keys can be specified by separating them with commas. If the specified room_keys match more than one room then the object will be randomly placed.

For example: placement: kitchen,bedroom*

count no This controls how many of the object are placed in the area. It defaults to 1.
repop no This controls whether the object will repopulate.

Valid values are "default" and "none".

A value of "default" will cause the object to be recreated (if it is destroyed) following the normal mud rules. A value of "none" will mean the object is never recreated after it is destroyed. This defaults to "default".

Topic UsingTheAreaEngine . { Edit | Attach | Ref-By | Printable | Diffs | r1.18 | > | r1.17 | > | r1.16 | More }
Revision r1.9 - 19 Jan 2007 - 12:54 GMT - FantoM
Parents: WebHome > BuilderPages
Copyright © 2001 by the contributing authors. All material on this collaboration tool is the property of the contributing authors.
Ideas, requests, problems regarding Tharsis? Send feedback.