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

Conversation

RenechCDDA
Copy link
Member

@RenechCDDA RenechCDDA commented May 13, 2024

Summary

Balance "The average skill level of NPCs will rise over time"

Purpose of change

NPCs are often outclassed by a player of any (gameplay skill) level that can survive long enough to meet the NPC.

We have no time scaling for NPCs. We can apply skills on a class basis, but there's no way to restrict the class from spawning day 1. This means our classes are hamstrung by conflicting needs of balancing the 'early' and 'late' cataclysm experience.

NPCs are often seen as dead weight, as they have no growth curve at all. They don't spend all day huddled in cabins ruthlessly skilling up like our players tend to do.

Describe the solution

Well, give NPCs a gentle growth curve. Those that survive tend to be the skilled and the lucky - and the lucky are still alive, so they can learn to become skilled.

Add two external options: days per level, and level cap. At the time the NPC is generated and randomized, check how many days we are passed the cataclysm. Divide that by days per level, and try to randomly apply that number of levels to skills one at a time. If that skill is at or over the cap, the roll is wasted (meaning growth starts falling off as skills hit the cap, although even that takes a VERY long time).

The options are external so mods may access them as needed.

Describe alternatives you've considered

Applying some sort of time scalars directly to NPC classes on a class-by-class basis

Testing

Rigged up some debug messages to catch values.

Set the date forward an absurd 10 years, spawned a random NPC. They got 520 skill increases and were 7 across the board.

Reloaded, set the date forward only 1 year and spawned a new NPC. Got this:
image

Additional context

