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.12k forks source link

Add check for total frequency in monster group #48690

Open Salty-Panda opened 3 years ago

Salty-Panda commented 3 years ago

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

https://discord.com/channels/598523535169945603/598529174302490644/836790330853425182 When too many mods or too many entries in vanilla modify some monster group things past 1000 will never spawn

Describe the solution you'd like

Add check on json loading I don't know if there is need to consider season, starts and ends parameters of group

Describe alternatives you've considered

Expect that contributors will count total frequency of monster group during editing and make consideration of other mods

Edit the code and remove limitation of 1000 total frequency

Salty-Panda commented 3 years ago

@Venera3 Did I summarize it properly?

Venera3 commented 3 years ago

The spawn conditionals influence if they can actually overload the roll (otherwise you'd never see spiders in swamps, for example) so you'd need to check for those as well and that gets a bit broad for an on-load check - you'd need to cross-check all possible permutations of start/end/season/time of day to be confident that your overload alarm isn't a false positive. A leaner check could only look at start and end-date, or if the gametime is known on json load maybe only at the time of the saved game, with the bigger test being included in the unit tests to catch in-repo offenders at least.

The ideal solution would be to move monster groups over to the same weighted list system that map extras use, that one seems to work with arbitrary weight sizes, eliminating the need for a check altogether but that's probably a bit more involved.

Venera3 commented 3 years ago

So actually this isn't really necessary. There's a lot of undocumented fields in the monstergroup definitions, including freq_total. Setting that to an arbitrary number turns the roll from a 1-in-1000 to a 1-in-X roll, preventing overloading as long as it's equal to or higher than the frequency totals. It would obviously be better if that was done automatically under the hood, but it should make auditing the existing groups and fixing mods easier than having to redo the whole lists. I'll do some testing to see if the other variables work as advertised and update the docs.

Salty-Panda commented 3 years ago

but it should make auditing the existing groups and fixing mods easier than having to redo the whole lists.

What about third-party mods, ff you update the value with mainline in mind won't it still fail if a mod increases it? Not sure how load order is determined but for the case: Vanilla - third party - in-repo mod Won't third-party potentially stop in-repo mod from spawning?

Venera3 commented 3 years ago

Ooof, depending on how the mod load orders work that might introduce (or has already introduced, in the cases where mods extended existing groups) some very context-dependent weirdness. Updating the in-repo stuff would work, but only if the players load one mod that touches a given monstergroup at a time - otherwise they'll either stack on top of each other or overwrite each other's total frequencies. The other option would be for each mod to use a dedicated monster group, and/or compatibility groups with other mods, but that's a prohibitively work-intensive solution.

In the short-term I'll update the documentation and go over the main games' groups I guess.

Salty-Panda commented 3 years ago

I have never seen a Magiclysm's wisp in the nature. It's supposed to spawn in swamps and it drops some dust which is a vital ingredient to multiple recipes. The dust hardly ever spawn on its own too. Could it be caused by this? @KorGgenT

Venera3 commented 3 years ago

Swamps shouldn't be close to overloading at any time, unless a lot of mods pile up. But wisps only spawn if you generate the map at night, meaning you'd have to go out to an evening stroll through an unknown Happy Fun Swamp to give them any chance of showing up - that's the reason I did away with time-of-day-based spawns in the vanilla group.

Salty-Panda commented 3 years ago

generate the map at night

The generation you speak about here is the one occurring when a tile enters the simulation bubble for the first time?

Venera3 commented 3 years ago

Yes, apart from rot spawns, horde movement, update_mapgen, spells and hardcoded attacks every mob gets placed on the first mapgen.