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

Allow "place_monster" to spawn exactly one monster from a monster group #33256

Merged
merged 27 commits into from
Aug 21, 2019

Conversation

Hirmuolio
Copy link
Contributor

@Hirmuolio Hirmuolio commented Aug 15, 2019

Summary

SUMMARY: Infrastructure "Allow spawning exactly one monster from a monster group and set it mission target"

Purpose of change

With "place_monster" you can spawn exactly one monster of the type you define. You can also set the name of the monster and that it is the mission target.
For example "place_monster": [ { "monster": "mon_darkman", "x": 8, "y": 10 } ]

With "place_monsters" you can spawn vague number of random monsters from a monster group. The name can not be set and neither the mission target.

If you want to spawn exactly one random monster from a monster group you couldn't do it.

Describe the solution

"place_monster" can now take either monster (monster ID) or group (monster group ID).

map::place_spawns already has individual parameter that causes exactly one monster to spawn. But it was not used ever with json. It is used here now.

So you can do something like this to spawn a random mission target from a monster group.
"place_monster": [ { "monster": "GROUP_REFUGEE_BOSS_ZOMBIE", "name": "Sean McLaughlin", "x": 10, "y": 10, "target": true } ]

If multiple targets are spawned then killing any one of them is enough to complete mission.

I have also updated the first mission from the merchant in the refugee center to show the feature.

Before: Electric zombie was spawned. If this monster was blacklisted nothing was spawned and mission was broken (with mods like "mundane zombies" or "classic zombies").

New: 50/50 to spawn either electric or acidic zombie. If both are blacklisted a tough zombie is spawned instead.

Describe alternatives you've considered

Use "place_monsters" instead.

Additional context

I very much copied things from jmapgen_monster to jmapgen_monster_group to make this work. I am not 100% sure what all of the parts did but the result seems to work fine. The code should be looked closely.

As far I can see "place_monster" is not documented at all. There is "place_groups" in mapgen.md which doesn't even exist. Was the name changed at some point?

The pack_size is ignored when using group. Excactly one monster is always placed. If you want to place multiple monsters you should still use the "place_monsters".
When monster is used a high spawn density setting can cause multiple monsters to spawn. Not with group.

@Hirmuolio Hirmuolio changed the title Allow spawning exactly one monster and mission targets with monstergroup Allow spawning exactly one monster from a monster group and set it mission target Aug 15, 2019
@codemime
Copy link
Contributor

Allow "place_monster" to specify monster group instead of monster ID. But that seemed more complicated.

The alternative you've described looks far more appealing to me. The existed separation was rather natural: place_monster places one exact monster (which can have a name), and place_monster_group places the whole group. It does what it says. Now the separation erodes, and so does the implementation: place_monster_group places groups most of the time, but may place individuals in a pinch for the cost of code duplication. Then what's the point keeping place_monster? I'd rather allow "place_monster" to specify either "monster" or "monster_group" (picking one from that group).

src/map.h Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display Missions Quests and missions labels Aug 16, 2019
@Hirmuolio
Copy link
Contributor Author

Hirmuolio commented Aug 16, 2019

After thinking I agree that using "place_monster" instead of "place_monsters" seems more sensible.

Something like "place_monster": [ { "monster_group": "SOME_GROUP" } ] to add one monster from a group.

I was also thinking that this almost makes "place_monster" and "place_monsters" same. The only extra feature in "place_monsters" is the density. Everything else is/could be identical. They could be combined to same thing or at least partially in code in some other pull request.

@Hirmuolio Hirmuolio changed the title Allow spawning exactly one monster from a monster group and set it mission target [WIP] Allow spawning exactly one monster from a monster group Aug 16, 2019
src/mapgen.cpp Outdated Show resolved Hide resolved
doc/MAPGEN.md Outdated Show resolved Hide resolved
@Hirmuolio Hirmuolio changed the title [WIP] Allow spawning exactly one monster from a monster group Allow "place_monster" to spawn exactly one monster from a monster group Aug 18, 2019
@Hirmuolio
Copy link
Contributor Author

Hirmuolio commented Aug 18, 2019

This should now be practically ready (unless that branch merge about points causes issues) (which it of course does. But it was easy fix).

The doc had nothing about "place_monster" so I added info for it in mapgen.md. It is formatted different from other things in there. I took the style from JSON_INFO.md which in my opinion is much more readable. I am not sure about the formatting and wording of the doc but the contents should be correct.

@kevingranade kevingranade merged commit baefa54 into CleverRaven:master Aug 21, 2019
@Hirmuolio Hirmuolio deleted the Hirmuolio-spawn-one branch August 22, 2019 07:32
misterprimus pushed a commit to misterprimus/Cataclysm-DDA that referenced this pull request Sep 21, 2019
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` [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display Missions Quests and missions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants