Custom Stats - AnduoGames/ThirdCrisisModding GitHub Wiki
Every character has stats. By default, the game assigns each character 12 stats that we hardcoded. You can add stats on top of that to specific characters yourself:
var stat = new Stat()
{
Name = "Modded Stat",
BaseMax = 40,
ID = "stat_unique_modded_stat_name",
DisplayColor = Color.magenta
};
// Add the stat to the global pool of stats. Do this during the OnModInitialized method call. Required to have the stat persist saving and loading.
stat.Initialize();
// Get Jennas Character
var jenna = Character.Get("Jenna");
// Add the stat
stat.AddToCharacter(jenna);
// Set a default value
jenna.GetStat(stat.ID).BaseValue = 20;
You can hook into a few events on Stats. Globally, you can listen for any Stat's value changing:
Stat.OnStatValueChanged.AddListener((info) =>
{
if(info.Stat.ID == "stat_unique_modded_stat_name")
{
Debug.Log("My stat was changed by " + info.Difference);
}
});
Stats also have instanced Eventlisteners:
Character.Get("Jenna").GetStat("stat_perversion").OnValueChanged.AddListener((info) =>
{
Debug.Log("Jenna's perversion changed to " + info.NewAmount);
});