Skip to content

Commit

Permalink
get_armor_cut_base
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Apr 27, 2020
1 parent 79d26c1 commit e650787
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
30 changes: 15 additions & 15 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"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 ] ],
"cut_protec": [ [ "ARM_L", 3 ], [ "ARM_R", 3 ] ],
"cut_protec": [ [ "arm_l", 3 ], [ "arm_r", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
Expand All @@ -55,7 +55,7 @@
"occupied_bodyparts": [ [ "EYES", 1 ] ],
"env_protec": [ [ "eyes", 7 ] ],
"bash_protec": [ [ "eyes", 3 ] ],
"cut_protec": [ [ "EYES", 3 ] ],
"cut_protec": [ [ "eyes", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
Expand All @@ -65,7 +65,7 @@
"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 ] ],
"cut_protec": [ [ "HEAD", 3 ] ],
"cut_protec": [ [ "head", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
Expand All @@ -75,7 +75,7 @@
"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 ] ],
"cut_protec": [ [ "LEG_L", 3 ], [ "LEG_R", 3 ] ],
"cut_protec": [ [ "leg_l", 3 ], [ "leg_r", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
Expand All @@ -85,7 +85,7 @@
"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 ] ],
"cut_protec": [ [ "TORSO", 3 ] ],
"cut_protec": [ [ "torso", 3 ] ],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
{
Expand Down Expand Up @@ -186,16 +186,16 @@
[ "foot_r", 2 ]
],
"cut_protec": [
[ "TORSO", 4 ],
[ "HEAD", 4 ],
[ "ARM_L", 4 ],
[ "ARM_R", 4 ],
[ "HAND_L", 4 ],
[ "HAND_R", 4 ],
[ "LEG_L", 4 ],
[ "LEG_R", 4 ],
[ "FOOT_L", 4 ],
[ "FOOT_R", 4 ]
[ "torso", 4 ],
[ "head", 4 ],
[ "arm_l", 4 ],
[ "arm_r", 4 ],
[ "hand_l", 4 ],
[ "hand_r", 4 ],
[ "leg_l", 4 ],
[ "leg_r", 4 ],
[ "foot_l", 4 ],
[ "foot_r", 4 ]
],
"flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
},
Expand Down
4 changes: 2 additions & 2 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ This section describes each json file and their contents. Each json has their ow
"description": "Surgically implanted in your trachea is an advanced filtration system. If toxins, or airborne diseases find their way into your windpipe, the filter will attempt to remove them.",
"occupied_bodyparts": [ [ "TORSO", 4 ], [ "MOUTH", 2 ] ],
"env_protec": [ [ "mouth", 7 ] ],
"bash_protec": [ [ "LEG_L", 3 ], [ "LEG_R", 3 ] ],
"cut_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" ]
}
```
Expand Down
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ void load_bionic( const JsonObject &jsobj )
ja.get_int( 1 ) );
}
for( JsonArray ja : jsobj.get_array( "cut_protec" ) ) {
new_bionic.cut_protec.emplace( get_body_part_token( ja.get_string( 0 ) ),
new_bionic.cut_protec.emplace( bodypart_str_id( ja.get_string( 0 ) ),
ja.get_int( 1 ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct bionic_data {
/**Amount of bash protection offered by this bionic*/
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;
std::map<bodypart_str_id, size_t> cut_protec;

/** bionic enchantments */
std::vector<enchantment_id> enchantments;
Expand Down
12 changes: 6 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7087,7 +7087,7 @@ int Character::get_armor_bash( bodypart_id bp ) const

int Character::get_armor_cut( bodypart_id bp ) const
{
return get_armor_cut_base( bp->token ) + armor_cut_bonus;
return get_armor_cut_base( bp ) + armor_cut_bonus;
}

int Character::get_armor_type( damage_type dt, body_part bp ) const
Expand Down Expand Up @@ -7145,22 +7145,22 @@ int Character::get_armor_bash_base( bodypart_id bp ) const
return ret;
}

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

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

Expand Down Expand Up @@ -8310,7 +8310,7 @@ float Character::bionic_armor_bonus( body_part bp, damage_type dt ) const
float result = 0.0f;
if( dt == DT_CUT || dt == DT_STAB ) {
for( const bionic_id &bid : get_bionics() ) {
const auto cut_prot = bid->cut_protec.find( bp );
const auto cut_prot = bid->cut_protec.find( convert_bp( bp ) );
if( cut_prot != bid->cut_protec.end() ) {
result += cut_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 @@ -1729,7 +1729,7 @@ class Character : public Creature, public visitable<Character>
/** Returns bashing resistance from the creature and armor only */
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;
int get_armor_cut_base( bodypart_id bp ) const override;
/** Returns overall env_resist on a body_part */
int get_env_resist( bodypart_id bp ) const override;
/** Returns overall acid resistance for the 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 @@ -1369,7 +1369,7 @@ int Creature::get_armor_bash_base( bodypart_id ) const
{
return armor_bash_bonus;
}
int Creature::get_armor_cut_base( body_part ) const
int Creature::get_armor_cut_base( bodypart_id ) const
{
return armor_cut_bonus;
}
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,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( bodypart_id bp ) const;
virtual int get_armor_cut_base( body_part bp ) const;
virtual int get_armor_cut_base( bodypart_id 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 @@ -3128,8 +3128,8 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts
info.push_back( iteminfo( "DESCRIPTION",
_( "<bold>Cut Protection</bold>: " ),
iteminfo::no_newline ) );
for( const std::pair< const body_part, size_t > &element : bid->cut_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->cut_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 e650787

Please sign in to comment.