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

Conditional nesting in mapgen - by overmap neighbor adjacency #22131

Merged
merged 5 commits into from
Nov 5, 2017

Conversation

Coolthulhu
Copy link
Contributor

A step in the direction of jsonized labs. Still not there yet, but not far from it.

A nested entry now has an optional "neighbors" field. If the field exists, the nested mapgen will only be applied if all the neighbors match the ones specified there. For example:

{
  "chunks": [ "gun_with_casings", "shrubs_3x3" ],
  x: [ 10, 20 ],
  y: [ 10, 20 ],
  "neighbors": { "north": [ "forest", "field" }, "south": [ "forest", "field" ] }
}

In this case one of the two nested mapgens will be applied at random point in square from [ 10, 10 ] to [ 20, 20 ] only if north is a forest or field and south is a forest or field (can be mixed, like north being forest and south being field).

I edited the swamp_shack.json to show this new feature. The changes are as follows:

  • Moved the shack to center of the block, like most structures
  • Removed random chance of cattail on mixed terrain (they should only grow on shallow water)
  • Each side (north/east/south/west) gets an average of 2.5 cattails (in shallow, fresh water) if that side is adjacent to a swamp

Additionally, minor tweaks:

  • Supply const mapgendata & instead of map * to json mapgen pieces. That structure is already created in mapgen above and it usually goes to waste. This structure contains adjacency data (for the feature here), but also "biome" data. Biomes are nowhere near functional, but having this data would make it somewhat more likely that this will move somewhere sometime.
  • Minor refactor of mapgendata structure.

}
},
"place_nested": [
{ "chunks": [ "cattail", "null" ], "x": [ 0, 6 ], "y": [ 0, 6 ], "neighbors": { "north": "forest_water" } },
Copy link
Member

@John-Candlebury John-Candlebury Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the null mean in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the null is rolled, nothing is nested. They have equal weights. So 50% chance for cattail.
This is to pad the chances a bit, to make it somewhat more like the surrounding forest. Doing this whole "x rolls for cattail, 50% chance" makes it more like the math in forest cattail placement than just rolling "1 to 4 cattails" and placing those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants