Clint has summarized it well, so I have nothing more to say :D. Here is the algorithm:
- I use a matrice with integers to generate the map. 0 for full wall, 1 for full ground and -1 for undefined. At initialization, the matrice is filled with 0. Numbers from 2 to 15 corresponds to tiles with ground and wall.
- Create X rooms with a random position, width = 3, height=3
- Keep enlarging rooms in the 4 directions. When a room meet another room, stop enlarging it.
- Remove impossible patterns : cells are put to -1 according to neighborhood conditions (e.g. 0 near 1)
- Replace all -1 with number from 0 to 15 according some rules. Using sets here to simplify the task. When the background layer is written, tiles of the corresponding class (among the 16) are taken at random
- The starting point is put as far as possible from the center of the map. The exit is put as far as possible of the entrance : usually the entrance is in a corner and the exit at the opposite corner.
- For tiles variation, tiles with the same class are taken at random. Perhaps by teaking the randomness or by pytting conditions a better result can be obtained. For instance forbid to put 3 walls with a torch in a row.
- Yes I have seen these cut-away "half walls", I have tried some maps with them but the result don't have a good look. I think it can be done with putting additionnal rules for tiles selection. For the moment there are only two kinds of tiles handled by the script. I'll try to increase this number.
- For the moment, I see this script as a mean to quickly add content. I would be very pleased if I could generate some dungeons that would be included in the game :).
I probably won't do the colored monster thing. It was easier to do in Diablo because all the graphics were in a 256 color pallete. But it could come later if I change the rendering to OpenGL.
I tough it could be done with SDL. But finally it seems there is no pixel manipulation with SDL
If I want to put a dungeon entrance at the end of the path, should it be in the background layer or object layer ? I believe it's the second solution because the tile for the entrance is much bigger than other tiles.
I have never used regular expressions in C++, but boost provide a regex module that seems solid.
I have some Java code to generate random fractal landscape on an hexagonal mesh. This can easily be tuned for a square grid.
Some random trees (fractal algorithm too) :
I can rewrite the code in C++, eventually start a library, but I will need help for the specifications.
Hi,
Clint has summarized it well, so I have nothing more to say :D. Here is the algorithm:
- I use a matrice with integers to generate the map. 0 for full wall, 1 for full ground and -1 for undefined. At initialization, the matrice is filled with 0. Numbers from 2 to 15 corresponds to tiles with ground and wall.
- Create X rooms with a random position, width = 3, height=3
- Keep enlarging rooms in the 4 directions. When a room meet another room, stop enlarging it.
- Remove impossible patterns : cells are put to -1 according to neighborhood conditions (e.g. 0 near 1)
- Replace all -1 with number from 0 to 15 according some rules. Using sets here to simplify the task. When the background layer is written, tiles of the corresponding class (among the 16) are taken at random
- The starting point is put as far as possible from the center of the map. The exit is put as far as possible of the entrance : usually the entrance is in a corner and the exit at the opposite corner.
What else do you want to know ? :)
Same for me. And I am not an artist, so I will be only here :P.
I can help here if you need forum maintainers
Here is a 5 level dungeon filled with goblins :
http://www-valoria.univ-ubs.fr/Nicolas.Bonnel/OSARE/osare.tar.gz
Unpack in resources folder and it should be ok. This will modify some files :
- tilesetdefs/tileset_dungeon.txt : add 2 new tiles for entrance and exit
- images/tilesets/tileset_dungeon.png : add 2 new tiles for entrance and exit
- spawn.txt : change the start to this dungeon
And add other files :
- images/enemies/goblin_color.png : made some variations of color, this can be improved because the weapon color change too
- enemies/goblinX.txt : goblins from level 1 to 6, each have a different color
- maps/dungeonX.txt : the 5 new maps
Thanks for the feedback :)
- For tiles variation, tiles with the same class are taken at random. Perhaps by teaking the randomness or by pytting conditions a better result can be obtained. For instance forbid to put 3 walls with a torch in a row.
- Yes I have seen these cut-away "half walls", I have tried some maps with them but the result don't have a good look. I think it can be done with putting additionnal rules for tiles selection. For the moment there are only two kinds of tiles handled by the script. I'll try to increase this number.
- For the moment, I see this script as a mean to quickly add content. I would be very pleased if I could generate some dungeons that would be included in the game :).
Okay, thanks for the details. Here is a dungeon with monsters and chests :
http://www-valoria.univ-ubs.fr/Nicolas.Bonnel/OSARE/dungeon.txt
The python script used to generate the map :
http://www-valoria.univ-ubs.fr/Nicolas.Bonnel/OSARE/generateDungeon.py
Next I ll try to add :
- some teleports to others generated maps
- Bosses with their minions : garding nice treasure chests or teleports
- some mechanism to make the player run (switches that open doors at the opposite of the dungeon :D)
- some kind of premade rooms (with thrones, statues, benches and switches)
Thanks for the fast reply !
A last question : for random loot, is the level of the loot affected by random variations (5% chance to have -3, 10% to have -2, ...)
For the documentation, I can compile all informations about OSARE map format in a thread if you want.
Hi, again I have a few questions :)
I would like to add chest and other objects in my maps.
- What are the 2 last numbers in a location line used for ? (the first two are the coordinates I believe)
- Can mapmod be used with the background layer ?
- What are the other types of event in addition to 'run_once' ?
- What are the 3 numbers of loot used for ? (I believe the first one is the level of the loot)
- Is it possible to add enemy spawn as event ? (for instance a monster appears after having opened a chest)
I probably won't do the colored monster thing. It was easier to do in Diablo because all the graphics were in a 256 color pallete. But it could come later if I change the rendering to OpenGL.
I tough it could be done with SDL. But finally it seems there is no pixel manipulation with SDL
I have updated the two link :
http://www-valoria.univ-ubs.fr/Nicolas.Bonnel/OSARE/outdoor.txt (starting point is 6,6)
http://www-valoria.univ-ubs.fr/Nicolas.Bonnel/OSARE/generateIsland.py : A random walker that puts rectangles of grass and monsters on his path. Monsters level increase during the walk (from goblins to big skeletons)
If I want to put a dungeon entrance at the end of the path, should it be in the background layer or object layer ? I believe it's the second solution because the tile for the entrance is much bigger than other tiles.
Pages