From 0f2a242b308cdc248aed66def3d1f7e55992ebbd Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 21 May 2025 20:18:57 +0200 Subject: [PATCH] Add options for level up stats and skills --- .../BanquetForFools/BanquetForCyka/Class1.cs | 85 ++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/Projects/BanquetForFools/BanquetForCyka/Class1.cs b/Projects/BanquetForFools/BanquetForCyka/Class1.cs index e0e57ae..168813d 100644 --- a/Projects/BanquetForFools/BanquetForCyka/Class1.cs +++ b/Projects/BanquetForFools/BanquetForCyka/Class1.cs @@ -16,21 +16,35 @@ namespace BanquetForCyka { public static ConfigEntry debug; public static ConfigEntry debugXp; public static ConfigEntry debugDodgeWindow; + public static ConfigEntry debugStatEntry; + public static ConfigEntry debugSkillEntry; + public static ConfigEntry debugLevelUpEntry; public static ExpressionConfigEntry xpMultiplier; public static ExpressionConfigEntry dodgeWindow; + public static ExpressionConfigEntry levelUpStatEntry; + public static ExpressionConfigEntry levelUpSkillEntry; public void Awake() { debug = Config.Bind("Debug", "Global Debug", false); debugXp = Config.Bind("Debug", "XP Debug", false); debugDodgeWindow = Config.Bind("Debug", "Dodge Window Debug", false); + debugStatEntry = Config.Bind("Debug", "Stat Entry Debug", false); + debugSkillEntry = Config.Bind("Debug", "Skill Entry Debug", false); + debugLevelUpEntry = Config.Bind("Debug", "Level Up Entry Debug", false); xpMultiplier = new ExpressionConfigEntry( Config, "General", "XP Multiplier", "v*1", "XP Multiplier expression. Use 'v' to represent the original value.", debugXp); - dodgeWindow = new ExpressionConfigEntry( - Config, "General", "Dodge Window", "v*1", - "Dodge Window expression. Use 'v' to represent the original value.", debugDodgeWindow); + dodgeWindow = new ExpressionConfigEntry(Config, "General", "Dodge Window", "v*1", + "Dodge Window expression. Use 'v' to represent the original value.", + debugDodgeWindow); + levelUpStatEntry = new ExpressionConfigEntry( + Config, "General", "Level Up Stat Entry", "v*1", + "Stat Entry expression. Use 'v' to represent the original value.", debugStatEntry); + levelUpSkillEntry = new ExpressionConfigEntry( + Config, "General", "Level Up Skill Entry", "v*1", + "Skill Entry expression. Use 'v' to represent the original value.", debugSkillEntry); Logger.LogInfo("BanquetForCyka loaded"); HarmonyFileLog.Enabled = true; @@ -65,4 +79,69 @@ namespace BanquetForCyka { Main.LogDebug("Modified dodge window: " + __result, Main.debugDodgeWindow); } } + + [HarmonyPatch(typeof(LevelUp), "ClickedStat")] + public class Actions_ClickedStat { + private static float originalStr; + private static float originalAgi; + private static float originalDex; + private static float originalPag; + private static float originalSen; + + public static void Prefix(ref LevelUp __instance) { + Main.LogDebug("Original Str: " + __instance.character.stats.strength, Main.debugStatEntry); + Main.LogDebug("Original Agi: " + __instance.character.stats.agility, Main.debugStatEntry); + Main.LogDebug("Original Dex: " + __instance.character.stats.dexterity, Main.debugStatEntry); + Main.LogDebug("Original Pag: " + __instance.character.stats.pagan, Main.debugStatEntry); + Main.LogDebug("Original Sen: " + __instance.character.stats.sensory, Main.debugStatEntry); + + originalStr = __instance.character.stats.strength; + originalAgi = __instance.character.stats.agility; + originalDex = __instance.character.stats.dexterity; + originalPag = __instance.character.stats.pagan; + originalSen = __instance.character.stats.sensory; + } + + public static void Postfix(ref LevelUp __instance) { + float deltaStr = __instance.character.stats.strength - originalStr; + float deltaAgi = __instance.character.stats.agility - originalAgi; + float deltaDex = __instance.character.stats.dexterity - originalDex; + float deltaPag = __instance.character.stats.pagan - originalPag; + float deltaSen = __instance.character.stats.sensory - originalSen; + + Main.LogDebug("Delta Str: " + deltaStr, Main.debugStatEntry); + Main.LogDebug("Delta Agi: " + deltaAgi, Main.debugStatEntry); + Main.LogDebug("Delta Dex: " + deltaDex, Main.debugStatEntry); + Main.LogDebug("Delta Pag: " + deltaPag, Main.debugStatEntry); + Main.LogDebug("Delta Sen: " + deltaSen, Main.debugStatEntry); + + float resultStr = Main.levelUpStatEntry.Evaluate(deltaStr); + float resultAgi = Main.levelUpStatEntry.Evaluate(deltaAgi); + float resultDex = Main.levelUpStatEntry.Evaluate(deltaDex); + float resultPag = Main.levelUpStatEntry.Evaluate(deltaPag); + float resultSen = Main.levelUpStatEntry.Evaluate(deltaSen); + + Main.LogDebug("Result Str: " + resultStr, Main.debugStatEntry); + Main.LogDebug("Result Agi: " + resultAgi, Main.debugStatEntry); + Main.LogDebug("Result Dex: " + resultDex, Main.debugStatEntry); + Main.LogDebug("Result Pag: " + resultPag, Main.debugStatEntry); + Main.LogDebug("Result Sen: " + resultSen, Main.debugStatEntry); + + __instance.character.stats.strength = resultStr; + __instance.character.stats.agility = resultAgi; + __instance.character.stats.dexterity = resultDex; + __instance.character.stats.pagan = resultPag; + __instance.character.stats.sensory = resultSen; + } + } + + [HarmonyPatch(typeof(LevelUp), "IncreaseAmount")] + public class Actions_IncreaseAmount { + public static void Postfix(ref int __result) { + Main.LogDebug("Original amount: " + __result, Main.debugLevelUpEntry); + float result = Main.levelUpSkillEntry.Evaluate(__result); + __result = (int)result; + Main.LogDebug("Modified amount: " + __result, Main.debugLevelUpEntry); + } + } }