Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map_bash_info to fields #37865

Merged
merged 39 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d475900
Add map_bash_info to fields
Feb 9, 2020
ae131da
drop_group for fields
Feb 10, 2020
6ce0a11
succes msg and move cost to basing fields
Feb 10, 2020
0a04746
jsonize bashing cobwebs
Feb 10, 2020
ee31ca5
doc for bash in fields
Feb 10, 2020
101d9f9
doc move_cost
Feb 10, 2020
b015958
Merge branch 'master' into json_bash_field
Fris0uman Feb 10, 2020
f8a93f1
Update src/handle_action.cpp
Fris0uman Feb 10, 2020
11f83e4
Apply suggestions from code review
Fris0uman Feb 11, 2020
20825d3
Apply suggestions from code review
Fris0uman Feb 11, 2020
b5c78e7
[Aftershock] Millyficent whately and the migo (#36908)
Maleclypse Mar 6, 2020
b62f1e5
DinoModv3: DinoDNA (#26525)
LyleSY Mar 6, 2020
69527a1
Dark Skies Part 2: Blacklists
ephemeralstoryteller Mar 1, 2020
ce5f6c7
Dark Skies Part 3: Effects and Items
ephemeralstoryteller Mar 1, 2020
8c8984e
Part 3.1
ephemeralstoryteller Mar 1, 2020
08a98dc
Dark Skies Part 4: Overrides (#38526)
ephemeralstoryteller Mar 6, 2020
70708bc
Override scraps
ephemeralstoryteller Mar 4, 2020
f7e0228
adds snippets
ephemeralstoryteller Mar 4, 2020
de1caa4
Adds files related to monsters
ephemeralstoryteller Mar 4, 2020
7c681af
Removes door opening from certain soldiers
ephemeralstoryteller Mar 4, 2020
db65552
Slows down consecrators
ephemeralstoryteller Mar 4, 2020
813090f
Slows down emissaries
ephemeralstoryteller Mar 4, 2020
0b85f94
Lints neworder_loworder
ephemeralstoryteller Mar 4, 2020
1b58c70
[Aftershock] Mutant npcs to aftershock (#37530)
Maleclypse Mar 6, 2020
584bb08
Aftershock Crafting System (#37707)
John-Candlebury Mar 6, 2020
5ba0257
Adds new starting scenario - Crazy party and new starting profession …
CountAlex Mar 6, 2020
1208879
Add subway maps (#37540)
wapcaplet Mar 6, 2020
5af8e88
Add The Satanic Bible (#37806)
karthas077 Mar 6, 2020
3d18006
add shot counter to mods and gun
Feb 4, 2020
2b6e39b
Refluff power armour and adjust stats slightly (#37578)
I-am-Erk Mar 6, 2020
51e0405
Fix line endings
ZhilkinSerg Mar 6, 2020
974886d
Allow professions to start with a nearby vehicle - trucker profession…
Mar 6, 2020
ed6a6d7
Dark Skies 8: Adds strays, lurker, enemies; updates modinfo (#38596)
ephemeralstoryteller Mar 6, 2020
e409ccb
updates for spell fixes (#38643)
ephemeralstoryteller Mar 8, 2020
414f387
[Magiclysm] Add Magiclysm academy (#38511)
curstwist Mar 8, 2020
6e83cb4
Magiclysm: Forest Tomb (#37699)
arijust Mar 8, 2020
5ff4f80
Merge branch 'dev' into json_bash_field
ZhilkinSerg Mar 9, 2020
43d55a3
Update power_armor.json
ZhilkinSerg Mar 10, 2020
c6da2b8
Merge branch 'dev' into json_bash_field
ZhilkinSerg Mar 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/json/field_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@
"priority": 2,
"phase": "solid",
"display_items": false,
"bash": {
"str_min": 1,
"str_max": 3,
"sound_vol": 2,
"sound_fail_vol": 2,
"sound": "hsh!",
"msg_succes": "You brush aside some webs."
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
},
"display_field": true
},
{
Expand Down
9 changes: 9 additions & 0 deletions data/mods/My_Sweet_Cataclysm/sweet_field_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
"priority": 2,
"phase": "solid",
"half_life": "2 h",
"bash": {
"str_min": 1,
"str_max": 3,
"sound_vol": 2,
"sound_fail_vol": 2,
"sound": "shwip",
"sound_fail": "shwomp",
"msg_succes": "You brush the gum web aside."
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
},
"display_items": false,
"display_field": true
},
Expand Down
17 changes: 17 additions & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2971,4 +2971,21 @@ Setting of sprite sheets. Same as `tiles-new` field in `tile_config`. Sprite fil
"type": "field_type", // this is a field type
"id": "fd_gum_web", // id of the field
"immune_mtypes": [ "mon_spider_gum" ], // list of monster immune to this field
"bash": {
"str_min": 1, // lower bracket of bashing damage required to bash
"str_max": 3, // higher bracket
"sound_vol": 2, // noise made when succesfully bashing the field
"sound_fail_vol": 2, // noise made when failing to bash the field
"sound": "shwip", // sound on success
"sound_fail": "shwomp", // sound on failure
"msg_succes": "You brush the gum web aside.", // message on success
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
"move_cost": 120, // how many moves it costs to succesfully bash that field (default: 100)
"items": [ // item dropped upon succesfull bashing
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
{ "item": "2x4", "count": [ 5, 8 ] },
{ "item": "nail", "charges": [ 6, 8 ] },
{ "item": "splinter", "count": [ 3, 6 ] },
{ "item": "rag", "count": [ 40, 55 ] },
{ "item": "scrap", "count": [ 10, 20 ] }
]
}
}
2 changes: 2 additions & 0 deletions src/field_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ void field_type::load( const JsonObject &jo, const std::string & )
optional( jo, was_loaded, "display_items", display_items, true );
optional( jo, was_loaded, "display_field", display_field, false );
optional( jo, was_loaded, "wandering_field", wandering_field_id, "fd_null" );

bash_info.load( jo, "bash", map_bash_info::field );
}

void field_type::finalize()
Expand Down
2 changes: 2 additions & 0 deletions src/field_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "color.h"
#include "effect.h"
#include "enums.h"
#include "mapdata.h"
#include "type_id.h"
#include "string_id.h"
#include "translations.h"
Expand Down Expand Up @@ -143,6 +144,7 @@ struct field_type {
bool has_elec = false;
bool has_fume = false;
description_affix desc_affix;
map_bash_info bash_info;

// chance, issue, duration, speech
std::tuple<int, std::string, time_duration, std::string> npc_complain_data;
Expand Down
28 changes: 22 additions & 6 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,28 @@ static void smash()
crit->use_mech_power( -3 );
}
}
if( m.get_field( smashp, fd_web ) != nullptr ) {
m.remove_field( smashp, fd_web );
sounds::sound( smashp, 2, sounds::sound_t::combat, _( "hsh!" ), true, "smash", "web" );
add_msg( m_info, _( "You brush aside some webs." ) );
u.moves -= 100;
return;
for( std::pair<const field_type_id, field_entry> &fd_to_smsh : m.field_at( smashp ) ) {
const map_bash_info &bash_info = fd_to_smsh.first->bash_info;
if( bash_info.str_min == -1 ) {
continue;
}
if( smashskill < bash_info.str_min && one_in( 10 ) ) {
add_msg( m_neutral, _( "You don't seem to be damaging the %s." ), fd_to_smsh.first->get_name() );
return;
} else if( smashskill >= rng( bash_info.str_min, bash_info.str_max ) ) {
sounds::sound( smashp, bash_info.sound_vol, sounds::sound_t::combat, bash_info.sound, true, "smash",
"field" );
m.remove_field( smashp, fd_to_smsh.first );
g->m.spawn_items( smashp, item_group::items_from( bash_info.drop_group, calendar::turn ) );
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
u.mod_moves( - bash_info.fd_bash_move_cost );
add_msg( m_info, _( bash_info.field_bash_msg_succes ) );
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
return;
} else {
sounds::sound( smashp, bash_info.sound_fail_vol, sounds::sound_t::combat, bash_info.sound_fail,
true, "smash",
"field" );
return;
}
}

for( const auto &maybe_corpse : m.i_at( smashp ) ) {
Expand Down
27 changes: 17 additions & 10 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ map_bash_info::map_bash_info() : str_min( -1 ), str_max( -1 ),
drop_group( "EMPTY_GROUP" ),
ter_set( ter_str_id::NULL_ID() ), furn_set( furn_str_id::NULL_ID() ) {}

bool map_bash_info::load( const JsonObject &jsobj, const std::string &member, bool is_furniture )
bool map_bash_info::load( const JsonObject &jsobj, const std::string &member,
map_object_type obj_type )
{
if( !jsobj.has_object( member ) ) {
return false;
Expand Down Expand Up @@ -230,13 +231,19 @@ bool map_bash_info::load( const JsonObject &jsobj, const std::string &member, bo
j.read( "sound", sound );
j.read( "sound_fail", sound_fail );

if( is_furniture ) {
furn_set = furn_str_id( j.get_string( "furn_set", "f_null" ) );
} else {
const std::string ter_set_string = j.get_string( "ter_set" );
ter_set = ter_str_id( ter_set_string );
ter_set_bashed_from_above = ter_str_id( j.get_string( "ter_set_bashed_from_above",
ter_set_string ) );
switch( obj_type ) {
case map_bash_info::furniture:
furn_set = furn_str_id( j.get_string( "furn_set", "f_null" ) );
break;
case map_bash_info::terrain:
ter_set = ter_str_id( j.get_string( "ter_set" ) );
ter_set_bashed_from_above = ter_str_id( j.get_string( "ter_set_bashed_from_above",
ter_set.c_str() ) );
break;
case map_bash_info::field:
assign( j, "move_cost", fd_bash_move_cost, 100 );
j.read( "msg_succes", field_bash_msg_succes );
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
break;
}

if( j.has_member( "items" ) ) {
Expand Down Expand Up @@ -1166,7 +1173,7 @@ void ter_t::load( const JsonObject &jo, const std::string &src )
optional( jo, was_loaded, "transforms_into", transforms_into, ter_str_id::NULL_ID() );
optional( jo, was_loaded, "roof", roof, ter_str_id::NULL_ID() );

bash.load( jo, "bash", false );
bash.load( jo, "bash", map_bash_info::terrain );
deconstruct.load( jo, "deconstruct", false );
}

Expand Down Expand Up @@ -1269,7 +1276,7 @@ void furn_t::load( const JsonObject &jo, const std::string &src )
optional( jo, was_loaded, "open", open, string_id_reader<furn_t> {}, furn_str_id::NULL_ID() );
optional( jo, was_loaded, "close", close, string_id_reader<furn_t> {}, furn_str_id::NULL_ID() );

bash.load( jo, "bash", true );
bash.load( jo, "bash", map_bash_info::furniture );
deconstruct.load( jo, "deconstruct", true );

if( jo.has_object( "workbench" ) ) {
Expand Down
9 changes: 8 additions & 1 deletion src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,25 @@ struct map_bash_info {
int sound_vol; // sound volume of breaking terrain/furniture
int sound_fail_vol; // sound volume on fail
int collapse_radius; // Radius of the tent supported by this tile
int fd_bash_move_cost = 100; // cost to bash a field
bool destroy_only; // Only used for destroying, not normally bashable
bool bash_below; // This terrain is the roof of the tile below it, try to destroy that too
std::string drop_group; // item group of items that are dropped when the object is bashed
translation sound; // sound made on success ('You hear a "smash!"')
translation sound_fail; // sound made on fail
std::string field_bash_msg_succes; // message upon successfully bashing a field
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
ter_str_id ter_set; // terrain to set (REQUIRED for terrain))
ter_str_id ter_set_bashed_from_above; // terrain to set if bashed from above (defaults to ter_set)
furn_str_id furn_set; // furniture to set (only used by furniture, not terrain)
// ids used for the special handling of tents
std::vector<furn_str_id> tent_centers;
map_bash_info();
bool load( const JsonObject &jsobj, const std::string &member, bool is_furniture );
enum map_object_type {
furniture = 0,
terrain,
field
};
bool load( const JsonObject &jsobj, const std::string &member, map_object_type obj_type );
};
struct map_deconstruct_info {
// Only if true, the terrain/furniture can be deconstructed
Expand Down