From 531af0ab23bec5fea52b2c587d86dbf5caf95b9f Mon Sep 17 00:00:00 2001 From: BubkisLord <101391373+BubkisLord@users.noreply.github.com> Date: Sun, 5 Jun 2022 19:43:07 +0800 Subject: [PATCH] Add files via upload --- BetterCDash.cs | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ GlassCannon.cs | 64 +++++++++++++++++++++++++++++++++++++++++++++++ HKBlessing.cs | 39 +++++++++++++++++++++++++++++ HuntersMark.cs | 56 +++++++++++++++++++++++++++++++++++++++++ PowerfulDash.cs | 45 +++++++++++++++++++++++++++++++++ Quickfall.cs | 46 ++++++++++++++++++++++++++++++++++ Slowfall.cs | 46 ++++++++++++++++++++++++++++++++++ SturdyNail.cs | 43 ++++++++++++++++++++++++++++++++ TripleJump.cs | 55 ++++++++++++++++++++++++++++++++++++++++ WealthyAmulet.cs | 57 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 516 insertions(+) create mode 100644 BetterCDash.cs create mode 100644 GlassCannon.cs create mode 100644 HKBlessing.cs create mode 100644 HuntersMark.cs create mode 100644 PowerfulDash.cs create mode 100644 Quickfall.cs create mode 100644 Slowfall.cs create mode 100644 SturdyNail.cs create mode 100644 TripleJump.cs create mode 100644 WealthyAmulet.cs diff --git a/BetterCDash.cs b/BetterCDash.cs new file mode 100644 index 0000000..c483c78 --- /dev/null +++ b/BetterCDash.cs @@ -0,0 +1,65 @@ +using HutongGames.PlayMaker.Actions; + +namespace CharmMod +{ + internal class BetterCDash : Charm + { + public static readonly BetterCDash Instance = new(); + public override string Sprite => "BetterCDash.png"; + public override string Name => "Enraged Crystal Dash"; + public override string Description => "Desc"; + public override int DefaultCost => 3; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private BetterCDash() { } + + public override CharmSettings Settings(SaveSettings s) => s.BetterCDash; + + public override List<(string, string, Action)> FsmEdits => new() + { + ("SD Burst", "damages_enemy", IncreaseCDashDamage), + ("SuperDash Damage", "damages_enemy", IncreaseCDashDamage), + ("Knight", "Superdash", IncreaseCDashSpeed) + }; + + private const int DamageWhenEquipped = 50; + private const int DamageWhenUnequipped = 10; + + private void IncreaseCDashDamage(PlayMakerFSM fsm) + { + var sendEvent = fsm.GetState("Send Event"); + // Guard against the IntCompare action not being there. That sometimes happens, + // even though the code works. This is only to keep it from flooding modlog + // with spurious exceptions. + var damage = (sendEvent?.Actions[0] as IntCompare)?.integer1; + if (damage != null && sendEvent != null) + { + sendEvent.PrependAction(() => { + damage.Value = Equipped() ? DamageWhenEquipped : DamageWhenUnequipped; + }); + } + } + private const int SpeedWhenEquipped = 60; + private const int SpeedWhenUnequipped = 30; + + private void IncreaseCDashSpeed(PlayMakerFSM fsm) + { + var left = fsm.GetState("Left"); + var speed = (left.Actions[0] as SetFloatValue).floatVariable; + void SetLeftSpeed() + { + speed.Value = -(Equipped() ? SpeedWhenEquipped : SpeedWhenUnequipped); + } + void SetRightSpeed() + { + speed.Value = Equipped() ? SpeedWhenEquipped : SpeedWhenUnequipped; + } + left.ReplaceAction(0, SetLeftSpeed); + fsm.GetState("Right").ReplaceAction(0, SetRightSpeed); + fsm.GetState("Enter L").ReplaceAction(0, SetLeftSpeed); + fsm.GetState("Enter R").ReplaceAction(0, SetRightSpeed); + } + } +} \ No newline at end of file diff --git a/GlassCannon.cs b/GlassCannon.cs new file mode 100644 index 0000000..e3d6c59 --- /dev/null +++ b/GlassCannon.cs @@ -0,0 +1,64 @@ +using Modding; + +namespace CharmMod +{ + internal class GlassCannon : Charm + { + public static readonly GlassCannon Instance = new(); + public override string Sprite => "GlassCannon.png"; + public override string Name => "Charm of Radiance"; + public override string Description => "Desc"; + public override int DefaultCost => 3; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private GlassCannon() {} + + public override CharmSettings Settings(SaveSettings s) => s.GlassCannon; + + public override void Hook() + { + ModHooks.GetPlayerIntHook += BuffNail; + ModHooks.SetPlayerBoolHook += UpdateNailDamageOnEquip; + ModHooks.TakeHealthHook += OnHealthTaken; + } + private int BuffNail(string intName, int damage) + { + if (intName == "nailDamage" && Equipped()) + { + damage = 6000; + } + return damage; + } + private int OnHealthTaken(int damage) + { + if(Equipped()) { + PlayerData.instance.health = 0; + return damage; + } + else { + return damage; + } + } + internal static void UpdateNailDamage() + { + IEnumerator WaitThenUpdate() + { + yield return null; + PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); + } + GameManager.instance.StartCoroutine(WaitThenUpdate()); + } + + + private bool UpdateNailDamageOnEquip(string boolName, bool value) + { + if (boolName == $"equippedCharm_{Num}") + { + UpdateNailDamage(); + } + return value; + } + } +} \ No newline at end of file diff --git a/HKBlessing.cs b/HKBlessing.cs new file mode 100644 index 0000000..a610cc7 --- /dev/null +++ b/HKBlessing.cs @@ -0,0 +1,39 @@ +using HutongGames.PlayMaker.Actions; + +namespace CharmMod +{ + internal class HKBlessing : Charm + { + public static readonly HKBlessing Instance = new(); + public override string Sprite => "HKBlessing.png"; + public override string Name => "Hollow Knight's Blessing"; + public override string Description => "Desc"; + public override int DefaultCost => 2; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private HKBlessing() { } + + public override CharmSettings Settings(SaveSettings s) => s.HKBlessing; + + public override void Hook() + { + ModHooks.BlueHealthHook += BlueHPRestored; + } + + + //This snippet makes the lifeblood charms twice as effective. + public int BlueHPRestored() { + if (Equipped()) + { + int retValue = 0; + if (PlayerData.instance.GetBool("equippedCharm_8")) retValue += 2; + if (PlayerData.instance.GetBool("equippedCharm_9")) retValue += 4; + return retValue; + } + else + return 0; + } + } +} \ No newline at end of file diff --git a/HuntersMark.cs b/HuntersMark.cs new file mode 100644 index 0000000..9c27193 --- /dev/null +++ b/HuntersMark.cs @@ -0,0 +1,56 @@ +using Modding; +using UnityEngine; +using GlobalEnums; +using HutongGames.PlayMaker.Actions; + +namespace CharmMod +{ + internal class HuntersMark : Charm + { + public static readonly HuntersMark Instance = new(); + public override string Sprite => "HuntersMark.png"; + public override string Name => "The Hunter's Mark"; + public override string Description => "Desc"; + public override int DefaultCost => 0; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private HuntersMark() {} + + public override CharmSettings Settings(SaveSettings s) => s.HuntersMark; + + public override void Hook() + { + ModHooks.HeroUpdateHook += OnStep; + + } + + private void OnStep() + { + if(Equipped()) { + PlayerData pd = PlayerData.instance; + // Whether the player has the Hunter's Journal + pd.hasJournal = true; + // Last entry looked at + pd.lastJournalItem = 0; + // Whether the player has seen the journal message + pd.seenJournalMsg = true; + // Whether the player has seen the hunter message + pd.seenHunterMsg = true; + // Whether the player has a full journal + pd.fillJournal = true; + // Amount of completed entries + pd.journalEntriesCompleted = 164; + // Idk if it is used + pd.journalNotesCompleted = 164; + // Amount of total entries + pd.journalEntriesTotal = 164; + if (HeroController.instance == null) + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/PowerfulDash.cs b/PowerfulDash.cs new file mode 100644 index 0000000..713781e --- /dev/null +++ b/PowerfulDash.cs @@ -0,0 +1,45 @@ +namespace CharmMod +{ + internal class PowerfulDash : Charm + { + public static readonly PowerfulDash Instance = new(); + public override string Sprite => "PowerfulDash.png"; + public override string Name => "Powerful Dash"; + public override string Description => "Desc"; + public override int DefaultCost => 2; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private PowerfulDash() { } + + public override CharmSettings Settings(SaveSettings s) => s.PowerfulDash; + + public override void Hook() + { + ModHooks.DashVectorHook += ChangeDashVel; + } + //This snippet makes you accelerate during dashes + public Vector2 ChangeDashVel(Vector2 velocity ) { + if(PlayerData.instance.GetBool("equippedCharm_16") && !PlayerData.instance.GetBool("equippedCharm_31") && Equipped()) { + return velocity = velocity * 125 * Time.deltaTime; + } + if(PlayerData.instance.GetBool("equippedCharm_31") && !PlayerData.instance.GetBool("equippedCharm_16") && Equipped()) { + return velocity = velocity * 100 * Time.deltaTime; + } + if(PlayerData.instance.GetBool("equippedCharm_16") && PlayerData.instance.GetBool("equippedCharm_31") && Equipped()) { + return velocity = velocity * 165 * Time.deltaTime; + } + if(!PlayerData.instance.GetBool("equippedCharm_16") && !PlayerData.instance.GetBool("equippedCharm_31") && Equipped()) { + return velocity = velocity * 75 * Time.deltaTime; + } + if(!Equipped()) { + return velocity; + } + else + { + return velocity; + } + } + } +} \ No newline at end of file diff --git a/Quickfall.cs b/Quickfall.cs new file mode 100644 index 0000000..10e78f2 --- /dev/null +++ b/Quickfall.cs @@ -0,0 +1,46 @@ +using Modding; +using UnityEngine; +using GlobalEnums; + +namespace CharmMod +{ + internal class Quickfall : Charm + { + public static readonly Quickfall Instance = new(); + public override string Sprite => "Quickfall.png"; + public override string Name => "Quickfall"; + public override string Description => "Desc"; + public override int DefaultCost => 1; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private Quickfall() {} + + public override CharmSettings Settings(SaveSettings s) => s.Quickfall; + + public override void Hook() + { + ModHooks.HeroUpdateHook += ChangeGravity; + } + + private void ChangeGravity() + { + if (HeroController.instance == null) + { + return; + } + var rb = HeroController.instance.gameObject.GetComponent(); + // Gravity gets set to 0 during transitions; we must not mess with that or + // the game will hardlock bouncing back and forth between two rooms when + // passing through a horizontal transition. + if (rb.gravityScale == 0) + { + return; + } + // Keep normal gravity after going through upwards transitions, so that the player does not fall + // through spikes in some rooms before they gain control. + rb.gravityScale = (Equipped() && HeroController.instance.transitionState == HeroTransitionState.WAITING_TO_TRANSITION) ? 2.4f : 0.79f; + } + } +} \ No newline at end of file diff --git a/Slowfall.cs b/Slowfall.cs new file mode 100644 index 0000000..59fccf2 --- /dev/null +++ b/Slowfall.cs @@ -0,0 +1,46 @@ +using Modding; +using UnityEngine; +using GlobalEnums; + +namespace CharmMod +{ + internal class Slowfall : Charm + { + public static readonly Slowfall Instance = new(); + public override string Sprite => "Slowfall.png"; + public override string Name => "Slowfall"; + public override string Description => "Desc"; + public override int DefaultCost => 1; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private Slowfall() {} + + public override CharmSettings Settings(SaveSettings s) => s.Slowfall; + + public override void Hook() + { + ModHooks.HeroUpdateHook += ChangeGravity; + } + + private void ChangeGravity() + { + if (HeroController.instance == null) + { + return; + } + var rb = HeroController.instance.gameObject.GetComponent(); + // Gravity gets set to 0 during transitions; we must not mess with that or + // the game will hardlock bouncing back and forth between two rooms when + // passing through a horizontal transition. + if (rb.gravityScale == 0) + { + return; + } + // Keep normal gravity after going through upwards transitions, so that the player does not fall + // through spikes in some rooms before they gain control. + rb.gravityScale = (Equipped() && HeroController.instance.transitionState == HeroTransitionState.WAITING_TO_TRANSITION) ? 0.2f : 0.79f; + } + } +} \ No newline at end of file diff --git a/SturdyNail.cs b/SturdyNail.cs new file mode 100644 index 0000000..63e71ac --- /dev/null +++ b/SturdyNail.cs @@ -0,0 +1,43 @@ +using Modding; + +namespace CharmMod +{ + internal class SturdyNail : Charm + { + public static readonly SturdyNail Instance = new(); + public override string Sprite => "SturdyNail.png"; + public override string Name => "Sturdy Nail"; + public override string Description => "Desc"; + public override int DefaultCost => 2; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + private SturdyNail() {} + + public override CharmSettings Settings(SaveSettings s) => s.SturdyNail; + + public override void Hook() + { + ModHooks.GetPlayerIntHook += BuffNail; + ModHooks.SetPlayerBoolHook += UpdateNailDamageOnEquip; + } + + private int BuffNail(string intName, int damage) + { + if (intName == "nailDamage" && Equipped()) + { + damage = damage * 2; + } + return damage; + } + + private bool UpdateNailDamageOnEquip(string boolName, bool value) + { + if (boolName == $"equippedCharm_{Num}") + { + CharmMod.UpdateNailDamage(); + } + return value; + } + } +} \ No newline at end of file diff --git a/TripleJump.cs b/TripleJump.cs new file mode 100644 index 0000000..e0a4d1c --- /dev/null +++ b/TripleJump.cs @@ -0,0 +1,55 @@ +using Modding; + +namespace CharmMod +{ + internal class TripleJump : Charm + { + public static readonly TripleJump Instance = new(); + public override string Sprite => "SturdyNail.png"; + public override string Name => "Triple Jump"; + public override string Description => "Desc"; + public override int DefaultCost => 1; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + private TripleJump() {} + + public override CharmSettings Settings(SaveSettings s) => s.TripleJump; + + public override void Hook() + { + + } + + public int GainSoul(int amount) + { + if(Equipped()) { + if (PlayerData.instance.health == 1) { + HeroController.instance.TakeGeo(20); + return amount * 2; + } + else { + HeroController.instance.TakeGeo(10); + return amount; + } + } + else { + return amount; + } + } + + //healing costs 100 geo. + public int BeforeAddHealth( int amount ) { + if(Equipped()) { + if(PlayerData.instance.geo > 100 ) { + HeroController.instance.AddGeo(100); + return amount; + } + else + return 0; + } + else + return amount; + } + } +} \ No newline at end of file diff --git a/WealthyAmulet.cs b/WealthyAmulet.cs new file mode 100644 index 0000000..6f4ac6f --- /dev/null +++ b/WealthyAmulet.cs @@ -0,0 +1,57 @@ +using Modding; + +namespace CharmMod +{ + internal class WealthyAmulet : Charm + { + public static readonly WealthyAmulet Instance = new(); + public override string Sprite => "WealthyAmulet.png"; + public override string Name => "Amulet of Wealth"; + public override string Description => "Desc"; + public override int DefaultCost => 2; + public override string Scene => "Ruins2_11"; + public override float X => 0f; + public override float Y => 0f; + + private WealthyAmulet() {} + + public override CharmSettings Settings(SaveSettings s) => s.WealthyAmulet; + + public override void Hook() + { + ModHooks.BeforeAddHealthHook += BeforeAddHealth; + ModHooks.SoulGainHook += GainSoul; + } + + public int GainSoul(int amount) + { + if(Equipped()) { + if (PlayerData.instance.health == 1) { + HeroController.instance.AddGeo(20); + return amount * 2; + } + else { + HeroController.instance.AddGeo(10); + return amount; + } + } + else { + return amount; + } + } + + //healing costs 100 geo. + public int BeforeAddHealth( int amount ) { + if(Equipped()) { + if(PlayerData.instance.geo > 100 ) { + HeroController.instance.TakeGeo(100); + return amount; + } + else + return 0; + } + else + return amount; + } + } +} \ No newline at end of file