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 bullet damage type #38912

Merged
merged 11 commits into from
May 3, 2020
Prev Previous commit
Next Next commit
Bullet damage UI bits
  • Loading branch information
anothersimulacrum committed Apr 28, 2020
commit 5b62cfeaa5c1f13ad04e38cf4c9358e857ea7df0
2 changes: 2 additions & 0 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ std::vector<std::string> clothing_protection( const item &worn_item, const int w
string_format( "%3d", static_cast<int>( worn_item.bash_resist() ) ), width ) );
prot.push_back( name_and_value( space + _( "Cut:" ),
string_format( "%3d", static_cast<int>( worn_item.cut_resist() ) ), width ) );
prot.push_back( name_and_value( space + _( "Ballistic:" ),
string_format( "%3d", static_cast<int>( worn_item.bullet_resist() ) ), width ) );
prot.push_back( name_and_value( space + _( "Acid:" ),
string_format( "%3d", static_cast<int>( worn_item.acid_resist() ) ), width ) );
prot.push_back( name_and_value( space + _( "Fire:" ),
Expand Down
3 changes: 2 additions & 1 deletion src/dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode,

} else if( what == "ARMOR" ) {
header = {
"Name", "Encumber (fit)", "Warmth", "Weight", "Storage", "Coverage", "Bash", "Cut", "Acid", "Fire"
"Name", "Encumber (fit)", "Warmth", "Weight", "Storage", "Coverage", "Bash", "Cut", "Bullet", "Acid", "Fire"
};
auto dump = [&rows]( const item & obj ) {
std::vector<std::string> r;
Expand All @@ -112,6 +112,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode,
r.push_back( to_string( obj.get_coverage() ) );
r.push_back( to_string( obj.bash_resist() ) );
r.push_back( to_string( obj.cut_resist() ) );
r.push_back( to_string( obj.bullet_resist() ) );
r.push_back( to_string( obj.acid_resist() ) );
r.push_back( to_string( obj.fire_resist() ) );
rows.push_back( r );
Expand Down
4 changes: 4 additions & 0 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ class armor_inventory_preset: public inventory_selector_preset
return get_number_string( loc->cut_resist() );
}, _( "CUT" ) );

append_cell( [ this ]( const item_location & loc ) {
return get_number_string( loc->bullet_resist() );
}, _( "BULLET" ) );

append_cell( [ this ]( const item_location & loc ) {
return get_number_string( loc->acid_resist() );
}, _( "ACID" ) );
Expand Down
12 changes: 11 additions & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,8 @@ void item::armor_protection_info( std::vector<iteminfo> &info, const iteminfo_qu
if( parts->test( iteminfo_parts::ARMOR_PROTECTION ) ) {
info.push_back( iteminfo( "ARMOR", _( "<bold>Protection</bold>: Bash: " ), "",
iteminfo::no_newline, bash_resist() ) );
info.push_back( iteminfo( "ARMOR", space + _( "Cut: " ), cut_resist() ) );
info.push_back( iteminfo( "ARMOR", space + _( "Cut: " ), "", iteminfo::no_newline, cut_resist() ) );
info.push_back( iteminfo( "ARMOR", space + _( "Ballistic: " ), bullet_resist() ) );
info.push_back( iteminfo( "ARMOR", space + _( "Acid: " ), "",
iteminfo::no_newline, acid_resist() ) );
info.push_back( iteminfo( "ARMOR", space + _( "Fire: " ), "",
Expand Down Expand Up @@ -3135,6 +3136,15 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts
}
}

if( !bid->bullet_protec.empty() ) {
info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Ballistic Protection</bold>: " ),
iteminfo::no_newline ) );
for( const std::pair<const bodypart_str_id, size_t > &element : bid->bullet_protec ) {
info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ),
" <num> ", iteminfo::no_newline, element.second ) );
}
}

if( !bid->stat_bonus.empty() ) {
info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Stat Bonus</bold>: " ),
iteminfo::no_newline ) );
Expand Down
2 changes: 2 additions & 0 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4740,6 +4740,8 @@ int sew_advanced_actor::use( player &p, item &it, bool, const tripoint & ) const
std::string desc;
desc += format_desc_string( _( "Bash" ), mod.bash_resist(), temp_item.bash_resist(), true );
desc += format_desc_string( _( "Cut" ), mod.cut_resist(), temp_item.cut_resist(), true );
desc += format_desc_string( _( "Ballistic" ), mod.bullet_resist(), temp_item.bullet_resist(),
true );
desc += format_desc_string( _( "Acid" ), mod.acid_resist(), temp_item.acid_resist(), true );
desc += format_desc_string( _( "Fire" ), mod.fire_resist(), temp_item.fire_resist(), true );
desc += format_desc_string( _( "Warmth" ), mod.get_warmth(), temp_item.get_warmth(), true );
Expand Down
2 changes: 1 addition & 1 deletion tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TEST_CASE( "armor coverage and protection values", "[item][iteminfo][armor]" )
"Coverage: <color_c_yellow>90</color>% Warmth: <color_c_yellow>5</color>\n"
"--\n"
"<color_c_white>Encumbrance</color>: <color_c_yellow>3</color> <color_c_red>(poor fit)</color>\n"
"<color_c_white>Protection</color>: Bash: <color_c_yellow>1</color> Cut: <color_c_yellow>1</color> Bullet: <color_c_yellow>1</color>\n"
"<color_c_white>Protection</color>: Bash: <color_c_yellow>1</color> Cut: <color_c_yellow>1</color> Ballistic: <color_c_yellow>1</color>\n"
" Acid: <color_c_yellow>0</color> Fire: <color_c_yellow>0</color> Environmental: <color_c_yellow>0</color>\n" );
}

Expand Down