-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9df7b8
commit 531af0a
Showing
10 changed files
with
516 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PlayMakerFSM>)> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Rigidbody2D>(); | ||
// 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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Rigidbody2D>(); | ||
// 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; | ||
} | ||
} | ||
} |
Oops, something went wrong.