diff --git a/data/json/bionics.json b/data/json/bionics.json index aa4c08298d428..f4953a024a9ff 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -61,6 +61,7 @@ "name": "Protective Lenses", "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 ] ], "flags": [ "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ] }, { @@ -778,6 +779,7 @@ "name": "Air Filtration System", "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 ] ], "flags": [ "BIONIC_NPC_USABLE" ] }, { diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index c58ac6ff45178..f75bcc619ef22 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -174,6 +174,8 @@ Currently, only effect names, item action names, and item category names support | canceled_mutations | (_optional_) A list of mutations/traits that are removed when this bionic is installed (e.g. because it replaces the fault biological part). | included_bionics | (_optional_) Additional bionics that are installed automatically when this bionic is installed. This can be used to install several bionics from one CBM item, which is useful as each of those can be activated independently. | included | (_optional_) Whether this bionic is included with another. If true this bionic does not require a CBM item to be defined. (default: `false`) +| env_protec | (_optional_) How much environmental protection does this bionic provide on the specified body parts. +| occupied_bodyparts | (_optional_) A list of body parts occupied by this bionic, and the number of bionic slots it take on those parts. ```C++ { @@ -187,6 +189,15 @@ Currently, only effect names, item action names, and item category names support "description" : "You have a battery draining attachment, and thus can make use of the energy contained in normal, everyday batteries. Use 'E' to consume batteries.", "canceled_mutations": ["HYPEROPIC"], "included_bionics": ["bio_blindfold"] +}, +{ + "id": "bio_purifier", + "type": "bionic", + "name": "Air Filtration System", + "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 ] ], + "flags": [ "BIONIC_NPC_USABLE" ] } ``` diff --git a/src/bionics.cpp b/src/bionics.cpp index 266d720d2ef26..3f39586d69cb1 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -1994,6 +1994,15 @@ void load_bionic( JsonObject &jsobj ) } } + JsonArray json_arr = jsobj.get_array( "env_protec" ); + if( !json_arr.empty() ) { + while( json_arr.has_more() ) { + JsonArray ja = json_arr.next_array(); + new_bionic.env_protec.emplace( get_body_part_token( ja.get_string( 0 ) ), + ja.get_int( 1 ) ); + } + } + new_bionic.activated = new_bionic.toggled || new_bionic.power_activate > 0 || new_bionic.charge_time > 0; diff --git a/src/bionics.h b/src/bionics.h index 2cb0019f213de..b058f3a0bf640 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -74,6 +74,8 @@ struct bionic_data { * If true, this bionic is included with another. */ bool included = false; + /**Amount of environemental protection offered by this bionic*/ + std::map env_protec; /** * Body part slots used to install this bionic, mapped to the amount of space required. */ diff --git a/src/player.cpp b/src/player.cpp index 82520728208b0..7ed3a89538c3d 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -230,7 +230,6 @@ static const bionic_id bio_metabolics( "bio_metabolics" ); static const bionic_id bio_noise( "bio_noise" ); static const bionic_id bio_plut_filter( "bio_plut_filter" ); static const bionic_id bio_power_weakness( "bio_power_weakness" ); -static const bionic_id bio_purifier( "bio_purifier" ); static const bionic_id bio_reactor( "bio_reactor" ); static const bionic_id bio_recycler( "bio_recycler" ); static const bionic_id bio_shakes( "bio_shakes" ); @@ -10186,19 +10185,14 @@ int player::get_env_resist( body_part bp ) const } } - if( bp == bp_mouth && has_bionic( bio_purifier ) && ret < 5 ) { - ret += 2; - if( ret > 5 ) { - ret = 5; + for( const bionic &bio : *my_bionics ) { + for( const auto &element : bio.info().env_protec ) { + if( element.first == bp || ( bp == bp_eyes && element.first == bp_head ) ) { + ret += element.second; + } } } - if( bp == bp_eyes && has_bionic( bio_armor_eyes ) && ret < 5 ) { - ret += 2; - if( ret > 5 ) { - ret = 5; - } - } if( bp == bp_eyes && has_trait( trait_SEESLEEP ) ) { ret += 8; }