From 32ecdad5535e8fb84e2bff2f0b1db8ecd1690649 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Sun, 21 Mar 2021 01:08:34 -0500 Subject: [PATCH] mapgen: allow placing active bomb items for better craters in Dark Skies Above (#48137) * mapgen: allow activated items to be placed on the map Add the new item flag "ACTIVATE_ON_PLACE". Items placed during mapgen with this flag will be activated immediately after they are placed on the map. * Dark Skies Above: use active bombs to create large bomb craters Use the new ACTIVATE_ON_PLACE flag with active bombs with 1 second count-downs in a new map special that randomly wrecks buildings across multiple z-levels. The bombs have max_noise = 0 and explode silently to preserve the avatar's hearing. Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com> --- data/json/flags.json | 6 +++ .../mapgen/map_extras/bombed_crater.json | 47 +++++++++++++++++++ .../overrides/region_settings.json | 2 + doc/MAPGEN.md | 4 +- src/flag.cpp | 1 + src/flag.h | 1 + src/map.cpp | 4 ++ 7 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 data/mods/Dark-Skies-Above/mapgen/map_extras/bombed_crater.json diff --git a/data/json/flags.json b/data/json/flags.json index 0ce224a92a9c3..713a0ebdfa551 100644 --- a/data/json/flags.json +++ b/data/json/flags.json @@ -1820,6 +1820,12 @@ "type": "json_flag", "context": [ "AMMO", "CONSUMABLE" ] }, + { + "id": "ACTIVATE_ON_PLACE", + "type": "json_flag", + "context": [ ], + "info": "This item will be activated when it is placed in mapgen." + }, { "id": "ACT_IN_FIRE", "type": "json_flag", diff --git a/data/mods/Dark-Skies-Above/mapgen/map_extras/bombed_crater.json b/data/mods/Dark-Skies-Above/mapgen/map_extras/bombed_crater.json new file mode 100644 index 0000000000000..cfa896c6537d1 --- /dev/null +++ b/data/mods/Dark-Skies-Above/mapgen/map_extras/bombed_crater.json @@ -0,0 +1,47 @@ +[ + { + "id": "tool_dsa_alien_bomb_act", + "type": "TOOL", + "category": "weapons", + "name": { "str": "active alien bomb" }, + "looks_like": "tool_rdx_charge_act", + "description": "This is an alien bomb. It has been activated and will soon explode, delivering its entire destructive power to everything in sight.", + "weight": "4400 g", + "volume": "10 L", + "price": 0, + "to_hit": -5, + "bashing": 20, + "material": [ "steel" ], + "symbol": "(", + "color": "light_red", + "initial_charges": 1, + "max_charges": 1, + "turns_per_charge": 1, + "explode_in_fire": true, + "explosion": { "power": 40000, "max_noise": 0 }, + "use_action": { + "type": "explosion", + "no_deactivate_msg": "You've already activated the bomb - clear the area immediately!", + "explosion": { "power": 40000, "max_noise": 0 } + }, + "flags": [ "BOMB", "TRADER_AVOID" ] + }, + { + "type": "mapgen", + "method": "json", + "update_mapgen_id": "mx_dsa_bombed_crater", + "object": { + "place_item": [ { "item": "tool_dsa_alien_bomb_act", "x": 12, "y": 12, "amount": 1, "custom-flags": [ "ACTIVATE_ON_PLACE" ] } ] + } + }, + { + "id": "mx_dsa_bombed_crater", + "type": "map_extra", + "name": { "str": "Bomb Crater" }, + "description": "A bomb crater.", + "generator": { "generator_method": "update_mapgen", "generator_id": "mx_dsa_bombed_crater" }, + "sym": ".", + "color": "brown", + "autonote": true + } +] diff --git a/data/mods/Dark-Skies-Above/overrides/region_settings.json b/data/mods/Dark-Skies-Above/overrides/region_settings.json index 35fff324dddea..fddeba421ac44 100644 --- a/data/mods/Dark-Skies-Above/overrides/region_settings.json +++ b/data/mods/Dark-Skies-Above/overrides/region_settings.json @@ -35,6 +35,7 @@ }, "road": { "extras": { + "mx_dsa_bombed_crater": 200, "mx_mayhem": 0, "mx_portal": 0, "mx_portal_in": 0, @@ -57,6 +58,7 @@ "build": { "chance": 2, "extras": { + "mx_dsa_bombed_crater": 200, "mx_house_spider": 0, "mx_house_wasp": 0, "mx_military": 1, diff --git a/doc/MAPGEN.md b/doc/MAPGEN.md index bdaa60394aca9..2e765138c9f9b 100644 --- a/doc/MAPGEN.md +++ b/doc/MAPGEN.md @@ -594,7 +594,8 @@ Example: | repeat | (optional) Value: `[ n1, n2 ]`. Spawn item randomly between `n1` and `n2` times. Only makes sense if the coordinates are random. Example: `[ 1, 3 ]` - repeat 1-3 times. | custom-flags | (optional) Value: `[ "flag1", "flag2" ]`. Spawn item with specific flags. - +The special custom flag "ACTIVATE_ON_PLACE" causes the item to be activated as it is placed. This is useful to have noisemakers that are already turned on as the avatar approaches. It can also be used with explosives with a 1 second countdown to have locations explode as the avatar approaches, creating uniquely ruined terrain. + ## Extra map features with specials **optional** Special map features that do more than just placing furniture / terrain. @@ -1072,4 +1073,3 @@ update_mapgen adds new optional keywords to a few mapgen JSON items. place_npc, place_monster, and place_computer can take an optional target boolean. If they have `"target": true` and are invoked by update_mapgen with a valid mission, then the NPC, monster, or computer will be marked as the target of the mission. - diff --git a/src/flag.cpp b/src/flag.cpp index 641d9c5966be2..5b5b68364f9c0 100644 --- a/src/flag.cpp +++ b/src/flag.cpp @@ -9,6 +9,7 @@ const flag_id flag_NULL = flag_id( "null" ); // intentionally invalid flag const flag_id flag_ACID( "ACID" ); const flag_id flag_ACID_IMMUNE( "ACID_IMMUNE" ); +const flag_id flag_ACTIVATE_ON_PLACE( "ACTIVATE_ON_PLACE" ); const flag_id flag_ACTIVE_CLOAKING( "ACTIVE_CLOAKING" ); const flag_id flag_ACT_IN_FIRE( "ACT_IN_FIRE" ); const flag_id flag_ACT_ON_RANGED_HIT( "ACT_ON_RANGED_HIT" ); diff --git a/src/flag.h b/src/flag.h index 316de675b7686..ce60d0a3f6580 100644 --- a/src/flag.h +++ b/src/flag.h @@ -16,6 +16,7 @@ template class generic_factory; extern const flag_id flag_NULL; extern const flag_id flag_ACID; extern const flag_id flag_ACID_IMMUNE; +extern const flag_id flag_ACTIVATE_ON_PLACE; extern const flag_id flag_ACTIVE_CLOAKING; extern const flag_id flag_ACT_IN_FIRE; extern const flag_id flag_ACT_ON_RANGED_HIT; diff --git a/src/map.cpp b/src/map.cpp index e6ed9c2bb73b3..1102a2a0b890e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4484,6 +4484,10 @@ item &map::add_item( const tripoint &p, item new_item ) new_item.set_var( "reveal_map_center_omt", ms_to_omt_copy( getabs( p ) ) ); } + if( new_item.has_flag( flag_ACTIVATE_ON_PLACE ) ) { + new_item.activate(); + } + current_submap->is_uniform = false; invalidate_max_populated_zlev( p.z );