From ab1cda777a1386e0bead834eb22c1bcc7b1809ed Mon Sep 17 00:00:00 2001 From: karxi Date: Thu, 5 Dec 2024 11:16:28 -0500 Subject: [PATCH] feat: Military ID cards can deactivate plutonium generator security for retrieval (#5790) * Allow using a military ID card to disengage a plutonium generator, for retrieval. * Changed description for t_plut_generator to reflect alternative means of retrieval. * Modified 'no keycard' message to be more concise. * style(autofix.ci): automated formatting --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../terrain-manufactured.json | 5 +++-- src/iexamine.cpp | 20 +++++++++++++++++++ src/iexamine.h | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/data/json/furniture_and_terrain/terrain-manufactured.json b/data/json/furniture_and_terrain/terrain-manufactured.json index e7cceab301a4..fd0983e16aa0 100644 --- a/data/json/furniture_and_terrain/terrain-manufactured.json +++ b/data/json/furniture_and_terrain/terrain-manufactured.json @@ -708,7 +708,7 @@ "type": "terrain", "id": "t_plut_generator", "name": "plutonium generator", - "description": "This imposing apparatus harnesses the power of the atom, configured to provide nearly limitless backup power from the nuclear fuel installed in it. It's not doing much good here though. It has a complicated security system that is dangerous and difficult to bypass without the code.", + "description": "This imposing apparatus harnesses the power of the atom, configured to provide nearly limitless backup power from the nuclear fuel installed in it. It's not doing much good here though. It has a complicated security system that is dangerous and difficult to bypass without authorization; a small slot suggests that it can accept some form of ID card.", "symbol": "0", "color": "light_green", "looks_like": "t_machinery_electronic", @@ -729,7 +729,8 @@ ], "//": "Variable reduction, destroy_threshold equal to str_min instead of str_max due to delicate electronics", "ranged": { "reduction": [ 25, 50 ], "destroy_threshold": 50, "block_unaimed_chance": "50%" } - } + }, + "examine_action": "cardreader_plutgen" }, { "type": "terrain", diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 4f298d37674c..8c80253efbc1 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -152,6 +152,7 @@ static const itype_id itype_marloss_seed( "marloss_seed" ); static const itype_id itype_mycus_fruit( "mycus_fruit" ); static const itype_id itype_nail( "nail" ); static const itype_id itype_petrified_eye( "petrified_eye" ); +static const itype_id itype_plut_generator_item( "plut_generator_item" ); static const itype_id itype_sheet( "sheet" ); static const itype_id itype_stick( "stick" ); static const itype_id itype_string_36( "string_36" ); @@ -6319,6 +6320,24 @@ void iexamine::migo_nerve_cluster( player &p, const tripoint &examp ) } } +void iexamine::cardreader_plutgen( player &p, const tripoint &examp ) +{ + map &here = get_map(); + itype_id card_type = itype_id_military; + if( p.has_amount( card_type, 1 ) && query_yn( _( "Swipe your ID card?" ) ) ) { + // The duration taken may need modification. + p.mod_moves( -100 ); + p.use_amount( card_type, 1 ); + add_msg( _( "You insert your ID card." ) ); + add_msg( m_good, + _( "The plutonium generator beeps twice, then disengages from the surrounding conduits with a series of mechanical clunks." ) ); + here.ter_set( examp, t_concrete ); + here.add_item_or_charges( examp, item::spawn( itype_plut_generator_item, calendar::turn ) ); + } else { + add_msg( _( "The plutonium generator has significant security measures in place. Without the necessary ID, you'll have to remove it by hand." ) ); + } +} + /** * Given then name of one of the above functions, returns the matching function * pointer. If no match is found, defaults to iexamine::none but prints out a @@ -6413,6 +6432,7 @@ iexamine_function iexamine_function_from_string( const std::string &function_nam { "dimensional_portal", &iexamine::dimensional_portal }, { "check_power", &iexamine::check_power }, { "migo_nerve_cluster", &iexamine::migo_nerve_cluster }, + { "cardreader_plutgen", &iexamine::cardreader_plutgen }, } }; diff --git a/src/iexamine.h b/src/iexamine.h index e0ab3e38658d..d5829327f991 100644 --- a/src/iexamine.h +++ b/src/iexamine.h @@ -115,6 +115,7 @@ void workbench( player &p, const tripoint &examp ); void dimensional_portal( player &p, const tripoint &examp ); void check_power( player &p, const tripoint &examp ); void migo_nerve_cluster( player &p, const tripoint &examp ); +void cardreader_plutgen( player &p, const tripoint &examp ); detached_ptr pour_into_keg( const tripoint &pos, detached_ptr &&liquid ); std::optional getGasPumpByNumber( const tripoint &p, int number );