Skip to content

Commit

Permalink
fix: wrong damage
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Apr 8, 2022
1 parent 5683ffc commit 4e2292a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GodSeekerPlus/GodSeekerPlus.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>GodSeekerPlus</AssemblyTitle>
<Version>0.19.1</Version>
<Version>0.19.2</Version>
<Description>A Hollow Knight mod to enhance your Godhome experience</Description>
<Authors>Clazex</Authors>

Expand Down
31 changes: 24 additions & 7 deletions GodSeekerPlus/Modules/BossChallenge/P5Health.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
using MonoMod.RuntimeDetour;

namespace GodSeekerPlus.Modules.BossChallenge;

[ToggleableLevel(ToggleableLevel.ChangeScene)]
internal sealed class P5Health : Module {
private protected override void Load() =>
On.BossSceneController.Awake += OverrideLevel;
private Detour? detour = null;

private protected override void Load() {
detour = new(
ReflectionHelper.GetPropertyInfo(typeof(BossSceneController), "BossLevel").GetGetMethod(),
ReflectionHelper.GetMethodInfo(typeof(P5Health), nameof(OverrideLevel))
);

private protected override void Unload() =>
On.BossSceneController.Awake -= OverrideLevel;
ModHooks.TakeDamageHook += FixDamage;
}

private void OverrideLevel(On.BossSceneController.orig_Awake orig, BossSceneController self) {
orig(self);
private protected override void Unload() {
detour?.Dispose();

self.BossLevel = 0;
ModHooks.TakeDamageHook -= FixDamage;
}

private int OverrideLevel() => 0;

private int FixDamage(ref int hazardType, int damage) => BossSceneController.IsBossScene
? ReflectionHelper.GetField<BossSceneController, int>(BossSceneController.Instance, "bossLevel") switch {
1 => damage * 2,
2 => 9999,
_ => damage,
}
: damage;
}

0 comments on commit 4e2292a

Please sign in to comment.