DesktopAdventures
DesktopAdventures copied to clipboard
World Generation
Yoda Stories has a megafunction at 0x422210 for generating the world. While this probably won't be imported directly into DesktopAdventures, this engine will need some kind of world generation similar. The basic function of the world generation is as follows:
- A 32-bit seed is generated randomly for the world and is given to the world generator function. This seed is also presumably used in the save so that map state doesn't have to be saved in unexplored or unmodified(?) maps.
- In the world generator function, the RNG is seeded with srand and a world is generated based on the seed
- In Yoda Stories, the world generator function can return failure. If this happens, a new seed is generated until the function returns success.
Other Notes
- The world size parameter sets a list of mins and maxes for world generation:
if ( world_size_param == WORLD_SMALL )
{
world_width_max = 8;
world_width_min = 5;
world_unk1_max = 6;
world_unk1_min = 4;
world_unk2_max = 1;
world_unk2_min = 1;
unk3_max = 1;
unk3_min = 1;
}
else if ( world_size_param == WORLD_LARGE )
{
world_width_max = 12;
world_width_min = 6;
world_unk1_max = 12;
world_unk1_min = 6;
world_unk2_max = 11;
world_unk2_min = 6;
unk3_max = 11;
unk3_min = 4;
}
else
{
world_width_max = 9;
world_width_min = 5;
world_unk1_max = 9;
world_unk1_min = 5;
world_unk2_max = 8;
world_unk2_min = 4;
unk3_max = 8;
unk3_min = 3;
}
Knowing exactly what the unknown parameters are for will help in figuring out world generation. May be doable just via tweaking the variables at runtime and examining the map.
Some experiments with these mins/maxes:
World with width max/min set to 3 and 1. Doesn't quite look like a width...
Width max/min set to 2 and 2
After checking how those are used, the final value for that parameter ends up being (rand() % 3) + (rand() % -4) + world_min_width + rand % (world_max_width - world_min_width + 1). Modifying the value directly doesn't seem to show a width or anything immediately obvious.
Setting all values to 0 gets this result:
Looking at the last screenshot, it looks like there's at least a minimum of two item exchanges. I might keep setting values to minimums to get an idea of the minimum requirements for worlds.