Skip to content

Commit

Permalink
feat(content): new voltmeter/bionic scanner CBM (#4107)
Browse files Browse the repository at this point in the history
* feat(content): new voltmeter/bionic scanner CBM

* Lil fix

* Update iuse.cpp

* screm
  • Loading branch information
chaosvolt authored Jan 20, 2024
1 parent cb159d8 commit 38c6f90
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 24 deletions.
20 changes: 20 additions & 0 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,26 @@
"fake_item": "bio_blaster_gun",
"flags": [ "BIONIC_GUN", "BIONIC_NPC_USABLE" ]
},
{
"id": "bio_electrosense",
"type": "bionic",
"name": { "str": "Electrosense Scanner" },
"description": "Activating this bionic will allow you to see robots and other electric creatures through walls, and automatically scan nearby corpses for bionics that could be harvested, at the cost of steadily draining power.",
"occupied_bodyparts": [ [ "head", 1 ] ],
"flags": [ "BIONIC_TOGGLED" ],
"act_cost": "20 J",
"react_cost": "20 J",
"time": 1,
"included_bionics": [ "bio_electrosense_voltmeter" ]
},
{
"id": "bio_electrosense_voltmeter",
"type": "bionic",
"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",
"included": true
},
{
"id": "bio_perpetual_test",
"type": "bionic",
Expand Down
18 changes: 12 additions & 6 deletions data/json/itemgroups/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
[ "afs_bio_linguistic_coprocessor", 10 ],
[ "afs_bio_dopamine_stimulators", 10 ],
[ "bio_blaster", 5 ],
[ "bio_reactor", 10 ]
[ "bio_reactor", 10 ],
[ "bio_electrosense", 10 ]
]
},
{
Expand Down Expand Up @@ -211,7 +212,8 @@
[ "bio_jointservo", 10 ],
[ "bio_shotgun", 10 ],
[ "bio_blaster", 5 ],
[ "afs_bio_dopamine_stimulators", 10 ]
[ "afs_bio_dopamine_stimulators", 10 ],
[ "bio_electrosense", 10 ]
]
},
{
Expand Down Expand Up @@ -302,7 +304,8 @@
[ "bio_shotgun", 10 ],
[ "bn_bio_solar", 15 ],
[ "afs_bio_missiles", 10 ],
[ "afs_bio_dopamine_stimulators", 10 ]
[ "afs_bio_dopamine_stimulators", 10 ],
[ "bio_electrosense", 10 ]
]
},
{
Expand Down Expand Up @@ -366,7 +369,8 @@
[ "bio_night_vision", 10 ],
[ "bio_speed", 10 ],
[ "bio_ups", 10 ],
[ "bio_weight", 10 ]
[ "bio_weight", 10 ],
[ "bio_electrosense", 10 ]
]
},
{
Expand All @@ -384,7 +388,8 @@
[ "bio_faraday", 20 ],
[ "bio_weight", 20 ],
[ "bio_shock_absorber", 20 ],
[ "bio_soporific", 20 ]
[ "bio_soporific", 20 ],
[ "bio_electrosense", 5 ]
]
},
{
Expand Down Expand Up @@ -427,7 +432,8 @@
[ "bio_leukocyte", 15 ],
[ "bio_syringe", 2 ],
[ "bio_jointservo", 10 ],
[ "bio_soporific", 2 ]
[ "bio_soporific", 2 ],
[ "bio_electrosense", 8 ]
]
},
{
Expand Down
1 change: 1 addition & 0 deletions data/json/itemgroups/science_and_tech.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
[ "bio_soporific", 5 ],
[ "bio_surgical_razor", 5 ],
[ "bio_syringe", 8 ],
[ "bio_electrosense", 2 ],
[ "software_electronics_reference", 10 ],
[ "software_useless", 10 ],
[ "canteen", 15 ],
Expand Down
11 changes: 11 additions & 0 deletions data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,17 @@
"price": "2200 USD",
"difficulty": 3
},
{
"id": "bio_electrosense",
"copy-from": "bionic_general",
"type": "BIONIC_ITEM",
"name": { "str": "Electrosense CBM" },
"looks_like": "bio_int_enhancer",
"description": "An advanced set of digital scanning equipment for reading electrical signals. When installed it can be activated to scan nearby corpses for bionics, with the added bonus of detecting robots and creatures charged with electricity through walls. A secondary mode allows it to assist with electrical work like a voltmeter, for checking and modifying grid connections.",
"price": "4500 USD",
"weight": "500 g",
"difficulty": 6
},
{
"id": "bio_perpetual_test",
"copy-from": "bionic_general",
Expand Down
3 changes: 2 additions & 1 deletion data/json/items/tool/electronics.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
"type": "TOOL",
"category": "tools",
"name": { "str": "bionic scanner (on)" },
"description": "A small metal scanner specialized in detecting bionic hardware. Used automatically whenever you look at corpses that might contain bionics. Consumes power proportional to number of bionics identified this way.",
"description": "A small metal scanner specialized in detecting bionic hardware. While in use it will steadily drain power, automatically scanning corpses near you for bionics.",
"weight": "141 g",
"volume": "250 ml",
"price": "100 USD",
Expand All @@ -605,6 +605,7 @@
"color": "magenta",
"use_action": "NOTE_BIONICS",
"revert_to": "bionic_scanner",
"power_draw": 10000,
"revert_msg": "The %s shuts down."
}
]
2 changes: 1 addition & 1 deletion data/json/items/tool/science.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
"type": "TOOL",
"category": "tools",
"name": { "str": "voltmeter" },
"description": "This device has two probes that let you measure the electrical potential between two points.",
"description": "This device has two probes that let you measure the electrical potential between two points. Activate to check the status of any local grid connections or battery charge in your surroundings, as well as make modifications to grid connections",
"weight": "500 g",
"volume": "750 ml",
"price": 6000,
Expand Down
1 change: 1 addition & 0 deletions data/mods/Aftershock/player/professions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"bio_power_storage_mkII",
"bio_flashlight",
"bio_tools",
"bio_electrosense",
"bio_sunglasses"
],
"skills": [ { "level": 4, "name": "electronics" }, { "level": 2, "name": "launcher" } ],
Expand Down
44 changes: 44 additions & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ static const bionic_id bio_blood_filter( "bio_blood_filter" );
static const bionic_id bio_cqb( "bio_cqb" );
static const bionic_id bio_earplugs( "bio_earplugs" );
static const bionic_id bio_ears( "bio_ears" );
static const bionic_id bio_electrosense( "bio_electrosense" );
static const bionic_id bio_electrosense_voltmeter( "bio_electrosense_voltmeter" );
static const bionic_id bio_emp( "bio_emp" );
static const bionic_id bio_evap( "bio_evap" );
static const bionic_id bio_eye_optic( "bio_eye_optic" );
Expand Down Expand Up @@ -1080,6 +1082,11 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics
refund_power();
return false;
}
} else if( bio.id == bio_electrosense_voltmeter ) {
add_msg_activate();
item *vtm;
vtm = item::spawn_temporary( "voltmeter", calendar::start_of_cataclysm );
invoke_item( vtm );
} else {
add_msg_activate();
}
Expand Down Expand Up @@ -1773,6 +1780,43 @@ void Character::process_bionic( bionic &bio )
}
} else if( bio.id == afs_bio_dopamine_stimulators ) {
add_morale( MORALE_FEELING_GOOD, 20, 20, 30_minutes, 20_minutes, true );
} else if( bio.id == bio_electrosense ) {
// This is a horrible mess but can't use the active iuse behavior directly
map &here = get_map();
for( const tripoint &pt : here.points_in_radius( pos(), PICKUP_RANGE ) ) {
if( !here.has_items( pt ) || !sees( pt ) ) {
continue;
}
for( item * const &corpse : here.i_at( pt ) ) {
if( !corpse->is_corpse() ||
corpse->get_var( "bionics_scanned_by", -1 ) == getID().get_value() ) {
continue;
}

std::vector<const item *> cbms;
for( const item * const &maybe_cbm : corpse->get_components() ) {
if( maybe_cbm->is_bionic() ) {
cbms.push_back( maybe_cbm );
}
}

corpse->set_var( "bionics_scanned_by", getID().get_value() );
if( !cbms.empty() ) {
corpse->set_flag( flag_CBM_SCANNED );
std::string bionics_string =
enumerate_as_string( cbms.begin(), cbms.end(),
[]( const item * entry ) -> std::string {
return entry->display_name();
}, enumeration_conjunction::none );
//~ %1 is corpse name, %2 is direction, %3 is bionic name
add_msg_if_player( m_good, _( "A %1$s located %2$s contains %3$s." ),
corpse->display_name().c_str(),
direction_name( direction_from( pos(), pt ) ).c_str(),
bionics_string.c_str()
);
}
}
}
} else if( bio.id == bio_radscrubber ) {
if( calendar::once_every( 10_minutes ) ) {
const units::energy trigger_cost = bio.info().power_trigger;
Expand Down
3 changes: 2 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ static const bionic_id bio_climate( "bio_climate" );
static const bionic_id bio_cloak( "bio_cloak" );
static const bionic_id bio_earplugs( "bio_earplugs" );
static const bionic_id bio_ears( "bio_ears" );
static const bionic_id bio_electrosense( "bio_electrosense" );
static const bionic_id bio_faraday( "bio_faraday" );
static const bionic_id bio_flashlight( "bio_flashlight" );
static const bionic_id bio_gills( "bio_gills" );
Expand Down Expand Up @@ -6855,7 +6856,7 @@ float Character::active_light() const
bool Character::sees_with_specials( const Creature &critter ) const
{
// electroreceptors grants vision of robots and electric monsters through walls
if( has_trait( trait_ELECTRORECEPTORS ) &&
if( ( has_trait( trait_ELECTRORECEPTORS ) || has_active_bionic( bio_electrosense ) ) &&
( critter.in_species( ROBOT ) || critter.has_flag( MF_ELECTRIC ) ) ) {
return true;
}
Expand Down
15 changes: 0 additions & 15 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ static const itype_id itype_thermometer( "thermometer" );
static const itype_id itype_towel( "towel" );
static const itype_id itype_towel_soiled( "towel_soiled" );
static const itype_id itype_towel_wet( "towel_wet" );
static const itype_id itype_UPS( "UPS" );
static const itype_id itype_UPS_off( "UPS_off" );
static const itype_id itype_water( "water" );
static const itype_id itype_water_clean( "water_clean" );
Expand Down Expand Up @@ -2302,8 +2301,6 @@ int iuse::noise_emitter_on( player *p, item *it, bool t, const tripoint &pos )
// Ugly and uses variables that shouldn't be public
int iuse::note_bionics( player *p, item *it, bool t, const tripoint &pos )
{
const bool possess = p->has_item( *it );

if( !t ) {
it->deactivate( p, true );
return 0;
Expand Down Expand Up @@ -2335,18 +2332,6 @@ int iuse::note_bionics( player *p, item *it, bool t, const tripoint &pos )
}
}

int charges = static_cast<int>( cbms.size() );
charges -= it->ammo_consume( charges, pos );
if( possess && it->has_flag( flag_USE_UPS ) ) {
if( p->use_charges_if_avail( itype_UPS, charges ) ) {
charges = 0;
}
}
if( charges > 0 ) {
it->deactivate( p, true );
return 0;
}

corpse->set_var( "bionics_scanned_by", p->getID().get_value() );
if( !cbms.empty() ) {
corpse->set_flag( flag_CBM_SCANNED );
Expand Down

0 comments on commit 38c6f90

Please sign in to comment.