Author Topic: How did Infinite Dungeons work?  (Read 690 times)

Legacy_Ubai

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
How did Infinite Dungeons work?
« on: March 08, 2016, 12:06:25 am »


               

Hello,


 


I've been toying with the idea of random dungeon generation and I am wondering how it was scripted in Infinite Dungeons. Does anyone know how they did it?


 


Thanks!


Matt



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #1 on: March 08, 2016, 12:07:11 am »


               

I think there is a scripted system derived from ID on the Vault.



               
               

               
            

Legacy_Ubai

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #2 on: March 08, 2016, 01:12:14 am »


               

I have looked on the vault but the ones I have found don't seem to work the way ID did. I'm hoping someone can give me a brief summary of how ID worked so I can have a starting point to work from.


 


Thanks!


Matt



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #3 on: March 08, 2016, 11:42:10 pm »


               

Did you look at this one - ftp://neverwintervault.org/rolovault/projects/nwn1/modules/829/index.html' class='bbc_url' title='External link' rel='nofollow external'>ftp://neverwintervault.org/rolovault/projects/nwn1/modules/829/index.html



               
               

               
            

Legacy_Ubai

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #4 on: March 09, 2016, 02:28:51 am »


               

I have, but it appears to pick randomly from a series of premade dungeons, and I think ID actually generated random dungeons on the fly. I could be wrong though, I wish I could crack ID open and look at the module!



               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #5 on: March 09, 2016, 10:13:26 am »


               


I have, but it appears to pick randomly from a series of premade dungeons, and I think ID actually generated random dungeons on the fly. I could be wrong though, I wish I could crack ID open and look at the module!




 


You are wrong. ID also picked randomly from a series of premade dungeons, only it had a large selection of them so it appeared that they were generated on the fly. It's impossible to generate random areas.


 


And well, you actually can open and look at the module. I can send you the decrypted version if you'd like, but it won't do you much good. There are no source scripts, so you can't learn much.



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #6 on: March 09, 2016, 10:48:22 am »


               


You are wrong. ID also picked randomly from a series of premade dungeons, only it had a large selection of them so it appeared that they were generated on the fly. It's impossible to generate random areas.


 


And well, you actually can open and look at the module. I can send you the decrypted version if you'd like, but it won't do you much good. There are no source scripts, so you can't learn much.




 


I'd say its very difficult, but not impossible to generate random areas on the fly.


Given that areas can be loaded server side via nwnx_resman and nwnx_areas -


The only stumbling block would be the generation of the are, git and gic files dynamically during run time.


If they could be generated by an algorithm during play, then the loading of the area is easy. 


They are basically gff file structures - we already have tools and code that can manipulate gff file structures - so why not modify / create new are,git,gic files during server play?


 


There are some nwnx plugins that achieve tasks that are more complex than this.


The only issue would be 'generating' an area that is meaningful and interesting.


Eg: Correct tiles linked together etc.


 


That's where using an appropriate algorithm would be important.


 


 


While I haven't done runtime generation of are, git, gic files,


I have made 'endless' dungeons, using nwnx_Areas and nwnx_resman.


 


Just put a script on a door, that generates a new area, then links to the door within the area.


When that area is generated, the player enters via the door.


That area then has another door, sharing the generation script, which keeps the generation going infinitely.


 


nwnx_areas also has a nice destroyarea method, that is good for cleanup.


Just need to be sure that no players have logged out in an area that you intend to destroy though.


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #7 on: March 09, 2016, 12:53:31 pm »


               


There are some nwnx plugins that achieve tasks that are more complex than this.


The only issue would be 'generating' an area that is meaningful and interesting.


Eg: Correct tiles linked together etc.




I got a suitable alghorithm in my mind already.


 


Improving upon this project of mine, basically, the same way as I am generating the "dungeon" map can be generated the actual area map - and after that map is done, you just need to convert each map tile to the tilename. For that, all thats needed is a custom 2da with a list of all tiles in better format than .SET that also gets cached on module as it will be subject to multiple loops where 2DA reads would be too slow.


 


The only problem is that I don't have time to also create a plugin which would create the *are and *git files which is essential to make this work.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #8 on: March 09, 2016, 01:58:10 pm »


               

Just thinking on this - 


It would be complex for a script to identify where a chest should be placed.


 


So things like placeables would be difficult to dynamically place within a truly random area.


 


Eg: An area where the tileset tiles are placed programatically.


 


The only thing I can think of is that the x,y,z and facing of 'correct' locations is saved somewhere like a db for each tile.


When that tile is placed - we ask ourselves if we want to add a chest to this tile (wouldnt be nice to add a chest to every instance of that tile)


If we add the chest, then create it at the XYZ location on that tile (gives the impression that it was placed by hand in toolset)


 


This logic could be expanded to include lighting placeables : Letting you the script work out color schemes for areas.


Eg: If its a Drow Dungeon - maybe use green lighting placeable, vampire dungeon maybe use red?


 


I think nwnx has plugin capability to draw triggers / encounters, so you could potentially set the bounds of a dynamically added encounter to encompass specific tiles/tiletypes.


 


Then - once you work all this out, you just need to serialize it to a gff structure, then save to disk as


AreaName.git and AreaName.gic


