From 6f3c00edc789eaf447c4ff1bf9c692fb411490f5 Mon Sep 17 00:00:00 2001
From: Habble53 <87115317+Habble53@users.noreply.github.com>
Date: Fri, 22 May 2026 18:24:39 +0300
Subject: [PATCH] Made Morning Star and Kaleidoscope crit tags no longer apply
in the vanilla Damage() method to account for SummonTag class handling them
---
ILEditing/BalancingILChanges.cs | 34 +++++++++++++++++++++++++++++++++
ILEditing/ILChangesLoading.cs | 1 +
2 files changed, 35 insertions(+)
diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs
index 324678faa4..086b566167 100644
--- a/ILEditing/BalancingILChanges.cs
+++ b/ILEditing/BalancingILChanges.cs
@@ -850,5 +850,39 @@ namespace CalamityMod.ILEditing
});
}
#endregion
+
+ #region Remove Vanilla Whip Tag Crits
+ // Code written by Habble
+ ///
+ /// IL edits both vanilla whip crit tags' crit bool set calls to ensure they're never assigned a new value
+ ///
+ ///
+ private static void PreventVanillaWhipTagCrits(ILContext context)
+ {
+ ILCursor cursor = new(context);
+ #region Morning Star
+ // Go to the unique instructions nearest to the Morning Star tag's crit roll and then stand before the crit bool set call
+ if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdloc(59)) || !cursor.TryGotoNext(MoveType.Before, i => i.MatchStloc(30)))
+ {
+ LogFailure("Removing vanilla whip tag crits", "Could not locate the crit bool set call under Morning Star tag");
+ return;
+ }
+ // Put the previous value of the crit bool on the stack to then return that instead of the supplied value by "consuming" them as parameters, so as to not overwrite it
+ // This is more ideal than modifying label conditions because it is likelier for the latter to change over time
+ cursor.Emit(OpCodes.Ldloc, 30);
+ cursor.EmitDelegate((int input, bool originalValue) => originalValue.ToInt());
+ #endregion Morning Star
+ #region Kaleidoscope
+ // Similar deal for Kaleidoscope as well
+ if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(30)) || !cursor.TryGotoNext(MoveType.Before, i => i.MatchStloc(30)))
+ {
+ LogFailure("Removing vanilla whip tag crits", "Could not locate the crit bool set call under Kaleidoscope tag");
+ return;
+ }
+ cursor.Emit(OpCodes.Ldloc, 30);
+ cursor.EmitDelegate((int input, bool originalValue) => originalValue.ToInt());
+ #endregion Kaleidoscope
+ }
+ #endregion
}
}
diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs
index a4463dddb6..4000c108ed 100644
--- a/ILEditing/ILChangesLoading.cs
+++ b/ILEditing/ILChangesLoading.cs
@@ -104,6 +104,7 @@ namespace CalamityMod.ILEditing
// Damage and health balance
On_Main.DamageVar_float_int_float += AdjustDamageVariance;
IL_NPC.ScaleStats_ApplyExpertTweaks += RemoveExpertHardmodeScaling;
+ IL_Projectile.Damage += PreventVanillaWhipTagCrits;
IL_Projectile.Damage += VanillaBossResistChanges;
IL_Projectile.AI_026 += PygmyAggroOnClosestPointInHitbox;
IL_Projectile.AI_099_2 += LimitTerrarianProjectiles;