Skip to content

Commit

Permalink
JSONize some trap features, replace trap int_id externs with string_i…
Browse files Browse the repository at this point in the history
…ds (CleverRaven#47933)

* JSONize trap sonar detectibility

Add trap flags - just the same as normal flags, but for traps! Stick
them in their own separate file to avoid confusion.

* JSONize trap memorial messages

light_snare and heavy_snare seem to no longer exist, or I couldn't find
any reference to them but this and tilesets.

Updated dissector trap message, and added a trap message to some traps
(the hallway ones, one or two of the similar-but-not-the-same variants
of existing traps).

* JSONize trap temperature convection

Not quite sure how to describe it, went the lazy route.

* Move traps externs from int to string ids

When loading the game without this content, these will now only give an
error on the use of these, instead of at the end data loading for traps.

Previously there were performance concerns with this, but this should be
fine since CleverRaven#44261 - see CleverRaven#44500.

tr_null must remain an int id, as it used in the string to int id
conversion. This is fine, as it will always be loaded (it's in
data/core).

Move the ledge trap over to data/core as well, because everything will
need the 'open space' trap.
  • Loading branch information
anothersimulacrum committed Jul 3, 2021
1 parent 8ed782f commit 24922b2
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 196 deletions.
17 changes: 17 additions & 0 deletions data/core/traps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"//": "We're always going to need a 'nothing here' tile, we currently use traps for this.",
"type": "trap",
"id": "tr_ledge",
"name": "ledge",
"color": "i_cyan",
"memorial_male": { "ctxt": "memorial_female", "str": "Fell down a ledge." },
"memorial_female": { "ctxt": "memorial_female", "str": "Fell down a ledge." },
"symbol": " ",
"visibility": 0,
"avoidance": 99999,
"difficulty": 99,
"action": "ledge",
"vehicle_data": { "is_falling": true }
}
]
12 changes: 12 additions & 0 deletions data/json/flags/trap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"type": "json_flag",
"id": "SONAR_DETECTABLE",
"context": [ ]
},
{
"type": "json_flag",
"id": "CONVECTS_TEMPERATURE",
"context": [ ]
}
]
78 changes: 66 additions & 12 deletions data/json/traps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"id": "tr_bubblewrap",
"name": "bubble wrap",
"color": "light_cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on bubble wrap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on bubble wrap." },
"symbol": "_",
"visibility": 0,
"avoidance": 8,
Expand All @@ -17,6 +19,8 @@
"id": "tr_glass",
"name": "glass shards",
"color": "light_cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on glass." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on glass." },
"symbol": "_",
"visibility": 6,
"avoidance": 8,
Expand Down Expand Up @@ -103,6 +107,8 @@
"id": "tr_microlab_shifting_hall",
"name": "microlab shifting hall",
"color": "brown",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a dimensional anomaly." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a dimensional anomaly." },
"symbol": ".",
"visibility": 99,
"avoidance": 99,
Expand All @@ -116,6 +122,8 @@
"id": "tr_microlab_shifting_hall_2",
"name": "microlab shifting hall",
"color": "brown",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a dimensional anomaly." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a dimensional anomaly." },
"symbol": ".",
"visibility": 99,
"avoidance": 99,
Expand All @@ -130,6 +138,8 @@
"trigger_weight": "200 g",
"name": "bear trap",
"color": "blue",
"memorial_male": { "ctxt": "memorial_male", "str": "Caught by a beartrap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Caught by a beartrap." },
"symbol": "^",
"visibility": 2,
"avoidance": 7,
Expand All @@ -152,12 +162,15 @@
"trigger_weight": "200 g",
"name": "buried bear trap",
"color": "blue",
"memorial_male": { "ctxt": "memorial_male", "str": "Caught by a beartrap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Caught by a beartrap." },
"symbol": "^",
"visibility": 9,
"avoidance": 8,
"difficulty": 4,
"action": "beartrap",
"drops": [ "beartrap" ],
"flags": [ "SONAR_DETECTABLE" ],
"vehicle_data": {
"damage": 300,
"sound_volume": 8,
Expand All @@ -173,6 +186,8 @@
"id": "tr_nailboard",
"name": "spiked board",
"color": "light_gray",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on a spiked board." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on a spiked board." },
"symbol": "_",
"visibility": 1,
"avoidance": 6,
Expand All @@ -186,6 +201,8 @@
"id": "tr_caltrops",
"name": "caltrops",
"color": "dark_gray",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on a caltrop." },
"memorial_female": { "ctxt": "memorial_female", "str": "stepped on a caltrop." },
"symbol": "_",
"visibility": 4,
"avoidance": 6,
Expand All @@ -199,6 +216,8 @@
"id": "tr_caltrops_glass",
"name": "glass caltrops",
"color": "dark_gray",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on a glass caltrop." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on a glass caltrop." },
"symbol": "_",
"visibility": 6,
"avoidance": 6,
Expand All @@ -212,6 +231,8 @@
"id": "tr_tripwire",
"name": "tripwire",
"color": "light_red",
"memorial_male": { "ctxt": "memorial_male", "str": "Tripped on a tripwire." },
"memorial_female": { "ctxt": "memorial_female", "str": "Tripped on a tripwire." },
"symbol": "^",
"visibility": 6,
"avoidance": 4,
Expand All @@ -225,6 +246,8 @@
"trigger_weight": "200 g",
"name": "crossbow trap",
"color": "green",
"memorial_male": { "ctxt": "memorial_male", "str": "Trigged a crossbow trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Trigged a crossbow trap." },
"symbol": "^",
"visibility": 5,
"avoidance": 4,
Expand All @@ -248,6 +271,8 @@
"trigger_weight": "200 g",
"name": "shotgun trap",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a shotgun trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a shotgun trap." },
"symbol": "^",
"visibility": 4,
"avoidance": 5,
Expand All @@ -270,6 +295,8 @@
"trigger_weight": "200 g",
"name": "shotgun trap",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a shotgun trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a shotgun trap." },
"symbol": "^",
"visibility": 4,
"avoidance": 5,
Expand All @@ -293,6 +320,8 @@
"trigger_weight": "200 g",
"name": "shotgun trap",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a shotgun trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a shotgun trap." },
"symbol": "^",
"visibility": 4,
"avoidance": 5,
Expand Down Expand Up @@ -329,6 +358,8 @@
"id": "tr_blade",
"name": "spinning blade",
"color": "cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a blade trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a blade trap." },
"symbol": "\\",
"visibility": 0,
"avoidance": 4,
Expand All @@ -342,6 +373,8 @@
"trigger_weight": "200 g",
"name": "land mine",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on a land mine." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on a land mine." },
"symbol": "^",
"visibility": 1,
"avoidance": 14,
Expand All @@ -364,12 +397,15 @@
"trigger_weight": "200 g",
"name": "buried land mine",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped on a land mine." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped on a land mine." },
"symbol": "_",
"visibility": 10,
"avoidance": 14,
"difficulty": 10,
"action": "landmine",
"drops": [ "landmine" ],
"flags": [ "SONAR_DETECTABLE" ],
"vehicle_data": {
"do_explosion": true,
"damage": 1000,
Expand All @@ -386,6 +422,8 @@
"trigger_weight": "200 g",
"name": "teleport pad",
"color": "magenta",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a teleport trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a teleport trap." },
"symbol": "_",
"visibility": 0,
"avoidance": 15,
Expand All @@ -398,6 +436,8 @@
"id": "tr_goo",
"name": "goo pit",
"color": "dark_gray",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped into thick goo." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped into thick goo." },
"symbol": "_",
"visibility": 0,
"avoidance": 15,
Expand All @@ -409,6 +449,8 @@
"id": "tr_dissector",
"name": "exposed high-energy conduit",
"color": "cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped into an exposed high-energy conduit." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped into an exposed high-energy conduit." },
"symbol": "7",
"visibility": 2,
"avoidance": 20,
Expand All @@ -421,18 +463,23 @@
"id": "tr_sinkhole",
"name": "sinkhole",
"color": "brown",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped into a sinkhole." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped into a sinkhole." },
"symbol": "_",
"visibility": 10,
"avoidance": 14,
"difficulty": 99,
"action": "sinkhole",
"flags": [ "SONAR_DETECTABLE" ],
"vehicle_data": { "damage": 500 }
},
{
"type": "trap",
"id": "tr_pit",
"name": "pit",
"color": "brown",
"memorial_male": { "ctxt": "memorial_male", "str": "Fell in a pit." },
"memorial_female": { "ctxt": "memorial_female", "str": "Fell in a pit." },
"symbol": "0",
"visibility": 0,
"avoidance": 8,
Expand All @@ -445,6 +492,8 @@
"id": "tr_spike_pit",
"name": "spiked pit",
"color": "blue",
"memorial_male": { "ctxt": "memorial_male", "str": "Fell into a spiked pit." },
"memorial_female": { "ctxt": "memorial_female", "str": "Fell into a spiked pit." },
"symbol": "0",
"visibility": 0,
"avoidance": 8,
Expand All @@ -457,42 +506,37 @@
"id": "tr_lava",
"name": "lava",
"color": "red",
"memorial_male": { "ctxt": "memorial_male", "str": "Stepped into lava." },
"memorial_female": { "ctxt": "memorial_female", "str": "Stepped into lava." },
"symbol": "~",
"visibility": 0,
"avoidance": 99,
"difficulty": 99,
"action": "lava",
"flags": [ "CONVECTS_TEMPERATURE" ],
"vehicle_data": { "damage": 500 }
},
{
"type": "trap",
"id": "tr_portal",
"name": "shimmering portal",
"color": "magenta",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a teleoport trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a teleoport trap." },
"symbol": "%",
"visibility": 0,
"avoidance": 99,
"difficulty": 99,
"action": "portal"
},
{
"type": "trap",
"id": "tr_ledge",
"name": "ledge",
"color": "i_cyan",
"symbol": " ",
"visibility": 0,
"avoidance": 99999,
"difficulty": 99,
"action": "ledge",
"vehicle_data": { "is_falling": true }
},
{
"type": "trap",
"id": "tr_boobytrap",
"trigger_weight": "200 g",
"name": "booby trap",
"color": "light_cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a booby trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a booby trap." },
"symbol": "^",
"visibility": 5,
"avoidance": 4,
Expand All @@ -514,6 +558,8 @@
"id": "tr_temple_flood",
"name": "ledge",
"color": "light_gray",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a flood trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a flood trap." },
"symbol": "^",
"visibility": 9,
"avoidance": 20,
Expand Down Expand Up @@ -561,6 +607,8 @@
"id": "tr_shadow",
"name": "",
"color": "white",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a shadow trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a shadow trap." },
"symbol": "^",
"visibility": 99,
"avoidance": 99,
Expand All @@ -573,6 +621,8 @@
"id": "tr_drain",
"name": "",
"color": "white",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a life-draining trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a life-draining trap." },
"symbol": "^",
"visibility": 99,
"avoidance": 99,
Expand All @@ -585,6 +635,8 @@
"id": "tr_snake",
"name": "",
"color": "white",
"memorial_male": { "ctxt": "memorial_male", "str": "Triggered a shadow snake trap." },
"memorial_female": { "ctxt": "memorial_female", "str": "Triggered a shadow snake trap." },
"symbol": "^",
"visibility": 99,
"avoidance": 99,
Expand All @@ -597,6 +649,8 @@
"id": "tr_glass_pit",
"name": "glass pit",
"color": "cyan",
"memorial_male": { "ctxt": "memorial_male", "str": "Fell into a pit filled with glass shards." },
"memorial_female": { "ctxt": "memorial_female", "str": "Fell into a pit filled with glass shards." },
"symbol": "0",
"visibility": 0,
"avoidance": 8,
Expand Down
4 changes: 4 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ These are handled through `ammo_types.json`. You can tag a weapon with these to
- ```WIDE``` Prevents `HARDTOSHOOT` monster flag from having any effect. Implied by ```SHOT``` or liquid ammo.
- ```NON_FOULING``` This ammo does not cause dirtying or blackpowder fouling on the gun when fired.

