This article was originally written for Darren Hebden's RLNews
Introduction
Most roguelikes of reasonable popularity contain towns, though
not always in the design we are used to seeing them in real life.
I for one am utterly confused by the first town in ADOM. How is
it that this small group of farmers and rations salesmen were not
wiped out long ago by horrible dorn beasts? How do they defend
themselves? And with the multitude of eager young adventurers at
their doorstep, why has no one opened a sucker-market?
In this article I intend on addressing these points, and other
problems I have encountered with town-creation. This method
should, with few adjustments, work equally well with all sizes
of towns and can be used both as a random-town generator (like in
Angband) and to help with preset-town design (like in ADOM).
For code excerpts I have used C++, as I favor it. I could
have used Pseudocode for those of you who don't understand C++, but
then nobody would be happy.
Features
Most of this article will refer to 'Feature's. This is a class
created for the town design stage. A Feature represents an arbitrary
feature in your town, be it a house, a forest or a grave. You may
even decide for consitency to make the Town a Feature as well. A Feature
upon creation often creates other Features which are part of it, such
as a Castle Feature which creates a Moat, a Guardhouse and a Keep.
A simple C++ interface for the class Feature could be as follows:
/-*/
class Feature {
public:
// Construction / Destruction
Feature( Level*l, char x1, char y1, char x2, char y2 )
: onlevel( l ), name( "" ), bounds( x1, y1, x2, y2 ) {
create();
}
virtual ~Feature( void );
// public methods
virtual void create( void ) = 0; // Specialized classes must override
// this method.
protected:
// inheritable data
String name;
Rectangle bounds;
Level *onlevel;
};
/*-/
This class would interact with the Level class, which describes a 2d
array of LevelElements where each LevelElement represents one game
square. The create() method would then alter the Level accordingly,
adding walls, floor space, trees or whatever.
Natural Terrain
All towns (which I intend on covering here) are situated in the
'real' world that you have created, and as such all have surrounding
terrain. In fact many of the decisions to be made regarding the
features found in your town will be affected by the terrain in and
around the town.
We all know that when people decide to establish a town, the terrain
is already there. For this reason, we should create the surrounding
terrain first.
One way of implementing this is to make a series of specialized
Features each dealing with a different type of terrain. Classes such
as Clearing, Swamp, Coast and Hills are all examples of this. These
classes can then create the streams, forests and so forth.
TEST RUN::
The following is an example of terrain creation.
We begin with a blank 15x5 level like so:
xxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx x unallocated LevelElement
xxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
We then decide (using our special number generator) to create a
grass field. The GrassField class calls its version of create() which
at first will do nothing more than filling the level with grass squares,
like so:
...............
............... . grass
...............
...............
...............
create() then has some decisions to make, such as how sparse vegetation
is and how frequently streams occur. Our GrassField decides to have a
SmallStream and a few scattered trees. Soon out GrassField looks like
this:
...............
.T....T..=...T. . grass
.........===... T tree
..T....==...... = water (now part of SmallStream)
.....==.....T..
The actual generation of your terrain is up to you. You can make this
as simple or complicated as you wish.
Now that we have a Level filled with adequate terrain, it is time to
establish a settlement.
Your Town
In order to make a sensible Town, it must be created and inhabited
by your residents, with all of the benefits and drawbacks this brings.
eg. If you wish to have thieves in your world, it makes sense to either
have a thieving skill (such as ADOM's Pickpocketing) or to have houses
where our friend the Aimless Merchant keeps all of his most valued
posessions. Otherwise our poor friend the thief would be out of a job.
In order to know what types of features to create, we really should
know the types of people who will be interacting with them.
To get the ball rolling, I have created a small list of likely residents
in a fantasy world. In doing this, it becomes more clear what sorts of
features I will expect to find in towns.
Professions (in no particular order)
- Warriors - Mages - Scholars
- Smiths - Guides - Alchemists
- Rogues - Bards - Merchants
- Assassins - Paladins - Monks
- Priests - Runesmiths - Thieves
- Druids - Rangers - Farmers
- Men-at-Arms - Knights - Guards (and police)
- Traders - Pirates - Masons
- Healers - and so on...
Try to make the list smallish to begin with to speed things up a little,
you can always return to this point if you think of more later.
Profession-Related Features
For each possible profession in your rich and complex world, you
will require a place for them to 'hang out'. Examine your profession
list and see what you can come up with. For this I have separated
my profession list into three categories: Class, Guild and Religion-
based, though this is not really necessary.
Class-based features
- Taverns (for Bards and drunkards [warriors, rogues]),
- Houses (for people to live in and thieves to steal from),
- Library (for Scholars and Mages),
- Hospital (for Healers),
- xxxxsmiths (for Smiths),
- Shops (for Merchants),
- Ports (for Traders, Pirates, Rogues, &c.),
- Farms (for Farmers),
- Alpharmacy? (for Alchemists).
Guilds
- Barracks (for Men-at-Arms),
- Thieves Guild,
- Assassins Guild,
- Runemasters Guild,
- Gatehouse (for Guards),
- School of Magic (for Mages),
- Palaces, Castles, &c. (for Guards, Knights).
Religions
- Assorted Temples and Churches. These should have variance to
shew the alignments of your gods, eg.
- Monastery,
- Nunnery,
- Cathedral,
- Stone Circle (for Druids).
Other
- Inn,
- Stables,
- Asylum?,
- Town Square.
Now that we have a nice beginner's list of features for every fantasy
denizen, we can flesh it out by adding some nice small details. Many
other types of features are required for efficient town life. These
quite frequently have to do with keeping the residents alive, or
disposing with the dead. Small additions such as wells and fountains
can add much richness to a settlement; as can graveyards, statues,
gibbets (and all other forms of public humiliation and execution), and
so forth.
Town Themes
Before taking the above information directly to coding, one key issue
must be addressed: that of town themes. In life, towns are frequently
created for specific needs, be it a need for metals thereby necessitating
a minetown or merely a need for clean water and safe refuge.
If you wish to have more than one town in your game, it will be quite
integral to their design to give them themes. The best example of why
town themes are important is to think briefly of what your towns would
look like without them. Imagine ten towns, all of roughly the same size,
all with mines, all with markets, all with churches, all with guilds.
These towns look artificial and can be much worse to play in than towns
built completely randomly merely because of the cookie-cutter look they
will have.
I will assume here that if you do wish to have more than one town, you
have a way of modelling the landscapes surrounding them, like the realm
maps of ADOM, Omega, &c. This is not required, though as themed towns
can add a lot of flavour even to games like Vanillangband with only one
town.
It may be handy to make note of the types of terrain your denomination
of humanoids may inhabit, and why they would be there.
eg. Human - Mainly near water, forests. Have Castles on hills, Ports
near running water, only small towns in mountains.
Dwarf - Mainly on hills. Have Mines in mountains.
&c.
Doing so will help the software in setting the theme for a town.
Upon the decision to settle a specific area, the designer should examine
the surrounding areas to see what a town here could add to life elsewhere.
Is it a port for merchant ships? an oasis for passing travellers? a mine-
town to supply precious metals to neighbors? You will acquire a rough
idea of how large a town will grow to be, given the amount the town
is needed at its location and the theme of town created. eg. If a town
theme TouristTown is decided upon for an area with only a small
surrounding population and no hot tourist spots (no dungeons, &c.) then
the town will be quite small. Whereas if a MineTown is decided upon and
the mine is a necessary backbone for the arms and armour of a whole race,
I would bet that it would be defended quite well, no matter how close
they were to the enemy borders.
Town themes also generally restrict the types of Features occuring in
them. It would be nothing short of disastrous to have your
WitheredHouse near the StoneCircle filled with Cultists, only to have
the evil random number generator put HappyJoesFriendlyInn between
them.
After the decision of what Theme to use has been made by the software
for the town, it should then access a list of what features will be
available for this theme. You can do this any way you wish. For
article continuity I will use a similar sort of list as Joseph Swing
[JSwing@wport.com] used in his article on Continuous Content in dungeons,
though I have adapted it to make use of my system of Features creating
sub-Features.
A sample list of a Human MineTown:
Human MineTown
.1 MineShaft ( exactly 1 )
.2 Port ( if running water is available, maximum of 1 )
.1 Market
.3 Keep ( exactly 1 )
.3 Tower
.3 Castle ( if town is large, maximum of 1 )
.1 City Walls ( exactly 1 )
.2 Keep ( exactly 1 )
.3 Gatehouse
.3 Barracks
.4 Tower
.5 Tower
.6 Tower
.4 Temple ( or other religious site )
.5 Tavern
.5 Inn
.1 Tavern
.5 Shop
.6 Shop
.6 xxxsmith
.6 Town Square
.7 Farm
.7 Farm
.7 House
.8 House
.9 House
The actual order of adding Features to your town is up to
you. I suggest that you first create the important parts, such as
mines, ports, and any other parts which depend on a certain type of
terrain for positioning. This is to ensure that you don't place
another Feature where it will obscure access to the required terrain.
You may wish to add (for added complexity) a system which records
certain values for each town: foodAccess, shelter, defence, trade,
and so on. This will allow you to avoid adding redundant features,
such as excessive shelter per resident, and more food than your
residents can eat, trade or store.
Townspeople (t)
Now that you have a reasonable idea of how you can design the towns,
you now have the option of adding towns-people. I say option, because it
would be nice to have a version which doesn't create 'regular' inhabitants
so you could adapt it to create ghost-towns, overrun towns, and more.
This could easily be done by creating the class Town, then the derived
classes PopulatedTown, GhostTown, &c. Then all that these specialized
versions need do is add the residents (possibly also knocking a few walls
down for that 'derelict' look). This is also a nice way to create over-
run towns, such as the Human town taken over by Goblin Berserkers (or
vice-versa).
I will not go into the depths of creature behaviour here, though I
will say that if you are going to this much trouble to make realistic
towns, you really should think about adding at least a little depth
and complexity to your creatures.
You may also wish to consider racial tensions (if any) when creating
your towns. It is a fairly common fantasy convention that Dwarves
don't really like anyone. This could be taken into account when creating
your towns, lowering the probability of other races living in a mainly
Dwarvern town. In the system I have developed, I take a creature's
religious alignment to be much more important than their actual alignment.
This allows creatures of all nationalities to befriend each other should
they follow the same god: but creatures of opposed gods will certainly
not tolerate living in the same town as each other.
Creation
TEST RUN::
Below is a demonstration of the previous methods in action, of the steps
an implementation of this might undergo.
- Map. We begin with a map, created by some other means, showing our
lovely countryside, as below. Take note that this is a 'Realm Map',
such as in ADOM.
..^^....==... # Dungeon (or tower, ghost town, etc.)
^~^~.^~..=... . Clearing
^#~......==~~ T Forest
.....TT...=== = River
......TT..~^^ ~ Hills
.T.........~. ^ Mountains
- Choose an area. How you do this is up to you: you can use the RNG,
or (my personal preference) you can have a Race(Human) class make the
decision on where they would likely settle. If you use this method
you must choose at this point what race will be living here. We will
create a Human city for this example. Here, the X marks the spot where
we have decided to build.
..^^....==...
^~^~.^~..=...
^#~......==~~ X Proposed town site
.....TT...===
......TT..X^^
.T.........~.
- Pick a Theme. Examining the terrain around the designated area,
we see that on four sides there are plains, on two sides there are
rivers, and on one side each there are mountains and hills. Given
also that this site has high access (from the river) and is on
hilly terrain, the designer decides to create a large city, which
will contain mines, a castle for defense from the denizens of the
dungeon '#' (and because, as was written above, Humans usually build
their Castles on hills), and a port for trade. We also decide now
whether to create a populated town or not: for this example we will
not make a population - this is really another topic, and dependant
on how your creature system works.
- Now we create the town, terrain first. I will use (to save space
here) a quarter-screen sized map, 40x12. You may not wish to use
elevation in your RL, but I have added here hills, marked with ':'.
These have a few special rules: combat bonuses for creatures on
elevated areas when in combat with those on normal ground; improved
LOS and missile range. Our terrain generator has created a HillyArea,
which has then created a River, some Hills and a few scattered trees.
...............====............=======..
................======================== . ground
..T................=============...:.=== : hill
......................:::T::......:::... T trees
...T...::.....:.......:::::......::::..: = water
....:::::....::......:T..:T:........::::
.....::....::::...........:.........::::
...::::...:::.::::.............::....:.:
..........::...::.......:::............:
......::.T......:.......:::.....TT....::
...........T.............::..........:::
.................................:::::::
- The Town. We have the list of Features above, and by now you have
likely added to the list some of your own favourites. Now choose
the first Feature from the list ( MineShaft ) and add it somewhere
sensible (near hills). We can then continue in the fashion described
by Mr Swing ( 75% chance of choosing the next item, 25% chance of
choosing the previous ), creating a Port and so on.
...............====............=======..
................======================== a Mine
..T................=#===#=======...:.=== b Port
....................#b::#T::......:::...
...T...::.....:.....#+###::......::::..:
....:::::....::......:T..:T:........::::
.....::....::::...........:.........::::
...::::...:::.::::.............::....:.:
..........::...::.......:::......##+###:
......::.T......:.......:::.....T#a..>#:
...........T.............::......######:
.................................:::::::
After a few more recursions, the town will hav begun to take shape.
The map below shows what the town might look like after having created
a castle. Note that the castle walls do not fully include the Mine.
This was due to the mine being close to the border of the map.
Obviously there will be situations such as this, so your code might
need a little tweaking. Given the small scale of the map used, I will
end the demonstration here, though on a larger map there would be
sufficient room for adding the rest of the features on the list.
The up staircases on the map below connect with to the second floor
(where any guards would be) and the down staircases in the Mine and
Keep can connect with Mines and Dungeons respectively. There are
enough articles on how to make these last two items: you shouldn't
need my help.
Ground Floor
...............====............=======..
................========================
..T........#+####..=#===#=======...:.=== a Gatehouses
......####.#a.#.#####.::####......:::... b Towers
...T..#<b####+#....c#+###:<#.....::::..: c City walls
....::#::+...::.........#:b#........:::: d Keep
.....:##+#####:.........#+###..######:::
...::::#.#<..+::::g.......+a+..+<+.a#:.:
.......#.#>.f#.::.......#+#########+###: e space (on a larger map
......:#.#####.:........#:b#....T#...>#: you would add
.......#.......##########:<#.....######: shops, houses,
.......#########........####.....::::::: an inn, and such.)
Upstairs
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x Either unallocated
xxxxxxxxxxx######xxx#####xxxxxxxxxxxxxxx tiles or 'air' tiles.
xxxxxx######....#####...####xxxxxxxxxxxx
xxxxxx#>................/.>#xxxxxxxxxxxx
xxxxxx#..################..#xxxxxxxxxxxx
xxxxxx########xxxxxxxxxx#..##########xxx
xxxxxx#>..#xxxxxxxxxxxxx#.......>...#xxx
xxxxxx#...#xxxxxxxxxxxxx#..#######..###x
xxxxxx#####xxxxxxxxxxxxx#..#xxxxx#....#x
xxxxxxxxxxxxxxxxxxxxxxxx#.>#xxxxx######x
xxxxxxxxxxxxxxxxxxxxxxxx####xxxxxxxxxxxx
That's it. After creating your town, you have only the task
of giving it some inhabitants of reasonable wit. I hope that I
have inspired a little something in some of you. Please feel
free to send me comments to me [michaelblackney@hotmail.com].
/-*/
|