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

Rework Monster Groups (2/2) #52323

Merged
merged 4 commits into from
Oct 23, 2021
Merged

Conversation

dseguin
Copy link
Member

@dseguin dseguin commented Oct 16, 2021

Summary

None

Purpose of change

Fixes #52284 and fixes #49392.

This is part 2 of the monstergroup behaviour changes. The purpose is to allow monster groups to contain subgroups for spawn definitions.

Describe the solution

See #52288 for part 1 of these modifications, otherwise these fields won't make sense.

In monster groups, within the "monsters" array, you can define "group" objects as well as "monster" objects. Groups use the same fields as monsters, but they are processed differently. When the game looks for possible spawns from a monster group, it will recursively check subgroups if they exist. The weight of the subgroup is defined just like monster objects, so spawn chances only matter for top-level objects. Example:

{
  "type": "monstergroup",
  "name": "GROUP_MIGO_RAID",
  "//": "Meta-group for mi-gos on-the-go.",
  "monsters": [
    { "group": "GROUP_MI-GO_BASE_CAPTORS", "weight": 150, "cost_multiplier": 6, "pack_size": [ 1, 2 ] },
    { "group": "GROUP_MI-GO_SCOUT_TOWER", "weight": 100, "cost_multiplier": 4, "pack_size": [ 0, 2 ] },
    { "monster": "mon_mi_go_guard", "weight": 200, "cost_multiplier": 4 },
    { "monster": "mon_mi_go", "weight": 500, "cost_multiplier": 2, "pack_size": [ 3, 4 ] }
  ]
}

In that example, if the spawn rng chooses a weight of 200, a monster from the GROUP_MI-GO_SCOUT_TOWER subgroup will be selected. The selection follows a recursive model, so if that subgroup has its own subgroups, then the rng could select a monster from a subgroup of a subgroup.

The magic in this solution is MonsterGroupEntry::group and MonsterGroupEntry::is_group(). This means that we can no longer assume that a MonsterGroupEntry is a monster. It could also be a monster group.

Describe alternatives you've considered

The monstergroup loader could be converted to use a similar model to itemgroups, but it's drastically different and would involve some project-wide refactoring.

Testing

Added the following subgroup to "GROUP_ZOMBIE":

{ "group": "GROUP_ZOMBIE_SCORCHED", "weight": 1500, "pack_size": [ 3, 5 ] }

After visiting a city, scorched zombies from the subgroup spawned with the regular zombies:
test_results

Additional context

Some additional catch-up changes will be needed once part 1 is merged:

  • Fix conflicts
  • Update documentation
  • Testing

@Maleclypse Maleclypse added [C++] Changes (can be) made in C++. Previously named `Code` Spawn Creatures, items, vehicles, locations appearing on map labels Oct 17, 2021
@dseguin dseguin marked this pull request as ready for review October 22, 2021 16:15
@kevingranade kevingranade merged commit d8cd7f9 into CleverRaven:master Oct 23, 2021
@dseguin dseguin deleted the mon_subgroups branch November 7, 2021 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Spawn Creatures, items, vehicles, locations appearing on map
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make monstergroups work the way one would expect Allow nesting monster groups
3 participants