Skip to content

Commit

Permalink
mapgen: allow placing active bomb items for better craters in Dark Sk…
Browse files Browse the repository at this point in the history
…ies 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>
  • Loading branch information
2 people authored and anothersimulacrum committed Jul 3, 2021
1 parent 38d11b8 commit 32ecdad
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
6 changes: 6 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
47 changes: 47 additions & 0 deletions data/mods/Dark-Skies-Above/mapgen/map_extras/bombed_crater.json
Original file line number Diff line number Diff line change
@@ -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
}
]
2 changes: 2 additions & 0 deletions data/mods/Dark-Skies-Above/overrides/region_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"road": {
"extras": {
"mx_dsa_bombed_crater": 200,
"mx_mayhem": 0,
"mx_portal": 0,
"mx_portal_in": 0,
Expand All @@ -57,6 +58,7 @@
"build": {
"chance": 2,
"extras": {
"mx_dsa_bombed_crater": 200,
"mx_house_spider": 0,
"mx_house_wasp": 0,
"mx_military": 1,
Expand Down
4 changes: 2 additions & 2 deletions doc/MAPGEN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

1 change: 1 addition & 0 deletions src/flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
1 change: 1 addition & 0 deletions src/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ template <typename T> 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;
Expand Down
4 changes: 4 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit 32ecdad

Please sign in to comment.