148 lines
7.2 KiB
C#
148 lines
7.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using BepInEx;
|
|
using BepInEx.Configuration;
|
|
using HarmonyLib;
|
|
using HarmonyLib.Tools;
|
|
|
|
namespace BanquetForCyka {
|
|
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
|
|
public class Main : BaseUnityPlugin {
|
|
private const string PluginGuid = "BanquetForCyka";
|
|
private const string PluginName = "BanquetForCyka";
|
|
private const string PluginVersion = "1.0.0";
|
|
|
|
public static ConfigEntry<bool> debug;
|
|
public static ConfigEntry<bool> debugXp;
|
|
public static ConfigEntry<bool> debugDodgeWindow;
|
|
public static ConfigEntry<bool> debugStatEntry;
|
|
public static ConfigEntry<bool> debugSkillEntry;
|
|
public static ConfigEntry<bool> 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);
|
|
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;
|
|
Harmony harmony = new Harmony(PluginGuid);
|
|
harmony.PatchAll();
|
|
var originalMethods = harmony.GetPatchedMethods();
|
|
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
|
}
|
|
|
|
public static void LogDebug(string message, ConfigEntry<bool> debugFlag = null) {
|
|
if (debug.Value || (debugFlag != null && debugFlag.Value))
|
|
Console.WriteLine(message);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Stats), "AddXP")]
|
|
public class Stats_AddXP {
|
|
public static void Prefix(ref int amt) {
|
|
Main.LogDebug("Original XP amount: " + amt, Main.debugXp);
|
|
float result = Main.xpMultiplier.Evaluate(amt);
|
|
amt = (int)result;
|
|
Main.LogDebug("Modified XP amount: " + amt, Main.debugXp);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Actions), "DodgeCalculation")]
|
|
public class Actions_DodgeCalculation {
|
|
public static void Postfix(ref float __result) {
|
|
Main.LogDebug("Original dodge window: " + __result, Main.debugDodgeWindow);
|
|
float result = Main.dodgeWindow.Evaluate(__result);
|
|
__result = result;
|
|
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);
|
|
}
|
|
}
|
|
}
|