-
Notifications
You must be signed in to change notification settings - Fork 0
PlayerUtil
Kanisuko edited this page May 23, 2026
·
7 revisions
Namespace: ScavLib.util
Safe, null-protected wrappers around the player's Body component. All
methods return safe default values (0, false, null) when no world is
loaded — they will never throw a NullReferenceException.
Two write paths are provided:
- Recommended path — methods that respect the game's internal logic (animations, sounds, side effects). Use these by default.
-
Raw path (suffix
Raw) — direct field writes withMathf.Clampprotection. Bypass game logic intentionally. Use only when you know what you are doing.
| Method | Returns | Notes |
|---|---|---|
GetBloodOxygen() |
float |
0~100. Normal: ~98 |
GetBloodVolume() |
float |
Normal: 100, max: 200 |
GetHeartRate() |
float |
BPM. Normal: ~70 |
GetBloodPressure() |
float |
Systolic. Normal: ~120 |
GetRespiratoryRate() |
float |
0~100. Normal: ~100 |
GetTemperature() |
float |
Celsius. Normal: ~36.6 |
GetHunger() |
float |
0~100. Below 0 = starvation |
GetThirst() |
float |
Normal: 100. Above 175 = over-hydration |
GetStamina() |
float |
0~100 |
GetEnergy() |
float |
0~100 |
GetConsciousness() |
float |
Below 30 = unconscious |
GetBrainHealth() |
float |
At 0 = dead |
GetHappiness() |
float |
-100~100 composite score |
| Method | Returns | Condition |
|---|---|---|
IsAlive() |
bool |
brainHealth > 0 |
IsConscious() |
bool |
Alive AND consciousness > 30
|
IsDying() |
bool |
Any critical vital threshold breached |
IsCriticallyDying() |
bool |
Imminent death |
IsInCardiacArrest() |
bool |
heartRate < 20 |
IsSleeping() |
bool |
Player is asleep |
IsExercising() |
bool |
Player is performing a workout |
These methods respect the game's internal state — use them in preference to the Raw equivalents unless you have a specific reason not to.
| Method | Description |
|---|---|
Feed(float amount) |
Add to hunger, clamped to 100 |
Hydrate(float amount) |
Add to thirst, clamped to 200 |
RestoreStamina(float amount) |
Add to stamina, clamped to 100 |
RestoreEnergy(float amount) |
Add to energy, clamped to 100 |
HealAll() |
Heal all limbs, reset vitals to safe values. Does not regrow dismembered limbs. |
Direct field writes. The Raw suffix signals that game logic (animations,
sounds, stat coupling) is bypassed. Clamp ranges are enforced.
| Method | Clamp Range |
|---|---|
SetHungerRaw(float) |
-100 ~ 100 |
SetThirstRaw(float) |
0 ~ 200 |
SetStaminaRaw(float) |
0 ~ 100 |
SetEnergyRaw(float) |
0 ~ 100 |
SetBloodVolumeRaw(float) |
-100 ~ 200 |
SetBloodOxygenRaw(float) |
0 ~ 100 |
SetTemperatureRaw(float) |
20 ~ 45 |
SetBrainHealthRaw(float) |
0 ~ 100 — setting to 0 kills the player |
SetConsciousnessRaw(float) |
0 ~ 100 |
| Method | Description |
|---|---|
FindItemById(string id, out Item item) |
Search full inventory (including containers) by ID |
FindItemByTag(string tag, out Item item) |
Search full inventory by tag |
GiveItem(string id) |
Spawn item at player feet and auto-pickup |
A nested static class containing named constants for every status threshold used by the game's moodle system. Use these instead of magic numbers to keep your mod consistent with the game's own UI.
using static ScavLib.util.PlayerUtil;
if (PlayerUtil.GetBloodPressure() < Thresholds.BLOOD_PRESSURE_CRITICAL_LOW)
{
// Player is in critical hypotension
}| Constant | Value |
|---|---|
BLOOD_PRESSURE_CRITICAL_LOW |
60 |
BLOOD_PRESSURE_LOW_3 |
83 |
BLOOD_PRESSURE_LOW_2 |
96 |
BLOOD_PRESSURE_LOW_1 |
110 |
BLOOD_PRESSURE_HIGH_1 |
130 |
BLOOD_PRESSURE_HIGH_2 |
145 |
BLOOD_PRESSURE_HIGH_3 |
162 |
BLOOD_PRESSURE_CRITICAL_HIGH |
180 |
| Constant | Value |
|---|---|
BLOOD_OXYGEN_CRITICAL |
45 |
BLOOD_OXYGEN_SEVERE |
60 |
BLOOD_OXYGEN_LOW |
75 |
BLOOD_OXYGEN_MILD |
90 |
| Constant | Value |
|---|---|
HEART_RATE_CARDIAC_ARREST |
20 |
HEART_RATE_BRADYCARDIA_SEVERE |
40 |
HEART_RATE_BRADYCARDIA_MILD |
60 |
HEART_RATE_TACHYCARDIA_MILD |
110 |
HEART_RATE_TACHYCARDIA_SEVERE |
160 |
HEART_RATE_TACHYCARDIA_CRITICAL |
200 |
| Constant | Value |
|---|---|
TEMPERATURE_HYPOTHERMIA_CRITICAL |
28.0 |
TEMPERATURE_HYPOTHERMIA_SEVERE |
32.5 |
TEMPERATURE_HYPOTHERMIA_MILD |
34.0 |
TEMPERATURE_COLD |
35.5 |
TEMPERATURE_NORMAL |
36.6 |
TEMPERATURE_WARM |
38.0 |
TEMPERATURE_HYPERTHERMIA_MILD |
39.0 |
TEMPERATURE_HYPERTHERMIA_SEVERE |
40.25 |
TEMPERATURE_HYPERTHERMIA_CRITICAL |
41.5 |
| Constant | Value |
|---|---|
BLEED_SPEED_CRITICAL |
0.30 |
BLEED_SPEED_HEAVY |
0.15 |
BLEED_SPEED_MEDIUM |
0.06 |
| Constant | Value |
|---|---|
HUNGER_STARVING |
15 |
HUNGER_VERY_HUNGRY |
35 |
HUNGER_HUNGRY |
50 |
HUNGER_PECKISH |
75 |
THIRST_OVERHYDRATED |
175 |
STAMINA_EXHAUSTED |
15 |
STAMINA_VERY_TIRED |
35 |
STAMINA_TIRED |
50 |
STAMINA_MILDLY_TIRED |
70 |
ENERGY_EXHAUSTED |
7 |
ENERGY_VERY_TIRED |
15 |
ENERGY_TIRED |
25 |
ENERGY_MILDLY_TIRED |
35 |
CONSCIOUSNESS_UNCONSCIOUS |
20 |
CONSCIOUSNESS_INCAPACITATED |
30 |
PAIN_AGONY |
80 |
PAIN_SEVERE |
55 |
PAIN_MODERATE |
30 |
PAIN_MILD |
10 |
BRAIN_DAMAGE_SEVERE |
30 |
BRAIN_DAMAGE_MODERATE |
60 |
BRAIN_DAMAGE_MILD |
80 |
BRAIN_DAMAGE_SLIGHT |
95 |
STROKE_CRITICAL |
70 |
SEPSIS_CRITICAL |
80 |
RADIATION_CRITICAL |
80 |