-
Notifications
You must be signed in to change notification settings - Fork 69
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