From 05d417c22db86fb4b68d357b46f113aae7d04ba2 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Mon, 9 Sep 2019 06:52:24 -0500 Subject: [PATCH] hacking: change the electrohack formula to make sense Fixes #29898 Change the electrohack target number to be computer skill level + int / 2 - 4, and calculate success as a normal roll with an average of target number and a standard deviation of 5. That gives the following success rates at Int 8: Skill Wreck Short Nothing Success 0 21% 21% 42% 16% 3 8% 13% 44% 34% 5 4% 8% 38% 50% 10 0% 1% 14% 84% I also added an additional cost of 25 charges on a short, to distinguish it from the nothing result. --- src/iexamine.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/iexamine.cpp b/src/iexamine.cpp index fcec7dbb73f85..40f4c7d380135 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -5697,6 +5697,17 @@ iexamine_function iexamine_function_from_string( const std::string &function_nam return &iexamine::none; } +static int hack_level( const player &p ) +{ + ///\EFFECT_COMPUTER increases success chance of hacking card readers + int target = p.get_skill_level( skill_computer ); + // odds go up with int>8, down with int<8 + // 4 int stat is worth 1 computer skill here + ///\EFFECT_INT increases success chance of hacking card readers + target += static_cast( p.int_cur / 2 - 8 ); + return target; +} + hack_result iexamine::hack_attempt( player &p ) { if( p.has_trait( trait_ILLITERATE ) ) { @@ -5713,33 +5724,31 @@ hack_result iexamine::hack_attempt( player &p ) p.moves -= to_moves( 5_minutes ); p.practice( skill_computer, 20 ); - ///\EFFECT_COMPUTER increases success chance of hacking card readers - int player_computer_skill_level = p.get_skill_level( skill_computer ); - int success = rng( player_computer_skill_level / 4 - 2, player_computer_skill_level * 2 ); - success += rng( -3, 3 ); if( using_fingerhack ) { p.charge_power( -25 ); - success++; - } - if( using_electrohack ) { + } else { p.use_charges( "electrohack", 25 ); - success++; } - // odds go up with int>8, down with int<8 - // 4 int stat is worth 1 computer skill here - ///\EFFECT_INT increases success chance of hacking card readers - success += rng( 0, static_cast( ( p.int_cur - 8 ) / 2 ) ); - + // only skilled supergenius never cause short circuits, but the odds are low for people + // with moderate skills + const int hack_stddev = 5; + int success = std::ceil( normal_roll( hack_level( p ), hack_stddev ) ); if( success < 0 ) { add_msg( _( "You cause a short circuit!" ) ); + if( using_fingerhack ) { + p.charge_power( -25 ); + } else { + p.use_charges( "electrohack", 25 ); + } + if( success <= -5 ) { if( using_electrohack ) { add_msg( m_bad, _( "Your electrohack is ruined!" ) ); p.use_amount( "electrohack", 1 ); } else { add_msg( m_bad, _( "Your power is drained!" ) ); - p.charge_power( -rng( 0, p.power_level ) ); + p.charge_power( -rng( 25, p.power_level ) ); } } return HACK_FAIL;