Skip to content

Commit

Permalink
this isn't working but should stop attacks at high strain
Browse files Browse the repository at this point in the history
  • Loading branch information
I-am-Erk committed Apr 6, 2024
1 parent 9d2dd4f commit bef204e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/core/game_balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"name": "PLAYER_BASE_STRAIN_REGEN_RATE",
"info": "Sets base strain regeneration per turn of the player, before modifiers. May be used as an offset in strain draining effects.",
"stype": "float",
"value": 50
"value": 20
},
{
"type": "EXTERNAL_OPTION",
Expand Down
5 changes: 5 additions & 0 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,11 @@ static void smash()
if( player_character.is_mounted() ) {
mech_smash = true;
}

if( !mech_smash && player_character.get_strain() != player_character.get_strain_max() && player_character.get_strain() < 2 * player_character.get_standard_stamina_cost() ){
add_msg( m_bad, _( "Your muscles are too strained to smash!" ) );
return;
}

const bool allow_floor_bash = debug_mode; // Should later become "true"
const std::optional<tripoint> smashp_ = choose_adjacent( _( "Smash where?" ), allow_floor_bash );
Expand Down
18 changes: 12 additions & 6 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,18 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special,
}

const bool hits = hit_spread >= 0;

/** @EFFECT_MELEE reduces stamina cost of melee attacks */
const int deft_bonus = !hits && has_trait( trait_DEFT ) ? 50 : 0;
const int base_stam = get_base_melee_stamina_cost();
const int total_stam = enchantment_cache->modify_value(
enchant_vals::mod::MELEE_STAMINA_CONSUMPTION,
get_total_melee_stamina_cost() );

if( get_strain() != get_strain_max() && get_strain() < std::min( 50, total_stam + deft_bonus ) ){
add_msg( m_bad, _( "Your muscles are too strained to make an attack!" ) );
return false;
}

if( monster *m = t.as_monster() ) {
cata::event e = cata::event::make<event_type::character_melee_attacks_monster>( getID(),
Expand Down Expand Up @@ -936,12 +948,6 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special,
handle_melee_wear( cur_weapon );
}

/** @EFFECT_MELEE reduces stamina cost of melee attacks */
const int deft_bonus = !hits && has_trait( trait_DEFT ) ? 50 : 0;
const int base_stam = get_base_melee_stamina_cost();
const int total_stam = enchantment_cache->modify_value(
enchant_vals::mod::MELEE_STAMINA_CONSUMPTION,
get_total_melee_stamina_cost() );

burn_energy_arms( std::min( -50, total_stam + deft_bonus ) );
add_msg_debug( debugmode::DF_MELEE, "Stamina burn base/total (capped at -50): %d/%d", base_stam,
Expand Down

0 comments on commit bef204e

Please sign in to comment.