with the area layout information being placed in AreaName.are


 


 


Only problem I see, is that over time - random areas will accrue lots of junk resrefs.


Eg: 5000 people login, go to your random dungeon - you end up with 5000 x 3 files.


You would need to destroy the area files after you are done with them.


               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #9 on: March 09, 2016, 02:48:18 pm »


               


Just thinking on this - 


It would be complex for a script to identify where a chest should be placed.


 


So things like placeables would be difficult to dynamically place within a truly random area.


 


Eg: An area where the tileset tiles are placed programatically.


 


The only thing I can think of is that the x,y,z and facing of 'correct' locations is saved somewhere like a db for each tile.


When that tile is placed - we ask ourselves if we want to add a chest to this tile (wouldnt be nice to add a chest to every instance of that tile)


If we add the chest, then create it at the XYZ location on that tile (gives the impression that it was placed by hand in toolset)


 


This logic could be expanded to include lighting placeables : Letting you the script work out color schemes for areas.


Eg: If its a Drow Dungeon - maybe use green lighting placeable, vampire dungeon maybe use red?


 


I think nwnx has plugin capability to draw triggers / encounters, so you could potentially set the bounds of a dynamically added encounter to encompass specific tiles/tiletypes.


 


Then - once you work all this out, you just need to serialize it to a gff structure, then save to disk as


AreaName.git and AreaName.gic


with the area layout information being placed in AreaName.are


 


 


Only problem I see, is that over time - random areas will accrue lots of junk resrefs.


Eg: 5000 people login, go to your random dungeon - you end up with 5000 x 3 files.


You would need to destroy the area files after you are done with them.




 


First of all - right, I know generating random areas on the fly is possible with NWNX, by "impossible" I actually meant not achievable with what BioWare offers us, given that the topic was about one of the official modules, Infinite Dungeons.


 


When I began reading your last post I had a thought that information such as chest locations would need to be contained in the tiles and then when I read further I found out that this was your thought as well. '<img'> 


 


Anyway, I'm not sure if the investment in such plugins (and tileset modifications) is worth the end-result. Infinite Dungeons does, in my opinion, some very good job without even requiring NWNX. Of course it also depends on what the module needs. ID is nothing but a random dungeon and the way it was built makes it impossible for several players to explore two or more different dungeons at the same time.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #10 on: March 09, 2016, 04:09:59 pm »


               

If you wanted a pure vanilla solution, the best you could get would be planning for a maximum amount of potential random dungeons / players.


Create a large amount of instances of different areas


Then string them together in random order based on area transition events.


 


I think I remember a housing system that was prefixed with hh_  that did something like this.


 


It made it so that you had maybe 5 area interiors - but could have 40 house exteriors.


Only 5 players could be inside their houses at a single time.


When one exits their house - it despawns all their furnature, items etc


 


When another player enters, it ports them to the interior instance that belonged to the player who just left their house.


It spawns all the furniture and items belonging to that player then.


 


Giving the impression of a unique house interior for different players, but re-using the same area instance. (up to a max of X interiors)


 


In the context of a map, you could just make it so you plan for 10 possible dungeons, constructed from area instances strung together by area transitions.


 


You can then determine if dungeon1 has been setup yet - 


if not: set it up


if it has: load the setup already determined.


 


The setup method would determine the areas to string together, fog color, lighting, weather, placeable locations, monsters etc


 


Once Dungeon 1 is setup, anyone entering Dungeon 1 will see the same dungeon attributes.


If someone enters Dungeon 2 (through the entrance/door) : 


It would then say that Dungeon 1 is done, so setup Dungeon 2: Work out a random collection of areas to connect to, fog color and so on.


 


 


In theory - if you can live with the same area layout (tile placements), you can still achieve infinite dungeons, by going from one area to another, then back to area 1, but loading new properties.


 


 


Eg:


 


 


Area 1                          Area 2                          Area 3                                                                                              Area 4


Default Settings   >      Default Settings    >    Is Area 1, but with new placeables, monsters, fog color, etc    >     Is Area 2, but with new properties too


 


 


With this approach, you could get a pseudo-infinite area dungeon.


You just need to protect against players going back to Area 1, while someone goes forward to Area 3.


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #11 on: March 09, 2016, 04:26:55 pm »


               


Just thinking on this - 


It would be complex for a script to identify where a chest should be placed.


 


So things like placeables would be difficult to dynamically place within a truly random area.




Yes thats another thing to solve. To make this smooth and look good, each tile name would need to have a x,y,z positions assigned for things like placeables be it corpse, barrel or crate. Chests would probably make sense only in a specific tiles.


 


Either way. Randomly placed objects will hardly ever get close to manually placed objects. So if you want to do this then you need to take that downside.


 


IIRC there was actually some random placeable placement script at vault, but never looked for it (I needed random area generator not area population).


               
               

               
            

Legacy_Ubai

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
How did Infinite Dungeons work?
« Reply #12 on: March 10, 2016, 03:34:59 am »


               

Thank you all very much for the replies! I had always assumed that ID randomly generated dungeons on the fly, perhaps I took the term "infinite" too literally. '<img'> For me at least, the random selection of premade dungeons will be fine, so I'll take another look at the random generator suggested above.


 


-Matt