From f50440c39676021a2657432c1c778423cae857e5 Mon Sep 17 00:00:00 2001 From: Habble53 <87115317+Habble53@users.noreply.github.com> Date: Sat, 7 Feb 2026 14:47:39 +0300 Subject: [PATCH 1/3] Update BrainOfCthulhuSystem.cs --- .../Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs index e2e80efb76..65d889e6d2 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs @@ -230,6 +230,8 @@ public class BrainOfCthulhuSystem : ModSystem public override void PostUpdateNPCs() { + if (VerletTendrils is null) + return; if (!NPC.AnyNPCs(NPCID.BrainofCthulhu)) BrainOfCthulhuAI.SummonedViaItem = false; From fe4c3beb1892ad1f979fe60d7be09ced4f1a35d2 Mon Sep 17 00:00:00 2001 From: Habble53 <87115317+Habble53@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:01:33 +0300 Subject: [PATCH 2/3] Distance check on Sulph Sea Acid Bubble spawns --- Tiles/Abyss/SulphurousSand.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 4a5f1aa3da..e8ca086808 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -58,10 +58,24 @@ namespace CalamityMod.Tiles.Abyss { if (!Main.tile[i, tileLocationY].HasTile) { - if (!CalamityPlayer.areThereAnyDamnBosses && Main.tile[i, tileLocationY].LiquidAmount == 255 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && - Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && !Main.tile[i, tileLocationY - 2].HasTile && Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && !CalamityPlayer.areThereAnyDamnBosses) { - Projectile.NewProjectile(new EntitySource_WorldEvent(), (float)(i * 16 + 16), (float)(tileLocationY * 16 + 16), 0f, -0.1f, ModContent.ProjectileType(), 0, 2f, Main.myPlayer); + bool nearby = false; + Vector2 tileWorldPos = new Vector2(i, tileLocationY).ToWorldCoordinates(); + foreach (Player player in Main.ActivePlayers) + { + + if (!player.dead && !player.ghost && player.DistanceSQ(tileWorldPos) < 4000000f) // Don't spawn Acid Bubbles if no players are nearby + { + nearby = true; + break; + } + } + if (nearby && Main.tile[i, tileLocationY].LiquidAmount == 255 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && + Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && !Main.tile[i, tileLocationY - 2].HasTile) + { + Projectile.NewProjectile(new EntitySource_WorldEvent(), (float)(i * 16 + 16), (float)(tileLocationY * 16 + 16), 0f, -0.1f, ModContent.ProjectileType(), 0, 2f, Main.myPlayer); + } } if (i < 250 || i > Main.maxTilesX - 250) From 8715f73868df71e5d966139c8ed8e12870f047b7 Mon Sep 17 00:00:00 2001 From: Habble53 <87115317+Habble53@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:39:58 +0300 Subject: [PATCH 3/3] Pygmy Staff now checks for aggro distance based on closest points in hitboxes rather than the centers --- ILEditing/BalancingILChanges.cs | 68 +++++++++++++++++++++++++++++++++ ILEditing/ILChangesLoading.cs | 3 ++ 2 files changed, 71 insertions(+) diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 2e0e15714d..b9918f5a9b 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -748,5 +748,73 @@ namespace CalamityMod.ILEditing } } #endregion + + #region Tweak Pygmy Staff aggro distance logic + + private static void PygmyAggroOnClosestPointInHitbox(ILContext context) + { + ILCursor cursor = new(context); + if (!cursor.TryGotoNext(i => i.MatchStloc(131))) + {// Go to the latest newly set variable near the point we wanna be, as that is an easy unique instruction to jump to + // 131 is the number assigned to that variable in ILview + LogFailure("Tweaking Pygmy Staff aggro distance logic", "Could not locate unique Stloc(131) instruction nearest to aggro distance check."); + return; + } + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(126))) + {// Before the minion range variable emission so as to receive the value being targetted at it + LogFailure("Tweaking Pygmy Staff aggro distance logic", "Could not locate the minion range variable."); + return; + } + cursor.Emit(OpCodes.Ldarg_0); // Emit the Projectile entity as we are in Projectile.cs::AI_026 + cursor.Emit(OpCodes.Ldloc, 129); // Emit the NPC index via the incremented loop variable + cursor.Emit(OpCodes.Ldloc, 6); // Emit the bool containing type check for pygmies + cursor.EmitDelegate((float distance, Projectile projectile, int npcIndex, bool pygmy) => + {// Replace the distance with a different value calculated off of closest point in hitboxes + if (!pygmy) + return distance; + + NPC npc = Main.npc[npcIndex]; + Player player = Main.player[projectile.owner]; + float finalDistance = npc.Hitbox.ClosestPointInRect(player.Center).Distance(player.Hitbox.ClosestPointInRect(npc.Center)); + return finalDistance; + }); + // That was part 1, time for part 2. + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchStloc(185))) + {// Go directly before the instruction that's meant to receive the distance value of this tagged NPC + LogFailure("Tweaking Pygmy Staff aggro distance logic", "Could not locate first unique Stloc(185) instruction."); + return; + } + cursor.Emit(OpCodes.Ldarg_0); + cursor.Emit(OpCodes.Ldloc, 181); // Emit the tagged NPC + cursor.Emit(OpCodes.Ldloc, 6); + cursor.EmitDelegate((float distance, Projectile projectile, NPC npc, bool pygmy) => + {// Replace the distance with a different value calculated off of closest point in hitboxes + if (!pygmy) + return distance; + + float finalDistance = npc.Hitbox.ClosestPointInRect(projectile.Center).Distance(projectile.Hitbox.ClosestPointInRect(npc.Center)); + return finalDistance; + }); + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchStloc(189))) + {// Go directly before the instruction that's meant to receive the distance value of this NPC currently being iterated over + LogFailure("Tweaking Pygmy Staff aggro distance logic", "Could not locate first unique Stloc(189) instruction."); + return; + } + cursor.Emit(OpCodes.Ldarg_0); + cursor.Emit(OpCodes.Ldloc, 186); // Emit the NPC index via the incremented loop variable + cursor.Emit(OpCodes.Ldloc, 6); + cursor.EmitDelegate((float distance, Projectile projectile, int npcIndex, bool pygmy) => + {// Replace the distance with a different value calculated off of closest point in hitboxes + if (!pygmy) + return distance; + + NPC npc = Main.npc[npcIndex]; + float finalDistance = npc.Hitbox.ClosestPointInRect(projectile.Center).Distance(projectile.Hitbox.ClosestPointInRect(npc.Center)); + return finalDistance; + }); + } + + #endregion Tweak Pygmy Staff aggro distance logic } } diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index d5fb8e25e0..454d0141fb 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -187,6 +187,9 @@ namespace CalamityMod.ILEditing // Fix vanilla behaviour of not calling CheckDead for NPCs that realLife is set IL_NPC.StrikeNPC_HitInfo_bool_bool += EnsureCheckDeadOnSegments; + // Change Pygmy Staff minion AI to check distance based on closest points in hitboxes + IL_Projectile.AI_026 += PygmyAggroOnClosestPointInHitbox; + //Additional detours that are in their own item files given they are only relevant to these specific items: //Rover drive detours on Player.DrawInfernoRings to draw its shield //Wulfrum armor hooks on Player.KeyDoubleTap and DrawPendingMouseText to activate its set bonus and spoof the mouse text to display the stats of the activated weapon if shift is held