diff --git a/data/mods/TEST_DATA/monstergroups.json b/data/mods/TEST_DATA/monstergroups.json index a12e15d399bc2..26ef371891275 100644 --- a/data/mods/TEST_DATA/monstergroups.json +++ b/data/mods/TEST_DATA/monstergroups.json @@ -103,6 +103,11 @@ "type": "monstergroup", "monsters": [ { "monster": "mon_test_shearable", "pack_size": [ 4, 6 ] } ] }, + { + "name": "test_upgrades_multi_null", + "type": "monstergroup", + "monsters": [ { "monster": "mon_null" }, { "monster": "mon_test_zombie_cop", "pack_size": [ 4, 6 ], "starts": "2 days" } ] + }, { "name": "test_upgrades_multi_late", "type": "monstergroup", diff --git a/data/mods/TEST_DATA/monsters.json b/data/mods/TEST_DATA/monsters.json index 68296dfa81d78..ef303663ae6af 100644 --- a/data/mods/TEST_DATA/monsters.json +++ b/data/mods/TEST_DATA/monsters.json @@ -94,7 +94,14 @@ "weight": "81500 g", "hp": 100, "speed": 50, - "flags": [ "SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "PET_WONT_FOLLOW" ] + "flags": [ "SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "PET_WONT_FOLLOW" ], + "upgrades": { + "half_life": 0, + "into_group": "test_upgrades_multi_null", + "multiple_spawns": true, + "spawn_range": 5, + "despawn_when_null": true + } }, { "id": "dissect_mon_test_CBM", diff --git a/doc/MONSTERS.md b/doc/MONSTERS.md index 4e6b6e7336975..8c2cf53c552c7 100644 --- a/doc/MONSTERS.md +++ b/doc/MONSTERS.md @@ -519,6 +519,7 @@ The upgrades object may have the following members: | `age_grow` | (int, optional) Number of days needed for monster to change into another monster. Does not scale with the evolution factor. | `multiple_spawns` | (bool, optional) If using `into_group`, the selected entry spawns a number of monsters based on the entry's `pack_size`. | `spawn_range` | (int, optional) Mandatory when `multiple_spawns` is true. Determines how far away from the original monster the upgraded monsters can spawn. +| `despawn_when_null` | (bool, optional) For `into_group`, when `mon_null` is selected as the group entry upgrade, the monster will despawn leaving no trace when this is true. Otherwise the monster "dies" naturally. Defaults to false. ## "reproduction" (dictionary, optional) diff --git a/tests/mongroup_test.cpp b/tests/mongroup_test.cpp index 69aafbba1c729..99a5a4a4ebd65 100644 --- a/tests/mongroup_test.cpp +++ b/tests/mongroup_test.cpp @@ -391,4 +391,23 @@ TEST_CASE( "mongroup_multi_spawn_restrictions", "[mongroup]" ) CHECK( counts.count( mon_test_shearable ) > 0 ); CHECK( counts.count( mon_test_zombie_cop ) > 0 ); } + + SECTION( "no valid spawns, with mon_null" ) { + std::map counts; + + test_multi_spawn( mon_test_CBM, 5, 4, 6, calendar::turn_zero + 1_days, + { mon_null, mon_test_CBM, mon_test_zombie_cop }, counts ); + + CHECK( counts.empty() ); + } + + SECTION( "1 valid spawn, with mon_null" ) { + std::map counts; + + test_multi_spawn( mon_test_CBM, 5, 4, 6, calendar::turn_zero + 4 * 3_days + 12_hours, + { mon_null, mon_test_CBM, mon_test_zombie_cop }, counts ); + + CHECK( counts.size() == 1 ); + CHECK( counts.count( mon_test_zombie_cop ) > 0 ); + } }