My Random Dungeon approach (looking for feedback)

Hi all.

As you might saw some of my earlier posts I was wondering about systems for random dungeons and I decided to go the easy way, the pseudorandom based on different templates.

This is what I have and I’m looking for feedback.

First of all, most of it is stored in MySQL for easier management.

Areas

I have different areas. In the database I save the resref of the area, plus the tileset type (cave, dungeon …) plus a value of 0 to 3 depending on:

0 - single level dungeon, it has only one entrance
1 - first level dungeon, has an entrance and a transition going down (stairs, ramp …)
2 - middle level dungeon, has a transition to go up and a transition to go down
3 - bottom level dungeon, has only a transition to go up.

Bottom level dungeon can be used for dungeons of only 1 level where you enter going down.

I have several designs of each one, however I’m currently only using single level dungeon because is easier to create 10 caves, 10 crypts … etc than 40 (10 for each level) as I have some sort of variety.

When you enter a dungeon, the transition is empty and there is an onclick event that checks for:

  • Number of levels
  • Type of enemies (it can be totally random)
  • Type of dungeon (tileset)
  • Name of the dungeon
  • Tag of boss item (the boss can drop a specific item if needed for a quest).

Then a new dungeon is instanced for the player. Whenever you enter a dungeon you enter your party leader’s dungeon or your own if you are not in a party, the leader does not have an instance or you are the leader.

It can happen that you enter your own dungeon becaues your leader has no instance, then he creates his own instance and then you exit your dungeon and then enter again and end up in your leader’s dungeon.

One of the things that I have to do is that whenever a new instance is created for you, your old instance(s) are deleted. This can lead to you being the leader of a party, entering a new dungeon and having to delete an instance with players in it. In this case they are moved back to the entrance. This should not happen often but is needed to avoid having tons of areas instanced and not played. Also instances are cdkey based and not player based.

This is ok in my action setting as RP is not forced so this things can happen.

My question here, how do you see that scenario? When you are sent out of a dungeon because the owner started another instance? It shouldn’t happen a lot but I want to keep the module free of useless areas.

Enemies

This I’m working on at the moment looking for the most optimal solution.

Right now, I have level 1 creatures using the wizard, a couple of goblins, orcs etc … and I spawn whatever I need and level them up accordingly. I also add some effects like regeneration or more damage for more high level creatures.

My idea was to have level 1 templates of, Animal, Fighter, Barbarian, Rogue, Wizard, Druid, Cleric … and then change appearance and sound but I don’t know if is possible to change the voiceset of a NPC without using NWNx (I’m on Windows) so I might need more templates (one for each race basically) which makes the module bigger.

I can always remove the voiceset and script the onattack so it plays some sounds depending on the creature.

My question here is how would you do it so is the most optimal? Having 4 templates for goblins (fighter, rogue, druid, wizard) and 4 for orcs (the same for example) and 1 for wolves and 1 for bears … because I cannot change the voiceset or just generic and use some scripts to play some sounds?

Thanks for the feedback.

It seems very complex.

Instead of deleting your old instance when you load a new one, why not have the instance be deleted when the last person exits? And why not just have only areas that exit in all 6 directions? You can always make the script say the passage is blocked or flooded or whatever if it exceeds a cap. That’s what I do.

I don’t know about spawns. Haven’t gotten to that, yet.

Hello charles.

About deleting when the last person exists I just didn’t want to loop everytime someone exists, I can loop only once, when you require a new instance or I can also check that if you are not in a party I automatically delete the instance if you killed the boss or something like that. Is the less of my concerns to be honest.

About the exists, what I did is the following:

All dungeon areas have 4 transitions, 2 normal entrances on the same level, one to go a level up and one to go a level down.

The entrances are all blocked by a placeable that looks like walls of the same tilesets and blocks movement and vision.

Once the area is instanced I delete whats needed.

If the dungeon is just a cave with no end and no levels I only delete one wall so when you enter you can only leave.
If the dungeon is a second level and you can go to a third level I only delete the walls from the stairs.
If the dungeon is a passage to cross a mountain without going up or down I just delete the walls of the same level entrances.

I have the entrances 2 by 2 in opposite sides of the dungeon, normal entrance plus stairs up on one side and normal entrance plus stairs down on the other side of the dungeon.

This way I have everything I need and I only need to design one type of dungeon that will be very versatile.

I can map 20 caves, 20 dungeons, 20 crypts and have it grow with time very easily.

I can then have some places where you will get a completely random dungeon, like any type of enemies, any tipe of layout and 10 levels, I don’t know like a magical dungeon or whatever.

