Skip to content

Commit

Permalink
Update throwing stamina cost (#39987)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBandit authored Apr 30, 2020
1 parent c81cdcb commit 161371e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,12 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f
}

const int melee = get_skill_level( skill_melee );
/** @EFFECT_STR reduces stamina cost for melee attack with heavier weapons */
const int weight_cost = cur_weapon.weight() / ( 2_gram * std::max( 1, str_cur ) );

// Previously calculated as 2_gram * std::max( 1, str_cur )
// using 16_gram normalizes it to 8 str. Same effort expenditure
// for each strike, regardless of weight. This is compensated
// for by the additional move cost as weapon weight increases
const int weight_cost = cur_weapon.weight() / ( 16_gram );
const int encumbrance_cost = roll_remainder( ( encumb( bp_arm_l ) + encumb( bp_arm_r ) ) *
2.0f );
const int deft_bonus = hit_spread < 0 && has_trait( trait_DEFT ) ? 50 : 0;
Expand Down
10 changes: 8 additions & 2 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,17 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item &
const int move_cost = throw_cost( *this, to_throw );
mod_moves( -move_cost );

const int throwing_skill = get_skill_level( skill_throw );
units::volume volume = to_throw.volume();
units::mass weight = to_throw.weight();

const int stamina_cost = ( static_cast<int>( get_option<float>( "PLAYER_BASE_STAMINA_REGEN_RATE" ) )
+ ( weight / 10_gram ) + 200 ) * -1;
// Previously calculated as 2_gram * std::max( 1, str_cur )
// using 16_gram normalizes it to 8 str. Same effort expenditure
// for being able to throw farther.
const int weight_cost = weight / ( 16_gram );
const int encumbrance_cost = roll_remainder( ( encumb( bp_arm_l ) + encumb( bp_arm_r ) ) * 2.0f );
const int stamina_cost = ( weight_cost + encumbrance_cost - throwing_skill + 50 ) * -1;

bool throw_assist = false;
int throw_assist_str = 0;
if( is_mounted() ) {
Expand Down

0 comments on commit 161371e

Please sign in to comment.