Skip to content

Commit

Permalink
Hotkeys for Remove Lore, Make hidden items purchaseable and Sell ever…
Browse files Browse the repository at this point in the history
…ything.
  • Loading branch information
ADDB committed Nov 3, 2023
1 parent 848dfbd commit 9673372
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
48 changes: 40 additions & 8 deletions FTK2lorestore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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);
}
}
}
}
}
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
2 changes: 1 addition & 1 deletion ftk2lorestore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net472</TargetFramework>
<AssemblyName>ftk2lorestore</AssemblyName>
<Description>FTK 2 Lore Store Cheats</Description>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
Expand Down

0 comments on commit 9673372

Please sign in to comment.