feat: Adds configurable skill and stat gain (#1489)

### Summary

- Adds the following configurations:
```json
"stats.statMax": "125",
"stats.gainChanceMultiplier": 1.0,
"stats.primaryStatGainChance": 0.75,
"stats.gainDelay": "00:10:00",
"stats.petGainDelay": "00:05:00",
"stats.usePub45StatGain": "False"
```

- Adds Pub 45 stat gain rate for UOML+.
- Reduces the gain delay for legacy stat gain from 15 minutes to 10 minutes.
- Legacy gain no longer requires a gain in skill to gain in a stat.
This commit is contained in:
Vitalii Zurian 2023-10-14 21:02:36 +02:00 • committed by GitHub
parent 29c7d839a7
commit f9517854d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 311 additions and 118 deletions

View file

@ -64,6 +64,12 @@ public static class ServerConfiguration
return bool.TryParse(strValue, out var value) ? value : defaultValue;
}
public static TimeSpan GetSetting(string key, TimeSpan defaultValue)
{
_settings.Settings.TryGetValue(key, out var strValue);
return TimeSpan.TryParse(strValue, out var value) ? value : defaultValue;
}
public static T GetSetting<T>(string key, T defaultValue) where T : struct, Enum
{
_settings.Settings.TryGetValue(key, out var strValue);

View file

@ -76,6 +76,13 @@ public enum SkillName
Throwing = 57
}
public enum Stat
{
Str,
Dex,
Int
}
[PropertyObject]
public class Skill
{
@ -135,7 +142,7 @@ public class Skill
}
}
if (Lock is < SkillLock.Up or > SkillLock.Locked)
if (Lock > SkillLock.Locked)
{
Lock = SkillLock.Up;
}
@ -245,25 +252,29 @@ public class Skill
get
{
var baseValue = Base;
var inv = 100.0 - baseValue;
if (inv < 0.0)
{
inv = 0.0;
}
inv /= 100.0;
var statsOffset = Owner.Owner.RawStr * Info.StrScale +
Owner.Owner.RawDex * Info.DexScale +
Owner.Owner.RawInt * Info.IntScale;
var statTotal = Info.StatTotal * inv;
statsOffset *= inv;
var inv = 100.0 - baseValue;
if (statsOffset > statTotal)
if (inv <= 0.0)
{
statsOffset = statTotal;
statsOffset = 0.0;
}
else
{
statsOffset *= inv;
if (Info.StatTotal > 0)
{
var statTotal = Info.StatTotal * inv;
if (statsOffset > statTotal)
{
statsOffset = statTotal;
}
}
}
var value = baseValue + statsOffset;
@ -323,7 +334,7 @@ public class Skill
public void SetLockNoRelay(SkillLock skillLock)
{
if (skillLock is < SkillLock.Up or > SkillLock.Locked)
if (skillLock > SkillLock.Locked)
{
return;
}
@ -387,7 +398,7 @@ public class SkillInfo
public SkillInfo(
int skillID, string name, double strScale, double dexScale, double intScale, string title,
SkillUseCallback callback, double strGain, double dexGain, double intGain, double gainFactor,
string professionSkillName = null
string professionSkillName, Stat primaryStat, Stat secondaryStat
)
{
Name = name;
@ -403,6 +414,8 @@ public class SkillInfo
GainFactor = gainFactor;
ProfessionSkillName = professionSkillName ?? Name.RemoveOrdinal(" ");
StatTotal = strScale + dexScale + intScale;
PrimaryStat = primaryStat;
SecondaryStat = secondaryStat;
}
public SkillUseCallback Callback { get; set; }
@ -431,6 +444,10 @@ public class SkillInfo
public string ProfessionSkillName { get; set; }
public Stat PrimaryStat { get; set; }
public Stat SecondaryStat { get; set; }
public static SkillInfo[] Table { get; set; } = Array.Empty<SkillInfo>();
}