diff --git a/CharmMod.cs b/CharmMod.cs index 06546d4..dbbc01f 100644 --- a/CharmMod.cs +++ b/CharmMod.cs @@ -21,10 +21,23 @@ public class CharmMod : Mod, ILocalSettings HKBlessing.Instance, HuntersMark.Instance, PowerfulDash.Instance, + HealthyShell.Instance, + DoubleDash.Instance, + SoulSpeed.Instance, + SoulSpell.Instance, + SoulHunger.Instance, + RavenousSoul.Instance, + SoulSwitch.Instance, + GeoSwitch.Instance, WealthyAmulet.Instance, - TripleJump.Instance + SoulSlow.Instance, + SlowTime.Instance, + SpeedTime.Instance }; + public int NewCharms = Charms.Count; //STARTS AT 0 (almost definately) + public int OldCharms = 40; //STARTS AT 1 (for some reason) + internal static CharmMod Instance; private Dictionary> BoolGetters = new(); @@ -73,7 +86,9 @@ public override void Initialize() On.PlayMakerFSM.OnEnable += EditFSMs; On.PlayerData.CountCharms += CountOurCharms; ModHooks.NewGameHook += GiveCharms; - ModHooks.HeroUpdateHook += SetDefaultNotchCosts; + ModHooks.HeroUpdateHook += OnUpdate; + ModHooks.SoulGainHook += GrantAllOurCharmsOnSoul; + StartTicking(); if (ModHooks.GetMod("DebugMod") != null) { @@ -84,7 +99,6 @@ public override void Initialize() } } // breaks infinite loop when reading equippedCharm_X - private bool Equipped(Charm c) => c.Settings(Settings).Equipped; private Dictionary<(string Key, string Sheet), Func> TextEdits = new(); @@ -101,7 +115,8 @@ private void GiveCharms() { GrantAllOurCharms(); } - public override string GetVersion() => "6.3.2"; + + public override string GetVersion() => "8.30.3"; internal SaveSettings Settings = new(); @@ -149,9 +164,39 @@ private string GetCharmStrings(string key, string sheetName, string orig) } return orig; } - private void SetDefaultNotchCosts() + private void OnUpdate() { - GrantAllOurCharms(); + //give charms when certain things are done. + + if (PlayerData.instance.colosseumBronzeCompleted) Quickfall.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.colosseumSilverCompleted) Slowfall.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasShadowDash) PowerfulDash.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasNailArt) SturdyNail.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasHuntersMark) HuntersMark.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasDreamGate) SoulHunger.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasDreamNail) SoulSlow.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasSuperDash && PlayerData.instance.gaveSlykey) BetterCDash.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.killedHollowKnight) HKBlessing.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.hasKingsBrand) HealthyShell.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.killedHollowKnightPrime) GlassCannon.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.bankerAccountPurchased) WealthyAmulet.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.colosseumGoldCompleted) RavenousSoul.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.canOvercharm) DoubleDash.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.collectorDefeated) SoulSpell.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.grubsCollected > 10) SlowTime.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.fatGrubKing) SpeedTime.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.mageLordDreamDefeated) GeoSwitch.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.killedMageLord) SoulSwitch.Instance.Settings(Settings).Got = true; + if (PlayerData.instance.nailsmithConvoArt) SoulSpeed.Instance.Settings(Settings).Got = true; + + //end + //ik it is messy, but what else is there to do. Also, if u are seeing this code and think that there is a more appropriate time to give the charm, DM me on discord. I am BubkisLord#5187 + + + if (PlayerData.instance.maxHealth < 1) + { + HeroController.instance.AddToMaxHealth(1); + } foreach (Charm charm in CharmMod.Charms) { charm.Settings(this.Settings).Cost = charm.DefaultCost; @@ -216,25 +261,6 @@ private void CountOurCharms(On.PlayerData.orig_CountCharms orig, PlayerData self self.SetInt("charmsOwned", self.GetInt("charmsOwned") + Charms.Count(c => c.Settings(Settings).Got)); } - private void RandomizeNotchCosts(int seed) - { - // This log statement is here to help diagnose a possible bug where charms cost more than - // they ever should. - Log("Randomizing notch costs"); - var rng = new System.Random(seed); - var total = Charms.Select(x => x.DefaultCost).Sum(); - for (var i = 0; i < total; i++) - { - var possiblePicks = Charms.Select(x => x.Settings(Settings)).Where(s => s.Cost < 6).ToList(); - if (possiblePicks.Count == 0) - { - break; - } - var pick = rng.Next(possiblePicks.Count); - possiblePicks[pick].Cost++; - } - } - internal static void UpdateNailDamage() { IEnumerator WaitThenUpdate() @@ -253,9 +279,27 @@ public void GrantAllOurCharms() } } - public void OnLoadLocal(SaveSettings s) + public int GrantAllOurCharmsOnSoul(int soulamount) { - ((ILocalSettings)Instance).OnLoadLocal(s); + foreach (var charm in Charms) + { + charm.Settings(Settings).Got = true; + } + return soulamount; + } + + public int GiveSpecificCharm(int numberino) + { + Charms[numberino].Settings(Settings).Got = true; + return numberino; + } + + public void TakeAllOurCharms() + { + foreach (var charm in Charms) + { + charm.Settings(Settings).Got = false; + } } SaveSettings ILocalSettings.OnSaveLocal() @@ -267,5 +311,10 @@ public SaveSettings OnSaveLocal() { throw new NotImplementedException(); } + + public void OnLoadLocal(SaveSettings s) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/CharmMod.csproj b/CharmMod.csproj index d4c4af9..6c26322 100644 --- a/CharmMod.csproj +++ b/CharmMod.csproj @@ -80,7 +80,7 @@ $(HollowKnightRefs)/Mods/SFCore/SFCore.dll - $(HollowKnightRefs)/Mods/ItemChanger/ItemChanger.dll + C:\Program Files (x86)\Hollow Knight\Hollow Knight_Data\Managed\Mods\ItemChanger\ItemChanger.dll $(HollowKnightRefs)/Mods/MenuChanger/MenuChanger.dll diff --git a/Menu.cs b/Menu.cs new file mode 100644 index 0000000..590a043 --- /dev/null +++ b/Menu.cs @@ -0,0 +1,204 @@ +using Satchel.BetterMenus; + +namespace CharmMod +{ + public class ClassName : Mod, ICustomMenuMod, ITogglableMod, ILocalSettings, IMod + { + public ClassName() : base("Charm Mod") { } + public override string GetVersion() => CharmMod.Instance.GetVersion(); + public override int LoadPriority() => 1; + public bool ToggleButtonInsideMenu => throw new NotImplementedException(); + + private int charmSelect = 0; + public override void Initialize() + { + ModHooks.LanguageGetHook += LanguageGet; + } + + public string LanguageGet(string key, string sheetTitle, string orig) + { + //Check for the key and sheet for MainMenu "Yes" text + if (key == "HU_DEFEAT" && sheetTitle == "Ghosts") + { + return "My mind... it clears. Have we been sleeping? No, not you, little knight. ...I remember... ...those proud lords, were they truly monsters? Their eyes, bright and clear. Why, why did you tell me to fear them so? They were going to help... ...it was I who brought the madness... ...finally, you have stopped, you cruel voice... ...who are you?..."; + } + + if (key == "TOWN" && sheetTitle == "Map Zones") + { + return "Elderbug The Amazing's Domain"; + } + + if (key == "CLIFFS" && sheetTitle == "Map Zones") + { + return "The Forgotten Edge"; + } + + if (key == "DISTANT_VILLAGE" && sheetTitle == "Map Zones") + { + return "Herrah's Den"; + } + + if (key == "BONE_FOREST" && sheetTitle == "Map Zones") + { + return "Bone Forest"; + } + + if (key == "TEST_AREA" && sheetTitle == "Map Zones") + { + return "Test area, TELL ME WHERE U FOUND THIS. Ping me @BubkisLord#5187 (discord)"; + } + + if (key == "DREAM_WORLD" && sheetTitle == "Map Zones") + { + return "Dream World"; + } + + if (key == "ELDERBUG_FLOWER" && sheetTitle == "Prompts") + { + return "Give him the Delicate Flower like a giga-chad?"; + } + + if (key == "ELDERBUG_INTRO_VISITEDCROSSROAD" && sheetTitle == "Elderbug") + { + return "WHAT THE HELL WAS THAT? THE ONLY VISITOR FOR YEARS JUST WALKS PAST ME? HOW DARE YOU! Go away!"; + } + + if (key == "ELDERBUG_DREAM" && sheetTitle == "Elderbug") + { + return "Hello? Is someone there? Who is that? Aah! What was that? That feeling. ...Like the cold, terrifying embrace of death..."; + } + + if (orig.Contains("Hollow Knight")) + { + return orig.Replace("Hollow Knight", "Infected Vessel"); + } + + if (orig.Contains("Pure Vessel")) + { + return orig.Replace("Pure Vessel", "Hollow Vessel"); + } + + if (orig.Contains("Mantis")) + { + return orig.Replace("Mantis", "Bubkis"); + } + + if (orig.Contains("mantis")) + { + return orig.Replace("mantis", "bubkis"); + } + + if (orig.Contains("The Forgotten Town")) + { + return orig.Replace("The Forgotten Town", "The Realm of Elderbug"); + } + + if (ZoteBorn.Instance.Equipped() && key == "" && sheetTitle == "Prices") + { + return "Test area, TELL ME WHERE U FOUND THIS. Ping me @BubkisLord#5187 (discord)"; + } + + return orig; + } + + private Menu MenuRef; + public MenuScreen GetMenuScreen(MenuScreen modListMenu, ModToggleDelegates? modtoggledelegates) + { + MenuRef ??= new Menu( + "CharmMod", + new Element[] + { + new MenuButton("Reset health", "Make health to max health.", (_) => HealthReset()), + new MenuButton("Add health", "Change health by 1.", (_) => AddHealth()), + new MenuButton("Take health", "Change health by -1.", (_) => TakeHealth()), + new MenuButton("Reset Max Health", "Sets max health to 5", (_) => MaxHealthReset()), + new MenuButton("Add Max Health", "Increase max health by one. (Equip and de-equip the slow soul charm to update)", (_) => AddMaxHealth()), + new MenuButton("Take Max Health", "Decrease max health by one. (Equip and de-equip the slow soul charm to update)", (_) => TakeMaxHealth()), + new MenuButton("Reset Soul", "Make soul the max soul amount.", (_) => HeroController.instance.AddMPCharge(PlayerData.instance.MPReserveMax)), + new MenuButton("Add Soul", "Add one charge of soul.", (_) => HeroController.instance.AddMPCharge(33)), + new MenuButton("Take Soul", "Take one charge of soul.", (_) => HeroController.instance.TakeMP(33)), + new MenuButton("Give Specific Charm", "+1 to charm select", (_) => SelectCharm(1)), + new MenuButton("Give Specific Charm", "Pick the charm", (_) => GiveSpecificCharm(charmSelect)), + new MenuButton("Give Charms", "Get all CharmMod charms.", (_) => CharmMod.Instance.GrantAllOurCharms()), + new MenuButton("Take Charms", "Take all CharmMod charms.", (_) => CharmMod.Instance.TakeAllOurCharms()) + } + ); + return MenuRef.GetMenuScreen(modListMenu); + } + + public int SelectCharm(int bubkis) + { + if (charmSelect > CharmMod.Instance.NewCharms) + { + charmSelect = 0; + } + charmSelect += bubkis; + return bubkis; + } + + public int GiveSpecificCharm(int bubkis) + { + CharmMod.Instance.GiveSpecificCharm(bubkis); + return bubkis; + } + + public void AddHealth() + { + HeroController.instance.AddHealth(1); + } + public void TakeHealth() + { + HeroController.instance.TakeHealth(1); + } + public void AddMaxHealth() + { + HeroController.instance.AddToMaxHealth(1); + PlayerData.instance.MaxHealth(); + HeroController.instance.MaxHealth(); + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = true; + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = false; + } + + public void TakeMaxHealth() + { + HeroController.instance.AddToMaxHealth(-1); + PlayerData.instance.MaxHealth(); + HeroController.instance.MaxHealth(); + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = true; + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = false; + } + public void MaxHealthReset() + { + var CurrentMaxHp = PlayerData.instance.maxHealth; + var WantedMaxHp = 5; + var MaxHpChangeAmount = WantedMaxHp - CurrentMaxHp; + HeroController.instance.AddToMaxHealth(MaxHpChangeAmount); + PlayerData.instance.MaxHealth(); + HeroController.instance.MaxHealth(); + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = true; + SoulSlow.Instance.Settings(CharmMod.Instance.Settings).Equipped = false; + } + + public void HealthReset() + { + var hp = PlayerData.instance.health; + var maxhp = PlayerData.instance.maxHealth; + var changeamount = maxhp - hp; + HeroController.instance.AddHealth(changeamount); + } + public void Unload() + { + throw new NotImplementedException(); + } + + public void OnLoadLocal(SaveSettings s) + { + throw new NotImplementedException(); + } + + public SaveSettings OnSaveLocal() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/SaveSettings.cs b/SaveSettings.cs index d1c3cc1..f2c47ba 100644 --- a/SaveSettings.cs +++ b/SaveSettings.cs @@ -11,7 +11,17 @@ public class SaveSettings public CharmSettings GlassCannon = new(); public CharmSettings WealthyAmulet = new(); public CharmSettings PowerfulDash = new(); - public CharmSettings TripleJump = new(); + public CharmSettings DoubleDash = new(); + public CharmSettings SoulSpeed = new(); + public CharmSettings SoulSpell = new(); + public CharmSettings SoulHunger = new(); + public CharmSettings RavenousSoul = new(); + public CharmSettings SoulSwitch = new(); + public CharmSettings HealthyShell = new(); + public CharmSettings GeoSwitch = new(); + public CharmSettings SoulSlow = new(); + public CharmSettings SlowTime = new(); + public CharmSettings SpeedTime = new(); public bool[] gotCharms = new[] { true, true, true, true }; public bool[] newCharms = new[] { false, false, false, false };