I removed an existing across-the-board bonus to speech which dated back quite a few years. The trade formula has changed since then, I don't think it's necessary.

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` Game: Balance Balancing of (existing) in-game features. json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels May 13, 2024
@RenechCDDA RenechCDDA force-pushed the NPCs_skills_over_time branch from b5799c4 to e6d020c Compare May 13, 2024 09:33
Copy link
Member

@anothersimulacrum anothersimulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but how about giving them experience instead of skills directly? It'll look a little more natural.

@PGR-14
Copy link

PGR-14 commented May 13, 2024

Yeah, I'd agree. Also, why don't we make it so that a certain classes of npc get the ability to learn more. I.E. A doctor pre-cataclysm would have way more experience 10 years later than a random office worker reading medical studies

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 13, 2024
@IdleSol
Copy link
Contributor

IdleSol commented May 13, 2024

She's kind of weak, for 1 year post-cataclysm. I wouldn't have taken her at the start. And you forgot about proficiency. She's survived a year, but hasn't learned anything.

Some ideas.

  1. Dependence on intelligence
  2. Separate combat and non-combat experience.
  3. Emphasis on melee, ranged, or crafting skills
  4. Prioritization based on starting professions. To associate NPC backstory and skills.
  5. Focus on skills with max level, especially if they are combat related skills.

@RenechCDDA
Copy link
Member Author

I like it, but how about giving them experience instead of skills directly? It'll look a little more natural.

Good idea. I'm looking at the formula for skill levels and I'll have to do some math to make sure the resulting values are reasonable.

And you forgot about proficiency. She's survived a year, but hasn't learned anything.

Proficiencies are subject to change in a much greater degree than skills are. The number of skills available to character has changed almost not at all in cdda's lifetime (even mods have only added a few), whereas proficiencies are pure JSON and can be built out by any contributor willing to put in the time.

I have some alternative plans for giving NPCs reasonable proficiencies (mostly involving tying them to backgrounds). If I'm able to do that it'll probably come in a separate PR as it'll need at least a little bit of infrastructure to load json. In particular I want to get NPCs up to player standards - almost all of them should start with the same basic proficiencies that the standard player does (home cooking, driver's license).

Separate combat and non-combat experience.
Emphasis on melee, ranged, or crafting skills
Prioritization based on starting professions. To associate NPC backstory and skills.
Focus on skills with max level, especially if they are combat related skills.

I have considered a distribution other than pure random, but the main problem with that is that it needs to consider mods as well. Right now in vanilla we have two 'categories', right? 14 combat skills, 13 non-combat skills. If we balanced it separately per-category, a mod that added say 10 more combat skills and 0 non-combat skills would suddenly have a huge imbalance. We could counter this by separating out the options for each category, but that isn't very scalable.

Basically, your ideas have some merit but I don't have a great idea for implementation that works for all circumstances. I'll be thinking about it.

@RenechCDDA
Copy link
Member Author

Okay, I pushed a changed version. The time for a average NPC to reach level 7 remains the same, but allocation is based on exp per day. Because it now pipes through Character::practice() we can now take character focus into account, as well as other modifiers such as savant and pacifist. Additionally, practicing is set to always allow 'multileveling', so that exp past the level cap isn't discarded.

There is some weirdness in Character::practice() which causes the actual exp value to be multiplied by 100. This makes the external option's values confusing in isolation (50 exp per day is in fact, 5000 exp per day before focus), but I don't think tearing that pillar down is a particularly good idea.

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 14, 2024
src/npc.cpp Outdated Show resolved Hide resolved
@IdleSol
Copy link
Contributor

IdleSol commented May 14, 2024

If we balanced it separately per-category, a mod that added say 10 more combat skills and 0 non-combat skills would suddenly have a huge imbalance. We could counter this by separating out the options for each category, but that isn't very scalable.

We don't have to strike a balance. You have 24 hours in a day. To give you an example, half the time you're in training to create, the other half to destroy.

In other words. The experience calculated by you is divided in a given proportion, which does not depend on the number of skills. (For example 1/2+1/2 or 1/3+2/3). Each portion is divided by the number of skills in the combat and peace segments. The fewer they are, the more significant the increase. There is a logic to this. Focused on doing one thing or taking on everything.

Then we would get:

  • EXP * 1/2 * ( sum(combat_skills) / sum(all_skills) )
  • EXP * 1/2 * ( sum(peace_skills) / sum(all_skills) )

This could be the first realization.

Second realization.

Add up all the levels taken in all skills. This is 100%. We take each skill and divide its level by this sum. So, for each skill we get a priority. Experience is distributed depending on the priority. Skill with a level of 10, is not taken into account. Alternatively, separate calculation for combat and production skills.

Example. A character is created with skills: melee 3, athletics 1 and tailoring 5.

  • Sum: 9
  • Priorities: 3/9, 1/9 and 5/9.

More than half of the experience will go into tailoring until it reaches level 10.

Third realization.

We add some random component. Let's say it's equal to the sum of skills. Now it's 13 or 14, depending on what we're counting for. It's added to the sum calculated earlier. The ratio of it to the new sum is the experience distributed randomly.

Same example. Random component = 13.

  • New sum = 9+13 = 22.
  • Priorities: 3/22, 1/22, 5/22 and 13/22 (distributed randomly among 13 skills)

Second example. A character with skills melee 9, athletics 9, and tailoring 9.

  • Sum: 9 + 9 + 9 + 13=40
  • Priorities: 9/40, 9/40, 9/40 and 13/40

As you can see, the more skills have a level and the higher that level, the smaller the random component. It's a curve realization of the character's focus on his strengths. That to survive, he focused on what he was good at. Even if it's tailoring.

P.S. You might like the idea of adding character experience for their age. In the second half of the post, there were some ideas.

#67580 (comment)

@RenechCDDA RenechCDDA force-pushed the NPCs_skills_over_time branch from 21d30ad to 76c5d7e Compare May 14, 2024 12:08
src/character.cpp Outdated Show resolved Hide resolved
@RenechCDDA RenechCDDA force-pushed the NPCs_skills_over_time branch from 76c5d7e to 1af429c Compare May 14, 2024 12:18
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels May 14, 2024
src/npc.cpp Outdated Show resolved Hide resolved
Co-authored-by: anothersimulacrum <[email protected]>
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 14, 2024
@dseguin dseguin merged commit 814ba07 into CleverRaven:master May 14, 2024
22 of 27 checks passed
@RenechCDDA RenechCDDA deleted the NPCs_skills_over_time branch May 15, 2024 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Game: Balance Balancing of (existing) in-game features. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants