Skip to content

Commit

Permalink
hacking: change the electrohack formula to make sense
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlangsdorf committed Sep 9, 2019
1 parent 92a1956 commit 05d417c
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( p.int_cur / 2 - 8 );
return target;
}

hack_result iexamine::hack_attempt( player &p )
{
if( p.has_trait( trait_ILLITERATE ) ) {
Expand All @@ -5713,33 +5724,31 @@ hack_result iexamine::hack_attempt( player &p )

p.moves -= to_moves<int>( 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<int>( ( 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;
Expand Down

0 comments on commit 05d417c

Please sign in to comment.