diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 25c3d2c67a..cda4b08a97 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -220,10 +220,6 @@ namespace CalamityMod.ILEditing On_Main.DrawPlayerChatBubbles += UI_Unflip_Start; On_Main.DrawInterface += UI_Unflip_End; - // Fix vanilla bugs exposed by Calamity mechanics - IL_NPC.NPCLoot += FixSplittingWormBannerDrops; - On_NPC.PlayerInteraction += FixSplittingWormInteraction; - // Fix vanilla not accounting for spritebatch modification in held projectile drawing On_PlayerDrawLayers.DrawHeldProj += FixHeldProjectileBlendState; diff --git a/ILEditing/VanillaBugfixingILChanges.cs b/ILEditing/VanillaBugfixingILChanges.cs index 69df735490..23b271f586 100644 --- a/ILEditing/VanillaBugfixingILChanges.cs +++ b/ILEditing/VanillaBugfixingILChanges.cs @@ -12,52 +12,6 @@ namespace CalamityMod.ILEditing { public partial class ILChanges { - #region Fixing Splitting Worm Banner Spam in Deathmode - // CONTEXT FOR FIX: In Death Mode, normal worms are capable of splitting similarly to the Eater of Worlds. This, as expected, comes with problems with loot dropping, as you can kill multiple - // head segments from the same original worm. TML allows us to safely handle this with its drop hooks. Unfortunately, however, this does not apply to banner dropping logic based on total kills or - // for bestiary registrations. - // As such, we must IL Edit the vanilla drop method to stop it from registering kills based on worms that can still be split. This references the same blocking logic as the aforementioned hooks. - private static void FixSplittingWormBannerDrops(ILContext il) - { - var cursor = new ILCursor(il); - - // Find the first return in the method. This will be marked as a label to jump to if the splitting loot check is failed, effectively terminating any and all - // loot code, including banners and bestiary stuff. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchRet())) - { - LogFailure("Splitting worm banner spam fix", "Could not locate the first method return."); - } - - // Save the ret as a place to return to. - ILLabel ret = cursor.MarkLabel(); - - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(0))) - { - LogFailure("Splitting worm banner spam fix", "Could not locate the closest player storage."); - return; - } - - // Load the NPC caller onto the stack. - cursor.Emit(OpCodes.Ldarg_0); - cursor.EmitDelegate>(npc => CalamityGlobalNPC.SplittingWormLootBlockWrapper(npc, CalamityMod.Instance)); - - // If the block is false (indicating the drop logic should stop), return the method early. - cursor.Emit(OpCodes.Brfalse, ret); - } - #endregion Fixing Splitting Worm Banner Spam in Deathmode - - #region Fixing Splitting Worm Interaction in Deathmode - // CONTEXT FOR FIX: In Death Mode, normal worms are capable of splitting similarly to the Eater of Worlds. This comes with problems with bestiary entries. The entries are incremented only when - // the killed npc is the head segment and it has been interacted at least once. These two conditions may be violated because NPC.NPCLoot only triggers once because of the above fix. - // The fix for former condition is in CalamityGlobalNPCLoot.OnKill. For the latter condition, NPC.PlayerInteraction should broadcast interaction to every other worm segments. - // This is already done for vanilla worm enemies like EOW. - private static void FixSplittingWormInteraction(On_NPC.orig_PlayerInteraction orig, NPC npc, int player) - { - orig(npc, player); - CalamityGlobalNPC.SplittingWormBroadcastInteractionWrapper(npc, player); - } - #endregion - #region Fixing Vanilla Not Accounting For Spritebatch Modification in Held Projectiles private static bool HasLoggedHeldProjectileBlendStateCatch = false; private void FixHeldProjectileBlendState(On_PlayerDrawLayers.orig_DrawHeldProj orig, PlayerDrawSet drawinfo, Projectile proj) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 006d5bdc34..77cd50d0bf 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1411,11 +1411,6 @@ namespace CalamityMod.NPCs #region Revengeance and Death Mode Stat Changes private void RevDeathStatChanges(NPC npc, Mod mod) { - if (CalamityNPCSets.DeathModeSplittingWorm[npc.type] && CalamityWorld.death) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.15); - } - if (npc.type == NPCID.Mothron) { npc.scale *= 1.25f; @@ -3713,21 +3708,6 @@ namespace CalamityMod.NPCs case NPCID.BloodEelBody: case NPCID.BloodEelTail: return RevengeanceAndDeathAI.BuffedWormAI(npc, Mod); - - // Death Mode splitting worms. - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - if (CalamityWorld.death) - return RevengeanceAndDeathAI.BuffedWormAI(npc, Mod); - else - return true; } break; @@ -7555,26 +7535,6 @@ namespace CalamityMod.NPCs } } - if (CalamityWorld.death) - { - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - return true; - - default: - break; - } - } - return null; } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 9b12e70b82..9ffa8cc567 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1945,14 +1945,6 @@ namespace CalamityMod.NPCs if (AcidRainEvent.AcidRainEventIsOngoing) AcidRainEvent.OnEnemyKill(npc); - // Stop Death Mode splitting worms from dropping excessive loot - if (CalamityWorld.death && !SplittingWormLootBlockWrapper(npc, Mod)) - DropHelper.BlockEverything(); - - // Correctly increment bestiary entries for splitting worms - if (npc.AnyInteractions()) - SplittingWormBestiaryUpdate(npc); - // Determine whether this NPC is the second Twin killed in a fight, regardless of which Twin it is. bool lastTwinStanding = false; if (npc.type == NPCID.Retinazer) @@ -2205,121 +2197,5 @@ namespace CalamityMod.NPCs } } #endregion - - #region Splitting Worm Loot - internal static void SplittingWormBroadcastInteractionWrapper(NPC npc, int player) - { - if (!CalamityWorld.death) - return; - - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.DiggerHead, NPCID.DiggerBody, NPCID.DiggerTail); - return; - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.SeekerHead, NPCID.SeekerBody, NPCID.SeekerTail); - return; - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.DuneSplicerHead, NPCID.DuneSplicerBody, NPCID.DuneSplicerTail); - return; - } - } - - internal static void SplittingWormBroadcastInteraction(NPC npc, int player, int head, int body, int tail) - { - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) - { - n.ApplyInteraction(player); - } - } - } - - internal static void SplittingWormBestiaryUpdate(NPC npc) - { - if (!CalamityWorld.death) - return; - - switch (npc.type) - { - case NPCID.DiggerBody: - case NPCID.DiggerTail: - NPC diggerHead = new(); - diggerHead.SetDefaults(NPCID.DiggerHead); - Main.BestiaryTracker.Kills.RegisterKill(diggerHead); - return; - case NPCID.SeekerBody: - case NPCID.SeekerTail: - NPC seekerHead = new(); - seekerHead.SetDefaults(NPCID.SeekerHead); - Main.BestiaryTracker.Kills.RegisterKill(seekerHead); - return; - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - NPC duneSplicerHead = new(); - duneSplicerHead.SetDefaults(NPCID.DuneSplicerHead); - Main.BestiaryTracker.Kills.RegisterKill(duneSplicerHead); - return; - } - } - - internal static bool SplittingWormLootBlockWrapper(NPC npc, Mod mod) - { - if (!CalamityWorld.death) - return true; - - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - return SplittingWormLoot(npc, mod, 0); - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - return SplittingWormLoot(npc, mod, 1); - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - return SplittingWormLoot(npc, mod, 2); - default: - return true; - } - } - - internal static bool SplittingWormLoot(NPC npc, Mod mod, int wormType) - { - switch (wormType) - { - case 0: return CheckSegments(NPCID.DiggerHead, NPCID.DiggerBody, NPCID.DiggerTail); - case 1: return CheckSegments(NPCID.SeekerHead, NPCID.SeekerBody, NPCID.SeekerTail); - case 2: return CheckSegments(NPCID.DuneSplicerHead, NPCID.DuneSplicerBody, NPCID.DuneSplicerTail); - default: - break; - } - - bool CheckSegments(int head, int body, int tail) - { - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) - { - return false; - } - } - return true; - } - - return true; - } - #endregion } } diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs index fdeb333044..f9722a2b14 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs @@ -4318,25 +4318,9 @@ PrepareToShoot: bool wormHead = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); float acceleration = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; - bool isSplittingNPC = (npc.type >= NPCID.DiggerHead && npc.type <= NPCID.DiggerTail) || (npc.type >= NPCID.SeekerHead && npc.type <= NPCID.SeekerTail) || (npc.type >= NPCID.DuneSplicerHead && npc.type <= NPCID.DuneSplicerTail); - - bool isSplittingNPCHead = npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.DuneSplicerHead; - - bool isSplittingNPCBody = npc.type == NPCID.DiggerBody || npc.type == NPCID.SeekerBody || npc.type == NPCID.DuneSplicerBody; - - bool isSplittingNPCTail = npc.type == NPCID.DiggerTail || npc.type == NPCID.SeekerTail || npc.type == NPCID.DuneSplicerTail; - - if (isSplittingNPC) - { - npc.realLife = -1; - } - else - { - npc.defense = (int)Math.Round(npc.defDefense * 1.3); - - if (npc.ai[3] > 0f) - npc.realLife = (int)npc.ai[3]; - } + npc.defense = (int)Math.Round(npc.defDefense * 1.3); + if (npc.ai[3] > 0f) + npc.realLife = (int)npc.ai[3]; if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) { @@ -4467,15 +4451,12 @@ PrepareToShoot: currentBloodEel = bloodEelSegment; } } - else if ((isSplittingNPCHead || isSplittingNPCBody || npc.type == NPCID.GiantWormHead || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerHead || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody) && npc.ai[0] == 0f) + else if ((npc.type == NPCID.GiantWormHead || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerHead || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody) && npc.ai[0] == 0f) { - if (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead) + if (npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead) { - if (!isSplittingNPCHead) - { - npc.ai[3] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - } + npc.ai[3] = (float)npc.whoAmI; + npc.realLife = npc.whoAmI; switch (npc.type) { @@ -4504,7 +4485,7 @@ PrepareToShoot: npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } - else if ((isSplittingNPCBody || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechBody) && npc.ai[2] > 0f) + else if ((npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechBody) && npc.ai[2] > 0f) { npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } @@ -4513,90 +4494,32 @@ PrepareToShoot: npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } - if (!isSplittingNPC) - { - Main.npc[(int)npc.ai[0]].ai[3] = npc.ai[3]; - Main.npc[(int)npc.ai[0]].realLife = npc.realLife; - } + Main.npc[(int)npc.ai[0]].ai[3] = npc.ai[3]; + Main.npc[(int)npc.ai[0]].realLife = npc.realLife; Main.npc[(int)npc.ai[0]].ai[1] = (float)npc.whoAmI; Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f; npc.netUpdate = true; } - if (!isSplittingNPC) + if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) { - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle) { - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - if (npc.ai[0] > 0f && npc.ai[0] < (float)Main.npc.Length) - { - if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.active = false; + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); } } - else + if (npc.ai[0] > 0f && npc.ai[0] < (float)Main.npc.Length) { - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) + if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle) { npc.life = 0; npc.HitEffect(0, 10.0); - npc.checkDead(); npc.active = false; NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); } - if (isSplittingNPCHead && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (isSplittingNPCTail && !Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle)) - { - npc.type = npc.type - 1; - int whoAmI = npc.whoAmI; - float currentHealthAmt = (float)npc.life / (float)npc.lifeMax; - float newSegment = npc.ai[0]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * currentHealthAmt); - npc.ai[0] = newSegment; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI; - } - if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) - { - int whoAmI2 = npc.whoAmI; - float currentHealthAmt2 = (float)npc.life / (float)npc.lifeMax; - float newSegment = npc.ai[1]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * currentHealthAmt2); - npc.ai[1] = newSegment; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI2; - } } if (!npc.active && Main.dedServ) @@ -4667,7 +4590,7 @@ PrepareToShoot: } } - if (!flying && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) + if (!flying && (npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); int noFlyZone = 1000; diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 3b0852464f..596ac189ab 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -176,14 +176,6 @@ namespace CalamityMod.Systems.Collections NPCID.Butcher, NPCID.CreatureFromTheDeep, NPCID.Fritz, NPCID.Nailhead, NPCID.Psycho, NPCID.DeadlySphere, NPCID.DrManFly, NPCID.ThePossessed, NPCID.Mothron, NPCID.MothronEgg, NPCID.MothronSpawn); - // TODO: This set should really also handle the actual splitting behavior and loot, but unsure of the best way to do that looking at what we have right now - /// - /// If for an NPC type, then that NPC is part of a worm which splits in Death Mode. Solely used to reduce their max health to 15% of its standard value.
- /// Defaults to . - ///
- public static bool[] DeathModeSplittingWorm = Factory.CreateBoolSet(NPCID.DuneSplicerHead, NPCID.DuneSplicerBody, NPCID.DuneSplicerTail, - NPCID.DiggerHead, NPCID.DiggerBody, NPCID.DiggerTail, NPCID.SeekerHead, NPCID.SeekerBody, NPCID.SeekerTail); - /// /// If for an NPC type, then the NPC will receive a 30 second global cooldown to slowing debuffs after being inflicted by one.
/// Also used to prevent weapon pulling effects and Anarchy Blade's ability to instantly kill enemies that are below 50% health.