Skip to content

Commit

Permalink
get_armor_bash_base
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Apr 27, 2020
1 parent cfd2efc commit 79d26c1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
30 changes: 15 additions & 15 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"name": { "str": "Alloy Plating - Arms" },
"description": "The flesh on your arms has been surgically replaced by alloy plating. Provides passive protection and can be used in conjunction with bionic martial arts.",
"occupied_bodyparts": [ [ "ARM_L", 4 ], [ "ARM_R", 4 ] ],
"bash_protec": [ [ "ARM_L", 3 ], [ "ARM_R", 3 ] ],
"bash_protec": [ [ "arm_l", 3 ], [ "arm_r", 3 ] ],
"cut_protec": [ [ "ARM_L", 3 ], [ "ARM_R", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand All @@ -54,7 +54,7 @@
"description": "Your eye sockets have been surgically sealed with highly protective mirrored lenses and your tear ducts have been re-routed to your mouth. When you cry, you must spit out or swallow your tears.",
"occupied_bodyparts": [ [ "EYES", 1 ] ],
"env_protec": [ [ "eyes", 7 ] ],
"bash_protec": [ [ "EYES", 3 ] ],
"bash_protec": [ [ "eyes", 3 ] ],
"cut_protec": [ [ "EYES", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand All @@ -64,7 +64,7 @@
"name": { "str": "Alloy Plating - Head" },
"description": "The flesh on your head has been surgically replaced by alloy plating, protecting both your head and jaw regions.",
"occupied_bodyparts": [ [ "HEAD", 5 ], [ "MOUTH", 1 ] ],
"bash_protec": [ [ "HEAD", 3 ] ],
"bash_protec": [ [ "head", 3 ] ],
"cut_protec": [ [ "HEAD", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand All @@ -74,7 +74,7 @@
"name": { "str": "Alloy Plating - Legs" },
"description": "The flesh on your legs has been surgically replaced by alloy plating. Provides passive protection and can be used in conjunction with bionic martial arts.",
"occupied_bodyparts": [ [ "LEG_L", 6 ], [ "LEG_R", 6 ] ],
"bash_protec": [ [ "LEG_L", 3 ], [ "LEG_R", 3 ] ],
"bash_protec": [ [ "leg_l", 3 ], [ "leg_r", 3 ] ],
"cut_protec": [ [ "LEG_L", 3 ], [ "LEG_R", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand All @@ -84,7 +84,7 @@
"name": { "str": "Alloy Plating - Torso" },
"description": "The flesh on your torso has been surgically replaced by alloy plating, protecting it from physical trauma.",
"occupied_bodyparts": [ [ "TORSO", 10 ] ],
"bash_protec": [ [ "TORSO", 3 ] ],
"bash_protec": [ [ "torso", 3 ] ],
"cut_protec": [ [ "TORSO", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand Down Expand Up @@ -174,16 +174,16 @@
[ "FOOT_R", 1 ]
],
"bash_protec": [
[ "TORSO", 2 ],
[ "HEAD", 2 ],
[ "ARM_L", 2 ],
[ "ARM_R", 2 ],
[ "HAND_L", 2 ],
[ "HAND_R", 2 ],
[ "LEG_L", 2 ],
[ "LEG_R", 2 ],
[ "FOOT_L", 2 ],
[ "FOOT_R", 2 ]
[ "torso", 2 ],
[ "head", 2 ],
[ "arm_l", 2 ],
[ "arm_r", 2 ],
[ "hand_l", 2 ],
[ "hand_r", 2 ],
[ "leg_l", 2 ],
[ "leg_r", 2 ],
[ "foot_l", 2 ],
[ "foot_r", 2 ]
],
"cut_protec": [
[ "TORSO", 4 ],
Expand Down
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,7 @@ void load_bionic( const JsonObject &jsobj )
}

for( JsonArray ja : jsobj.get_array( "bash_protec" ) ) {
new_bionic.bash_protec.emplace( get_body_part_token( ja.get_string( 0 ) ),
new_bionic.bash_protec.emplace( bodypart_str_id( ja.get_string( 0 ) ),
ja.get_int( 1 ) );
}
for( JsonArray ja : jsobj.get_array( "cut_protec" ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct bionic_data {
std::map<bodypart_str_id, size_t> env_protec;

/**Amount of bash protection offered by this bionic*/
std::map<body_part, size_t> bash_protec;
std::map<bodypart_str_id, size_t> bash_protec;
/**Amount of cut protection offered by this bionic*/
std::map<body_part, size_t> cut_protec;

Expand Down
12 changes: 6 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7082,7 +7082,7 @@ std::string Character::activity_level_str() const

int Character::get_armor_bash( bodypart_id bp ) const
{
return get_armor_bash_base( bp->token ) + armor_bash_bonus;
return get_armor_bash_base( bp ) + armor_bash_bonus;
}

int Character::get_armor_cut( bodypart_id bp ) const
Expand Down Expand Up @@ -7126,22 +7126,22 @@ int Character::get_armor_type( damage_type dt, body_part bp ) const
return 0;
}

int Character::get_armor_bash_base( body_part bp ) const
int Character::get_armor_bash_base( bodypart_id bp ) const
{
int ret = 0;
for( auto &i : worn ) {
if( i.covers( bp ) ) {
if( i.covers( bp->token ) ) {
ret += i.bash_resist();
}
}
for( const bionic_id &bid : get_bionics() ) {
const auto bash_prot = bid->bash_protec.find( bp );
const auto bash_prot = bid->bash_protec.find( bp.id() );
if( bash_prot != bid->bash_protec.end() ) {
ret += bash_prot->second;
}
}

ret += mutation_armor( bp, DT_BASH );
ret += mutation_armor( bp->token, DT_BASH );
return ret;
}

Expand Down Expand Up @@ -8317,7 +8317,7 @@ float Character::bionic_armor_bonus( body_part bp, damage_type dt ) const
}
} else if( dt == DT_BASH ) {
for( const bionic_id &bid : get_bionics() ) {
const auto bash_prot = bid->bash_protec.find( bp );
const auto bash_prot = bid->bash_protec.find( convert_bp( bp ) );
if( bash_prot != bid->bash_protec.end() ) {
result += bash_prot->second;
}
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ class Character : public Creature, public visitable<Character>
/** Returns overall cutting resistance for the body_part */
int get_armor_cut( bodypart_id bp ) const override;
/** Returns bashing resistance from the creature and armor only */
int get_armor_bash_base( body_part bp ) const override;
int get_armor_bash_base( bodypart_id bp ) const override;
/** Returns cutting resistance from the creature and armor only */
int get_armor_cut_base( body_part bp ) const override;
/** Returns overall env_resist on a body_part */
Expand Down
2 changes: 1 addition & 1 deletion src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ int Creature::get_armor_cut( bodypart_id ) const
{
return armor_cut_bonus;
}
int Creature::get_armor_bash_base( body_part ) const
int Creature::get_armor_bash_base( bodypart_id ) const
{
return armor_bash_bonus;
}
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class Creature

virtual int get_armor_bash( bodypart_id bp ) const;
virtual int get_armor_cut( bodypart_id bp ) const;
virtual int get_armor_bash_base( body_part bp ) const;
virtual int get_armor_bash_base( bodypart_id bp ) const;
virtual int get_armor_cut_base( body_part bp ) const;
virtual int get_armor_bash_bonus() const;
virtual int get_armor_cut_bonus() const;
Expand Down
4 changes: 2 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3118,8 +3118,8 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts
info.push_back( iteminfo( "DESCRIPTION",
_( "<bold>Bash Protection</bold>: " ),
iteminfo::no_newline ) );
for( const std::pair< const body_part, size_t > &element : bid->bash_protec ) {
info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first, 1 ),
for( const std::pair< const bodypart_str_id, size_t > &element : bid->bash_protec ) {
info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ),
" <num> ", iteminfo::no_newline, element.second ) );
}
}
Expand Down

0 comments on commit 79d26c1

Please sign in to comment.