Skip to content

SkillUtil

QinShenYu edited this page Jun 10, 2026 · 2 revisions

Namespace:​ ScavLib.util

Safe wrappers around the player's Skills component. Uses the typed SkillType enum instead of the game's internal magic integers (0, 1, 2), making skill-related code self-documenting and refactor-safe.

All methods return safe default values when no world is loaded.


SkillType Enum

public enum SkillType
{
    Strength    = 0,  // Physical power, melee damage, push-up training
    Resilience  = 1,  // Endurance, stamina recovery, squat training
    Intelligence = 2, // Crafting, medical, learning speed
}

Level Queries

Method Returns Description
GetLevel(SkillType) int Current skill level. Returns 0 if not in game.
GetExperience(SkillType) float Raw absolute XP value.
GetProgress(SkillType) float Normalized 0~1 progress toward next level. Useful for progress bars.
GetExperienceInLevel(SkillType) float XP accumulated within the current level.
GetExperienceForNextLevel(SkillType) float Total XP required to advance from current level to next.

Example:

int strLevel = SkillUtil.GetLevel(SkillType.Strength);
float strProgress = SkillUtil.GetProgress(SkillType.Strength);

GameUtil.Log($"STR: Level {strLevel} ({strProgress * 100f:F1}% to next)");

XP Modification

AddExperience(SkillType skill, float xp)

Add XP via the game's natural pathway. If the XP causes a level-up, the game's level-up alert and sound will trigger exactly as they would during normal gameplay.

// Grant 50 Resilience XP
SkillUtil.AddExperience(SkillType.Resilience, 50f);

SetLevelRaw(SkillType skill, int level)

Directly set a skill to a given level. XP boundaries are updated to match the new level, and XP is reset to the floor of that level. Does not trigger level-up alerts or sounds. Use AddExperience if you want the natural level-up flow.

// Set Intelligence to level 15 silently
SkillUtil.SetLevelRaw(SkillType.Intelligence, 15);

Global XP Multiplier

// Read
float current = SkillUtil.XpMultiplier; // default: 1.0

// Write (clamped to >= 0)
SkillUtil.XpMultiplier = 2.0f; // double XP from all sources

XpMultiplier maps directly to Skills.xpGainMult, a global static field in the game. Changing it affects all skills and all XP sources, including built-in actions such as workouts, crafting, and medical item use.


Level Curve Reference

The game uses an exponential XP curve. This is provided for reference — you do not need to calculate it manually, use GetExperienceForNextLevel() instead.

Level range XP per level
1 ~ 9 60 (linear)
10 100
11 ~ 20 Previous × 1.18
21 ~ 29 Previous × 1.18 × 1.15
30+ Previous × 1.18 × 1.15 × 2

To get the total XP required to reach any level from zero:

int xpNeeded = SkillUtil.GetExperienceForLevel(20);

Clone this wiki locally