## Traps

- ```SONAR_DETECTABLE``` This trap can be identified with ground-penetrating SONAR.
- ```CONVECTS_TEMPERATURE``` This trap convects temperature, like lava.

## Armor

Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,7 @@ it is present to help catch errors.
"spell_data": { "id": "bear_trap" }, // data required for trapfunc::spell()
"trigger_weight": "200 g", // If an item with this weight or more is thrown onto the trap, it triggers. TODO: what is the default?
"drops": [ "beartrap" ], // For disassembly?
"flags": [ "EXAMPLE_FLAG" ], // A set of valid flags for this trap
"vehicle_data": {
"damage": 300,
"sound_volume": 8,
Expand Down
3 changes: 2 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,10 +1873,11 @@ int get_heat_radiation( const tripoint &location, bool direct )

int get_convection_temperature( const tripoint &location )
{
static const flag_id trap_convects( "CONVECTS_TEMPERATURE" );
int temp_mod = 0;
map &here = get_map();
// Directly on lava tiles
int lava_mod = here.tr_at( location ) == tr_lava ?
int lava_mod = here.tr_at( location ).has_flag( trap_convects ) ?
fd_fire->get_intensity_level().convection_temperature_mod : 0;
// Modifier from fields
for( auto fd : here.field_at( location ) ) {
Expand Down
Loading

0 comments on commit 24922b2

Please sign in to comment.