-
Notifications
You must be signed in to change notification settings - Fork 68
Wilderness
The wilderness is a 64x64 array of wilderness blocks, of 64x64 tiles. Due to technical limitations, the gameplay occurs in a window of 2x2 blocks, with the game shifting the window contents and swapping 2 new blocks when player is less than 32 tiles closer to the edge.
The original game does not limit the player coordinates, which causes the out-of-bounds accesses and unintended behavior.
The 4 central blocks are special, as the game generates them from the current city layout. Only the walls, floor features and the city gates are transferred (details still need to be researched).
The seed value for the wilderness are the first 4 characters of a city name, interpreted as uint32
. There are 5 lists to choose the blocks from:
- normal blocks
@42D5C
- village blocks
@42D75
- dungeon blocks
@42D82
- inn blocks
@42D8F
- temple blocks
@42D9A
The list starts with a number of elements that follow.
srand(wildernessSeed)
wilderness <- byte[64*64]
for pos in (0,4095)
random <- rnd()
if random < 0x6666 then blockList <- normalBlocks
else
random <- random - 0x6666
if random < 0x4000 then blockList <- villageBlocks
else
random <- random - 0x4000
if random < 0x2666 then blockList <- dungeonBlocks
else
random <- random - 0x2666
if random < 0x1999 then blockList <- innBlocks
else blockList <- templeBlocks
block <- blockList[(rnd() & 0xFF) mod len(blockList)]
wilderness[pos] <- block
wilderness[2016] <- 1
wilderness[2017] <- 2
wilderness[2079] <- 3
wilderness[2080] <- 4
To generate blocks 1 to 4, the map is copied into 128x128 arrays and following transformations are made:
- All not-walls are erased;
-
A
-type blocks in 0x33..0x35 range are replaced with solid blocks 0x30 for the first story, 0xB for the second; - 0x2F blocks are replaced by 0x30 (walls), 0x2d with 0x2f, and 0x2e is unchanged (swap the halves of city gates);
- Second-story walls are replaced by 0x30, but their height flags (0x8080) are preserved;
- Floors are unchanged
- The unused space is filled with zeroes.
The generated map is split into 64x64 tiles which are used for the wilderness construction.