There won’t probably be any fancy stuff like “you need to unlock X and then do Y before continue” as this will be more hackandslash-y but that might change.

I wanted to update you because what you said with the directions gave me the idea of the stairs and so on. About the orientation I can always make a 2x2 area before entering the dungeon that will work as a room prior to the dungeon to reorient it to the proper side.

Well, if it works, it works. It’s hard to fully envision how it all interacts when its not in my own head.

Does your dungeon work with multiplayer? If we’re in the same area and you take the stairs up and I follow you, will I arrive in the area randomly chosen for you, or will I get a randomly chosen area of my own?

Mine is supposed to work with multiplayer and I’m pretty sure that it does, but I haven’t actually tested it. :stuck_out_tongue:

Ok, so I will try to explain ti better.

The dungeons I make are mostly 16x16, in the southwest corner I have 2 transition:

  • Transition at the same level
  • Transition from an upper floor

At the northeast I have 2 other transitions:

  • Transition at the same level
  • Transition to a lower floor.

This way, when you enter a dungeon I unlock only the one from the same level that is at the southwest and the one that goes to a lower level that is at the northeast.

In the second level (“last” level) I unlock the one that comes from the upper floor that is at the southwest and I unlock the one at the same level that is at the northeast.

That last transition at the same level leads you to the boss room. They are just small areas for the boss when there is one so I can control the last encounter better.

I will post screenshots so you can see what I mean, the thing is that 1 area can work as the entrance, as the lowest level, as an upper level … even as a passage to cross a mountain. So I have tons of versatility.

Yes, it works in multiplayer, all the instancing and code happens on the entrance, on the transition that is (most of the time) in an exterior area.

In that transition the following happens:

If you are in a group:
If you are not the leader, we check if the leader has an instance of that specific dungeon, if so you go into that, if not we create one for you
If you are the leader we check if you have a valid existing instance of that specific dungeon, if so you go to that, if not we create one for you.
If you are not in a group it happens the same as if you are the leader.

And when the instance is created all the transitions are set up, all the encounters generated, all the stuff is ready (also old instances are deleted to keep the module clean). So once you are inside no more scripting is necessary.

To create a dungeon:

  1. Place a transition
  2. Specify the onenter script for dungeons
  3. Fill some variables

That’s it. The variables you can specify are the following:

  • Dungeon name (this is used to identify the dungeon internally as well)
  • Dungeon type (tileset)
  • Enemy type (I have some defined already, they are up to 6 different mobs)
  • Max level (enemies are scaled to the level of the owner of the dungeon up to this level)
  • Min level (enemies are scaled to the level of the owner of the dungeon as low as this level)
  • Number of levels (actually number of areas)
  • Type of levels (can be all areas on the same level like a passage or just a bunch of areas going deeper)
  • Boss encounter (this is independent of the enemy types, you can have an archdruid guarding a cave of goblins because reasons)
  • Exit waypoint (in case you want to create a passage or you want the dungeon to have an exit)
  • Direction (if this is set you enter the dungeon from the “exit”, usefull for passages)

I don’t have any system yet to specify the level of the treasures or the amount of them because is an action server and I don’t really care but is something I could work on.

I can have generic transitions in the palete like “goblin cave” levels 1-40 and just place it everywhere.

I can also make an NPC that sends you to a random dungeon created only for you.

Basically I’m working in the system so then I can easily map lots of dungeons and is faster to make the world grow and also not making it stale.

You’re going with a very different approach than myself.
I set local variables on the areas where the entrance to the infinite dungeon is and then copy them onto the random area once selected. Most important are the integers X, Y and Z which is set at 0, 0, 1 for the entrance area. The toughness of the monsters is based on Z (meaning the deeper you go the tougher the mobs) and I use other strings and integers that are also copied to determine how deep one can go and how tough the monsters are on the first level.
My approach will be to have the process in the script where everything is determined for the generated area to check for things like active quests to spawn things like bosses and to have a random chance to spawn quest-givers, etc.
I’m also thinking about spawning in factions (ie tribes of kobolds, goblins, orcs, etc) and have their reputation to the PC faction be random so that they are most often hostile, sometimes too hostile to be turned neutral by charms - sometimes not, sometimes they will just be friendly by default, etc.
I might also want players to be able to murder eachother. This way it’s good that areas aren’t party based and anyone can meet anyone in a dungeon.
I based my entire naming convention for my dungeon tags, area transition names, etc. around my dungeon script and I think it’s about 65 lines atm at its most basic. All transitions in all dungeon areas and the transitions leading into it use that same script and I really like the idea of putting it in the cache and keeping the cache as small as possible.