diff --git a/data/json/bionics.json b/data/json/bionics.json index 79036d68082c..a5e52089fcdb 100644 --- a/data/json/bionics.json +++ b/data/json/bionics.json @@ -1301,6 +1301,7 @@ "name": { "str": "Electrosense Voltmeter" }, "description": "Using this bionic allows you to check the status of any local grid connections or battery charge in your surroundings, as well as make modifications to grid connections.", "act_cost": "10 J", + "fake_item": "voltmeter_bionic", "included": true }, { diff --git a/data/json/items/fake.json b/data/json/items/fake.json index fb62ec6c159c..42d2a08d7c50 100644 --- a/data/json/items/fake.json +++ b/data/json/items/fake.json @@ -47,6 +47,16 @@ [ "BUTCHER", -38 ] ] }, + { + "id": "voltmeter_bionic", + "sub": "voltmeter", + "copy-from": "fake_item", + "type": "TOOL", + "name": { "str": "integrated voltmeter" }, + "flags": [ "TRADER_AVOID", "USES_BIONIC_POWER" ], + "max_charges": 10000, + "use_action": [ "REPORT_GRID_CHARGE", "REPORT_GRID_CONNECTIONS", "MODIFY_GRID_CONNECTIONS" ] + }, { "id": "fake_goggles", "copy-from": "fake_item", diff --git a/src/bionics.cpp b/src/bionics.cpp index 4feb55319fe8..e03a3763b7a7 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -1096,7 +1096,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics } else if( bio.id == bio_electrosense_voltmeter ) { add_msg_activate(); item *vtm; - vtm = item::spawn_temporary( "voltmeter", calendar::start_of_cataclysm ); + vtm = item::spawn_temporary( "voltmeter_bionic", calendar::start_of_cataclysm ); invoke_item( vtm ); } else { add_msg_activate(); diff --git a/src/character.cpp b/src/character.cpp index 2f7418fef50e..342e7965ed17 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -203,6 +203,7 @@ static const itype_id itype_rope_6( "rope_6" ); static const itype_id itype_snare_trigger( "snare_trigger" ); static const itype_id itype_string_36( "string_36" ); static const itype_id itype_toolset( "toolset" ); +static const itype_id itype_voltmeter_bionic( "voltmeter_bionic" ); static const itype_id itype_UPS( "UPS" ); static const itype_id itype_UPS_off( "UPS_off" ); static const itype_id itype_power_storage( "bio_power_storage" ); @@ -10046,6 +10047,10 @@ std::vector> Character::use_charges( const itype_id &what, in if( qty <= 0 ) { return res; + } else if( what == itype_voltmeter_bionic ) { + mod_power_level( units::from_kilojoule( -qty ) ); + return res; + } else if( what == itype_toolset ) { mod_power_level( units::from_kilojoule( -qty ) ); return res; diff --git a/src/crafting.cpp b/src/crafting.cpp index 46f9f82cc606..9b0130df93f5 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -89,6 +89,7 @@ static const trait_id trait_BURROW( "BURROW" ); static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); static const trait_id trait_HYPEROPIC( "HYPEROPIC" ); +static const flag_id flag_BIONIC_TOGGLED( "BIONIC_TOGGLED" ); static const std::string flag_BLIND_EASY( "BLIND_EASY" ); static const std::string flag_BLIND_HARD( "BLIND_HARD" ); static const std::string flag_FULL_MAGAZINE( "FULL_MAGAZINE" ); @@ -562,7 +563,7 @@ const inventory &Character::crafting_inventory( const tripoint &src_pos, int rad cached_crafting_inventory += worn; for( const bionic &bio : *my_bionics ) { const bionic_data &bio_data = bio.info(); - if( ( !bio_data.activated || bio.powered ) && + if( ( !bio_data.has_flag( flag_BIONIC_TOGGLED ) || bio.powered ) && !bio_data.fake_item.is_empty() ) { cached_crafting_inventory += *item::spawn_temporary( bio.info().fake_item, calendar::turn, units::to_kilojoule( get_power_level() ) ); diff --git a/src/visitable.cpp b/src/visitable.cpp index 44a9ef6460f0..902739784d59 100644 --- a/src/visitable.cpp +++ b/src/visitable.cpp @@ -35,6 +35,7 @@ static const itype_id itype_apparatus( "apparatus" ); static const itype_id itype_adv_UPS_off( "adv_UPS_off" ); static const itype_id itype_toolset( "toolset" ); +static const itype_id itype_voltmeter_bionic( "voltmeter_bionic" ); static const itype_id itype_UPS( "UPS" ); static const itype_id itype_UPS_off( "UPS_off" ); static const itype_id itype_bio_armor( "bio_armor" ); @@ -42,6 +43,7 @@ static const itype_id itype_bio_armor( "bio_armor" ); static const quality_id qual_BUTCHER( "BUTCHER" ); static const bionic_id bio_tools( "bio_tools" ); +static const bionic_id bio_electrosense_voltmeter( "bio_electrosense_voltmeter" ); static const bionic_id bio_ups( "bio_ups" ); static const flag_id flag_BIONIC_ARMOR_INTERFACE( "BIONIC_ARMOR_INTERFACE" ); @@ -1054,6 +1056,14 @@ int visitable::charges_of( const itype_id &what, int limit, } } + if( what == itype_voltmeter_bionic ) { + if( p && p->has_bionic( bio_electrosense_voltmeter ) ) { + return std::min( units::to_kilojoule( p->get_power_level() ), limit ); + } else { + return 0; + } + } + if( what == itype_bio_armor ) { float efficiency = 1; int power_charges = 0; @@ -1167,6 +1177,10 @@ int visitable::amount_of( const itype_id &what, bool pseudo, int limi return 1; } + if( what == itype_voltmeter_bionic && pseudo && self->has_bionic( bio_electrosense_voltmeter ) ) { + return 1; + } + if( what == itype_apparatus && pseudo ) { int qty = 0; visit_items( [&qty, &limit, &filter]( const item * e ) {