Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenApoc does not generate the full range of OG maps for each mission #630

Open
FilmBoy84 opened this issue Jun 28, 2019 · 3 comments
Open
Labels
Battlescape An issue relating to something in the battle overview part of Apocalypse !BUG! low priority This is a bug in OpenApoc. It will need resolving when time allows. It does not always cause a CTD Code Query Something doesn't seem right in the code. It may not be a bug, but it probably needs fixing! Enhancement This is a request for something that makes OpenApoc work better or more intuitively Feature Request This is a request for a new thing to be added to OpenApoc Help Wanted Help is required in making this fix/feature complete. If you can code or test, please take a look! Not Yet Implemented This fix or feature is not yet implemented or merged with trunk Verified / Replicated This issue has been verified or replicated by a developer

Comments

@FilmBoy84
Copy link
Collaborator

As referred to specifically regarding Slum Maps in #396 it appears the problem with OpenApoc not generating the full range of maps for each building and area type is across the board

There are a considerable number of options that OpenApoc should be able to create, but it does not appear to

@Istrebitel 's youtube videos also show that in his OpenApoc builds at least, the map generator was creating more varieties of combat zone... This never appears to have made it to trunk or has been disabled since it was tested

Further investigation is required

Ideally, we should offer all the map combinations that OG did, but also allow more possibilities and variety of map sizes

It appears maps were scaled according to squad size in OG, but with a "random" element that meant that small squad numbers could rarely still end up on a very large map....

@FilmBoy84 FilmBoy84 added !BUG! low priority This is a bug in OpenApoc. It will need resolving when time allows. It does not always cause a CTD Enhancement This is a request for something that makes OpenApoc work better or more intuitively Help Wanted Help is required in making this fix/feature complete. If you can code or test, please take a look! Feature Request This is a request for a new thing to be added to OpenApoc labels Jun 28, 2019
@FilmBoy84
Copy link
Collaborator Author

FilmBoy84 commented Jun 29, 2019

Here's the response from Istrebitel on map generation

from what I remember, there's a list of blocks in the original game files, like, 9 or 18 different blocks for slums, with each block having min and max number of occurences, and map size itself being defined having a min and max possible size. Then the generator randomly picks and matches blocks together which results in a random map.

To force OpenApoc to generate maps of huge or tiny size you'd edit these "amount of blocks XYZ" numbers, wherever it reads them from, or just quickly change them in code (read a static instead of reading from file, i.e., always generate a 4x4x1 map of slums, instead of generating whatever's set for slums in the files).
More detailed explanation would be:

  • Every map has its own chunk size
  • Every map is built of blocks. Blocks are templates - different kinds of slum sectors, for example, or different kind of x-com base blocks. These are put together randomly to form a map
  • Blocks have a variable size in chunks. For example, there is a tileset, luxury appartments i think, which has a 1x1x2 block (a lift), a 1x2x1 block (a corridor) and many 1x1x1 blocks (appartments themselves). UFOs are simple 2x2x2 maps which feature only one 2x2x2 block. Etc.
  • Every block has a min and max occurence. For the luxury appts example, a lift block will have a min occurence of 1, otherwise a map without this block could get generated, and floors would be
    inaccessible without terrain destruction as there's no lift, only appartments and one-level corridors
  • Every map has a min and max size on all axes, in chunks (or maybe it just randomly adds or subtracts 1 to typical chunk size? I don't remember)
  • The algorithm of map generation is unknown, was not reverse engineered, so I built it from scratch, and it seemed to work close to vanilla
  • AFAIK, my algorithm first goes and makes a list of manadatory blocks and places them all randomly
  • Then it makes a list of remaining blocks (remaining max occurence>0) and places one of these blocks randomly until map's done
  • If it can't place, it shuffles around to make room, like tetris (but usually this never happens)
  • If it can't make a map, it retries with other sizes
  • Then gives up and spits error (usually this is never reached with vanilla map templates)
  • When it placed all blocks, it then generates the map itself
  • creates the map object and fills the map with objects based on the blocks (the walls, decorations, item spawn points etc.)

@FilmBoy84
Copy link
Collaborator Author

Further update from istrebitel

Yeah I think I almost got to that - larger maps for larger enemy counts.
The way spawning agents works is that maps are separated into LOS
blocks, which are used for pathfinding, LOS calculations and for
spawning all at the same time. Every tile in a map block belongs to
one of the LOS blocks, which are all box shaped. Then there's a global
setting whether you can exit or enter the map on certain edge, for
every map. Based on this, LOS block is either eligible or not to spawn
units of certain allegiance. There is a set of values set in the block
that govern this. Those values should be described somewhere on the
forums or in the txt files attached to the project. If I remember
correctly, there are block spawn values for player units, alien units,
hostile units, civilian units, maybe civilian x-com personel has a
separate one, maybe not, that I don't remember, and I do remember
there is a special block for spawning queen.

So, the way to chose map size based on squad size would be to either
intelligently study the blocks and see which block provides how many
spawning opportunities and judge based on that, or maybe the vanilla
just had a hardcoded hack akin to"if more than X then use Y size"

Also one thing to note, I don't think I solved this problem, the way
some blocks are made, spawn points of hostile parties can be in LOS of
each other, like MARSEC warehouses, for example, you can often see a
lot of marsec security spawn points from entry points. The game
somehow ensures that there is never such a situation that you spawn in
LOS of an enemy. You can spawn back to back, meaning,once your units
move a bit they see each other, but you cannot spawn with enemy
already in LOS. Logically, it should follow that the game somehow
excludes spawn points or LOS blocks based on wether this block is
observed by already spawned unit. Logically then, it may happen that a
theoretical open field map is generated, which on paper has enough
spawn points to spawn all the participating units, but then does not
have enough blocks to spawn every unit because any unit spawned sees
the whole block. I think in vanilla there were no such open field
blocks, so this would never happen, but with modding this most likely
will and we have to be ready for that.

@FilmBoy84
Copy link
Collaborator Author

Please see #396 for other stuff relating to this issue

@FilmBoy84 FilmBoy84 added Battlescape An issue relating to something in the battle overview part of Apocalypse Code Query Something doesn't seem right in the code. It may not be a bug, but it probably needs fixing! Not Yet Implemented This fix or feature is not yet implemented or merged with trunk Verified / Replicated This issue has been verified or replicated by a developer labels Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Battlescape An issue relating to something in the battle overview part of Apocalypse !BUG! low priority This is a bug in OpenApoc. It will need resolving when time allows. It does not always cause a CTD Code Query Something doesn't seem right in the code. It may not be a bug, but it probably needs fixing! Enhancement This is a request for something that makes OpenApoc work better or more intuitively Feature Request This is a request for a new thing to be added to OpenApoc Help Wanted Help is required in making this fix/feature complete. If you can code or test, please take a look! Not Yet Implemented This fix or feature is not yet implemented or merged with trunk Verified / Replicated This issue has been verified or replicated by a developer
Projects
None yet
Development

No branches or pull requests

1 participant