Skip to content

Commit

Permalink
feat(balance): sanity-check EXP gain of several activities
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt committed Nov 11, 2024
1 parent d023fc3 commit 406f227
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
15 changes: 4 additions & 11 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ void complete_construction( Character &ch )
const auto award_xp = [&]( player & c ) {
for( const auto &pr : built.required_skills ) {
const float built_time = to_moves<int>( built.time );
const float built_base = to_moves<int>( 30_minutes );
const float built_base = to_moves<int>( 10_minutes );
c.practice( pr.first, static_cast<int>(
( 10 + 15 * pr.second ) * ( 1.0f + built_time / built_base )
), static_cast<int>( pr.second * 1.25 ) );
Expand Down Expand Up @@ -1415,6 +1415,9 @@ void construct::done_deconstruct( const tripoint &p )
add_msg( m_info, _( "That %s can not be disassembled!" ), f.name() );
return;
}
if( f.active ) {
g->u.practice( skill_electronics, 20, 4 );
}
if( f.deconstruct.furn_set.str().empty() ) {
here.furn_set( p, f_null );
} else {
Expand Down Expand Up @@ -1444,16 +1447,6 @@ void construct::done_deconstruct( const tripoint &p )
}
done_deconstruct( top );
}
if( t.id == ter_str_id( "t_console_broken" ) ) {
if( g->u.get_skill_level( skill_electronics ) >= 1 ) {
g->u.practice( skill_electronics, 20, 4 );
}
}
if( t.id == ter_str_id( "t_console" ) ) {
if( g->u.get_skill_level( skill_electronics ) >= 1 ) {
g->u.practice( skill_electronics, 40, 8 );
}
}
here.ter_set( p, t.deconstruct.ter_set );
add_msg( _( "The %s is disassembled." ), t.name() );
std::vector<detached_ptr<item>> items_list = item_group::items_from( t.deconstruct.drop_group,
Expand Down
3 changes: 1 addition & 2 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6417,8 +6417,7 @@ void iexamine::practice_survival_while_foraging( player *p )
{
///\EFFECT_INT Intelligence caps survival skill gains from foraging
const int max_forage_skill = p->int_cur / 2 + 1;
///\EFFECT_SURVIVAL decreases survival skill gain from foraging (NEGATIVE)
const int max_exp = 2 * ( max_forage_skill - p->get_skill_level( skill_survival ) );
const int max_exp = 2 * max_forage_skill;
// Award experience for foraging attempt regardless of success
p->practice( skill_survival, rng( 1, max_exp ), max_forage_skill );
}
6 changes: 3 additions & 3 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ repair_item_actor::attempt_hint repair_item_actor::repair( player &pl, item &too
const int current_skill_level = pl.get_skill_level( used_skill );
const auto action = default_action( fix, current_skill_level );
const auto chance = repair_chance( pl, fix, action );
int practice_amount = repair_recipe_difficulty( pl, fix, true ) / 2 + 1;
int practice_amount = std::max( repair_recipe_difficulty( pl, fix, true ), 1 );
float roll_value = rng_float( 0.0, 1.0 );
enum roll_result {
SUCCESS,
Expand Down Expand Up @@ -3834,7 +3834,7 @@ int heal_actor::finish_using( player &healer, player &patient, item &it,
e.set_duration( e.get_int_dur_factor() * bandages_intensity );
patient.get_part( healed ).set_damage_bandaged( patient.get_part_hp_max(
bp ) - patient.get_part_hp_cur( bp ) );
practice_amount += 2 * bandages_intensity;
practice_amount += 3 * bandages_intensity;
}
if( disinfectant_power > 0 ) {
int disinfectant_intensity = get_disinfected_level( healer );
Expand All @@ -3843,7 +3843,7 @@ int heal_actor::finish_using( player &healer, player &patient, item &it,
e.set_duration( e.get_int_dur_factor() * disinfectant_intensity );
patient.get_part( healed ).set_damage_disinfected( patient.get_part_hp_max(
bp ) - patient.get_part_hp_cur( bp ) );
practice_amount += 2 * disinfectant_intensity;
practice_amount += 3 * disinfectant_intensity;
}
practice_amount = std::max( 9.0f, practice_amount );

Expand Down
14 changes: 5 additions & 9 deletions src/veh_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ int calc_xp_gain( const vpart_info &vp, const skill_id &sk, const Character &who

// how many levels are we above the requirement?
const int lvl = std::max( who.get_skill_level( sk ) - iter->second, 1 );
// also track the objective difficulty of requirement
const int diff = std::max( iter->second, 1 );

// scale xp gain per hour according to relative level
// 0-1: 60 xp /h
// 2: 15 xp /h
// 3: 6 xp /h
// 4: 4 xp /h
// 5: 3 xp /h
// 6: 2 xp /h
// 7+: 1 xp /h
// xp gain per hour starts at 60 times difficulty of installation
// as your level exceeds this, divide exp gain by the level difference squared
return std::ceil( static_cast<double>( vp.install_moves ) /
to_moves<int>( 1_minutes * std::pow( lvl, 2 ) ) );
to_moves<int>( 1_minutes * std::pow( lvl, 2 ) ) * diff );
}

vehicle_part &most_repairable_part( vehicle &veh, Character &who, bool only_repairable )
Expand Down

0 comments on commit 406f227

Please sign in to comment.