Changing Fatigue Loss Values
Posted: Sat Jan 13, 2024 3:28 am
I'm working on a mod which will - assuming I succeed - make fatigue into a more dynamic stat, like in later TES games. Actions will use up far more fatigue, but it will also regenerate more quickly.
I should say I'm not a programmer at all, this is my first time dabbling in Unity or C#, so there is a lot of trial and error here (and looking at other people's mods - Kirk O.'s Basic Magic Regen has been invaluable here, since it's doing some similar things).
I've got the regeneration part mostly working. I'm hitting a wall though when it comes to changing the fatigue loss associated with certain actions. This is defined in PlayerEntity.cs:
Fatigue loss itself is then applied later in PlayerEntity.cs.
I want to change these values from my mod script, but the fact that they're consts means I can't use the override method. I'm not sure if there is any way to change them - I know consts are fixed at compile-time, but I don't know if there's a way for a mod script to inject a different value during compile-time or whether these are already set in stone by the time mod scripts are loaded.
The alternative will be to implement a totally new method for fatigue loss which runs in the mod, alongside the vanilla method, which seems messy.
Anyone have any bright ideas?
I should say I'm not a programmer at all, this is my first time dabbling in Unity or C#, so there is a lot of trial and error here (and looking at other people's mods - Kirk O.'s Basic Magic Regen has been invaluable here, since it's doing some similar things).
I've got the regeneration part mostly working. I'm hitting a wall though when it comes to changing the fatigue loss associated with certain actions. This is defined in PlayerEntity.cs:
Code: Select all
// Fatigue loss per in-game minute
public const int DefaultFatigueLoss = 11;
public const int ClimbingFatigueLoss = 22;
public const int RunningFatigueLoss = 88;
public const int SwimmingFatigueLoss = 44;
public const int JumpingFatigueLoss = 11;
I want to change these values from my mod script, but the fact that they're consts means I can't use the override method. I'm not sure if there is any way to change them - I know consts are fixed at compile-time, but I don't know if there's a way for a mod script to inject a different value during compile-time or whether these are already set in stone by the time mod scripts are loaded.
The alternative will be to implement a totally new method for fatigue loss which runs in the mod, alongside the vanilla method, which seems messy.
Anyone have any bright ideas?