From a9d53bce0742504f0f0946d94906e99f1003a542 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 17 Dec 2025 13:17:44 +0900 Subject: [PATCH 01/23] Remove Deleted Namespace Using --- Systems/World/WorldgenManagementSystem.cs | 3 +-- Utilities/TileUtils.cs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Systems/World/WorldgenManagementSystem.cs b/Systems/World/WorldgenManagementSystem.cs index 14afae8ce8..95afc5eb94 100644 --- a/Systems/World/WorldgenManagementSystem.cs +++ b/Systems/World/WorldgenManagementSystem.cs @@ -5,7 +5,6 @@ using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.World; -using CalamityMod.World.Minibiomes; using CalamityMod.World.Planets; using Microsoft.Xna.Framework; using Terraria; @@ -195,7 +194,7 @@ namespace CalamityMod.Systems } } } - + })); } diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index c1557689c3..28e6382e8d 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -8,7 +8,6 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FloralParadise; using CalamityMod.Tiles.FurnitureAbyss; using CalamityMod.Tiles.FurnitureAshen; using CalamityMod.Tiles.FurnitureDriftwood; From 76f0b67e6678f0899f532fdf55e6c8efb7306e42 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 17 Dec 2025 14:54:49 -0500 Subject: [PATCH 02/23] Update RecipeSystem.cs --- Systems/Mechanic/RecipeSystem.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Systems/Mechanic/RecipeSystem.cs b/Systems/Mechanic/RecipeSystem.cs index a1f1fbd91a..3023f9758e 100644 --- a/Systems/Mechanic/RecipeSystem.cs +++ b/Systems/Mechanic/RecipeSystem.cs @@ -1578,15 +1578,6 @@ namespace CalamityMod.Systems r.Register(); r.DisableDecraft(); - // Rod of Discord - r = Recipe.Create(ItemID.RodofDiscord); - r.AddIngredient(ItemID.SoulofLight, 30); - r.AddIngredient(ItemID.CrystalShard, 25); - r.AddIngredient(ItemID.ChaosFish, 5); - r.AddTile(TileID.MythrilAnvil); - r.Register(); - r.DisableDecraft(); - // Sergeant United Shield r = Recipe.Create(ItemID.BouncingShield); r.AddRecipeGroup(AnyCobaltBar, 12); From 5e2618a6df8a46e677ecf1c2650884fde9febf5d Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 17 Dec 2025 15:33:29 -0500 Subject: [PATCH 03/23] Shield of the Ocean and Flame-Licked Shell cooldown icons --- Cooldowns/FlameShellParry.png | Bin 0 -> 433 bytes Cooldowns/FlameShellParryOutline.png | Bin 0 -> 222 bytes Cooldowns/FlameShellParryOverlay.png | Bin 0 -> 186 bytes Cooldowns/OceanShieldParry.png | Bin 0 -> 409 bytes Cooldowns/OceanShieldParryOutline.png | Bin 0 -> 238 bytes Cooldowns/OceanShieldParryOverlay.png | Bin 0 -> 199 bytes Cooldowns/ParryCooldown.cs | 15 ++++++--------- 7 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 Cooldowns/FlameShellParry.png create mode 100644 Cooldowns/FlameShellParryOutline.png create mode 100644 Cooldowns/FlameShellParryOverlay.png create mode 100644 Cooldowns/OceanShieldParry.png create mode 100644 Cooldowns/OceanShieldParryOutline.png create mode 100644 Cooldowns/OceanShieldParryOverlay.png diff --git a/Cooldowns/FlameShellParry.png b/Cooldowns/FlameShellParry.png new file mode 100644 index 0000000000000000000000000000000000000000..1de70227c23b63542816e4ad9bb6e12c88a49e3d GIT binary patch literal 433 zcmV;i0Z#sjP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0Y*tgK~y+TwUj+e z!%!54pNMhkP)H-TP%t8bQtHy+AZ{Y+7$+COA(Q{YpWx!`=;SOo3F4w%1hFV$ghGTQ zLIOgzIwUvbqlH3~ce>p7+r=A4YSTuhAq`HirqJ&}OGM_D6ns?H6Ll bsdU1BM%!pXmnMZt00000NkvXXu0mjfp;WQL literal 0 HcmV?d00001 diff --git a/Cooldowns/FlameShellParryOutline.png b/Cooldowns/FlameShellParryOutline.png new file mode 100644 index 0000000000000000000000000000000000000000..6caa5c1762aeff4508b3bb5410984e151b038357 GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!D3Gr#}E(ix03_;4k&OqzkFAp{%x~VaB@N3 zj2S=vwQx)kiC`};@0~f5v4Qu=$x!=g5BR0j^FP1jI<@acXt@RV>!sQjyiS*-P4@lm zy5=3;u>Y_BIa!{~_03Jc%Ei`BUbo<5U5WTaufN;l7+?CX5_Vgny@QdrHTv0^a}j(% P>lr*<{an^LB{Ts5q(@LP literal 0 HcmV?d00001 diff --git a/Cooldowns/FlameShellParryOverlay.png b/Cooldowns/FlameShellParryOverlay.png new file mode 100644 index 0000000000000000000000000000000000000000..4a34ae3a0c2bd18df6c2a52f01fc0be12d29256e GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0WL{IK~y+T#gs8i zLQxcezZbd|v^Xac1r9|m5f~=a5}}1djr|Crse(WdngYkSwpD|}E093YNyS0PrJ=F0 zBq*$2!}HX;w=M*|SKo3u=bp>`IEQ;J4D3v=x&GL`u2}xq#E72wEyi2La5Fy%fYW{g z;J8vYp5b2%iz{0IG{;)-1JmFQ^=S&yyZQS$CI7k<1E6T1DtRGr!$@O13cyij0)Uyj zuD3H>_Y?8YYM`9k2H@qUr{te)2f{G?nAFr_&IQ;Tcz2{``@S-;Rto^Q7bO4=6YJnJ zla~~pp&+J0HTeiYCzb@@!MO!sd0_*9-OCdQ(=ehZdi67lZ+;swtL4)GjP|{kqZ7E{ zmmccBjF=rn-;}y^HlxH>=T-O literal 0 HcmV?d00001 diff --git a/Cooldowns/OceanShieldParryOutline.png b/Cooldowns/OceanShieldParryOutline.png new file mode 100644 index 0000000000000000000000000000000000000000..19d632eb2fd4a1ce1f444ad30d1008f5bdb14b3b GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!Ddev#}E(itCMf@H5hO>AN~J7y=LR-AZIQ^ z0o(lD47$l>9Cz-1-#YW=zOXra4BPIfd{^H0oMA=rg?9NS%G}c0*}aI1_r*vAk26?e?8VwxFg ze_ys!nAJ5U&8&|xL1y);`8Ry$y=u)-tJP2Onx#L-bJ0@n|MxfSzw$2j)7A5wH&=a` rH^Fu3_m;q!@8@3lua_0OYXhURrG`jv!oNd6dl)=j{an^LB{Ts5+`~p2 literal 0 HcmV?d00001 diff --git a/Cooldowns/ParryCooldown.cs b/Cooldowns/ParryCooldown.cs index c226732eb7..fa400a7016 100644 --- a/Cooldowns/ParryCooldown.cs +++ b/Cooldowns/ParryCooldown.cs @@ -30,17 +30,14 @@ namespace CalamityMod.Cooldowns cooldownColorStart = new Color(181, 136, 177); cooldownColorEnd = new Color(255, 194, 161); break; - - //readd if spritework for the cooldown is done at a later point - /*case "flamelickedshell": - skinTexture = "FlameLickedShellParry"; + case "flamelickedshell": + skinTexture = "FlameShellParry"; outlineColor = new Color(211, 124, 93); - cooldownColorStart = Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - (instance?.Completion ?? 0)); - cooldownColorEnd = Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - (instance?.Completion ?? 0)); - break;*/ + cooldownColorStart = new Color(107, 6, 6); + cooldownColorEnd = new Color(228, 78, 78); + break; case "shieldoftheocean": - // skinTexture = "ShieldOfTheOceanParry"; - skinTexture = "ParryCooldown"; + skinTexture = "OceanShieldParry"; outlineColor = Color.White; cooldownColorStart = new Color(233, 111, 165); cooldownColorEnd = new Color(105, 139, 148); From d0167ffe4e4d1eaf935d58a55caffcce2b5ee4c7 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Tue, 9 Dec 2025 08:22:05 +0900 Subject: [PATCH 04/23] Separate StealthStrikePrefixBonus from CalamityGlobalItem --- CalPlayer/CalamityPlayer.cs | 6 +++--- Items/CalamityGlobalItem.cs | 19 ------------------- Items/RogueGlobalItem.cs | 33 +++++++++++++++++++++++++++++++++ Prefixes/RogueWeaponPrefix.cs | 5 +++-- 4 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 Items/RogueGlobalItem.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5521a0b86d..072b2e0681 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4861,13 +4861,13 @@ namespace CalamityMod.CalPlayer #region Get Weapon Damage And KB public override void ModifyWeaponDamage(Item item, ref StatModifier damage) { - if (item.CountsAsClass()) + if (item.CountsAsClass() && item.TryGetGlobalItem(out var rogueItem)) { // Apply weapon modifier stealth strike damage bonus // 01OCT2023: Ozzatron: This is a multiplicative bonus because it is a prefix. // It should be equivalent to x1.15 (or whatever multiplier) on the base damage of the weapon for stealth only. - if (item.Calamity().StealthStrikePrefixBonus != 0f && StealthStrikeAvailable()) - damage *= item.Calamity().StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage. + if (rogueItem.StealthStrikePrefixBonus != 0f && StealthStrikeAvailable()) + damage *= rogueItem.StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage. } } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 93bbdc5796..e68e7c24ac 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -52,10 +52,6 @@ namespace CalamityMod.Items { public override bool InstancePerEntity => true; - // TODO -- split out a separate GlobalItem for rogue behavior? - /// Tracks the stealth strike damage modifier for this item, derived from its prefix. - internal float StealthStrikePrefixBonus; - private BitsByte flag0 = 0; #region Chargeable Item Variables @@ -150,11 +146,6 @@ namespace CalamityMod.Items public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); - public CalamityGlobalItem() - { - StealthStrikePrefixBonus = 0f; - } - // Ozzatron 21MAY2022: This function is required by TML 1.4's new clone behavior. // This behavior is sadly mandatory because there are a few places in vanilla Terraria which use cloning. // Most notably: reforging and item tooltips. @@ -169,9 +160,6 @@ namespace CalamityMod.Items // BitFlags myClone.flag0 = flag0; - // Rogue - myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; - // Charge (Draedon's Arsenal) myClone.UsesCharge = UsesCharge; myClone.Charge = Charge; @@ -1684,13 +1672,6 @@ namespace CalamityMod.Items public static int RarityCalamityRedBuyPrice => Rarity17BuyPrice; #endregion - #region PreReforge - public override void PreReforge(Item item) - { - StealthStrikePrefixBonus = 0f; - } - #endregion - // // !! WARNING !! // diff --git a/Items/RogueGlobalItem.cs b/Items/RogueGlobalItem.cs new file mode 100644 index 0000000000..0215e92a00 --- /dev/null +++ b/Items/RogueGlobalItem.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items +{ + public sealed class RogueGlobalItem : GlobalItem + { + public override bool InstancePerEntity => true; + + /// Tracks the stealth strike damage modifier for this item, derived from its prefix. + internal float StealthStrikePrefixBonus = 0.0f; + + public override GlobalItem Clone(Item from, Item to) + { + RogueGlobalItem myClone = (RogueGlobalItem)base.Clone(from, to); + + // Rogue + myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; + + return myClone; + } + + public override bool AppliesToEntity(Item entity, bool lateInstantiation) + { + return entity.CountsAsClass(); + } + + public override void PreReforge(Item item) + { + StealthStrikePrefixBonus = 0f; + } + } +} diff --git a/Prefixes/RogueWeaponPrefix.cs b/Prefixes/RogueWeaponPrefix.cs index 56bfb5bd0b..0298790b1d 100644 --- a/Prefixes/RogueWeaponPrefix.cs +++ b/Prefixes/RogueWeaponPrefix.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Items; using Terraria; using Terraria.Localization; using Terraria.ModLoader; @@ -153,8 +154,8 @@ namespace CalamityMod.Prefixes // Applying stealth strike damage public override void Apply(Item item) { - if (item.CountsAsClass()) - item.Calamity().StealthStrikePrefixBonus = stealthDmgMult; + if (item.CountsAsClass() && item.TryGetGlobalItem(out var rogueItem)) + rogueItem.StealthStrikePrefixBonus = stealthDmgMult; } // Changing value based on prefix tier (rarity is set automatically around value multiplier) From d98449a007a4c405a52bd071d5c4ddfb836fdbc2 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 17 Dec 2025 14:01:03 +0900 Subject: [PATCH 05/23] Add Property to turn off AI Overrides --- ModSupport/ModCalls.cs | 17 ++++++++++++++++- NPCs/CalamityVanillaAIOverrideNPC.cs | 25 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 8be16c09d9..b7820a0559 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -1022,7 +1022,7 @@ namespace CalamityMod case "Ectoheart": player.Calamity().adrenalineBoostThree = value; break; case "CelestialOnion": player.Calamity().extraAccessoryML = value; break; - }; + } } #endregion @@ -1781,6 +1781,21 @@ namespace CalamityMod return null; } + case "GetVanillaAIOverrideEnabled": + { + return CalamityVanillaAIOverrideNPC.Enabled; + } + + case "SetVanillaAIOverrideEnabled": + { + if (args.Length < 1) + return new ArgumentNullException(nameof(args), "ERROR: Must specify a bool parameter"); + if (args[0] is not bool aiOverrideEnabled) + return new ArgumentException("ERROR: The third argument to \"SetVanillaAIOverrideEnabled\" must be a bool."); + CalamityVanillaAIOverrideNPC.Enabled = aiOverrideEnabled; + return null; + } + case "GetCalamityAI": case "GetNewAI": { diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index d0c53b0f67..c0521ba3b9 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -46,6 +46,11 @@ public static class VanillaAIOverrideExtension public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC { + /// + /// Toggle Entire System. External mods can toggle this out if they want. + /// + public static bool Enabled { get; set; } = true; + /// /// Specify the AI Override to work with. This handles AI, SendExtraAI and ReceiveExtraAI in instaned manner. /// @@ -881,16 +886,18 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC public override void SetDefaults(NPC npc) { - // Clients will get their instance in ReceiveExtraAI - if (Main.netMode != NetmodeID.MultiplayerClient) - { - AIOverride = GetVanillaAIOverrideToApply(npc); + if (!Enabled) + return; - if (AIOverride != null) - { - AIOverride.NPC = npc; - AIOverride.SetDefaults(Mod); - } + // Clients will get their instance in ReceiveExtraAI + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + AIOverride = GetVanillaAIOverrideToApply(npc); + if (AIOverride != null) + { + AIOverride.NPC = npc; + AIOverride.SetDefaults(Mod); } } From bc4dc07b946230ca20ffd7ef30c79c1314435d88 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 17 Dec 2025 14:55:38 +0900 Subject: [PATCH 06/23] Decouple NPC overrides in CalamityGlobalNPC so it could be opt-out --- NPCs/CalamityGlobalNPC.cs | 620 ------------------ NPCs/CalamityVanillaAIOverrideNPC.Global.cs | 359 ++++++++++ NPCs/CalamityVanillaAIOverrideNPC.cs | 36 +- .../Bosses/BrainOfCthulhuAI.cs | 63 ++ NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs | 53 ++ .../Bosses/PlanteraAI.cs | 75 +++ .../Bosses/SkeletronAI.cs | 43 ++ .../Bosses/SkeletronPrimeAI.cs | 42 ++ .../Bosses/WallOfFleshAI.cs | 27 + 9 files changed, 695 insertions(+), 623 deletions(-) create mode 100644 NPCs/CalamityVanillaAIOverrideNPC.Global.cs diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index fb7bb4e422..a053e8554d 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -11,7 +11,6 @@ using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.ExtraTextures; using CalamityMod.Graphics.Metaballs; using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Items; @@ -2915,49 +2914,12 @@ namespace CalamityMod.NPCs if (CalamityNPCSets.DealsZeroContactDamage[npc.type] && !(npc.type == NPCID.RuneWizard && Main.zenithWorld)) npc.damage = 0; - // Don't do damage for 42 frames after spawning in - if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) - npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; - if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC && !DoesNotDisappearInBossRush) BossRushForceDespawnOtherNPCs(npc, Mod); if (NPC.LunarApocalypseIsUp) PillarEventProgressionEdit(npc); - // Servant of Cthulhu light - if (npc.type == NPCID.ServantofCthulhu) - Lighting.AddLight(npc.Center, 0.2f, 0.2f, 0.2f); - - if (npc.type == NPCID.CultistBoss) - { - // Emit light - float lifeRatio = npc.life / (float)npc.lifeMax; - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - - // Decrement the hit counter for the shield flicker - if (newAI[1] > 0f) - newAI[1] -= 1f; - - // Cultist shield hitbox - Vector2 hitboxSize = new Vector2(216f / 1.4142f); - if (npc.Size != hitboxSize) - npc.Size = hitboxSize; - } - if (npc.type == NPCID.CultistBossClone) - { - if (Main.npc[(int)npc.ai[3]].active) - { - // Emit light - float lifeRatio = Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax; - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - } - } - #region Fairies Edit // Fairies don't run away and are immune to damage while wearing Fairy Boots. if (npc.type >= NPCID.FairyCritterPink && npc.type <= NPCID.FairyCritterBlue && (npc.ai[2] < 2f || npc.ai[2] == 7f)) @@ -3311,114 +3273,6 @@ namespace CalamityMod.NPCs } #endregion - #region AI - public override void AI(NPC npc) - { - // Fair contact damage - switch (npc.type) - { - case NPCID.DD2Betsy: - npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; - break; - - case NPCID.DD2WyvernT1: - case NPCID.DD2WyvernT2: - case NPCID.DD2WyvernT3: - npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; - break; - - case NPCID.Mothron: - npc.damage = npc.ai[0] == 3.2f ? (int)Math.Round(npc.defDamage * 1.3) : npc.ai[0] == 2f ? (int)Math.Round(npc.defDamage * 0.5) : 0; - break; - - case NPCID.MothronSpawn: - npc.damage = npc.ai[0] == 2.1f ? npc.defDamage : 0; - break; - - case NPCID.Mimic: - case NPCID.IceMimic: - case NPCID.PresentMimic: - npc.damage = (npc.ai[0] == 0f || npc.velocity.Y == 0f) ? 0 : npc.defDamage; - break; - - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - npc.damage = npc.ai[0] == 3f ? 0 : npc.defDamage; - - // Spend less time in closed state - if (npc.ai[0] == 3f) - npc.ai[1] += 0.5f; - - break; - - case NPCID.MartianDrone: - case NPCID.SolarCorite: - npc.damage = (npc.ai[0] == 2f || npc.ai[0] == 3f) ? npc.defDamage : 0; - break; - - case NPCID.GraniteFlyer: - npc.damage = npc.ai[0] == -1f ? 0 : npc.defDamage; - break; - - case NPCID.GraniteGolem: - npc.damage = npc.ai[2] < 0f ? 0 : npc.defDamage; - break; - - case NPCID.BlueSlime: - case NPCID.MotherSlime: - case NPCID.LavaSlime: - case NPCID.DungeonSlime: - case NPCID.CorruptSlime: - case NPCID.IlluminantSlime: - case NPCID.ToxicSludge: - case NPCID.IceSlime: - case NPCID.Crimslime: - case NPCID.UmbrellaSlime: - case NPCID.RainbowSlime: - case NPCID.SlimeMasked: - case NPCID.HoppinJack: - case NPCID.SlimeRibbonWhite: - case NPCID.SlimeRibbonYellow: - case NPCID.SlimeRibbonGreen: - case NPCID.SlimeRibbonRed: - case NPCID.SandSlime: - case NPCID.GoldenSlime: - case NPCID.ShimmerSlime: - case NPCID.GreenSlime: - case NPCID.RedSlime: - case NPCID.PurpleSlime: - case NPCID.YellowSlime: - case NPCID.BlackSlime: - case NPCID.JungleSlime: - case NPCID.BabySlime: - case NPCID.Pinky: - case NPCID.Slimeling: - case NPCID.Slimer2: - npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; - break; - - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.2) : 0; - break; - - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.4) : 0; - break; - - case NPCID.SolarSroller: - npc.damage = npc.ai[0] == 6f ? (int)Math.Round(npc.defDamage * 1.2) : 0; - break; - - default: - break; - } - } - #endregion - #region Post AI public override void PostAI(NPC npc) { @@ -4991,17 +4845,6 @@ namespace CalamityMod.NPCs #region Drawing public override void FindFrame(NPC npc, int frameHeight) { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - // Used to force the head to look to the sides for the laser spread attack - if (npc.type == NPCID.GolemHead && (npc.ai[0] == 2f || npc.ai[0] == 3f)) - { - if (npc.localAI[1] == 1f) - npc.frame.Y = frameHeight * 2; - else - npc.frame.Y = frameHeight * 4; - } - } // Increment the bestiary worm timer when hovering over the NPC or having their entry open. Pauses otherwise if (npc.IsABestiaryIconDummy) { @@ -5516,86 +5359,6 @@ namespace CalamityMod.NPCs TownNPCAlertSystem(npc, Mod, spriteBatch); - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) - shouldDrawBool = false; - - // Allows correct frames to draw in Rev+ phases - // GFB can rot for all I care - if (npc.type == NPCID.SkeletronPrime && !NPC.IsMechQueenUp) - { - int frameHeight = TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type]; - if (npc.ai[1] == 0f || npc.ai[1] == 4f) - { - newAI[2] += 1f; - if (newAI[2] >= 12f) - { - newAI[2] = 0f; - newAI[3] += frameHeight; - - if (newAI[3] / frameHeight >= 2f) - newAI[3] = 0f; - } - } - - // Spinning probe spawn or fly over phase - else if (npc.ai[1] == 5f || npc.ai[1] == 6f) - { - newAI[2] = 0f; - newAI[3] = frameHeight; - } - - // Spinning phase - else - { - newAI[2] = 0f; - newAI[3] = frameHeight * 2; - } - - npc.frame.Y = (int)newAI[3]; - } - - if (npc.type == NPCID.GolemHeadFree) - { - // Draw the head as usual. - Texture2D golemHeadTexture = TextureAssets.Npc[npc.type].Value; - Vector2 headDrawPosition = npc.Center - screenPos; - spriteBatch.Draw(golemHeadTexture, headDrawPosition, npc.frame, npc.GetAlpha(drawColor), 0f, npc.frame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - - // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. - Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); - Vector2 eyesDrawPosition = headDrawPosition - npc.scale * new Vector2(1f, 12f); - Rectangle eyesFrame = new Rectangle(0, 0, TextureAssets.Golem[1].Value.Width, TextureAssets.Golem[1].Value.Height / 2); - spriteBatch.Draw(TextureAssets.Golem[1].Value, eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - - // Draw the glowmasks. - int frameCounter = (int)npc.frameCounter / 4; - Rectangle frame = TextureAssets.Extra[ExtrasID.GolemLights4].Value.Frame(1, 8); - frame.Y += frame.Height * 2 * frameCounter + npc.frame.Y; - Rectangle glowFrame = frame; - spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights4].Value, eyesDrawPosition, glowFrame, eyeColor, 0f, glowFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - frame = npc.frame; - Rectangle glowFrame2 = frame; - spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights5].Value, eyesDrawPosition, glowFrame2, eyeColor, 0f, glowFrame2.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - - // Draw the sparkle telegraphs for the laser spread attack if applicable. - if (npc.ai[0] == 3f && npc.ai[1] <= 60f) - { - spriteBatch.SetBlendState(BlendState.Additive); - for (int i = -1; i <= 1; i += 2) - { - Texture2D sparkle = Request("CalamityMod/Particles/Sparkle2").Value; - Vector2 sparkleDraw = headDrawPosition + new Vector2(14f * i, -15f) * npc.scale; - Color drawFade = Color.Yellow * Utils.GetLerpValue(0, 30, 60f - npc.ai[1], true); - spriteBatch.Draw(sparkle, sparkleDraw, null, drawFade, MathHelper.Pi * 0.02f * npc.ai[1] * i, sparkle.Size() / 2f, 1.25f * npc.scale, SpriteEffects.None, 0f); - } - spriteBatch.SetBlendState(BlendState.AlphaBlend); - } - shouldDrawBool = false; - } - } - // VHex, Mana Burn and Miracle Blight visuals do not appear if Odd Mushroom is in use for sanity reasons if (!Main.LocalPlayer.Calamity().trippy) { @@ -5656,389 +5419,6 @@ namespace CalamityMod.NPCs return shouldDrawBool; } - public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Energy shield - if (npc.type == NPCID.CultistBoss || npc.type == NPCID.CultistBossClone) - { - spriteBatch.EnterShaderRegion(); - - float intensity = newAI[1] / 35f; - float lifeRatio = npc.type == NPCID.CultistBoss ? (npc.life / (float)npc.lifeMax) : (Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax); - - float flickerPower = 0f; - if (lifeRatio < 0.85f) - flickerPower += 0.1f; - if (lifeRatio < 0.7f) - flickerPower += 0.1f; - if (lifeRatio < 0.55f) - flickerPower += 0.1f; - if (lifeRatio < 0.4f) - flickerPower += 0.1f; - if (lifeRatio < 0.25f) - flickerPower += 0.1f; - if (lifeRatio < 0.1f) - flickerPower += 0.1f; - - float opacity = 1f; - opacity *= MathHelper.Lerp(MathHelper.Max(1f - flickerPower, 0.56f), 1f, (float)Math.Pow(Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.Lerp(3f, 5f, flickerPower)) * 0.5 + 0.5, 24D)); - - // Dampen the opacity and intensity slightly, to allow Cultist to be more easily visible inside of the forcefield. - // Dampen the opacity and intensity a bit more for the Clones. - float intensityAndOpacityMult = npc.type == NPCID.CultistBossClone ? 0.9f : 1f; - intensity *= intensityAndOpacityMult; - opacity *= intensityAndOpacityMult; - - Texture2D forcefieldTexture = SupremeCalamitas.SupremeCalamitas.ForcefieldTexture.Value; - - if (npc.type == NPCID.CultistBoss) - GameShaders.Misc["CalamityMod:SupremeShield"].SetShaderTexture(Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); - else - GameShaders.Misc["CalamityMod:SupremeShield"].UseImage1("Images/Misc/noise"); - - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color forcefieldColor = Color.Lerp(Color.MediumSpringGreen, Color.Black, colorTransitionAmt); - Color secondaryForcefieldColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - - forcefieldColor *= opacity; - secondaryForcefieldColor *= opacity; - - GameShaders.Misc["CalamityMod:SupremeShield"].UseSecondaryColor(secondaryForcefieldColor); - GameShaders.Misc["CalamityMod:SupremeShield"].UseColor(forcefieldColor); - GameShaders.Misc["CalamityMod:SupremeShield"].UseSaturation(1); - GameShaders.Misc["CalamityMod:SupremeShield"].UseOpacity(0.65f); - GameShaders.Misc["CalamityMod:SupremeShield"].Apply(); - - // Actual Cultist has a bigger shield than the Clones. - float shieldScale = npc.type == NPCID.CultistBossClone ? 1.65f : MathHelper.Lerp(1.65f, 3f, (float)Math.Pow((double)lifeRatio, 2D)); - spriteBatch.Draw(forcefieldTexture, npc.Center - Main.screenPosition, null, Color.White * opacity, 0f, forcefieldTexture.Size() * 0.5f, shieldScale, SpriteEffects.None, 0f); - - spriteBatch.ExitShaderRegion(); - } - - // Destroyer drawing and laser telegraphs - else if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) && !npc.IsABestiaryIconDummy) - { - Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Color segmentDrawColor = npc.GetAlpha(drawColor); - - // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) - { - for (int m = y; m <= y2; m++) - { - if (Lighting.Brightness(l, m) == 0f) - segmentDrawColor = Color.Black; - } - } - - // Draw segments - spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - - // Draw lights - if (npc.ai[2] == 0f && segmentDrawColor != Color.Black) - { - // This life ratio is fine now because all Destroyer segments update to have the same amount of life every frame - float destroyerLifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase4 = destroyerLifeRatio < (death ? 0.4f : 0.25f); - bool phase5 = destroyerLifeRatio < (death ? 0.2f : 0.1f); - - // Spawn DR check - bool hasSpawnDR = newAI[1] < DestroyerAI.DRIncreaseTime && newAI[1] > 60f; - - // Gradual color transition from ground to flight and vice versa - // 0f = Red, 1f = Purple - float phaseTransitionColorAmount = (hasSpawnDR || phase5) ? 1f : 0f; - if (!hasSpawnDR && !phase5) - { - if (newAI[3] >= DestroyerAI.GroundTelegraphStartGateValue) - phaseTransitionColorAmount = MathHelper.Clamp(1f - (newAI[3] - DestroyerAI.GroundTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); - else if (newAI[3] >= DestroyerAI.FlightTelegraphStartGateValue) - phaseTransitionColorAmount = MathHelper.Clamp((newAI[3] - DestroyerAI.FlightTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); - } - - // Light colors - int alpha = 192; - Color groundColor = new Color(150, 0, 0, alpha); - Color flightColor = revenge ? new Color(0, 0, 150, alpha) : groundColor; - Color segmentColor = Color.Lerp(groundColor, flightColor, phaseTransitionColorAmount); - Color telegraphColor_Red = new Color(255, 125, 125, alpha); - Color telegraphColor_Green = new Color(125, 255, 125, alpha); - Color telegraphColor_Cyan = new Color(0, 255, 255, alpha); - Color telegraphColor = telegraphColor_Red; - - // Telegraph for body lasers - float telegraphProgress = 0f; - if (npc.TryGetAIOverride(out var destroyerAI) && destroyerAI.LaserColor != -1) - { - float shootProjectileTime = death ? (phase5 ? 180f : phase4 ? 270f : 360f) : 450f; - float telegraphGateValue = shootProjectileTime - DestroyerAI.LaserTelegraphTime; - if (newAI[0] > telegraphGateValue) - { - switch (destroyerAI.LaserColor) - { - default: - case 0: - break; - case 1: - telegraphColor = telegraphColor_Green; - break; - case 2: - telegraphColor = telegraphColor_Cyan; - break; - } - telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); - } - } - - Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerHeadGlowmask.Value : TextureAssets.Dest[0].Value; - switch (npc.type) - { - default: - case NPCID.TheDestroyer: - break; - case NPCID.TheDestroyerBody: - glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerBodyGlowmask.Value : TextureAssets.Dest[1].Value; - break; - case NPCID.TheDestroyerTail: - glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerTailGlowmask.Value : TextureAssets.Dest[2].Value; - break; - } - - float alphaMultiplier = 1f - npc.alpha / 255f; - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, Color.Lerp(segmentColor, telegraphColor, telegraphProgress) * alphaMultiplier, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - - // Laser telegraph - else if (npc.type == NPCID.Probe) - { - float eyeTelegraphGateValue = (NPC.IsMechQueenUp ? DestroyerAI.ProbeLaserGateValue_Mechdusa : revenge ? DestroyerAI.ProbeLaserGateValue_Rev : DestroyerAI.ProbeLaserGateValue) - DestroyerAI.ProbeLaserTelegraphTime; - Texture2D glowTexture = Request("CalamityMod/Particles/Sparkle").Value; - Vector2 halfSize = npc.frame.Size() / 2; - - Vector2 drawPosition = npc.Center - screenPos + Vector2.UnitX.RotatedBy(npc.rotation) * (npc.width * 0.45f * npc.spriteDirection) + Vector2.UnitY * npc.gfxOffY; - float colorScale = MathHelper.Clamp((npc.localAI[0] - eyeTelegraphGateValue) / DestroyerAI.ProbeLaserTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(255, 100, 150, 192) * colorScale; - spriteBatch.SetBlendState(BlendState.Additive); - spriteBatch.Draw(glowTexture, drawPosition, npc.frame, drawColor2, npc.rotation, halfSize, npc.scale * 1.1f, SpriteEffects.None, 0f); - spriteBatch.SetBlendState(BlendState.AlphaBlend); - } - - if (revenge) - { - // Telegraph for charge and blood shots - if (npc.type == NPCID.Creeper) - { - if (NPC.crimsonBoss < 0) - return; - - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; - if (brainIsInPhase2) - { - Color currentColor = npc.GetAlpha(drawColor); - float opacity = (1f - Main.npc[NPC.crimsonBoss].life / (float)Main.npc[NPC.crimsonBoss].lifeMax) * 2f; - opacity *= opacity; - if (Main.getGoodWorld) - opacity = 1f; - - opacity = MathHelper.Clamp(opacity, 0f, 1f); - currentColor.R = (byte)(currentColor.R * opacity); - currentColor.G = (byte)(currentColor.G * opacity); - currentColor.B = (byte)(currentColor.B * opacity); - currentColor.A = (byte)(currentColor.A * opacity); - int totalAfterimages = 4; - for (int i = 0; i < totalAfterimages; i++) - { - Vector2 position = npc.position; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (i == 0 || i == 2) - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - else - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - - position.X -= npc.width / 2; - if (i == 0 || i == 1) - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - else - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - - position.Y -= npc.height / 2; - - int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); - int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + npc.width / 2 - width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - - float beginTelegraphGateValue = BrainOfCthulhuAI.TimeBeforeCreeperAttack - BrainOfCthulhuAI.CreeperTelegraphTime; - if (npc.ai[1] > beginTelegraphGateValue || npc.ai[0] == 1f) - { - float colorScale = npc.ai[0] == 1f ? 1f : MathHelper.Clamp((npc.ai[1] - beginTelegraphGateValue) / BrainOfCthulhuAI.CreeperTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 30, 30, 0) * colorScale; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Telegraph for charges - else if (npc.type == NPCID.SkeletronHead) - { - float beginTelegraphGateValue = SkeletronAI.ChargeGateValue - SkeletronAI.ChargeTelegraphTime; - if (npc.localAI[1] > beginTelegraphGateValue) - { - float colorScale = MathHelper.Clamp((npc.localAI[1] - beginTelegraphGateValue) / SkeletronAI.ChargeTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Telegraph for slaps - else if (npc.type == NPCID.SkeletronHand) - { - float beginTelegraphGateValue = SkeletronAI.HandSlapGateValue - SkeletronAI.HandSlapTelegraphTime; - if (newAI[2] > beginTelegraphGateValue) - { - float colorScale = MathHelper.Clamp((newAI[2] - beginTelegraphGateValue) / SkeletronAI.HandSlapTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Vector2 glowOffset = Vector2.UnitY * 8f; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY) - glowOffset, npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Laser telegraph - else if (npc.type == NPCID.WallofFleshEye && Main.wofNPCIndex >= 0) - { - bool enraged = npc.localAI[3] > 0f; - float eyeTelegraphGateValue = WallOfFleshAI.LaserShootGateValue - WallOfFleshAI.LaserShootTelegraphTime; - if (npc.localAI[1] > eyeTelegraphGateValue || npc.localAI[2] > 0f || enraged) - { - Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.WallOfFleshEyeGlowmask.Value : TextureAssets.Npc[npc.type].Value; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - float colorScale = enraged ? MathHelper.Clamp(npc.localAI[3] / WallOfFleshAI.EnragedLaserFiringDuration, 0f, 1f) : - npc.localAI[2] > 0f ? 1f - ((npc.localAI[2] - 1f) / WallOfFleshAI.TotalLasersPerBarrage) : - MathHelper.Clamp((npc.localAI[1] - eyeTelegraphGateValue) / WallOfFleshAI.LaserShootTelegraphTime, 0f, 1f); - - Color drawColor2 = new Color(100, 0, 200, 192) * colorScale; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - else if (npc.type == NPCID.Plantera) - { - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; - SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Color originalColor = npc.GetAlpha(drawColor); - Color newColor = new Color(100, 255, 100, 255); - Vector2 glowOffset = Vector2.UnitY * -4f; - Vector2 drawPosition = npc.Center - screenPos + new Vector2(0, npc.gfxOffY) + glowOffset; - Vector2 origin = npc.frame.Size() / 2; - - bool phase2 = lifeRatio <= 0.5f; - if (!phase2) - { - float telegraphTimer = Math.Abs(npc.ai[1]); - bool startSeedGatlingSporeGasTelegraph = npc.ai[1] > PlanteraAI.SeedGatlingColorChangeGateValue; - bool endSeedGatlingSporeGasTelegraph = npc.ai[1] < -PlanteraAI.SeedGatlingDuration + PlanteraAI.SeedGatlingColorChangeDuration; - if (startSeedGatlingSporeGasTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - PlanteraAI.SeedGatlingColorChangeGateValue) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - - // -300 to -120 - else if (endSeedGatlingSporeGasTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - (PlanteraAI.SeedGatlingDuration - PlanteraAI.SeedGatlingColorChangeDuration)) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - else - { - float telegraphTimer = Math.Abs(npc.ai[3]); - bool startChargeTelegraph = npc.ai[3] > PlanteraAI.ChargeTelegraphColorChangeGateValue; - bool endChargeTelegraph = npc.ai[3] <= -2f; - if (startChargeTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - PlanteraAI.ChargeTelegraphColorChangeGateValue) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - - // -195 to -2 - else if (endChargeTelegraph) - { - float telegraphScalar = MathHelper.Clamp((Math.Abs(PlanteraAI.StopChargeGateValue) - telegraphTimer) / Math.Abs(PlanteraAI.StopChargeGateValue), 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - - if (CalamityClientConfig.Instance.Afterimages) - { - int afterimageAmount = 10; - int afterImageIncrement = 2; - for (int j = 0; j < afterimageAmount; j += afterImageIncrement) - { - Color afterimageColor = telegraphColor; - afterimageColor = Color.Lerp(afterimageColor, originalColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (afterimageAmount - j) / 15f; - Vector2 afterimagePos = npc.oldPos[j] + new Vector2(npc.width, npc.height) / 2f - screenPos; - afterimagePos -= new Vector2(npcTexture.Width, npcTexture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY) + glowOffset; - spriteBatch.Draw(npcTexture, afterimagePos, npc.frame, afterimageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - } - } - } - public static Color buffColor(Color newColor, float R, float G, float B, float A) { newColor.R = (byte)((float)newColor.R * R); diff --git a/NPCs/CalamityVanillaAIOverrideNPC.Global.cs b/NPCs/CalamityVanillaAIOverrideNPC.Global.cs new file mode 100644 index 0000000000..87a35a5a30 --- /dev/null +++ b/NPCs/CalamityVanillaAIOverrideNPC.Global.cs @@ -0,0 +1,359 @@ +using System; +using CalamityMod.Events; +using CalamityMod.ExtraTextures; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.Systems.Collections; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs; + +public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC +{ + private static bool GlobalPreAI(NPC npc) + { + var calNPC = npc.GetGlobalNPC(); + + // Don't do damage for 42 frames after spawning in + if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) + npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; + + // Servant of Cthulhu light + if (npc.type == NPCID.ServantofCthulhu) + Lighting.AddLight(npc.Center, 0.2f, 0.2f, 0.2f); + + if (npc.type == NPCID.CultistBoss) + { + // Emit light + float lifeRatio = npc.life / (float)npc.lifeMax; + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); + + // Decrement the hit counter for the shield flicker + if (calNPC.newAI[1] > 0f) + calNPC.newAI[1] -= 1f; + + // Cultist shield hitbox + Vector2 hitboxSize = new Vector2(216f / 1.4142f); + if (npc.Size != hitboxSize) + npc.Size = hitboxSize; + } + if (npc.type == NPCID.CultistBossClone) + { + if (Main.npc[(int)npc.ai[3]].active) + { + // Emit light + float lifeRatio = Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax; + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); + } + } + + return true; + } + + private static void GlobalAI(NPC npc) + { + // Fair contact damage + switch (npc.type) + { + case NPCID.DD2Betsy: + npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; + break; + + case NPCID.DD2WyvernT1: + case NPCID.DD2WyvernT2: + case NPCID.DD2WyvernT3: + npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; + break; + + case NPCID.Mothron: + npc.damage = npc.ai[0] == 3.2f ? (int)Math.Round(npc.defDamage * 1.3) : npc.ai[0] == 2f ? (int)Math.Round(npc.defDamage * 0.5) : 0; + break; + + case NPCID.MothronSpawn: + npc.damage = npc.ai[0] == 2.1f ? npc.defDamage : 0; + break; + + case NPCID.Mimic: + case NPCID.IceMimic: + case NPCID.PresentMimic: + npc.damage = (npc.ai[0] == 0f || npc.velocity.Y == 0f) ? 0 : npc.defDamage; + break; + + case NPCID.BigMimicCorruption: + case NPCID.BigMimicCrimson: + case NPCID.BigMimicHallow: + case NPCID.BigMimicJungle: + npc.damage = npc.ai[0] == 3f ? 0 : npc.defDamage; + + // Spend less time in closed state + if (npc.ai[0] == 3f) + npc.ai[1] += 0.5f; + + break; + + case NPCID.MartianDrone: + case NPCID.SolarCorite: + npc.damage = (npc.ai[0] == 2f || npc.ai[0] == 3f) ? npc.defDamage : 0; + break; + + case NPCID.GraniteFlyer: + npc.damage = npc.ai[0] == -1f ? 0 : npc.defDamage; + break; + + case NPCID.GraniteGolem: + npc.damage = npc.ai[2] < 0f ? 0 : npc.defDamage; + break; + + case NPCID.BlueSlime: + case NPCID.MotherSlime: + case NPCID.LavaSlime: + case NPCID.DungeonSlime: + case NPCID.CorruptSlime: + case NPCID.IlluminantSlime: + case NPCID.ToxicSludge: + case NPCID.IceSlime: + case NPCID.Crimslime: + case NPCID.UmbrellaSlime: + case NPCID.RainbowSlime: + case NPCID.SlimeMasked: + case NPCID.HoppinJack: + case NPCID.SlimeRibbonWhite: + case NPCID.SlimeRibbonYellow: + case NPCID.SlimeRibbonGreen: + case NPCID.SlimeRibbonRed: + case NPCID.SandSlime: + case NPCID.GoldenSlime: + case NPCID.ShimmerSlime: + case NPCID.GreenSlime: + case NPCID.RedSlime: + case NPCID.PurpleSlime: + case NPCID.YellowSlime: + case NPCID.BlackSlime: + case NPCID.JungleSlime: + case NPCID.BabySlime: + case NPCID.Pinky: + case NPCID.Slimeling: + case NPCID.Slimer2: + npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; + break; + + case NPCID.GiantShelly: + case NPCID.GiantShelly2: + npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.2) : 0; + break; + + case NPCID.GiantTortoise: + case NPCID.IceTortoise: + npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.4) : 0; + break; + + case NPCID.SolarSroller: + npc.damage = npc.ai[0] == 6f ? (int)Math.Round(npc.defDamage * 1.2) : 0; + break; + + default: + break; + } + } + + private static bool GlobalPreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + var calNPC = npc.GetGlobalNPC(); + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Destroyer drawing and laser telegraphs + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) && !npc.IsABestiaryIconDummy) + { + Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; + Vector2 halfSize = npc.frame.Size() / 2; + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color segmentDrawColor = npc.GetAlpha(drawColor); + + // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly + int x = (int)((npc.position.X - 8f) / 16f); + int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); + int y = (int)((npc.position.Y - 8f) / 16f); + int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); + for (int l = x; l <= x2; l++) + { + for (int m = y; m <= y2; m++) + { + if (Lighting.Brightness(l, m) == 0f) + segmentDrawColor = Color.Black; + } + } + + // Draw segments + spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + + // Draw lights + if (npc.ai[2] == 0f && segmentDrawColor != Color.Black) + { + // This life ratio is fine now because all Destroyer segments update to have the same amount of life every frame + float destroyerLifeRatio = npc.life / (float)npc.lifeMax; + + // Phases + bool phase4 = destroyerLifeRatio < (death ? 0.4f : 0.25f); + bool phase5 = destroyerLifeRatio < (death ? 0.2f : 0.1f); + + // Spawn DR check + bool hasSpawnDR = calNPC.newAI[1] < DestroyerAI.DRIncreaseTime && calNPC.newAI[1] > 60f; + + // Gradual color transition from ground to flight and vice versa + // 0f = Red, 1f = Purple + float phaseTransitionColorAmount = (hasSpawnDR || phase5) ? 1f : 0f; + if (!hasSpawnDR && !phase5) + { + if (calNPC.newAI[3] >= DestroyerAI.GroundTelegraphStartGateValue) + phaseTransitionColorAmount = MathHelper.Clamp(1f - (calNPC.newAI[3] - DestroyerAI.GroundTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); + else if (calNPC.newAI[3] >= DestroyerAI.FlightTelegraphStartGateValue) + phaseTransitionColorAmount = MathHelper.Clamp((calNPC.newAI[3] - DestroyerAI.FlightTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); + } + + // Light colors + int alpha = 192; + Color groundColor = new Color(150, 0, 0, alpha); + Color flightColor = revenge ? new Color(0, 0, 150, alpha) : groundColor; + Color segmentColor = Color.Lerp(groundColor, flightColor, phaseTransitionColorAmount); + Color telegraphColor_Red = new Color(255, 125, 125, alpha); + Color telegraphColor_Green = new Color(125, 255, 125, alpha); + Color telegraphColor_Cyan = new Color(0, 255, 255, alpha); + Color telegraphColor = telegraphColor_Red; + + // Telegraph for body lasers + float telegraphProgress = 0f; + if (npc.TryGetAIOverride(out var destroyerAI) && destroyerAI.LaserColor != -1) + { + float shootProjectileTime = death ? (phase5 ? 180f : phase4 ? 270f : 360f) : 450f; + float telegraphGateValue = shootProjectileTime - DestroyerAI.LaserTelegraphTime; + if (calNPC.newAI[0] > telegraphGateValue) + { + switch (destroyerAI.LaserColor) + { + default: + case 0: + break; + case 1: + telegraphColor = telegraphColor_Green; + break; + case 2: + telegraphColor = telegraphColor_Cyan; + break; + } + telegraphProgress = MathHelper.Clamp((calNPC.newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); + } + } + + Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerHeadGlowmask.Value : TextureAssets.Dest[0].Value; + switch (npc.type) + { + default: + case NPCID.TheDestroyer: + break; + case NPCID.TheDestroyerBody: + glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerBodyGlowmask.Value : TextureAssets.Dest[1].Value; + break; + case NPCID.TheDestroyerTail: + glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerTailGlowmask.Value : TextureAssets.Dest[2].Value; + break; + } + + float alphaMultiplier = 1f - npc.alpha / 255f; + spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, Color.Lerp(segmentColor, telegraphColor, telegraphProgress) * alphaMultiplier, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + } + return false; + } + return true; + } + + private static void GlobalPostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + var calNPC = npc.GetGlobalNPC(); + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Energy shield + if (npc.type == NPCID.CultistBoss || npc.type == NPCID.CultistBossClone) + { + spriteBatch.EnterShaderRegion(); + + float intensity = calNPC.newAI[1] / 35f; + float lifeRatio = npc.type == NPCID.CultistBoss ? (npc.life / (float)npc.lifeMax) : (Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax); + + float flickerPower = 0f; + if (lifeRatio < 0.85f) + flickerPower += 0.1f; + if (lifeRatio < 0.7f) + flickerPower += 0.1f; + if (lifeRatio < 0.55f) + flickerPower += 0.1f; + if (lifeRatio < 0.4f) + flickerPower += 0.1f; + if (lifeRatio < 0.25f) + flickerPower += 0.1f; + if (lifeRatio < 0.1f) + flickerPower += 0.1f; + + float opacity = 1f; + opacity *= MathHelper.Lerp(MathHelper.Max(1f - flickerPower, 0.56f), 1f, (float)Math.Pow(Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.Lerp(3f, 5f, flickerPower)) * 0.5 + 0.5, 24D)); + + // Dampen the opacity and intensity slightly, to allow Cultist to be more easily visible inside of the forcefield. + // Dampen the opacity and intensity a bit more for the Clones. + float intensityAndOpacityMult = npc.type == NPCID.CultistBossClone ? 0.9f : 1f; + intensity *= intensityAndOpacityMult; + opacity *= intensityAndOpacityMult; + + Texture2D forcefieldTexture = SupremeCalamitas.SupremeCalamitas.ForcefieldTexture.Value; + + if (npc.type == NPCID.CultistBoss) + GameShaders.Misc["CalamityMod:SupremeShield"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); + else + GameShaders.Misc["CalamityMod:SupremeShield"].UseImage1("Images/Misc/noise"); + + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color forcefieldColor = Color.Lerp(Color.MediumSpringGreen, Color.Black, colorTransitionAmt); + Color secondaryForcefieldColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + + forcefieldColor *= opacity; + secondaryForcefieldColor *= opacity; + + GameShaders.Misc["CalamityMod:SupremeShield"].UseSecondaryColor(secondaryForcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseColor(forcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseSaturation(1); + GameShaders.Misc["CalamityMod:SupremeShield"].UseOpacity(0.65f); + GameShaders.Misc["CalamityMod:SupremeShield"].Apply(); + + // Actual Cultist has a bigger shield than the Clones. + float shieldScale = npc.type == NPCID.CultistBossClone ? 1.65f : MathHelper.Lerp(1.65f, 3f, (float)Math.Pow((double)lifeRatio, 2D)); + spriteBatch.Draw(forcefieldTexture, npc.Center - Main.screenPosition, null, Color.White * opacity, 0f, forcefieldTexture.Size() * 0.5f, shieldScale, SpriteEffects.None, 0f); + + spriteBatch.ExitShaderRegion(); + } + + // Laser telegraph + else if (npc.type == NPCID.Probe) + { + float eyeTelegraphGateValue = (NPC.IsMechQueenUp ? DestroyerAI.ProbeLaserGateValue_Mechdusa : revenge ? DestroyerAI.ProbeLaserGateValue_Rev : DestroyerAI.ProbeLaserGateValue) - DestroyerAI.ProbeLaserTelegraphTime; + Texture2D glowTexture = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Vector2 halfSize = npc.frame.Size() / 2; + + Vector2 drawPosition = npc.Center - screenPos + Vector2.UnitX.RotatedBy(npc.rotation) * (npc.width * 0.45f * npc.spriteDirection) + Vector2.UnitY * npc.gfxOffY; + float colorScale = MathHelper.Clamp((npc.localAI[0] - eyeTelegraphGateValue) / DestroyerAI.ProbeLaserTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(255, 100, 150, 192) * colorScale; + spriteBatch.SetBlendState(BlendState.Additive); + spriteBatch.Draw(glowTexture, drawPosition, npc.frame, drawColor2, npc.rotation, halfSize, npc.scale * 1.1f, SpriteEffects.None, 0f); + spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + } +} diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index c0521ba3b9..c322af9cb3 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -44,7 +44,7 @@ public static class VanillaAIOverrideExtension } } -public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC +public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC { /// /// Toggle Entire System. External mods can toggle this out if they want. @@ -905,11 +905,17 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC public override void OnSpawn(NPC npc, IEntitySource source) { + if (!Enabled) + return; + AIOverride?.OnSpawn(Mod); } public override bool PreAI(NPC npc) { + if (!Enabled) + return base.PreAI(npc); + if (AIOverride != null) { if (AIOverride.DisableMultiplayerSmoothing) @@ -920,34 +926,58 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC return AIOverride.AI(Mod); } - return base.PreAI(npc); + return GlobalPreAI(npc); + } + + public override void AI(NPC npc) + { + if (!Enabled) + return; + + GlobalAI(npc); } public override void PostAI(NPC npc) { + if (!Enabled) + return; + AIOverride?.PostAI(Mod); } public override void HitEffect(NPC npc, NPC.HitInfo hit) { + if (!Enabled) + return; + AIOverride?.HitEffect(Mod, hit); } public override void FindFrame(NPC npc, int frameHeight) { + if (!Enabled) + return; + AIOverride?.FindFrame(Mod, frameHeight); } public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (!Enabled) + base.PreDraw(npc, spriteBatch, screenPos, drawColor); + if (AIOverride != null) return AIOverride.PreDraw(Mod, spriteBatch, screenPos, drawColor); - return base.PreDraw(npc, spriteBatch, screenPos, drawColor); + return GlobalPreDraw(npc, spriteBatch, screenPos, drawColor); } public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (!Enabled) + return; + AIOverride?.PostDraw(Mod, spriteBatch, screenPos, drawColor); + GlobalPostDraw(npc, spriteBatch, screenPos, drawColor); } #endregion diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs index 998fa938cc..7dd8f07998 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs @@ -2,8 +2,10 @@ using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -941,6 +943,67 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + // Telegraph for charge and blood shots + if (NPC.crimsonBoss < 0) + return; + + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; + if (brainIsInPhase2) + { + var currentColor = NPC.GetAlpha(drawColor); + float opacity = (1f - Main.npc[NPC.crimsonBoss].life / (float)Main.npc[NPC.crimsonBoss].lifeMax) * 2f; + opacity *= opacity; + if (Main.getGoodWorld) + opacity = 1f; + + opacity = MathHelper.Clamp(opacity, 0f, 1f); + currentColor.R = (byte)(currentColor.R * opacity); + currentColor.G = (byte)(currentColor.G * opacity); + currentColor.B = (byte)(currentColor.B * opacity); + currentColor.A = (byte)(currentColor.A * opacity); + int totalAfterimages = 4; + for (int i = 0; i < totalAfterimages; i++) + { + Vector2 position = NPC.position; + float distanceFromTargetX = Math.Abs(NPC.Center.X - Main.LocalPlayer.Center.X); + float distanceFromTargetY = Math.Abs(NPC.Center.Y - Main.LocalPlayer.Center.Y); + if (i == 0 || i == 2) + position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; + else + position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; + + position.X -= NPC.width / 2; + if (i == 0 || i == 1) + position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; + else + position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; + + position.Y -= NPC.height / 2; + + int width = TextureAssets.Npc[NPC.type] is null ? 0 : TextureAssets.Npc[NPC.type].Width(); + int height = TextureAssets.Npc[NPC.type] is null ? 0 : TextureAssets.Npc[NPC.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, new Vector2(position.X - screenPos.X + NPC.width / 2 - width * NPC.scale / 2f + halfSize.X * NPC.scale, position.Y - screenPos.Y + (float)NPC.height - (float)height * NPC.scale / (float)Main.npcFrameCount[NPC.type] + 4f + halfSize.Y * NPC.scale + NPC.gfxOffY), NPC.frame, currentColor, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } + } + + float beginTelegraphGateValue = TimeBeforeCreeperAttack - CreeperTelegraphTime; + if (NPC.ai[1] > beginTelegraphGateValue || NPC.ai[0] == 1f) + { + float colorScale = NPC.ai[0] == 1f ? 1f : MathHelper.Clamp((NPC.ai[1] - beginTelegraphGateValue) / CreeperTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(150, 30, 30, 0) * colorScale; + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } + } + } } public static int GetBrainOfCthuluCreepersCountRevDeath() diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs index e4bada39db..146798a36a 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs @@ -4,8 +4,10 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -506,6 +508,57 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + public override void FindFrame(Mod mod, int frameHeight) + { + // Used to force the head to look to the sides for the laser spread attack + if (NPC.ai[0] == 2f || NPC.ai[0] == 3f) + { + if (NPC.localAI[1] == 1f) + NPC.frame.Y = frameHeight * 2; + else + NPC.frame.Y = frameHeight * 4; + } + } + + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + // Draw the head as usual. + Texture2D golemHeadTexture = TextureAssets.Npc[NPC.type].Value; + Vector2 headDrawPosition = NPC.Center - screenPos; + spriteBatch.Draw(golemHeadTexture, headDrawPosition, NPC.frame, NPC.GetAlpha(drawColor), 0f, NPC.frame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); + + // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. + Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); + Vector2 eyesDrawPosition = headDrawPosition - NPC.scale * new Vector2(1f, 12f); + Rectangle eyesFrame = new Rectangle(0, 0, TextureAssets.Golem[1].Value.Width, TextureAssets.Golem[1].Value.Height / 2); + spriteBatch.Draw(TextureAssets.Golem[1].Value, eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); + + // Draw the glowmasks. + int frameCounter = (int)NPC.frameCounter / 4; + Rectangle frame = TextureAssets.Extra[ExtrasID.GolemLights4].Value.Frame(1, 8); + frame.Y += frame.Height * 2 * frameCounter + NPC.frame.Y; + Rectangle glowFrame = frame; + spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights4].Value, eyesDrawPosition, glowFrame, eyeColor, 0f, glowFrame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); + frame = NPC.frame; + Rectangle glowFrame2 = frame; + spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights5].Value, eyesDrawPosition, glowFrame2, eyeColor, 0f, glowFrame2.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); + + // Draw the sparkle telegraphs for the laser spread attack if applicable. + if (NPC.ai[0] == 3f && NPC.ai[1] <= 60f) + { + spriteBatch.SetBlendState(BlendState.Additive); + for (int i = -1; i <= 1; i += 2) + { + Texture2D sparkle = ModContent.Request("CalamityMod/Particles/Sparkle2").Value; + Vector2 sparkleDraw = headDrawPosition + new Vector2(14f * i, -15f) * NPC.scale; + var drawFade = Color.Yellow * Utils.GetLerpValue(0, 30, 60f - NPC.ai[1], true); + spriteBatch.Draw(sparkle, sparkleDraw, null, drawFade, MathHelper.Pi * 0.02f * NPC.ai[1] * i, sparkle.Size() / 2f, 1.25f * NPC.scale, SpriteEffects.None, 0f); + } + spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; + } + public class FistAI : VanillaAIOverride { public override bool AI(Mod mod) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index fd41065ca3..23517398bb 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -4,8 +4,10 @@ using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -942,6 +944,79 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + var originalColor = NPC.GetAlpha(drawColor); + Color newColor = new Color(100, 255, 100, 255); + Vector2 glowOffset = Vector2.UnitY * -4f; + Vector2 drawPosition = NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) + glowOffset; + var origin = NPC.frame.Size() / 2; + + bool phase2 = lifeRatio <= 0.5f; + if (!phase2) + { + float telegraphTimer = Math.Abs(NPC.ai[1]); + bool startSeedGatlingSporeGasTelegraph = NPC.ai[1] > SeedGatlingColorChangeGateValue; + bool endSeedGatlingSporeGasTelegraph = NPC.ai[1] < -SeedGatlingDuration + SeedGatlingColorChangeDuration; + if (startSeedGatlingSporeGasTelegraph) + { + float telegraphScalar = MathHelper.Clamp((telegraphTimer - SeedGatlingColorChangeGateValue) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + + // -300 to -120 + else if (endSeedGatlingSporeGasTelegraph) + { + float telegraphScalar = MathHelper.Clamp((telegraphTimer - (SeedGatlingDuration - SeedGatlingColorChangeDuration)) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + } + else + { + float telegraphTimer = Math.Abs(NPC.ai[3]); + bool startChargeTelegraph = NPC.ai[3] > ChargeTelegraphColorChangeGateValue; + bool endChargeTelegraph = NPC.ai[3] <= -2f; + if (startChargeTelegraph) + { + float telegraphScalar = MathHelper.Clamp((telegraphTimer - ChargeTelegraphColorChangeGateValue) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + + // -195 to -2 + else if (endChargeTelegraph) + { + float telegraphScalar = MathHelper.Clamp((Math.Abs(StopChargeGateValue) - telegraphTimer) / Math.Abs(StopChargeGateValue), 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + + if (CalamityClientConfig.Instance.Afterimages) + { + int afterimageAmount = 10; + int afterImageIncrement = 2; + for (int j = 0; j < afterimageAmount; j += afterImageIncrement) + { + Color afterimageColor = telegraphColor; + afterimageColor = Color.Lerp(afterimageColor, originalColor, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmount - j) / 15f; + Vector2 afterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(npcTexture.Width, npcTexture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY) + glowOffset; + spriteBatch.Draw(npcTexture, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + } + } + public class HookAI : VanillaAIOverride { public override bool AI(Mod mod) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 9d5bdfaded..213633fa39 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -2,8 +2,10 @@ using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -743,6 +745,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + // Telegraph for charges + float beginTelegraphGateValue = ChargeGateValue - ChargeTelegraphTime; + if (NPC.localAI[1] > beginTelegraphGateValue) + { + float colorScale = MathHelper.Clamp((NPC.localAI[1] - beginTelegraphGateValue) / ChargeTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } + } + } + public class SkeletronHandAI : VanillaAIOverride { public override bool AI(Mod mod) @@ -1064,6 +1085,28 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + var calNPC = NPC.GetGlobalNPC(); + float beginTelegraphGateValue = HandSlapGateValue - HandSlapTelegraphTime; + if (calNPC.newAI[2] > beginTelegraphGateValue) + { + float colorScale = MathHelper.Clamp((calNPC.newAI[2] - beginTelegraphGateValue) / HandSlapTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Vector2 glowOffset = Vector2.UnitY * 8f; + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) - glowOffset, NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } + } + } } public class DungeonGuardianAI : VanillaAIOverride diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index 8c7f6b633a..80e8ee2736 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -4,8 +4,10 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -613,6 +615,46 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsMechQueenUp) + return true; + + // Allows correct frames to draw in Rev+ phases + // GFB can rot for all I care + var calNPC = NPC.GetGlobalNPC(); + int frameHeight = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + if (NPC.ai[1] == 0f || NPC.ai[1] == 4f) + { + calNPC.newAI[2] += 1f; + if (calNPC.newAI[2] >= 12f) + { + calNPC.newAI[2] = 0f; + calNPC.newAI[3] += frameHeight; + + if (calNPC.newAI[3] / frameHeight >= 2f) + calNPC.newAI[3] = 0f; + } + } + + // Spinning probe spawn or fly over phase + else if (NPC.ai[1] == 5f || NPC.ai[1] == 6f) + { + calNPC.newAI[2] = 0f; + calNPC.newAI[3] = frameHeight; + } + + // Spinning phase + else + { + calNPC.newAI[2] = 0f; + calNPC.newAI[3] = frameHeight * 2; + } + + NPC.frame.Y = (int)calNPC.newAI[3]; + return true; + } + public class PrimeLaserAI : VanillaAIOverride { public override bool AI(Mod mod) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs index 8e7fde87ff..98f99514cd 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs @@ -1,9 +1,12 @@ using System; using CalamityMod.Events; +using CalamityMod.ExtraTextures; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -508,6 +511,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + // Laser telegraph + bool enraged = NPC.localAI[3] > 0f; + float eyeTelegraphGateValue = LaserShootGateValue - LaserShootTelegraphTime; + if (NPC.localAI[1] > eyeTelegraphGateValue || NPC.localAI[2] > 0f || enraged) + { + Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.WallOfFleshEyeGlowmask.Value : TextureAssets.Npc[NPC.type].Value; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float colorScale = enraged ? MathHelper.Clamp(NPC.localAI[3] / EnragedLaserFiringDuration, 0f, 1f) : + NPC.localAI[2] > 0f ? 1f - ((NPC.localAI[2] - 1f) / TotalLasersPerBarrage) : + MathHelper.Clamp((NPC.localAI[1] - eyeTelegraphGateValue) / LaserShootTelegraphTime, 0f, 1f); + + Color drawColor2 = new Color(100, 0, 200, 192) * colorScale; + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(glowTexture, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } + } + } + public class HungryAI : VanillaAIOverride { public override bool AI(Mod mod) From 00c6594dd3106efaab1bf406f7c52155000f84ae Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 06:15:23 +0900 Subject: [PATCH 07/23] Proper Hook handling --- NPCs/CalamityVanillaAIOverrideNPC.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs index c322af9cb3..a4e1e8274e 100644 --- a/NPCs/CalamityVanillaAIOverrideNPC.cs +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -916,6 +916,8 @@ public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC if (!Enabled) return base.PreAI(npc); + bool result = true; + result &= GlobalPreAI(npc); if (AIOverride != null) { if (AIOverride.DisableMultiplayerSmoothing) @@ -923,10 +925,9 @@ public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC npc.netOffset = Vector2.Zero; } - return AIOverride.AI(Mod); + result &= AIOverride.AI(Mod); } - - return GlobalPreAI(npc); + return result; } public override void AI(NPC npc) @@ -966,9 +967,10 @@ public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC if (!Enabled) base.PreDraw(npc, spriteBatch, screenPos, drawColor); - if (AIOverride != null) - return AIOverride.PreDraw(Mod, spriteBatch, screenPos, drawColor); - return GlobalPreDraw(npc, spriteBatch, screenPos, drawColor); + bool result = true; + result &= GlobalPreDraw(npc, spriteBatch, screenPos, drawColor); + result &= AIOverride?.PreDraw(Mod, spriteBatch, screenPos, drawColor) ?? true; + return result; } public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -976,8 +978,8 @@ public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC if (!Enabled) return; - AIOverride?.PostDraw(Mod, spriteBatch, screenPos, drawColor); GlobalPostDraw(npc, spriteBatch, screenPos, drawColor); + AIOverride?.PostDraw(Mod, spriteBatch, screenPos, drawColor); } #endregion From 514460f4f48c4976d81c5f67cb915a9ef30af6f8 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 07:13:59 +0900 Subject: [PATCH 08/23] Split CalamityGlobalTownNPC as separate type --- ILEditing/MechanicILChanges.cs | 4 +- ModSupport/ModCalls.cs | 6 +- NPCs/CalClone/CalamitasClone.cs | 4 +- NPCs/CalamityGlobalNPC.cs | 18 -- NPCs/CalamityGlobalNPCLoot.cs | 11 +- NPCs/CalamityGlobalTownNPC.cs | 201 ++++++++++++++-------- NPCs/DevourerofGods/DevourerofGodsHead.cs | 124 ++++++------- NPCs/OldDuke/OldDuke.cs | 4 +- NPCs/Polterghast/Polterghast.cs | 4 +- NPCs/Yharon/Yharon.cs | 2 +- Systems/EntityUpdateInterceptionSystem.cs | 2 +- 11 files changed, 208 insertions(+), 172 deletions(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 69da5dee7e..1d068940fc 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -886,7 +886,7 @@ namespace CalamityMod.ILEditing return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalNPC.TotalTaxesPerNPC)}"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TotalTaxesPerNPC)}"); if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall(nameof(Item.buyPrice)))) { @@ -894,7 +894,7 @@ namespace CalamityMod.ILEditing return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalNPC.TaxesToCollectLimit)}"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TaxesToCollectLimit)}"); } #endregion diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index b7820a0559..9056efabe0 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -962,9 +962,9 @@ namespace CalamityMod #region Town NPC Alert support public static void RegisterTownNPCShop(int id, Predicate getShop, Action setShop) { - if (!CalamityGlobalNPC.npcAlertList.Contains((id, getShop, setShop))) + if (!CalamityGlobalTownNPC.npcAlertList.Contains((id, getShop, setShop))) { - CalamityGlobalNPC.npcAlertList.Add((id, getShop, setShop)); + CalamityGlobalTownNPC.npcAlertList.Add((id, getShop, setShop)); } } #endregion @@ -2180,7 +2180,7 @@ namespace CalamityMod return new ArgumentException("ERROR: The first argument to \"SetNewShopVariable\" must be an integer array of npc ids that should be alerted."); if (args.Length != 3 || args[2] is not bool alreadySet) return new ArgumentException("ERROR: The second argument to \"SetNewShopVariable\" Must be a bool that determines if the shop alert should show."); - CalamityGlobalNPC.SetNewShopVariable(npcs, alreadySet); + CalamityGlobalTownNPC.SetNewShopVariable(npcs, alreadySet); return null; } diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index 8a7ec86dcd..9e8f0d709b 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -96,7 +96,7 @@ namespace CalamityMod.NPCs.CalClone if (lifeRatio < 0.1f && !inBulletHell && CalamityWorld.death) baseSize *= MathHelper.Lerp(Main.getGoodWorld ? 0.22f : 0.4f, 1f, lifeRatio * 10f); // Scale down the lower health calclone has. Much lower bound on FTW. - return baseSize + new Vector4(-22, 0 ,22,0); + return baseSize + new Vector4(-22, 0, 22, 0); } public override void SetStaticDefaults() { @@ -1071,7 +1071,7 @@ namespace CalamityMod.NPCs.CalClone CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); // Mark the Calamitas Clone as dead DownedBossSystem.downedCalamitasClone = true; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a053e8554d..56e32e5f9e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -232,11 +232,6 @@ namespace CalamityMod.NPCs public const int maxPlayerImmunities = Main.maxPlayers + 1; public int[] dashImmunityTime = new int[maxPlayerImmunities]; - /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. - public int shopAlertAnimTimer = 0; - /// - public int shopAlertAnimFrame = 0; - /// /// If set to false, prevents this NPC from allowing Rage to be generated by nearby players, regardless of other factors.
/// Defaults to true. @@ -249,9 +244,6 @@ namespace CalamityMod.NPCs public float[] newAI = new float[maxAIMod]; public int killTimeTimer = 0; - /// Used for allowing Patreon names for Town NPCs. - public bool setNewName = true; - /// If set to true, the Boss Health Bar for this NPC will count the total health of all individual segments using worm segment logic. public bool SplittingWorm = false; /// If set to true, allows this NPC to draw a Boss Health Bar, regardless of other factors. @@ -541,9 +533,6 @@ namespace CalamityMod.NPCs for (int i = 0; i < maxPlayerImmunities; ++i) myClone.dashImmunityTime[i] = dashImmunityTime[i]; - myClone.shopAlertAnimTimer = shopAlertAnimTimer; - myClone.shopAlertAnimFrame = shopAlertAnimFrame; - myClone.ProvidesProximityRage = ProvidesProximityRage; myClone.newAI = new float[maxAIMod]; @@ -551,8 +540,6 @@ namespace CalamityMod.NPCs myClone.newAI[i] = newAI[i]; myClone.killTimeTimer = killTimeTimer; - myClone.setNewName = setNewName; - myClone.SplittingWorm = SplittingWorm; myClone.CanHaveBossHealthBar = CanHaveBossHealthBar; myClone.ShouldCloseHPBar = ShouldCloseHPBar; @@ -1248,7 +1235,6 @@ namespace CalamityMod.NPCs npc.SetDebuffImmunities(); VulnerabilitiesAndResistances(npc); - BoundNPCSafety(Mod, npc); } public override bool? CanFallThroughPlatforms(NPC npc) @@ -2882,8 +2868,6 @@ namespace CalamityMod.NPCs ManaBurnFireDrawer.Update(); } - SetPatreonTownNPCName(npc, Mod); - // Decrement each immune timer if it's greater than 0. for (int i = 0; i < maxPlayerImmunities; i++) { @@ -5357,8 +5341,6 @@ namespace CalamityMod.NPCs } } - TownNPCAlertSystem(npc, Mod, spriteBatch); - // VHex, Mana Burn and Miracle Blight visuals do not appear if Odd Mushroom is in use for sanity reasons if (!Main.LocalPlayer.Calamity().trippy) { diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 22b601d5e7..2fab5b9abd 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -31,6 +31,7 @@ using Terraria.Audio; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.NPCs.CalamityGlobalTownNPC; namespace CalamityMod.NPCs { @@ -699,7 +700,7 @@ namespace CalamityMod.NPCs case NPCID.Drippler: postEoC.Add(ModContent.ItemType(), 4); break; - + //Hardmode enemies drop orbs even if EoC is not dead //99% of players will not encounter this and challenge runners will appreciate it case NPCID.Clown: @@ -1701,12 +1702,12 @@ namespace CalamityMod.NPCs } } catch (ArgumentNullException) { } - DukeEditFailed: +DukeEditFailed: - // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic - // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); +// 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic +// npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); - // Would be in the bag otherwise +// Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), 10); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 006bbc258e..451ecf73dc 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -35,7 +35,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs { - public partial class CalamityGlobalNPC : GlobalNPC + public class CalamityGlobalTownNPC : GlobalNPC { public static float TaxYieldFactor { @@ -63,16 +63,42 @@ namespace CalamityMod.NPCs // Vanilla: 25 gold public static int TaxesToCollectLimit => (int)(Item.buyPrice(gold: 50) * TaxYieldFactor); + + /// Used for allowing Patreon names for Town NPCs. + public bool setNewName = true; + /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. + public int shopAlertAnimTimer = 0; + /// + public int shopAlertAnimFrame = 0; + + public override bool InstancePerEntity => true; + + public override bool AppliesToEntity(NPC entity, bool lateInstantiation) + { + return entity.isLikeATownNPC; + } + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityGlobalTownNPC myClone = (CalamityGlobalTownNPC)base.Clone(npc, npcClone); + + myClone.setNewName = setNewName; + myClone.shopAlertAnimTimer = shopAlertAnimTimer; + myClone.shopAlertAnimFrame = shopAlertAnimFrame; + + return myClone; + } + #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = - { + [ "Dazren", "Johnny Test", // <@!589966747977777197> (konorango) "Bling Bling Boy", // <@!522970788203069442> (phallguy) "RICE", // <@!400107830889152524> (rice_xd.) - }; + ]; private static readonly string[] ArmsDealerNames = - { + [ "Finchi", "Heniek", // <@!363404700445442050> (kazurgundu) "Fire", // <@!354362326947856384> (ultimatefirewaster) @@ -82,37 +108,37 @@ namespace CalamityMod.NPCs "The Cooler Arthur", // <@!568263512523014154> (gokuartillery) "Shark", // <@!874464051697172492> (congratsistrash) "Sagi", // <@!508233115781693441> (sagittariod) - }; + ]; private static readonly string[] ClothierNames = - { + [ "Joeseph Jostar", "Storm Havik", // <@!1013452363178197072> (fishnotduck) "Magorfis Splunt the Greater Finklejim", // <@!147490809334333440> (eidolbyssus) "Perrin", // <@!253764551139393537> (easyperrin) - }; + ]; private static readonly string[] CyborgNames = - { + [ "Sylux", // <@!331812782183809025> (gonkachino) "Nemesis", // <@!1104036024063107082> (yashimayamanata) - }; + ]; private static readonly string[] DemolitionistNames = - { + [ "Tavish DeGroot", // <@!442447226992721930> (magicoal) "Fimmy", // <@!407348617079160832> (darkmega5) "John Helldiver", // <@!614126424751603714> (exellent.) - }; + ]; private static readonly string[] DryadNames = - { + [ "Rythmi", "Izuna", "Jasmine", // <@!430532867479699456> (phantasmagoria.) "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (briny_coffee) "Kanna", // <@!730203712898859018> (cosmoredeathwish) - }; + ]; private static readonly string[] DyeTraderNames = null; private static readonly string[] GoblinTinkererNames = - { + [ "Verth", "Gormer", // <@!287651204924833795> (picassosbean2819 -- RIP) "TingFlarg", // <@!185605031716847616> (smugggo) @@ -126,10 +152,10 @@ namespace CalamityMod.NPCs "Bars Boldia", // <@!332989575708540939> (careless_imp) "Basel Raiden John Clive Fantasy 16", // <@!529392083136413696> (raiden_ii) "Gobby, Destroyer of Wallets", // <@!429024941296582658> (bwlstorm) - }; + ]; private static readonly string[] GolferNames = null; private static readonly string[] GuideNames = - { + [ "Lapp", "Ben Shapiro", "Streakist", // used to be "StreakistYT". couldn't find the youtube channel, and decided to remove the ad. @@ -148,39 +174,39 @@ namespace CalamityMod.NPCs "Dinkleberg", // <@!581993958037520404> (hyperionzx) "Wamy", // Fab added this name with no Discord ID. May be a donor who has no Discord account. "Baggute", // <@!535140564174110720> (thebaggutegamer) - }; + ]; private static readonly string[] MechanicNames = - { + [ "Lilly", "Daawn", // <@!206162323541458944> (daawnily) "Robin", // <@!654737510030639112> (altzeus) "Curly", // <@!673092101780668416> (curly4830) "Cobalt", // <@!132962828922388481> (cobalt_44) - }; + ]; private static readonly string[] MerchantNames = - { + [ "Morshu", // <@!194931581826236416> (uberransy) "Spamton G. Spamton", // <@!497146350438318101> (j.u.n.e.s) - }; + ]; private static readonly string[] NurseNames = - { + [ "Farsni", "Fanny", // <@!799749125720637460> (zombiewolf511) "Mausi", // <@!194156349347594241> (sadouken) "Fiona", // <@!475216964168450048> (thatgayguy69) - }; + ]; private static readonly string[] PainterNames = - { + [ "Picasso", // <@!353316526306361347> (sconicboom -- for the late picassosbean2819) "Bew", // <@!232291351167893505> (dmshi) - }; + ]; private static readonly string[] PartyGirlNames = - { + [ "Arin", // <@!268169458302976012> (kiyotu) "Typhäne", // <@!222064016107896832> (typhane.) - }; + ]; private static readonly string[] PirateNames = - { + [ "Tyler Van Hook", "Cap'n Deek", // "Alex N" on Patreon (No discord account) "Captain Billy Bones", // <@!699589229507772416> (djackv) @@ -189,9 +215,9 @@ namespace CalamityMod.NPCs "Yarrim", // <@!290061123137306624> (borb9834) "Hector Barbossa", // <@!615704209303797790> (thatrockisfullamagic) "Blunderbeard", // <@!1039460813490102293> (parmiigianoreggiano) - }; + ]; private static readonly string[] PrincessNames = - { + [ "Nyapano", // <@!120976656826368003> (nyapano) "Jade", // <@!187395834625785869> (verymasterninja) "Nyavi Aceso", // <@!270260920888852480> (navigator.) @@ -200,21 +226,21 @@ namespace CalamityMod.NPCs "Hael", // <@!641747280944431156> (kalebtull) "Yumesaki Mirrin", // <@!100235144744415232> (milinen) "Vela", // <@!208719047146209281> (nyxxynightstar) - }; + ]; private static readonly string[] SantaClausNames = - { + [ "Jank", // <@!339950757472239616> (jankle_) "Aoi Kurashiki", // <@!358411687885537291> (nothinpurrsonal) - }; + ]; private static readonly string[] SkeletonMerchantNames = - { + [ "Sans Undertale", // <@!534770496038895616> (done_22_) "Papyrus Undertale", // <@!262663471189983242> (nycro) "Mr. Bones", // <@!359215912856977408> (jaybones.) "Freakbob", // <@!377863128140087296> (jevilamv) - }; + ]; private static readonly string[] SteampunkerNames = - { + [ "Vorbis", "Angel", "Mòrag Ladair", // <@!161893929485074432> (jalapeno9) @@ -223,51 +249,51 @@ namespace CalamityMod.NPCs "Kreutz", // <@!553445849149997056> (red_r_kreutz) "Cathlyn", // <@!156672312425316352> (xaqult) "Eunice", // <@!358376627400605699> (srmg267) - }; + ]; private static readonly string[] StylistNames = - { + [ "Amber", // <@!114677116473180169> (mishirousui) "Faith", // <@!509050283871961123> (toasty1007) "Xsiana", // <@!625780237489143839> (lokistic) "Lain", // <@!655201622863118337> (literallyadeerfr) "Hamis", // <@!608455754093035521> (haefer) "Brio Scarlet", // <@!358576903701004289> (brio_scarlet) - }; + ]; private static readonly string[] TavernkeepNames = - { + [ "Tim Lockwood", // <@!605839945483026434> (pomvoid) "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (ryaegos) "Brutus", // <@!591889650692521984> (.brutus._) "Sloth", // <@!486265327387279391> (bossypunch) - }; + ]; private static readonly string[] TaxCollectorNames = - { + [ "Emmett", "Casino King Gray", // <@!555512087711973390> (eternalgrayson) - }; + ]; private static readonly string[] TravelingMerchantNames = - { + [ "Stan Pines", "Intergaze", // <@!923504188615450654> (intergaze) "Borgus", // <@!539127427482255376> (therealmeepman) "Postman Hiss", // <@!454638106122125312> (karinthefairy) - }; + ]; private static readonly string[] TruffleNames = - { + [ "Aldrimil", // <@!413719640238194689> (Thorioum#2475) "Wonton", // <@!1198092982923043040> (imonthatgudkush) "Mad Lad", // <@!215269032360804352> (crimsoncb) "Nokko", // <@!706732954079985745> (violet.prime) - }; + ]; private static readonly string[] WitchDoctorNames = - { + [ "Sok'ar", "Aeroni", // <@!348174404984766465> (aeroni) (previously: toxin) "Mixcoatl", // <@!284775927294984203> (.sharzz) "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) - }; + ]; private static readonly string[] WizardNames = - { + [ "Inorim, son of Ivukey", "Jensen", "Merasmus", // <@!288066987819663360> (spiderprovidence) @@ -278,16 +304,16 @@ namespace CalamityMod.NPCs "Nextdoor Psycho", // <@!173261518572486656> (nextdoorpsycho) "Mike Cyclops", // <@!702327497475227741> (seichoseicho) "Derin", // <@!466703979695308820> (god_15) - }; + ]; private static readonly string[] ZoologistNames = - { + [ "Kiriku", // <@!395312478160027668> (rulosss) "Lacuna", // <@!790746689211203604> (_lacuna_) "Mae Borowski", //<@!219158690433990656> (justakkolite) "Fera", // <@!195850711567826945> (juneark_) "Gwenhwyvar", // <@!291342874497515531> (diamondnife) "Daxie", // <@!465438861103988737> (daxie626) - }; + ]; // Town Slimes private static readonly string[] ClumsySlimeNames = null; private static readonly string[] CoolSlimeNames = null; @@ -295,10 +321,10 @@ namespace CalamityMod.NPCs private static readonly string[] ElderSlimeNames = null; private static readonly string[] MysticSlimeNames = null; private static readonly string[] NerdySlimeNames = - { + [ "Big Blungus", // <@!272759434282008577> (schmoov) "Rimuru Tempest", // <@!806463201398358036> (c0d3_404) - }; + ]; private static readonly string[] SquireSlimeNames = null; private static readonly string[] SurlySlimeNames = null; @@ -313,29 +339,29 @@ namespace CalamityMod.NPCs private const int TownDogDalmatianVanillaNames = 13; private const int TownDogHuskyVanillaNames = 16; private static readonly string[] TownDogNames = - { + [ "Ozymandias", // <@!146333264871686145> (ozzatron) "Miss Throws a Lot", // <@!799345607847182400> (oakhamsam) "Brikwilla", // <@!543803736909414438> (lavendercobra) - }; + ]; private static readonly string[] TownDogLabradorNames = - { + [ "Riley", // <@!260875558592708619> (potionpal) - }; + ]; private static readonly string[] TownDogPitBullNames = - { + [ "Splinter", // <@!320320801213775873> (kaimonick) - }; + ]; private static readonly string[] TownDogBeagleNames = - { + [ "Kendra", // <@!237247188005158912> (lordmetarex) - }; + ]; private static readonly string[] TownDogCorgiNames = null; private static readonly string[] TownDogDalmatianNames = null; private static readonly string[] TownDogHuskyNames = - { + [ "Yoshi", // <@!541127291426832384> (gregthespinarak) - }; + ]; private const int TownCatSiameseVanillaNames = 12; private const int TownCatBlackVanillaNames = 23; @@ -344,34 +370,34 @@ namespace CalamityMod.NPCs private const int TownCatSilverVanillaNames = 17; private const int TownCatWhiteVanillaNames = 15; private static readonly string[] TownCatNames = - { + [ "Smoogle", // <@!709968379334623274> (smooglin) "The Meowurer of Gods", // <@!385949114271268864> (thatgp) "Katsafaros", // <@!190595401328492544> (gr_mm) "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) "Octo", // <@!796112889353994281> (octolinggrimm) - }; + ]; private static readonly string[] TownCatSiameseNames = null; private static readonly string[] TownCatBlackNames = - { + [ "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) "Storm", // <@!620383533516718085> (airwaveslr) "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) - }; + ]; private static readonly string[] TownCatOrangeTabbyNames = - { + [ "Felix", // <@!183424826407518208> (lilac_vrt_olligoci) "Tardo", // <@!739343546867384391> (midnight295) "Dali", // <@!460238880436781061> (darthlego) "Kiba", // <@!852348657072340992> (jollydragonslayer) - }; + ]; private static readonly string[] TownCatRussianBlueNames = null; private static readonly string[] TownCatSilverNames = - { + [ "Archie", // <@!303022375191183360> (jackshiz) "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) - }; + ]; private static readonly string[] TownCatWhiteNames = null; private const int TownBunnyWhiteVanillaNames = 14; @@ -381,10 +407,10 @@ namespace CalamityMod.NPCs private const int TownBunnyLopVanillaNames = 13; private const int TownBunnySilverVanillaNames = 13; private static readonly string[] TownBunnyNames = - { + [ "Poco", // <@!1192261996146593872> (tostitomuncher33) "Puffer", // <@!181103507711983616> (piky) - }; + ]; private static readonly string[] TownBunnyWhiteNames = null; private static readonly string[] TownBunnyAngoraNames = null; private static readonly string[] TownBunnyDutchNames = null; @@ -734,6 +760,29 @@ namespace CalamityMod.NPCs } #endregion + #region SetDefaults + public override void SetDefaults(NPC npc) + { + BoundNPCSafety(Mod, npc); + } + #endregion + + #region PreAI + public override bool PreAI(NPC npc) + { + SetPatreonTownNPCName(npc, Mod); + return true; + } + #endregion + + #region PreDraw + public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + TownNPCAlertSystem(npc, Mod, spriteBatch); + return true; + } + #endregion + #region NPC New Shop Alert public static List<(int, Predicate, Action)> npcAlertList = new List<(int, Predicate, Action)>() @@ -896,7 +945,7 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.DarksunEclipse"); else if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneGlowshroom) { - chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); + chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); } else if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.SulphurSea"); diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 7cfd029d27..1d67b1fa91 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.DevourerofGods [LongDistanceNetSync] public class DevourerofGodsHead : ModNPC { - public static Color SpecialMoveColor => Color.Lerp(Color.Fuchsia, Color.Cyan, MathHelper.SmoothStep(0,1,(MathF.Sin(Main.GlobalTimeWrappedHourly*2)+1) * 0.5f)); + public static Color SpecialMoveColor => Color.Lerp(Color.Fuchsia, Color.Cyan, MathHelper.SmoothStep(0, 1, (MathF.Sin(Main.GlobalTimeWrappedHourly * 2) + 1) * 0.5f)); public static int phase1IconIndex; public static int phase2IconIndex; @@ -67,7 +67,7 @@ namespace CalamityMod.NPCs.DevourerofGods { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss"; - + phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -152,7 +152,7 @@ namespace CalamityMod.NPCs.DevourerofGods public bool isInPassiveState { - get + get { if (Phase2Started && NPC.ai[3] == 1) return true; @@ -625,7 +625,7 @@ namespace CalamityMod.NPCs.DevourerofGods { string key = "Mods.CalamityMod.Status.Boss.DoGPhase2"; Color messageColor = Color.Cyan; - var ctid = CombatText.NewText(NPC.Hitbox,messageColor, Language.GetTextValue(key),true); + var ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); if (ctid < Main.maxCombatText) player.Calamity().subtitletext = Main.combatText[ctid]; player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; @@ -685,7 +685,7 @@ namespace CalamityMod.NPCs.DevourerofGods AttemptingToEnterPortal = true; } #endregion - + // Phase 2 else { @@ -929,7 +929,8 @@ namespace CalamityMod.NPCs.DevourerofGods VelocityRotation -= maxSpeed; else VelocityRotation += dif; - } else + } + else { if (dif > maxSpeed) VelocityRotation += maxSpeed; @@ -975,11 +976,11 @@ namespace CalamityMod.NPCs.DevourerofGods float targetY = destination.Y; int destinationTileX = (int)(destination.X / 16f); int destinationTileY = (int)(destination.Y / 16f); - - + + speedCopy = homingSpeed; turnSpeedCopy = homingTurnSpeed; - + speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f; turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f; @@ -1013,7 +1014,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; - turnSpeedCopy *= NPC.Distance(destination) / ( death ? 800 : 1000f); + turnSpeedCopy *= NPC.Distance(destination) / (death ? 800 : 1000f); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1374,14 +1375,14 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { - + calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; if ((phase4)) { - calamityGlobalNPC.newAI[3] = AlphaGateValue-120; + calamityGlobalNPC.newAI[3] = AlphaGateValue - 120; NPC.ai[3] = 2f; } @@ -1405,11 +1406,12 @@ namespace CalamityMod.NPCs.DevourerofGods var currentVelLength = NPC.velocity.Length(); var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; - TurnTowards(goalpos,maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + TurnTowards(goalpos, maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength > 42 ? currentVelLength - 0.2f : currentVelLength); NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - } else + } + else { NPC.dontTakeDamage = true; } @@ -1441,7 +1443,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (isInPassiveState) { ShootFireballs(player, distanceFromTarget, revenge); - } + } else { calamityGlobalNPC.newAI[0] = 0f; @@ -1523,11 +1525,11 @@ namespace CalamityMod.NPCs.DevourerofGods calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) { - if (!Main.dedServ) - { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.Calamity().infiniteFlight = true; - } + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.Calamity().infiniteFlight = true; + } if (calamityGlobalNPC.newAI[1] >= laserBarrageGateValue) { calamityGlobalNPC.newAI[1] = 0f; @@ -1621,7 +1623,7 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = player.position.X + (player.width / 2); float targetY = player.position.Y + (player.height / 2); - + speedCopy = homingSpeed; turnSpeedCopy = homingTurnSpeed; @@ -1746,7 +1748,7 @@ namespace CalamityMod.NPCs.DevourerofGods { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; if (phase2) { NPC.ai[3] = 2; @@ -2185,8 +2187,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (!phase2Transition) teleportTimer = baseTeleportTime; - - SoundEngine.PlaySound(RiftOpenSound with {Volume = 1.5f}, player.Center); + + SoundEngine.PlaySound(RiftOpenSound with { Volume = 1.5f }, player.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -2227,31 +2229,31 @@ namespace CalamityMod.NPCs.DevourerofGods return; bool phase6 = NPC.life / (float)NPC.lifeMax < 0.25f; - if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs + if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs + { + float finalVelocity = death ? 12f : 10f; + int totalSpreads = revenge ? 6 : 3; + float mult = revenge ? 1.5f : 3f; + for (int i = 0; i < totalSpreads; i++) { - float finalVelocity = death ? 12f : 10f; - int totalSpreads = revenge ? 6 : 3; - float mult = revenge ? 1.5f : 3f; - for (int i = 0; i < totalSpreads; i++) + if (!death && i % 3 == 2) + continue; + int totalProjectiles = 12; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = finalVelocity - i * mult; + float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; + for (int k = 0; k < totalProjectiles; k++) { - if (!death && i % 3 == 2) - continue; - int totalProjectiles = 12; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = finalVelocity - i * mult; - float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); - } + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); } } + } NPC.TargetClosest(); NPC.position = newPosition; @@ -2259,17 +2261,17 @@ namespace CalamityMod.NPCs.DevourerofGods chargeVelocity *= (death) ? (!(phase6 && NPC.ai[3] < 7)) ? 2.5f : 3 : 2.25f; float maxChargeDistance = 1800f; postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); - int phase6dashcount = death ? 5 : 3; - if (phase6 && NPC.ai[3] < 2 + phase6dashcount) - { - if (NPC.ai[3] < 3) - NPC.ai[3] = 3; - NPC.ai[3]++; + int phase6dashcount = death ? 5 : 3; + if (phase6 && NPC.ai[3] < 2 + phase6dashcount) + { + if (NPC.ai[3] < 3) + NPC.ai[3] = 3; + NPC.ai[3]++; // On FTW the final 10% is infinite portal dashing if (Main.getGoodWorld && NPC.life / (float)NPC.lifeMax < 0.1f) { NPC.ai[3] = 4; - NPC.SimpleStrikeNPC(10000,1); + NPC.SimpleStrikeNPC(10000, 1); } } else @@ -2503,7 +2505,7 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); // If DoG has not been killed yet, notify players that the holiday moons are buffed if (!DownedBossSystem.downedDoG) @@ -2737,7 +2739,7 @@ namespace CalamityMod.NPCs.DevourerofGods { if (hurtInfo.Damage <= 0) return; - + if (target.Calamity().dogTextCooldown <= 0 && !BossRushEvent.BossRushActive) { string[] headHitKeys = new string[] @@ -2755,13 +2757,13 @@ namespace CalamityMod.NPCs.DevourerofGods "Mods.CalamityMod.Status.Boss.DoGHead11", "Mods.CalamityMod.Status.Boss.DoGHead12", "Mods.CalamityMod.Status.Boss.DoGHead13", - + }; Color messageColor = Color.Cyan; Rectangle location = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); var counter = target.Calamity().DoGHeadHitCounter; - string text = headHitKeys[Main.rand.Next(10, 13)]; + string text = headHitKeys[Main.rand.Next(10, 13)]; if (target.statLife - hurtInfo.Damage <= 0) { if (counter == 0) @@ -2777,7 +2779,8 @@ namespace CalamityMod.NPCs.DevourerofGods text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath1"; //Tasteless slop. else text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath2"; //A feast worthy of a god! - } else + } + else { if (counter == 0 && Phase2Started) { @@ -2785,7 +2788,8 @@ namespace CalamityMod.NPCs.DevourerofGods text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning2"; //WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! else text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning"; //You can't run forever! - } else + } + else { if (counter > 9) text = headHitKeys[Main.rand.Next(10, 13)]; //DogHead11-13 @@ -2793,7 +2797,7 @@ namespace CalamityMod.NPCs.DevourerofGods text = headHitKeys[9]; //DogHead10 else if (counter > 4) text = headHitKeys[Main.rand.Next(4, 9)]; //DogHead5-9 - else + else text = headHitKeys[Main.rand.Next(0, 4)]; //DogHead1-4 } } @@ -2804,7 +2808,7 @@ namespace CalamityMod.NPCs.DevourerofGods target.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; target.Calamity().dogTextCooldown = 60; } - target.Calamity().DoGHeadHitCounter++; + target.Calamity().DoGHeadHitCounter++; } } } diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index e54290bb3b..ea70d84fb2 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -1981,7 +1981,7 @@ namespace CalamityMod.NPCs.OldDuke drawLocation += new Vector2(Main.rand.NextFloat(-shake, shake), Main.rand.NextFloat(-shake, shake)); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(finalDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(overlayDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); float auraOutset = 6f + (float)(Math.Sin(VisualTimerSystem.GlobalVisualTimer / 10f) * 10f); @@ -2066,7 +2066,7 @@ namespace CalamityMod.NPCs.OldDuke CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); // Mark Old Duke as dead DownedBossSystem.downedBoomerDuke = true; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 142151602d..684cccea79 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.Polterghast { public static int phase1IconIndex; public static int phase3IconIndex; - + public override void Load() { string phase1IconPath = "CalamityMod/NPCs/Polterghast/Polterghast_Head_Boss"; @@ -943,7 +943,7 @@ namespace CalamityMod.NPCs.Polterghast CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); // If Polterghast has not been killed, notify players about the Abyss minibosses now dropping items if (!DownedBossSystem.downedPolterghast) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 6535fc98c8..c554318e43 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -3018,7 +3018,7 @@ namespace CalamityMod.NPCs.Yharon if (BossRushEvent.BossRushActive) return; - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); CalamityGlobalNPC.SetNewBossJustDowned(NPC); // If Yharon has not been killed yet, notify players of Auric Ore diff --git a/Systems/EntityUpdateInterceptionSystem.cs b/Systems/EntityUpdateInterceptionSystem.cs index 98a14899e8..5390343164 100644 --- a/Systems/EntityUpdateInterceptionSystem.cs +++ b/Systems/EntityUpdateInterceptionSystem.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Systems #region Post NPC Updating // TODO -- Apply caching to this process. For now most of the looping issues should be eradicated but it can be reduced further. - public override void PostUpdateNPCs() => CalamityGlobalNPC.ResetTownNPCNameBools(); + public override void PostUpdateNPCs() => CalamityGlobalTownNPC.ResetTownNPCNameBools(); #endregion #region Tile Entity Time Handler From cda5c217b6aaa878666555315280b3bf7ab25b58 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 07:58:11 +0900 Subject: [PATCH 09/23] Added storedPrefix change back for mod compat --- Prefixes/ReforgeChange.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Prefixes/ReforgeChange.cs b/Prefixes/ReforgeChange.cs index 4930d90c47..f76274b5e9 100644 --- a/Prefixes/ReforgeChange.cs +++ b/Prefixes/ReforgeChange.cs @@ -19,9 +19,14 @@ namespace CalamityMod.Prefixes // Ozzatron 31AUG2022: total rework to the reforge rework for mod compatibility // you can now disable the rework with config in case it isn't enough to solve your conflicts // removed data saved on items; reforging is now a coalescing flowchart that has no RNG + private static int storedPrefix = -1; + public override void PreReforge(Item item) + { + storedPrefix = item.prefix; + } + public override int ChoosePrefix(Item item, UnifiedRandom rand) { - int storedPrefix = item.prefix; if (storedPrefix == -1 && item.CountsAsClass() && (item.maxStack == 1 || item.AllowReforgeForStackableItem)) { // Crafting (or first reforge of) a rogue weapon has a 75% chance for a random modifier, this check is done by vanilla @@ -48,6 +53,8 @@ namespace CalamityMod.Prefixes public override void PostReforge(Item item) { + storedPrefix = -1; + // Bandit steals 20% of the total price of the reforge if she's around. if (NPC.AnyNPCs(NPCType())) { From 35731e0278316125812c9f52f443304e6f70d052 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 11:35:13 +0900 Subject: [PATCH 10/23] Metaball now uses accurate draw positions --- Graphics/Metaballs/MetaballManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs index aa1bf3ab10..a0755564d9 100644 --- a/Graphics/Metaballs/MetaballManager.cs +++ b/Graphics/Metaballs/MetaballManager.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Graphics.Metaballs public override void Load() { // Prepare event subscribers. + GeneralDrawLayerSystem.OnPrepareDraw += PrepareMetaballTargets; GeneralDrawLayerSystem.OnDrawLayer += DrawMetaballs; - RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets; } public override void OnModUnload() @@ -110,7 +110,7 @@ namespace CalamityMod.Graphics.Metaballs metaball.PrepareShaderForTarget(i); // Draw the metaball's raw contents with the shader. - Main.spriteBatch.Draw(metaball.LayerTargets[i], Main.screenLastPosition - Main.screenPosition, Color.White); + Main.spriteBatch.Draw(metaball.LayerTargets[i], Vector2.Zero, Color.White); } } From 28aa87f878bf421335fed2b3399833370fee5e1d Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 12:05:42 +0900 Subject: [PATCH 11/23] Standardize Metaball Transform Matrix --- Graphics/Metaballs/MetaballManager.cs | 6 +++--- Graphics/Metaballs/PaintMetaballs.cs | 2 +- Graphics/Metaballs/RancorLavaMetaball.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs index a0755564d9..c33bb5f83f 100644 --- a/Graphics/Metaballs/MetaballManager.cs +++ b/Graphics/Metaballs/MetaballManager.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Graphics.Metaballs return; // Prepare the sprite batch for drawing. Metaballs may restart the sprite batch via PrepareSpriteBatch if their implementation requires it. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); var gd = Main.instance.GraphicsDevice; foreach (Metaball metaball in activeMetaballs) @@ -78,7 +78,7 @@ namespace CalamityMod.Graphics.Metaballs // Flush metaball contents to its render target and reset the sprite batch for the next iteration. Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); } } @@ -100,7 +100,7 @@ namespace CalamityMod.Graphics.Metaballs /// The layer type to draw with. private static void DrawMetaballs(GeneralDrawLayer layerType) { - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise); foreach (Metaball metaball in metaballs.Where(m => m.DrawLayer == layerType && m.AnythingToDraw)) { diff --git a/Graphics/Metaballs/PaintMetaballs.cs b/Graphics/Metaballs/PaintMetaballs.cs index dfa9472c02..704fd06e90 100644 --- a/Graphics/Metaballs/PaintMetaballs.cs +++ b/Graphics/Metaballs/PaintMetaballs.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Graphics.Metaballs { // Draw with additive blending. Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); } public override void DrawInstances() diff --git a/Graphics/Metaballs/RancorLavaMetaball.cs b/Graphics/Metaballs/RancorLavaMetaball.cs index 4999ac66d2..54e2bb51ea 100644 --- a/Graphics/Metaballs/RancorLavaMetaball.cs +++ b/Graphics/Metaballs/RancorLavaMetaball.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Graphics.Metaballs { // Draw with additive blending. Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); } public override void DrawInstances() From 11ba2f77ac224b9dd6201a8ff92a5f7e219d2ff2 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 12:06:05 +0900 Subject: [PATCH 12/23] ArenaWallSystem - Now use correct matrix --- Systems/Mechanic/ArenaWallSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Systems/Mechanic/ArenaWallSystem.cs b/Systems/Mechanic/ArenaWallSystem.cs index a76c3697df..b035b16c39 100644 --- a/Systems/Mechanic/ArenaWallSystem.cs +++ b/Systems/Mechanic/ArenaWallSystem.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Systems.Mechanic /// /// The despawn logic to kill this box. Only runs when RemovalCondition is true. Return true to delete the box from ActiveBoxes. /// - public Func DespawnAction = (box) => true; + public Func DespawnAction = (box) => true; public bool PullPlayerWhenSizeChanged => false; public void DrawBoxWithOffset(float Offset, float Thickness, Color color) @@ -112,7 +112,7 @@ namespace CalamityMod.Systems.Mechanic DepthStencilState.None, RasterizerState.CullNone, null, - Main.GameViewMatrix.ZoomMatrix + Main.Transform ); foreach (var box in ActiveBoxes) { @@ -144,7 +144,7 @@ namespace CalamityMod.Systems.Mechanic ActiveBoxes.Remove(box); i--; } - + continue; } From 355970b54055c9b86d78c7beaefbb0f14d98a619 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 14:08:45 +0900 Subject: [PATCH 13/23] null check on Scal arena color --- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 2a71232038..16b78c1c15 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -60,7 +60,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas Count = 7 } - public static Color CurrentColor => CalamityGlobalNPC.SCal >= 0 && Main.npc[CalamityGlobalNPC.SCal].active && Main.npc[CalamityGlobalNPC.SCal].ModNPC().ArenaBox is not null ? Main.npc[CalamityGlobalNPC.SCal].ModNPC().ArenaBox.borderColor : SupremeCalamitas.AcceptanceColor; + public static Color CurrentColor + { + get + { + if (CalamityGlobalNPC.SCal < 0) + return AcceptanceColor; + + var npc = Main.npc[CalamityGlobalNPC.SCal]; + if (npc == null || !npc.active) + return AcceptanceColor; + + if (npc.ModNPC is not SupremeCalamitas calamitas || calamitas.ArenaBox is null) + return AcceptanceColor; + + return calamitas.ArenaBox.borderColor; + } + } public static Color GriefColor => Color.Crimson; public static Color LamentColor => Color.RoyalBlue; public static Color EpiphanyColor => new Color(219, 75, 2); @@ -682,20 +698,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas void UpdateArena(ArenaWallSystem.Box box) { - var x = 1f/TextureAssets.MagicPixel.Height(); - var p = ScalArenaMetaball.SpawnParticle((box.TopLeft + box.BottomLeft) * 0.5f - new Vector2(box.borderThickness*0.5f + 2,0), Vector2.Zero, 1); + var x = 1f / TextureAssets.MagicPixel.Height(); + var p = ScalArenaMetaball.SpawnParticle((box.TopLeft + box.BottomLeft) * 0.5f - new Vector2(box.borderThickness * 0.5f + 2, 0), Vector2.Zero, 1); p.SizeScaling = 0; p.TextureToUse = TextureAssets.MagicPixel.Value; - p.Scale = new Vector2(box.borderThickness-6, box.borderThickness*2 + box.Size.Y-4); + p.Scale = new Vector2(box.borderThickness - 6, box.borderThickness * 2 + box.Size.Y - 4); p.Scale.Y *= x; - + p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.BottomRight) * 0.5f + new Vector2(box.borderThickness * 0.5f + 2, 0), Vector2.Zero, 1); p.SizeScaling = 0; p.TextureToUse = TextureAssets.MagicPixel.Value; p.Scale = new Vector2(box.borderThickness - 6, box.borderThickness * 2 + box.Size.Y - 4); p.Scale.Y *= x; - p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.TopLeft) * 0.5f - new Vector2(0,box.borderThickness * 0.5f + 2), Vector2.Zero, 1); + p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.TopLeft) * 0.5f - new Vector2(0, box.borderThickness * 0.5f + 2), Vector2.Zero, 1); p.SizeScaling = 0; p.TextureToUse = TextureAssets.MagicPixel.Value; p.Scale = new Vector2(box.borderThickness * 2 + box.Size.X - 4, box.borderThickness - 6); From 704dfe2f6c9d31af68b322514a42b38d39ce0441 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 16:13:22 +0900 Subject: [PATCH 14/23] MiniGuardianRock - Use Texture ref from ProfanedRocks instead of Request --- Projectiles/Summon/MiniGuardianRock.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Projectiles/Summon/MiniGuardianRock.cs b/Projectiles/Summon/MiniGuardianRock.cs index 664e157772..0e6437ea00 100644 --- a/Projectiles/Summon/MiniGuardianRock.cs +++ b/Projectiles/Summon/MiniGuardianRock.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.Summon.Whips; using CalamityMod.Dusts; +using CalamityMod.NPCs.ProfanedGuardians; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -109,7 +110,7 @@ namespace CalamityMod.Projectiles.Summon var dye = Owner?.cMinion ?? 0; bool psc = Owner.Calamity().profanedCrystalBuffs; int rockType = (int)MathHelper.Clamp(Projectile.ai[2], 1f, 6f); ; - Texture2D texture = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedRocks" + rockType.ToString()).Value; + Texture2D texture = ProfanedRocks.Textures[rockType - 1].Value; Vector2 drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2); Vector2 drawPos = Projectile.Center - Main.screenPosition; From a4236508a281b68ed2249a9a74ce046f87189a22 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 17:25:04 +0900 Subject: [PATCH 15/23] HeldOnlyItem - Removed Double Casting --- Items/BaseItems/HeldOnlyItem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Items/BaseItems/HeldOnlyItem.cs b/Items/BaseItems/HeldOnlyItem.cs index 76bced9eb6..e7cd85529a 100644 --- a/Items/BaseItems/HeldOnlyItem.cs +++ b/Items/BaseItems/HeldOnlyItem.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.BaseItems private static void DrawSpecial(Terraria.UI.On_ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color) { - if (inv[slot].ModItem is HeldOnlyItem && !(inv[slot].ModItem as HeldOnlyItem).VisibleInUI) + if (inv[slot].ModItem is HeldOnlyItem heldOnlyItem && !heldOnlyItem.VisibleInUI) return; else @@ -45,14 +45,14 @@ namespace CalamityMod.Items.BaseItems private static void LockMouseToSpecialItem(Terraria.UI.On_ItemSlot.orig_LeftClick_ItemArray_int_int orig, Item[] inv, int context, int slot) { - if (!(Main.mouseItem.ModItem is HeldOnlyItem)) + if (Main.mouseItem.ModItem is not HeldOnlyItem) orig(inv, context, slot); } //https://media.discordapp.net/attachments/458432092301295618/993675527539916850/unknown.png private static void DontDropCoolStuff(Terraria.On_Player.orig_dropItemCheck orig, Terraria.Player self) { - if (!(Main.mouseItem.ModItem is HeldOnlyItem)) + if (Main.mouseItem.ModItem is not HeldOnlyItem) orig(self); } } From 2d0887223529ea4044615831845cc8734f070b25 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 21:24:54 +0900 Subject: [PATCH 16/23] Trigger Config SaveChanges only when it's actually changed --- UI/DraedonsArsenal/ChargeMeterUI.cs | 2 +- UI/FlightBar/FlightBar.cs | 2 +- UI/Rippers/RipperUI.cs | 4 ++-- UI/StealthUI.cs | 2 +- UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs | 2 +- UI/UnstableCastersGauntlet/VisUI.cs | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/UI/DraedonsArsenal/ChargeMeterUI.cs b/UI/DraedonsArsenal/ChargeMeterUI.cs index df22dcd4cb..84f2a693e8 100644 --- a/UI/DraedonsArsenal/ChargeMeterUI.cs +++ b/UI/DraedonsArsenal/ChargeMeterUI.cs @@ -129,7 +129,7 @@ namespace CalamityMod.UI.DraedonsArsenal } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; CalamityClientConfig.Instance.SaveChanges(); diff --git a/UI/FlightBar/FlightBar.cs b/UI/FlightBar/FlightBar.cs index a788cd2913..6339989af1 100644 --- a/UI/FlightBar/FlightBar.cs +++ b/UI/FlightBar/FlightBar.cs @@ -171,7 +171,7 @@ namespace CalamityMod.UI } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; CalamityClientConfig.Instance.SaveChanges(); diff --git a/UI/Rippers/RipperUI.cs b/UI/Rippers/RipperUI.cs index f36c398ae7..0ecab2c12f 100644 --- a/UI/Rippers/RipperUI.cs +++ b/UI/Rippers/RipperUI.cs @@ -222,7 +222,7 @@ namespace CalamityMod.UI.Rippers } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (rageDragOffset.HasValue && ms.LeftButton == ButtonState.Released) { rageDragOffset = null; CalamityClientConfig.Instance.SaveChanges(); @@ -264,7 +264,7 @@ namespace CalamityMod.UI.Rippers } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (adrenDragOffset.HasValue && ms.LeftButton == ButtonState.Released) { adrenDragOffset = null; CalamityClientConfig.Instance.SaveChanges(); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 8d9f46f226..c672532e74 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -135,7 +135,7 @@ namespace CalamityMod.UI } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; CalamityClientConfig.Instance.SaveChanges(); diff --git a/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs index f6b1e35b38..924de8f7cb 100644 --- a/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs +++ b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs @@ -120,7 +120,7 @@ namespace CalamityMod.UI.SulphurousWaterMeter } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; CalamityClientConfig.Instance.SaveChanges(); diff --git a/UI/UnstableCastersGauntlet/VisUI.cs b/UI/UnstableCastersGauntlet/VisUI.cs index f70469d37f..33f697ee43 100644 --- a/UI/UnstableCastersGauntlet/VisUI.cs +++ b/UI/UnstableCastersGauntlet/VisUI.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.CalPlayer; using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -6,7 +7,6 @@ using Microsoft.Xna.Framework.Input; using ReLogic.Content; using Terraria; using Terraria.ModLoader; -using CalamityMod.CalPlayer; namespace CalamityMod.UI.DraedonsArsenal { @@ -130,7 +130,7 @@ namespace CalamityMod.UI.DraedonsArsenal } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; CalamityClientConfig.Instance.SaveChanges(); From e28d59a860e2ea21cb5922f24f1c15fe712e717b Mon Sep 17 00:00:00 2001 From: Flowaria Date: Thu, 18 Dec 2025 21:50:47 +0900 Subject: [PATCH 17/23] Skip Loop if no item is present --- Utilities/TextureUtils/DeferredTextureLoadingManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Utilities/TextureUtils/DeferredTextureLoadingManager.cs b/Utilities/TextureUtils/DeferredTextureLoadingManager.cs index 71dd7e68d0..7902863691 100644 --- a/Utilities/TextureUtils/DeferredTextureLoadingManager.cs +++ b/Utilities/TextureUtils/DeferredTextureLoadingManager.cs @@ -8,12 +8,14 @@ namespace CalamityMod { private static readonly List Textures = []; private static readonly List TexturesToRemove = []; + private static bool HasItem = false; public static void Enqueue(IDeferredLoadTexture texture) { Main.QueueMainThreadAction(() => { Textures.Add(texture); + HasItem = true; }); } @@ -29,6 +31,9 @@ namespace CalamityMod private static void DoUpdate() { + if (!HasItem) + return; + int limitPerTick = 2; foreach (var texture in Textures) { @@ -39,7 +44,7 @@ namespace CalamityMod limitPerTick--; } - if (limitPerTick < 0) + if (limitPerTick <= 0) { break; } @@ -51,6 +56,7 @@ namespace CalamityMod } TexturesToRemove.Clear(); + HasItem = Textures.Count != 0; } } } From 60480bf07fd0f56d3ad42ae76096d895c83242fa Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Fri, 19 Dec 2025 00:51:03 -0500 Subject: [PATCH 18/23] 1 - Stohne no longer generates naturally 2 - Stohne no longer blends with common tiles or is part of the Any Stone recipe group 3 - Bohldohr no longer drops Lihzahrd Brick (They drop Stohne, which crafts into Lihzahrd Brick) --- ILEditing/ILChangesLoading.cs | 1 - ILEditing/MechanicILChanges.cs | 25 ------------------------- NPCs/NormalNPCs/Bohldohr.cs | 1 - Systems/Mechanic/RecipeSystem.cs | 3 +-- Utilities/TileUtils.cs | 1 - 5 files changed, 1 insertion(+), 30 deletions(-) diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index ffed28fb41..097e80ec90 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -136,7 +136,6 @@ namespace CalamityMod.ILEditing IL_UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey; On_WorldGen.MakeDungeon += LimitDungeonEntranceXPosition; IL_WorldGen.DungeonHalls += LimitDungeonHallsXPosition; - IL_JunglePass.GenerateFinishingTouches += AddStohne; // Removal of vanilla stupidity IL_Player.StatusFromNPC += RemoveExpertBrainRandomDebuffs; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 1d068940fc..d8c16eea1e 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -1321,31 +1321,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Add Stohne to the Jungle - private static void AddStohne(ILContext il) - { - var cursor = new ILCursor(il); - - if (!cursor.TryGotoNext(MoveType.Before, - c => c.MatchLdcI4(out var tileType) && tileType == TileID.Stone, - c => c.MatchLdcI4(out _), // bool addTile - c => c.MatchLdcR8(out _), // double speedX - c => c.MatchLdcR8(out _), // double speedY - c => c.MatchLdcI4(out _), // bool noYChange - c => c.MatchLdcI4(out _), // bool overRide - c => c.MatchLdcI4(out _), // int ignoreTileType - c => c.MatchCallOrCallvirt(nameof(WorldGen.TileRunner)))) - { - LogFailure("Add Stohne To Jungle", "Could not locate the TileRunner call for Stone"); - return; - } - - // Replace Next Instruction to Ldc.I4 :: Stohne - cursor.Next.OpCode = OpCodes.Ldc_I4; - cursor.Next.Operand = ModContent.TileType(); - } - #endregion - #region Hellscape for GlowMask ModPlants #region Tree Trunk / Cactus GlowMask diff --git a/NPCs/NormalNPCs/Bohldohr.cs b/NPCs/NormalNPCs/Bohldohr.cs index a7c0f35756..f6af30ac41 100644 --- a/NPCs/NormalNPCs/Bohldohr.cs +++ b/NPCs/NormalNPCs/Bohldohr.cs @@ -93,7 +93,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.LihzahrdBrick, 1, 10, 26); npcLoot.Add(ModContent.ItemType(), 1, 10, 26); npcLoot.Add(ItemID.LunarTabletFragment, 7, 10, 26); npcLoot.Add(ItemID.LihzahrdPowerCell, 50); diff --git a/Systems/Mechanic/RecipeSystem.cs b/Systems/Mechanic/RecipeSystem.cs index 3023f9758e..13fb7ee702 100644 --- a/Systems/Mechanic/RecipeSystem.cs +++ b/Systems/Mechanic/RecipeSystem.cs @@ -236,8 +236,7 @@ namespace CalamityMod.Systems ItemID.EbonstoneBlock, ItemID.CrimstoneBlock, ItemID.PearlstoneBlock, - ItemType(), - ItemType() + ItemType() }); AnyStoneBlock = RecipeGroup.RegisterGroup("AnyStoneBlock", group); diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 28e6382e8d..ff47fdb067 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -398,7 +398,6 @@ namespace CalamityMod TileType(), TileType(), TileType(), - TileType(), TileType(), }); From 900e9c76329088343323a8fd30adf5a87655108d Mon Sep 17 00:00:00 2001 From: Flowaria Date: Fri, 19 Dec 2025 18:36:43 +0900 Subject: [PATCH 19/23] Wrap Effect Unload with MainThreadAction --- Graphics/Primitives/PrimitiveRenderer.cs | 113 ++++++++++++----------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs index 4f06690c39..cde72d2990 100644 --- a/Graphics/Primitives/PrimitiveRenderer.cs +++ b/Graphics/Primitives/PrimitiveRenderer.cs @@ -98,8 +98,11 @@ namespace CalamityMod.Graphics.Primitives public override void OnModUnload() { - WireframeEffect?.Dispose(); - WireframeEffect = null; + Main.QueueMainThreadAction(() => + { + WireframeEffect?.Dispose(); + WireframeEffect = null; + }); } private static void PerformPixelationSafetyChecks(PrimitiveSettings settings) @@ -593,27 +596,27 @@ namespace CalamityMod.Graphics.Primitives return Vector2.Lerp(p1, p2, t); case PrimitiveSmoothingType.Cardinal: - { - float tension = MathHelper.Clamp(settings.SmoothingTension, -1f, 1f); - float scale = (1f - tension) * 0.5f; - Vector2 m0 = (p2 - p0) * scale; - Vector2 m1 = (p3 - p1) * scale; - return EvaluateHermiteSpan(p1, p2, m0, m1, t); - } + { + float tension = MathHelper.Clamp(settings.SmoothingTension, -1f, 1f); + float scale = (1f - tension) * 0.5f; + Vector2 m0 = (p2 - p0) * scale; + Vector2 m1 = (p3 - p1) * scale; + return EvaluateHermiteSpan(p1, p2, m0, m1, t); + } case PrimitiveSmoothingType.Hermite: - { - Vector2 m0 = 0.5f * (p2 - p0); - Vector2 m1 = 0.5f * (p3 - p1); - return EvaluateHermiteSpan(p1, p2, m0, m1, t); - } + { + Vector2 m0 = 0.5f * (p2 - p0); + Vector2 m1 = 0.5f * (p3 - p1); + return EvaluateHermiteSpan(p1, p2, m0, m1, t); + } case PrimitiveSmoothingType.CubicBezier: - { - Vector2 handle1 = p1 + (p2 - p0) / 3f; - Vector2 handle2 = p2 - (p3 - p1) / 3f; - return EvaluateBezierSpan(p1, handle1, handle2, p2, t); - } + { + Vector2 handle1 = p1 + (p2 - p0) / 3f; + Vector2 handle2 = p2 - (p3 - p1) / 3f; + return EvaluateBezierSpan(p1, handle1, handle2, p2, t); + } default: return Vector2.CatmullRom(p0, p1, p2, p3, t); @@ -677,49 +680,49 @@ namespace CalamityMod.Graphics.Primitives switch (MainSettings.JoinStyle) { case PrimitiveJoinStyle.Smooth: - { - Vector2 averageNormal = (prevNormal + defaultNormal + nextNormal) * (1f / 3f); - if (averageNormal.LengthSquared() <= Epsilon) - averageNormal = defaultNormal; + { + Vector2 averageNormal = (prevNormal + defaultNormal + nextNormal) * (1f / 3f); + if (averageNormal.LengthSquared() <= Epsilon) + averageNormal = defaultNormal; - Vector2 offset = averageNormal.SafeNormalize(defaultNormal) * halfWidth; - left = currentPosition - offset; - right = currentPosition + offset; - effectiveHalfWidth = halfWidth; - return; - } + Vector2 offset = averageNormal.SafeNormalize(defaultNormal) * halfWidth; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = halfWidth; + return; + } case PrimitiveJoinStyle.Miter: - { - Vector2 prev = prevNormal.SafeNormalize(defaultNormal); - Vector2 next = nextNormal.SafeNormalize(defaultNormal); - Vector2 miter = prev + next; - if (miter.LengthSquared() <= Epsilon) - miter = defaultNormal; + { + Vector2 prev = prevNormal.SafeNormalize(defaultNormal); + Vector2 next = nextNormal.SafeNormalize(defaultNormal); + Vector2 miter = prev + next; + if (miter.LengthSquared() <= Epsilon) + miter = defaultNormal; - miter = miter.SafeNormalize(defaultNormal); - float denom = Vector2.Dot(miter, next); - if (Math.Abs(denom) < Epsilon) - denom = denom >= 0f ? Epsilon : -Epsilon; + miter = miter.SafeNormalize(defaultNormal); + float denom = Vector2.Dot(miter, next); + if (Math.Abs(denom) < Epsilon) + denom = denom >= 0f ? Epsilon : -Epsilon; - float miterLength = halfWidth / denom; - float maxLength = halfWidth * MainSettings.JoinMiterLimit; - miterLength = MathHelper.Clamp(miterLength, -maxLength, maxLength); - Vector2 offset = miter * miterLength; - left = currentPosition - offset; - right = currentPosition + offset; - effectiveHalfWidth = Math.Max(Math.Abs(miterLength), Epsilon); - return; - } + float miterLength = halfWidth / denom; + float maxLength = halfWidth * MainSettings.JoinMiterLimit; + miterLength = MathHelper.Clamp(miterLength, -maxLength, maxLength); + Vector2 offset = miter * miterLength; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = Math.Max(Math.Abs(miterLength), Epsilon); + return; + } default: - { - Vector2 offset = defaultNormal * halfWidth; - left = currentPosition - offset; - right = currentPosition + offset; - effectiveHalfWidth = halfWidth; - return; - } + { + Vector2 offset = defaultNormal * halfWidth; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = halfWidth; + return; + } } } From 72a11fca3aec954d1e3339787d59c6f611129213 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Fri, 19 Dec 2025 19:19:08 +0900 Subject: [PATCH 20/23] ScabRipper - Now able to desummon while having spider minion --- Projectiles/Summon/BabyBloodCrawler.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index 10fdd37bb7..a206139565 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -46,6 +46,20 @@ namespace CalamityMod.Projectiles.Summon return true; } + private bool _hadSpiderMinion = false; + public override bool PreAI() + { + var owner = Main.player[Projectile.owner]; + _hadSpiderMinion = owner.spiderMinion; + owner.spiderMinion = false; + return true; + } + + public override void PostAI() + { + Main.player[Projectile.owner].spiderMinion = _hadSpiderMinion; + } + public override void AI() { if (bloodCooldown > 0) From d25bec465a828a2b9a3e1cf5e85b611f4b9af4be Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 20 Dec 2025 02:39:26 +0700 Subject: [PATCH 21/23] Warding Wave & Lucrecia Energy cooldown icons --- Cooldowns/LucreciaEnergy.png | Bin 385 -> 490 bytes Cooldowns/LucreciaEnergyOutline.png | Bin 179 -> 239 bytes Cooldowns/LucreciaEnergyOverlay.png | Bin 163 -> 184 bytes Cooldowns/WardingWave.png | Bin 216 -> 480 bytes Cooldowns/WardingWaveOutline.png | Bin 180 -> 243 bytes Cooldowns/WardingWaveOverlay.png | Bin 144 -> 207 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Cooldowns/LucreciaEnergy.png b/Cooldowns/LucreciaEnergy.png index 9891d6fd0b58093803a9e13976bc94ccb9298ed6..b30433733232aacb4d6d888986936da4307d8259 100644 GIT binary patch literal 490 zcmVPx#1ZP1_K>z@;j|==^1poj6lu1NER5(w))IVrbQ547V&yyMxLKPD!jf&-eMg#c#^<%={kcj%AAfCizg&o77 z-TWTH_^C2jwg$4b99VdIE8YruoI>TlEH5Y%hX|!bBqOJ7LcSTlI!k zyTM85Ju7DSh-hkH9bFlqO z9h{iCw!RBzr%r<6=&k^^m3A`-!lASglO1pG1$PROpY6Vsv^qb3fO`+lFi^t$rRXic zYCZ&4MdR(^S@5fyx9M>c?Ado1eERUZyArAIgu(QIInWN?C4T14YCeEWe)XR}b}6?% gfLbPx$J4r-AR7i=$Vq_!0}Rv_?XMgIZh{s%QRMIljOYKm?GKY)aPAc5d3 zDs~+LY!eW7?k4-%EsL0e>)y`n%$fJz+yN?TIX;}0}$ErMrr>(`4N2d;tKmT^j%}TK@n5rtghE*9b?P=d?>g#4$dRhGESUUnF6}db>eJxp1J0AW8v2WeWCvTo|EB$i6;KWkj f`L5jUZeHm#zW9|C8OpW#00000NkvXXu0mjf1F5cV diff --git a/Cooldowns/LucreciaEnergyOutline.png b/Cooldowns/LucreciaEnergyOutline.png index 247f332da8e9e3ef339e3cf58eadaf91069df809..af6bbe9b8554b284e59ab3c752808613dd8f9446 100644 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCikPdb&7|5e{7p`3GZSYEFbLlI`&F?*$u2i;6_IM%AS#{3z*POqci*BA( z>o}+ByWz|0mAlzLMb0SVs}jC3?|@0dv&8R`7ROB@e1GsMP1?V*y539Zfu)zw%LB3Y mlNd4>&u!t0d7e<+B)#;zj}-4R{urPm89ZJ6T-G@yGywpX173gt literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^Qb4T0!3HFGR%fsRDaPU;cPEB*=VV?2Ik}!Ljv*eM zZ>Kp5ISBGNAN~9O%(L4YI%*cbFv-r{Bc-Go_;hmA^s7y8UwMXXs_wXPF8$;=;g#tJ zuFY5eRqY?K*Y=_o=j(L0C+9hG`xrJHUhwt1`7Q&l#epBM#b%qF@IUme>YKQWamKW+ cr!yr3S+8+SURcK}1#%LDr>mdKI;Vst0H;PqH2?qr diff --git a/Cooldowns/LucreciaEnergyOverlay.png b/Cooldowns/LucreciaEnergyOverlay.png index 851597883bf2d1c124aea92897c89d454e24f0c9..1623d75cba45ecd668184e3038ce4ee3f9499400 100644 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lf{PZ!4!3;(MV9r+p*cv#B+{Gb2Yl_SJbKx}dGYqOhvK~p+9qNg--7b$qU z^M$PpS3BdjU^`FxS*tf~_w|o_xXZUYFh9yb=Qj-FW&s$yYaQQm5A@qu;X&u?Dl2?`p@*9)7E04-wh MboFyt=akR{0C8kIOaK4? diff --git a/Cooldowns/WardingWave.png b/Cooldowns/WardingWave.png index 6e578a359ee978177fab7547a80fab96bb7da504..3f5e446cc0569ab2ca4176650fb9c65c71a73516 100644 GIT binary patch delta 454 zcmV;%0XhEI0pJ6WB!2;OQb$4nuFf3k00004XF*Lt006O%3;baP0004sNklY#F zXu*Y`AQ~zz-V#A`rSUu;rnp-z4?B=zkd_d^nUmOSl+Z6%#Xf_ z_1ZravO(M6K2XXgi_ovHOkKJI;`)^l*7okmv@vsJC>LiGG?H*h_3$+iKhA^FqiU-3 zrenjqbndJ?23uxQef#F!Ag*an4K)=`7;cPCf}VR5IakjuAgb%&#arOzhcQrkJ{ur> z`kvx!a}f$H<9{*2?6#CRw5uPS?%WExpC+Qo{^au8@^J0y9|{^uICuXwxIS_Ube}u` zI-acq@od-cTZ`;v@q{aGeg;kLt8y+6jNJ{eXYNac*2{ar)a~SM=eIQD{X@sd%)EHQ zmhrzoDt!}WaCEw|=zczFZ381$uh0;}g^9Y3pLhr^G(UGl8TSX4{vflLm1T*z{yP0X wLT6rqP17$xxqV}9mR)`My*&T5+L%A(CuRC~R)V=pn*aa+07*qoM6N<$f@HhdyZ`_I delta 188 zcmV;t07L)a1K0tOB!8btL_t(IPh(`DGGL^#c?`qAz`Uh*{v!v=q-Yhqz9Q&lsu>6~ z$XI~~?7%oHaWI{~>@Jwb0!3s#q6xRB}w zy5~&=$Lh!Dkg)px;RlKfIR!Yte6xTo;#^2|17XfVHy9?4%Qa;%d7QCKbpz2|3ghpb qlucPqfw`1w29jF55zNcO&p-eH-B=YFLxouY0000o0rLTnB!2;OQb$4nuFf3k00004XF*Lt006O%3;baP0001;Nkl-B!78HL_t(YOYK!b3cw%?Gyi{d#||B%QW7>Ykm*fHn>MD3VO}uj zA3q|9h`7rMK^Wp&@ zNsem)uyiFY+khFA!>g2*3T;3IQc5R<9|HT1l=XWl=M-&+U0FY_-tK#oU49SP0L#oU V6|JGay8r+H07*qoM6N<$f&eDBEw}&x From 96553cdbe300c204960720bb3276a3be213c07a5 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 20 Dec 2025 03:00:06 +0700 Subject: [PATCH 22/23] wave cooldown gradients to pink to match resprite --- Cooldowns/WardingWave.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cooldowns/WardingWave.cs b/Cooldowns/WardingWave.cs index 298e47c2e1..dd18e02873 100644 --- a/Cooldowns/WardingWave.cs +++ b/Cooldowns/WardingWave.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Cooldowns public override string Texture => "CalamityMod/Cooldowns/WardingWave"; public override Color OutlineColor => new Color(158, 158, 255); public override Color CooldownStartColor => new Color(72, 125, 204); - public override Color CooldownEndColor => new Color(97, 200, 255); + public override Color CooldownEndColor => new Color(255, 170, 204); public override SoundStyle? EndSound => SoundID.Item85; } } From 7af86d63bc70d2afbd3df85c03cfc1a335afa338 Mon Sep 17 00:00:00 2001 From: Dreitone Date: Fri, 19 Dec 2025 19:03:32 -0600 Subject: [PATCH 23/23] cherry-pick: fix unloading --- Graphics/Primitives/PrimitiveRenderer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs index cde72d2990..8c9a78f382 100644 --- a/Graphics/Primitives/PrimitiveRenderer.cs +++ b/Graphics/Primitives/PrimitiveRenderer.cs @@ -100,6 +100,18 @@ namespace CalamityMod.Graphics.Primitives { Main.QueueMainThreadAction(() => { + MainPositions = null; + MainVertices = null; + MainIndices = null; + MainCompletionRatios = null; + MainTangents = null; + MainNormals = null; + WireframeVertices = null; + NonSmoothIndexScratch = null; + VertexBuffer?.Dispose(); + VertexBuffer = null; + IndexBuffer?.Dispose(); + IndexBuffer = null; WireframeEffect?.Dispose(); WireframeEffect = null; });