mirror of
https://github.com/afritz1/OpenTESArena.git
synced 2026-09-11 12:56:41 +02:00
Page:
Dungeon Generation
Pages
Character Generation
Chasms
City Generation
Combat
Dialogue
Diseases
Dungeon Generation
Home
Interiors
Items
Light levels
Loot
Movement
NPCs
Name generation
Player stats
Resting
Save File Formats
Services
Shops
Sky behavior
Skybox
Spellmaker
Spells
Thieving
Time and Calendar
Timing
Travel
User interface
Weather
Wilderness
No results
4
Dungeon Generation
Carmina16 edited this page 2018-03-08 12:04:04 +07:00
Table of contents
Named dungeon seed
Each main quest dungeon and 14 province dungeons in each province have their seed:
getLocSeed(province, dunId) <-
X, Y <- getDungeonXY(province, dunId) # 16 last entries in CITYDATA.0x
seed <- (Y << 16) + X + province
return (~rol32(seed, 5)) & 0xFFFFFFFF
Main quest dungeons
Main quest dungeons have unique MIF files. Their names are generated as follows:
s <- String(seed)
mif <- s[:8] + ".MIF"
Other dungeons
SEED, W, H are the seed and width/height set for the particular dungeon. X coordinate increases to the left.
srand(SEED)
depth <- 1 + rnd() mod 2
if isArtifactDungeon() then depth <- 4
newSeed <- getRandomSeed()
transitions <- []
for i <- 0 to depth - 1
do
tY <- rnd() mod H
tX <- rnd() mod W
trBlock <- 10 * tY + tX
while trBlock == transitions[-1] # the last element, need to handle the case of i==0
transitions.append(trBlock)
for i <- 0 to depth - 1
srand(newSeed + i)
tileset <- rnd() mod 4
dY <- 0
for row <- 0 to H - 1
dX <- 0
for col <- 0 to W - 1
block <- tileset * 8 + rnd() mod 8
get a 'block' level from RANDOM1.MIF and paste in into level 'i' at dX, dY
dX <- dX + 32
dY <- dY + 32
draw a wall of 0x7800 blocks around each level
for each item in 'transitions', put up and down voxels in corresponding blocks
The local offset to possible up/down voxel position is (probably) 10, 10. The concrete voxel values should be taken from the INF file for RANDOM1.MIF.
Named dungeons
The 14 named dungeons in each province have the width of 2 blocks and height of 1.
Wilderness dungeons
Wilderness dungeons use the following seed and have the width and height of 2 blocks.
getWildernessSeed(cityId, wildBlockX, wildBlockY) <-
gX, gY <- getGlobalXY(cityId) # see 'Travel' article
baseSeed <- ((gX << 16) + gY) * (cityId >> 5) # province
return (baseSeed + ( ((wildBlockY << 6) + wildBlockX) & 0xFFFF) ) & 0xFFFFFFFF