CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.11k forks source link

Add math support for mapgen #75060

Open GuardianDll opened 1 month ago

GuardianDll commented 1 month ago

Is your feature request related to a problem? Please describe.

I don't think it was written anywhere, but mapgen would benefit enormously from being able to evaluate it's numbers using math and variables

Solution you would like.

notable example: terrain/furniture weight:

"+": [ [ "t_door_c", 5 ], [ "t_door_b", { "math": [ "time_since('cataclysm', 'unit':'days')" ] } ] ],

palette weights:

"distribution": [
  [ "standard_domestic_migration_palette", 9500 ],
  [ "standard_domestic_abandoned_palette", { "math": [ "time_since('cataclysm', 'unit':'days') + 370" ] } ],
  [ "house_hoarder_palette", 40 ],
  [ "house_survivor_palette", 90 ]
]

Nested chunks weights

"chunks": [
  [ "nest_vending_machine_broken", { "math": [ "time_since('cataclysm', 'unit':'days') + 85" ] } ],
  [ "nest_vending_machine_off", 10 ],
  [ "nest_vending_machine_broken_but_not_looted", 5 ]
]

weight of the map itself huh, doc says it already supports math

Describe alternatives you have considered.

No response

Additional context

No response

zachary-kaelan commented 1 month ago

Hell, instead of a weighted list, have the option of EoC syntax to return a furniture id. It has a function to pick from a weighted list. Then have it available globally under ids so instead of putting that list of weights you put in vending_machine_lootable across the entirety of mapgen in public places.

GuardianDll commented 1 month ago

what you just described is something we already have, in form of palettes and nests - you just assing specific palette or nest across multiple maps, and voila - all this maps can use symbols from this palette or use exactly same nest

zachary-kaelan commented 1 month ago

That's tight. One example I'm thinking of is to make it so that windows in a house are more likely to be broken over time, with a smaller chance to be cleared, but with decreasing chances based on how many are already broken while generating that tile.