Skip to content

Commit

Permalink
feat(content): looks_like, trigger message with spells, and can ala…
Browse files Browse the repository at this point in the history
…rm for trap (#3939)

* feat(content): expand trap options, some related code fixes

* style(autofix.ci): automated formatting

* Do thing

* Update doc/src/content/docs/en/mod/json/reference/graphics/external_tileset.md

Co-authored-by: scarf <[email protected]>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: scarf <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2023
1 parent 4ecf356 commit 7d54e3e
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 16 deletions.
3 changes: 2 additions & 1 deletion data/json/external_tileset/External_Tileset_DP_Normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
{ "id": "overlay_worn_armguard_bronze", "fg": 45 },
{ "id": "cacao_pod", "fg": 46 },
{ "id": "overlay_wielded_cacao_pod", "fg": 46 },
{ "id": "f_sign", "fg": 47 }
{ "id": "f_sign", "fg": 47 },
{ "id": "tr_can_alarm", "fg": 48 }
],
"sprite_width": 32,
"sprite_height": 32
Expand Down
Binary file modified data/json/external_tileset/External_Tileset_DP_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions data/json/items/tool/traps.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,30 @@
"done_message": "You string up the tripwire."
}
},
{
"id": "can_alarm_trap",
"type": "GENERIC",
"category": "tools",
"name": { "str": "makeshift perimeter alarm" },
"description": "This is a set of empty cans used as makeshift noisemakers, strung up across a doorway or other thin passage. It will make noise when activated to alert you of intruders, but is otherwise harmless.",
"weight": "120 g",
"volume": "1 L",
"price": "3 USD",
"price_postapoc": "10 cent",
"to_hit": -1,
"material": "aluminum",
"symbol": ";",
"looks_like": "boobytrap",
"color": "light_gray",
"use_action": {
"type": "place_trap",
"trap": "tr_can_alarm",
"needs_solid_neighbor": true,
"moves": 200,
"practice": 3,
"done_message": "You string up some cans on a tripwire."
}
},
{
"id": "glass_shard_trap",
"type": "GENERIC",
Expand Down
28 changes: 21 additions & 7 deletions data/json/recipes/other/traps.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@
"time": "30 s",
"autolearn": true,
"using": [ [ "cordage", 1 ] ],
"components": [ [ [ "superglue", 1 ] ] ]
"components": [ [ [ "adhesive", 1, "LIST" ], [ "nail", 2 ] ] ]
},
{
"type": "recipe",
"result": "can_alarm_trap",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_TRAPS",
"skill_used": "traps",
"skills_required": [ "survival", 2 ],
"difficulty": 2,
"time": "5 m",
"autolearn": true,
"components": [
[ [ "tripwire", 1 ] ],
[ [ "can_drink_unsealed", 4 ], [ "can_food_unsealed", 4 ] ],
[ [ "bb", 12 ], [ "pebble", 4 ], [ "pebble_clay", 4 ], [ "marble", 4 ], [ "bearing", 4 ] ]
]
},
{
"type": "recipe",
Expand Down Expand Up @@ -121,8 +137,7 @@
"reversible": true,
"decomp_learn": 2,
"autolearn": true,
"using": [ [ "cordage", 1 ] ],
"components": [ [ [ "crossbow", 1 ] ], [ [ "bolt_steel", 1 ], [ "bolt_wood", 4 ] ] ]
"components": [ [ [ "tripwire", 1 ] ], [ [ "crossbow", 1 ] ], [ [ "bolt_steel", 1 ], [ "bolt_wood", 4 ] ] ]
},
{
"type": "recipe",
Expand All @@ -136,8 +151,7 @@
"reversible": true,
"decomp_learn": 2,
"autolearn": true,
"using": [ [ "cordage", 1 ] ],
"components": [ [ [ "shotgun_d", 1 ] ], [ [ "shot_00", 2 ], [ "shot_slug", 2 ], [ "shot_flechette", 2 ] ] ]
"components": [ [ [ "tripwire", 1 ] ], [ [ "shotgun_d", 1 ] ], [ [ "shot_00", 2 ], [ "shot_slug", 2 ], [ "shot_flechette", 2 ] ] ]
},
{
"type": "recipe",
Expand All @@ -152,7 +166,7 @@
"decomp_learn": 3,
"book_learn": [ [ "manual_mechanics", 3 ], [ "manual_traps", 3 ], [ "howto_traps", 3 ], [ "book_icef", 4 ] ],
"qualities": [ { "id": "WRENCH", "level": 1 } ],
"components": [ [ [ "motor", 1 ] ], [ [ "blade", 2 ] ], [ [ "cordage", 1, "LIST" ] ] ]
"components": [ [ [ "motor", 1 ] ], [ [ "blade", 2 ] ], [ [ "tripwire", 1 ] ] ]
},
{
"type": "recipe",
Expand All @@ -164,9 +178,9 @@
"difficulty": 3,
"time": "5 m",
"book_learn": [ [ "manual_traps_mil", 3 ] ],
"using": [ [ "cordage_short", 1 ] ],
"qualities": [ { "id": "CUT", "level": 1 } ],
"components": [
[ [ "tripwire", 1 ] ],
[ [ "grenade", 1 ] ],
[ [ "clay_canister", 1 ], [ "can_drink_unsealed", 1 ], [ "can_food_unsealed", 1 ], [ "canister_empty", 1 ] ]
]
Expand Down
26 changes: 26 additions & 0 deletions data/json/spells_trap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"id": "spell_trap_can_alarm_trigger",
"type": "SPELL",
"name": { "str": "Can Alarm Trigger" },
"description": "Has to be a target_attack spell instead of noise because spellcasting traps are a hacky mess.",
"valid_targets": [ "self", "ally", "hostile" ],
"flags": [ "SILENT", "NO_EXPLOSION_VFX" ],
"min_aoe": 2,
"max_aoe": 2,
"effect": "target_attack",
"extra_effects": [ { "id": "spell_trap_can_alarm_effect" } ]
},
{
"type": "SPELL",
"id": "spell_trap_can_alarm_effect",
"name": { "str": "Can Alarm Effect" },
"description": "And this triggers the actual sound ",
"sound_description": "empty cans clattering!",
"min_damage": 25,
"max_damage": 25,
"valid_targets": [ "ground" ],
"flags": [ "NO_EXPLOSION_VFX" ],
"effect": "noise"
}
]
29 changes: 23 additions & 6 deletions data/json/traps.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,23 @@
"avoidance": 4,
"difficulty": 3,
"action": "tripwire",
"drops": [ "string_36" ]
"drops": [ "tripwire" ]
},
{
"type": "trap",
"id": "tr_can_alarm",
"name": "makeshift perimeter alarm",
"color": "light_gray",
"symbol": "^",
"looks_like": "tr_tripwire",
"//": "Set to be easier to spot than a plain tripwire, but harder to avoid and disarm without jostling the cans.",
"visibility": 4,
"avoidance": 6,
"difficulty": 5,
"action": "spell",
"spell_data": { "id": "spell_trap_can_alarm_trigger" },
"drops": [ "can_alarm_trap" ],
"vehicle_data": { "sound_volume": 25, "sound": "empty cans clattering!" }
},
{
"type": "trap",
Expand All @@ -242,7 +258,7 @@
"avoidance": 4,
"difficulty": 5,
"action": "crossbow",
"drops": [ "string_36", "crossbow", "bolt_steel" ],
"drops": [ "tripwire", "crossbow", "bolt_steel" ],
"vehicle_data": {
"chance": 30,
"damage": 300,
Expand All @@ -265,7 +281,7 @@
"avoidance": 5,
"difficulty": 6,
"action": "shotgun",
"drops": [ "string_36", "shotgun_d", { "item": "shot_00", "quantity": 2, "charges": 1 } ],
"drops": [ "tripwire", "shotgun_d", { "item": "shot_00", "quantity": 2, "charges": 1 } ],
"vehicle_data": {
"chance": 70,
"damage": 300,
Expand All @@ -287,7 +303,7 @@
"avoidance": 5,
"difficulty": 6,
"action": "shotgun",
"drops": [ "string_36", "shotgun_d", { "item": "shot_00", "quantity": 1, "charges": 1 } ],
"drops": [ "tripwire", "shotgun_d", { "item": "shot_00", "quantity": 1, "charges": 1 } ],
"vehicle_data": {
"chance": 70,
"damage": 300,
Expand All @@ -310,7 +326,7 @@
"avoidance": 5,
"difficulty": 6,
"action": "shotgun",
"drops": [ "string_36", "shotgun_s", { "item": "shot_00", "quantity": 1, "charges": 1 } ],
"drops": [ "tripwire", "shotgun_s", { "item": "shot_00", "quantity": 1, "charges": 1 } ],
"vehicle_data": {
"chance": 70,
"damage": 300,
Expand All @@ -334,7 +350,7 @@
"difficulty": 2,
"trap_radius": 1,
"action": "none",
"drops": [ "motor", "blade", "blade", "string_36" ]
"drops": [ "motor", "blade", "blade", "tripwire" ]
},
{
"type": "trap",
Expand Down Expand Up @@ -506,6 +522,7 @@
"name": "booby trap",
"color": "light_cyan",
"symbol": "^",
"looks_like": "tr_tripwire",
"visibility": 5,
"avoidance": 4,
"difficulty": 7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Links to relevant pull requests, for content covered below:
- Alternative ear/tail mutation: [#3340](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/3340)
- New trees: [#3626](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/3626)
- Alternative sign sprite: [#3670](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/3670)
- New traps: [#3939](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/3939)

## Undead People

Expand Down Expand Up @@ -75,6 +76,8 @@ Ultica are planned for the future.
- Battle masks, iron and bronze, including worn sprites. Items specific to BN.
- Bronze arm guards, including worn sprites. Item specific to BN.
- Cacao pods. Item specific to BN.
- Override for sign sprite. Removes lettering on the front specific to DDA.
- Makeshift perimeter alarm. Trap specific to BN.

### External_Tileset_DP_Tall.png

Expand All @@ -87,7 +90,6 @@ Ultica are planned for the future.
- Rewired street light, including active state. Furniture specific to BN.
- Cocoa tree. Terrain specific to BN.
- Cocoa plant. Terrain specific to BN.
- Override for sign sprite. Removes lettering on the front specific to DDA.

### alternative_mutation_tileset.png

Expand Down
2 changes: 2 additions & 0 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,8 @@ cata_tiles::find_tile_looks_like( const std::string &id, TILE_CATEGORY category,
return find_tile_looks_like_by_string_id<furn_t>( id, category, looks_like_jumps_limit );
case C_TERRAIN:
return find_tile_looks_like_by_string_id<ter_t>( id, category, looks_like_jumps_limit );
case C_TRAP:
return find_tile_looks_like_by_string_id<trap>( id, category, looks_like_jumps_limit );
case C_FIELD:
return find_tile_looks_like_by_string_id<field_type>( id, category, looks_like_jumps_limit );
case C_MONSTER:
Expand Down
4 changes: 4 additions & 0 deletions src/trap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ void trap::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "floor_bedding_warmth", floor_bedding_warmth, 0 );
optional( jo, was_loaded, "spell_data", spell_data );
assign( jo, "trigger_weight", trigger_weight );
if( was_loaded && jo.has_member( "copy-from" ) && looks_like.empty() ) {
looks_like = jo.get_string( "copy-from" );
}
jo.read( "looks_like", looks_like );
for( const JsonValue entry : jo.get_array( "drops" ) ) {
itype_id item_type;
int quantity = 0;
Expand Down
1 change: 1 addition & 0 deletions src/trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct trap {
int comfort = 0;
int floor_bedding_warmth = 0;
public:
std::string looks_like;
vehicle_handle_trap_data vehicle_data;
std::string name() const;
/**
Expand Down
4 changes: 3 additions & 1 deletion src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,10 +1417,12 @@ bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * )
if( critter == nullptr ) {
return false;
}
critter->add_msg_player_or_npc( m_bad, _( "You trigger a %s!" ), _( "<npcname> triggers a %s!" ),
g->m.tr_at( p ).name() );
const spell trap_spell = g->m.tr_at( p ).spell_data.get_spell( 0 );
npc dummy;
trap_spell.cast_all_effects( dummy, critter->pos() );
trap_spell.make_sound( p, 20 );
trap_spell.make_sound( p );
g->m.remove_trap( p );
return true;
}
Expand Down

0 comments on commit 7d54e3e

Please sign in to comment.