From e650787d1af7e3d2d9de28022b3592bbcc326bad Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 26 Apr 2020 17:43:48 +0200 Subject: [PATCH] get_armor_cut_base --- data/json/bionics.json | 30 +++++++++++++++--------------- doc/JSON_INFO.md | 4 ++-- src/bionics.cpp | 2 +- src/bionics.h | 2 +- src/character.cpp | 12 ++++++------ src/character.h | 2 +- src/creature.cpp | 2 +- src/creature.h | 2 +- src/item.cpp | 4 ++-- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/data/json/bionics.json b/data/json/bionics.json index 9eab9d7aa4092..b14137c6b27e5 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] }, diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index ab9f6504f320d..bb5c9a7e53b0e 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -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" ] } ``` diff --git a/src/bionics.cpp b/src/bionics.cpp index dd1573fd2d0bc..fdfff6f6956cc 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -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 ) ); } diff --git a/src/bionics.h b/src/bionics.h index 62a7414bba7e2..6d2d5a1d8918f 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -107,7 +107,7 @@ struct bionic_data { /**Amount of bash protection offered by this bionic*/ std::map bash_protec; /**Amount of cut protection offered by this bionic*/ - std::map cut_protec; + std::map cut_protec; /** bionic enchantments */ std::vector enchantments; diff --git a/src/character.cpp b/src/character.cpp index c11104bca4cc4..4342c865112e8 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -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 @@ -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; } @@ -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; } diff --git a/src/character.h b/src/character.h index 5150c8beea12c..cc7b74a937759 100644 --- a/src/character.h +++ b/src/character.h @@ -1729,7 +1729,7 @@ class Character : public Creature, public visitable /** 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 */ diff --git a/src/creature.cpp b/src/creature.cpp index f1525a398ca8c..4e1ae88311d5f 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -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; } diff --git a/src/creature.h b/src/creature.h index 27a45919b5897..ad5c01fbbea65 100644 --- a/src/creature.h +++ b/src/creature.h @@ -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; diff --git a/src/item.cpp b/src/item.cpp index a24aa11b21a5c..aa27cb2d41914 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3128,8 +3128,8 @@ void item::bionic_info( std::vector &info, const iteminfo_query *parts info.push_back( iteminfo( "DESCRIPTION", _( "Cut Protection: " ), 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 ), " ", iteminfo::no_newline, element.second ) ); } }