Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Average NPC skill level increases over time #73745

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions data/core/game_balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@
"stype": "int",
"value": 5
},
{
"type": "EXTERNAL_OPTION",
"name": "MIN_CATCHUP_EXP_PER_POST_CATA_DAY",
"info": "NPCs generated post-cataclysm will, when initially generated, receive this amount of exp to a random skill for each day that has passed since the Cataclysm.",
"stype": "int",
"value": 50
},
{
"type": "EXTERNAL_OPTION",
"name": "MAX_CATCHUP_EXP_PER_POST_CATA_DAY",
"info": "Same as above. This is the second value of rng(min, max) to determine base exp (before other character modifiers).",
"stype": "int",
"value": 150
},
{
"type": "EXTERNAL_OPTION",
"name": "EXTRA_NPC_SKILL_LEVEL_CAP",
"info": "The maximum skill level randomly generated NPCs can achieve via MIN_CATCHUP_EXP_PER_POST_CATA_DAY and MAX_CATCHUP_EXP_PER_POST_CATA_DAY.",
"stype": "int",
"value": 7
},
{
"type": "EXTERNAL_OPTION",
"name": "ETERNAL_WEATHER",
Expand Down
6 changes: 4 additions & 2 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,8 @@ std::vector<const item *> Character::get_pseudo_items() const
return pseudo_items;
}

bool Character::practice( const skill_id &id, int amount, int cap, bool suppress_warning )
bool Character::practice( const skill_id &id, int amount, int cap, bool suppress_warning,
bool allow_multilevel )
{
SkillLevel &level = get_skill_level_object( id );
const Skill &skill = id.obj();
Expand Down Expand Up @@ -2735,7 +2736,8 @@ bool Character::practice( const skill_id &id, int amount, int cap, bool suppress
if( amount > 0 && level.isTraining() ) {
int old_practical_level = static_cast<int>( get_skill_level( id ) );
int old_theoretical_level = get_knowledge_level( id );
get_skill_level_object( id ).train( amount, catchup_modifier, knowledge_modifier );
get_skill_level_object( id ).train( amount, catchup_modifier, knowledge_modifier,
allow_multilevel );
int new_practical_level = static_cast<int>( get_skill_level( id ) );
int new_theoretical_level = get_knowledge_level( id );
std::string skill_name = skill.name();
Expand Down
3 changes: 2 additions & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,8 @@ class Character : public Creature, public visitable
public:

/** This handles giving xp for a skill. Returns true on level-up. */
bool practice( const skill_id &id, int amount, int cap = 99, bool suppress_warning = false );
bool practice( const skill_id &id, int amount, int cap = 99, bool suppress_warning = false,
bool allow_multilevel = false );
/** This handles warning the player that there current activity will not give them xp */
void handle_skill_warning( const skill_id &id, bool force_warning = false );

Expand Down
23 changes: 18 additions & 5 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ static const skill_id skill_pistol( "pistol" );
static const skill_id skill_rifle( "rifle" );
static const skill_id skill_shotgun( "shotgun" );
static const skill_id skill_smg( "smg" );
static const skill_id skill_speech( "speech" );
static const skill_id skill_stabbing( "stabbing" );
static const skill_id skill_throw( "throw" );
static const skill_id skill_unarmed( "unarmed" );
Expand Down Expand Up @@ -633,10 +632,24 @@ void npc::randomize( const npc_class_id &type, const npc_template_id &tem_id )
set_skill_level( skill.ident(), level );
}

//A universal barter boost to keep NPCs competitive with players
//The int boost from trade wasn't active... now that it is, most
//players will vastly outclass npcs in trade without a little help.
mod_skill_level( skill_speech, rng( 2, 4 ) );
const int cataclysm_days = to_days<int>( calendar::turn - calendar::start_of_cataclysm );
const int level_cap = get_option<int>( "EXTRA_NPC_SKILL_LEVEL_CAP" );
const SkillLevelMap &skills_map = get_all_skills();
// Exp actually multiplied by 100 in Character::practice
const int min_exp = get_option<int>( "MIN_CATCHUP_EXP_PER_POST_CATA_DAY" );
const int max_exp = get_option<int>( "MAX_CATCHUP_EXP_PER_POST_CATA_DAY" );

for( int i = 0; i < cataclysm_days; i++ ) {
const int npc_exp_gained = rng( min_exp, max_exp );
const std::pair<const skill_id, SkillLevel> &pair = random_entry( skills_map );

// This resets focus to equilibrium before every practice, so NPCs with bonus learning/focus
// will have that reflected by the *actual* gained exp.
mod_focus( calc_focus_equilibrium( true ) - get_focus() );

practice( pair.first, npc_exp_gained, level_cap, false, true );
}


set_body();
recalc_hp();
Expand Down
Loading