From 967337219905120892dd92261688ebb72a7bfd72 Mon Sep 17 00:00:00 2001 From: ADDB Date: Fri, 3 Nov 2023 13:35:22 +0100 Subject: [PATCH] Hotkeys for Remove Lore, Make hidden items purchaseable and Sell everything. --- FTK2lorestore.cs | 48 ++++++++++++++++++++++++++++++++++++-------- README.md | 14 +++++++++++-- ftk2lorestore.csproj | 2 +- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/FTK2lorestore.cs b/FTK2lorestore.cs index 8a4354c..e08e0ee 100644 --- a/FTK2lorestore.cs +++ b/FTK2lorestore.cs @@ -10,12 +10,15 @@ namespace ftk2lorestore { public class FTK2lorestore : BaseUnityPlugin { public const string PLUGIN_GUID = "ftk2lorestore"; public const string PLUGIN_NAME = "FTK 2 Lore Store Cheats"; - public const string PLUGIN_VERSION = "1.0.0"; + public const string PLUGIN_VERSION = "1.0.1"; public static readonly Harmony HarmonyInstance = new Harmony(PLUGIN_GUID); internal static ManualLogSource log; internal static BepInEx.Configuration.KeyboardShortcut addLore = new(UnityEngine.KeyCode.F2, UnityEngine.KeyCode.LeftShift); internal static BepInEx.Configuration.KeyboardShortcut unlockAll = new(UnityEngine.KeyCode.F3, UnityEngine.KeyCode.LeftShift); - internal static BepInEx.Configuration.KeyboardShortcut buyAll = new(UnityEngine.KeyCode.F4, UnityEngine.KeyCode.LeftShift); + internal static BepInEx.Configuration.KeyboardShortcut unlockHidden = new(UnityEngine.KeyCode.F4, UnityEngine.KeyCode.LeftShift); + internal static BepInEx.Configuration.KeyboardShortcut buyAll = new(UnityEngine.KeyCode.F5, UnityEngine.KeyCode.LeftShift); + internal static BepInEx.Configuration.KeyboardShortcut removeLore = new(UnityEngine.KeyCode.F6, UnityEngine.KeyCode.LeftShift); + internal static BepInEx.Configuration.KeyboardShortcut sellAll = new(UnityEngine.KeyCode.F7, UnityEngine.KeyCode.LeftShift); internal static UserData user => RouterMono.GetEnv().User; private void Awake() { // Plugin startup logic @@ -29,23 +32,42 @@ private void Update() { StatsHelper.AddStat("TOTAL_LORE", 50, user.Stats, false, true); SaveGameHelper.SaveUser(user); } + if (removeLore.IsDown()) { + var current = StatsHelper.GetStat("TOTAL_LORE", user.Stats); + var dec = (current >= 50) ? 50 : current; + StatsHelper.AddStat("TOTAL_LORE", -dec, user.Stats, false, true); + SaveGameHelper.SaveUser(user); + } if (unlockAll.IsDown()) { - unlock(); + Unlock(); SaveGameHelper.SaveUser(user); } if (buyAll.IsDown()) { - buy(); + Buy(); SaveGameHelper.SaveUser(user); } + if (sellAll.IsDown()) { + Sell(); + SaveGameHelper.SaveUser(user); + } + if (unlockHidden.IsDown()) { + Unlock(true); + } } - private static void unlock() { + private static void Unlock(bool onlyHidden = false) { foreach (var item in Env.Configs.LoreStore.Keys.ToList()) { - if (StatsHelper.GetStat(item, user.Stats) < 0 && Env.Configs.LoreStore[item].DefaultState >= -2) { - StatsHelper.SetStat(item, 0, user.Stats, false, true); + if (onlyHidden) { + if (StatsHelper.GetStat(item, user.Stats) == -2) { + StatsHelper.SetStat(item, 0, user.Stats, false, true); + } + } else { + if (StatsHelper.GetStat(item, user.Stats) < 0 && Env.Configs.LoreStore[item].DefaultState >= -2) { + StatsHelper.SetStat(item, 0, user.Stats, false, true); + } } } } - private static void buy() { + private static void Buy() { foreach (var item in Env.Configs.LoreStore.Keys.ToList()) { if (!LoreStoreHelper.IsItemPurchased(item, user.Stats) && Env.Configs.LoreStore[item].DefaultState >= -2) { StatsHelper.SetStat(item, 0, user.Stats, false, true); @@ -56,5 +78,15 @@ private static void buy() { } } } + private static void Sell() { + foreach (var item in Env.Configs.LoreStore.Keys.ToList()) { + while (StatsHelper.GetStat(item, user.Stats) > 0) { + StatsHelper.AddStat(item, -1, user.Stats, pPerRun: false, pCheckLoreUnlocks: true); + StatsHelper.AddStat(eUserStats.LORE_STORE_PURCHASES, -1, user.Stats, pPerRun: false, pCheckLoreUnlocks: true); + StatsHelper.AddStat(eUserStats.LORE_POINTS_SPENT, -Env.Configs.LoreStore[item].Cost, user.Stats, pPerRun: false, pCheckLoreUnlocks: true); + StatsHelper.AddStat("TOTAL_LORE", Env.Configs.LoreStore[item].Cost, user.Stats, pPerRun: false, pCheckLoreUnlocks: true); + } + } + } } } \ No newline at end of file diff --git a/README.md b/README.md index d612ec5..960c91d 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,12 @@ The mod adds the following hotkeys (After using a Hotkey, if you already entered - LeftShift + F2: Add 50 Lore - LeftShift + F3: Make all items purchaseable -- LeftShift + F4: Instantly Unlock Everything +- LeftShift + F4: Make only hidden items purchaseable (stuff like preorder bonus and alpha unlockable I think) +- LeftShift + F5: Instantly Unlock Everything +- LeftShift + F6: Remove 50 Lore +- LeftShift + F7: Sell everything. Refunds every purchase (but still keeps everything unlocked). -### Installation +## Installation Download the BepInEx Package from the Releases and unzip into your game directory to set it up. @@ -32,3 +35,10 @@ Steamp/steamapps/common/For The King II/ ├── MonoBleedingEdge/ └── For The King II_Data/ + +## Changelog +## 1.0.1 (developed with For The King II 1.0.11 +- Hotkeys for Remove Lore, Make hidden items purchaseable and Sell everything. + +## 1.0.0 (developed with For The King II 1.0.9 +- Hotkeys for Add Lore, Make all items purchaseable and instantly unlock everything. \ No newline at end of file diff --git a/ftk2lorestore.csproj b/ftk2lorestore.csproj index 5bfd3b1..e88948f 100644 --- a/ftk2lorestore.csproj +++ b/ftk2lorestore.csproj @@ -5,7 +5,7 @@ net472 ftk2lorestore FTK 2 Lore Store Cheats - 1.0.0 + 1.0.1 true latest