From 55ca51846424a666274d858af26f9ca729eade86 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 1 Oct 2021 10:30:01 -0500 Subject: [PATCH 01/16] Another music muffle IL Edit fix attempt --- ILEditing/ILChanges.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index dfac76cf88..967debcd38 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -496,7 +496,7 @@ namespace CalamityMod.ILEditing private static void ManipulateSoundMuffleFactor(ILContext il) { ILCursor cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchStloc(30)); + cursor.GotoNext(MoveType.After, i => i.MatchStloc(20)); cursor.Emit(OpCodes.Ldloc, 20); cursor.EmitDelegate>(originalMuffleFactor => From 199199bad30c36e5c68359015800b2c1745aa5b3 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 1 Oct 2021 10:52:20 -0500 Subject: [PATCH 02/16] Fixed a Codebreaker cell use rounding error --- TileEntities/TECodebreaker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TileEntities/TECodebreaker.cs b/TileEntities/TECodebreaker.cs index c8c02729ee..0442166a17 100644 --- a/TileEntities/TECodebreaker.cs +++ b/TileEntities/TECodebreaker.cs @@ -306,7 +306,7 @@ namespace CalamityMod.TileEntities DecryptionCountdown--; // Gradually consume cells. - if (DecryptionCountdown % 5 == 4) + if (DecryptionCountdown % 5 == 0) { InputtedCellCount = InitialCellCountBeforeDecrypting - (int)(DecryptionCellCost * DecryptionCompletion); if (Main.netMode != NetmodeID.MultiplayerClient) From 7451e9294aece5936b7a4913ae80a5dca597cbd2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 1 Oct 2021 10:52:33 -0500 Subject: [PATCH 03/16] Fixed some Codebreaker UI scale issues --- UI/CodebreakerUI.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/UI/CodebreakerUI.cs b/UI/CodebreakerUI.cs index 9d93610dc4..46f8a49f1d 100644 --- a/UI/CodebreakerUI.cs +++ b/UI/CodebreakerUI.cs @@ -82,8 +82,8 @@ namespace CalamityMod.UI { if (canSummonDraedon) { - costVerificationLocation.X -= 15f; - summonButtonCenter.X += 15f; + costVerificationLocation.X -= GeneralScale * 15f; + summonButtonCenter.X += GeneralScale * 15f; } DrawCostVerificationButton(codebreakerTileEntity, costVerificationLocation); } @@ -91,16 +91,16 @@ namespace CalamityMod.UI else if (codebreakerTileEntity.DecryptionCountdown > 0) { if (!AwaitingCloseConfirmation) - DisplayDecryptCancelButton(codebreakerTileEntity, costVerificationLocation - Vector2.UnitY * 30f); + DisplayDecryptCancelButton(codebreakerTileEntity, costVerificationLocation - Vector2.UnitY * GeneralScale * 30f); else - DisplayDecryptCancelButton(codebreakerTileEntity, textPanelCenter + Vector2.UnitY * 110f); + DisplayDecryptCancelButton(codebreakerTileEntity, textPanelCenter + Vector2.UnitY * GeneralScale * 110f); } if (canSummonDraedon) HandleDraedonSummonButton(codebreakerTileEntity, summonButtonCenter); if (codebreakerTileEntity.DecryptionCountdown > 0 || AwaitingDecryptionTextClose) - HandleDecryptionStuff(codebreakerTileEntity, backgroundTexture, backgroundTopLeft, schematicSlotDrawCenter + Vector2.UnitY * 80f); + HandleDecryptionStuff(codebreakerTileEntity, backgroundTexture, backgroundTopLeft, schematicSlotDrawCenter + Vector2.UnitY * GeneralScale * 80f); if (codebreakerTileEntity.DecryptionCountdown > 0 && AwaitingCloseConfirmation) DrawDecryptCancelConfirmationText(textPanelCenter); @@ -124,7 +124,7 @@ namespace CalamityMod.UI spriteBatch.Draw(schematicIconBG, schematicSlotDrawCenter, null, Color.White, 0f, schematicIconBG.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); if (codebreakerTileEntity.HeldSchematicID != 0) spriteBatch.Draw(schematicIconTexture, schematicSlotDrawCenter, null, Color.White, 0f, schematicIconTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); - HandleSchematicSlotInteractions(codebreakerTileEntity, schematicSlotDrawCenter, cellTexture.Size()); + HandleSchematicSlotInteractions(codebreakerTileEntity, schematicSlotDrawCenter, cellTexture.Size() * GeneralScale); // Create a temporary item for drawing purposes. // If cells are present, make the item reflect that. @@ -262,11 +262,11 @@ namespace CalamityMod.UI // And draw the cells to the right of the text. Texture2D cellTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/PowerCell"); - Vector2 offsetDrawPosition = new Vector2(drawPosition.X + ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One, -1f).X + GeneralScale * 15f, drawPosition.Y + GeneralScale * 30f); + Vector2 offsetDrawPosition = new Vector2(drawPosition.X + ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One, -1f).X * GeneralScale + GeneralScale * 15f, drawPosition.Y + GeneralScale * 30f); Main.spriteBatch.Draw(cellTexture, offsetDrawPosition, null, Color.White, 0f, cellTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); // Display the cell quantity numerically below the drawn cells. - Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontItemStack, totalCellsCost.ToString(), offsetDrawPosition.X - 11f, offsetDrawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), GeneralScale * 0.75f); + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontItemStack, totalCellsCost.ToString(), offsetDrawPosition.X - GeneralScale * 11f, offsetDrawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), GeneralScale * 0.75f); } public static void DrawCostVerificationButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition) @@ -360,7 +360,7 @@ namespace CalamityMod.UI public static void HandleDecryptionStuff(TECodebreaker codebreakerTileEntity, Texture2D backgroundTexture, Vector2 backgroundTopLeft, Vector2 barCenter) { Texture2D textPanelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen"); - Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f); + Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width * GeneralScale + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f) * GeneralScale; Main.spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); // Generate gibberish and use slowly insert the real text. @@ -382,7 +382,7 @@ namespace CalamityMod.UI text[i] = trueMessage[i]; // Define the initial text draw position. - Vector2 currentTextDrawPosition = backgroundTopLeft + new Vector2(backgroundTexture.Width - textPanelTexture.Width + textPadding, 6f); + Vector2 currentTextDrawPosition = backgroundTopLeft + new Vector2(backgroundTexture.Width - textPanelTexture.Width + textPadding, 6f) * GeneralScale; // Draw the lines of text. A maximum of 10 may be drawn and the vertical offset per line is 16 pixels. foreach (string line in Utils.WordwrapString(text.ToString(), Main.fontMouseText, (int)(textPanelTexture.Width * 1.5 - textPadding * 2), 10, out _)) @@ -392,7 +392,7 @@ namespace CalamityMod.UI continue; ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, line, currentTextDrawPosition, Color.Cyan, 0f, Vector2.Zero, new Vector2(0.6f) * GeneralScale); - currentTextDrawPosition.Y += 16; + currentTextDrawPosition.Y += GeneralScale * 16f; } // Handle special drawing when decryption is ongoing. From d5523beaf911ae6ba68e424e5bfff8be797fecc6 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 1 Oct 2021 10:58:21 -0500 Subject: [PATCH 04/16] Fixed Gamma Head direction rotation issues --- Projectiles/Summon/GammaHead.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index d989b40b4b..0574ead5ae 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -150,6 +150,9 @@ namespace CalamityMod.Projectiles.Summon // Direction affecting. if (target.Center.X - spawnPosition.X < 0) fireAngle += MathHelper.Pi; + if (projectile.direction == (target.Center.X < spawnPosition.X).ToDirectionInt()) + fireAngle += MathHelper.Pi; + idealRotation = fireAngle; // Shoot the actual canister. From f62b079fa9158e3678a04badcab87e122bac18d9 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 1 Oct 2021 11:50:12 -0500 Subject: [PATCH 05/16] Fixed Daawnlight Spirit Origin bullseye hit math --- NPCs/CalamityGlobalNPC.cs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 8ee5695278..bd64f771ea 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3396,17 +3396,31 @@ namespace CalamityMod.NPCs // Bullseyes are visually larger on bosses, so account for that. float baseBullseyeRadius = npc.IsABoss() ? 116f : 54f; bool hasCollidedWithBullseye; + + // Custom math to determine if a direction would hit a target if the hitbox would not delete the projectile before it can. + // This can be visualized as using the NPC center as an anchor point, determining the direction to the bullseye from that anchor point, + // calculating the maximum amount of angular error there can be before a hit would not happen, and checking if the projectile's direction + // to the bullseye is within that margin of error. if (projectile.penetrate <= 1 && projectile.penetrate != -1) - hasCollidedWithBullseye = projectile.WithinRange(bullseye.Center, bullseye.scale * baseBullseyeRadius); - else { + // Directions to the bullseye relative to the NPC's center and the projectile that hit the NPC. Vector2 directionToBullseye = projectile.SafeDirectionTo(bullseye.Center, Vector2.UnitY); - Vector2 orthogonalEdgeOffset = Vector2.UnitX.RotatedBy(directionToBullseye.ToRotation() + MathHelper.PiOver2) * baseBullseyeRadius; - Vector2 edgeVector = projectile.Center - bullseye.Center + orthogonalEdgeOffset; - float inaccuracyLimit = directionToBullseye.AngleBetween(edgeVector); - float orthogonalityToIdealDirection = directionToBullseye.AngleBetween(projectile.velocity); - hasCollidedWithBullseye = orthogonalityToIdealDirection < inaccuracyLimit && projectile.WithinRange(bullseye.Center, bullseye.scale * baseBullseyeRadius); + Vector2 bullseyeCenterOffsetDirection = npc.SafeDirectionTo(bullseye.Center); + + // Use SOH-CAH-TOA to compute the angle which is needed to reach the edge of the bullseye from the center of the NPC. + // The length of the hypotenuse is the distance from the center of the NPC to the bullseye while the opposite side length is + // the circular hitbox radius of the bullseye. These are sufficient to calculate the angular margin of error. + // If an NPC has a tiny hitbox the arcsine will fail and return NaN, meaning any hit at all will cause a bullseye to be hit. + // In these cases, simply set the "limit" to an extremely large value. + float angularOffsetToEdgeOfBullseye = (float)Math.Asin(baseBullseyeRadius / npc.Distance(bullseye.Center)); + if (float.IsNaN(angularOffsetToEdgeOfBullseye)) + angularOffsetToEdgeOfBullseye = 1000f; + float orthogonalityToBullseye = directionToBullseye.AngleBetween(bullseyeCenterOffsetDirection); + + hasCollidedWithBullseye = orthogonalityToBullseye < angularOffsetToEdgeOfBullseye; } + else + hasCollidedWithBullseye = projectile.WithinRange(bullseye.Center, bullseye.scale * baseBullseyeRadius); // Do a very high amount of damage if hitting a bullseye. if (hasCollidedWithBullseye && bullseye.ai[1] == 0f) From 3070ec28c1c8308d9371db1b58ef118aa1f8d805 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 3 Oct 2021 16:49:44 -0500 Subject: [PATCH 06/16] Cart of Gods' segments can have shaders --- DataStructures/DoGCartSegment.cs | 6 ++++-- Items/Mounts/Minecarts/DoGCartMount.cs | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DataStructures/DoGCartSegment.cs b/DataStructures/DoGCartSegment.cs index 3662671bfd..e2f3ef6ba8 100644 --- a/DataStructures/DoGCartSegment.cs +++ b/DataStructures/DoGCartSegment.cs @@ -22,8 +22,10 @@ namespace CalamityMod.DataStructures OldDirection = direction; } - Rotation = (aheadPosition - Center).ToRotation(); - Center = aheadPosition - (aheadPosition - Center).SafeNormalize(Vector2.Zero) * 24f; + Vector2 offsetDirection = (aheadPosition - Center).SafeNormalize(Vector2.Zero); + offsetDirection = offsetDirection.ToRotation().AngleTowards(idealRotation, 0.2f).ToRotationVector2(); + Rotation = offsetDirection.ToRotation(); + Center = aheadPosition - offsetDirection * 20f; } } } diff --git a/Items/Mounts/Minecarts/DoGCartMount.cs b/Items/Mounts/Minecarts/DoGCartMount.cs index e2a4e57646..44140b9e54 100644 --- a/Items/Mounts/Minecarts/DoGCartMount.cs +++ b/Items/Mounts/Minecarts/DoGCartMount.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using Terraria; using Terraria.DataStructures; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -139,8 +140,12 @@ namespace CalamityMod.Items.Mounts.Minecarts Color segmentColor = Lighting.GetColor((int)segmentDrawPosition.X / 16, (int)segmentDrawPosition.Y / 16); Vector2 origin = segmentTexture.Size() * 0.5f; float segmentRotation = segment.Rotation - DelegateMethods.Minecart.rotation; + DrawData segmentDrawData = new DrawData(segmentTexture, segmentDrawPosition - Main.screenPosition, null, segmentColor, segmentRotation, origin, Vector2.One, SpriteEffects.None, 0) + { + shader = Mount.currentShader + }; - playerDrawData.Add(new DrawData(segmentTexture, segmentDrawPosition - Main.screenPosition, null, segmentColor, segmentRotation, origin, Vector2.One, SpriteEffects.None, 0)); + playerDrawData.Add(segmentDrawData); } return true; } From 069532d027d93ab108418318a1e852d45ae71411 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 3 Oct 2021 16:52:47 -0500 Subject: [PATCH 07/16] Increased the Enchant UI close radius --- UI/CalamitasEnchantments/CalamitasEnchantUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index 71007090c9..23634d8c55 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -34,7 +34,7 @@ namespace CalamityMod.UI.CalamitasEnchants if (!Main.npc.IndexInRange(NPCIndex) || !Main.npc[NPCIndex].active) return false; - Rectangle validTalkArea = Utils.CenteredRectangle(Main.LocalPlayer.Center, new Vector2(Player.tileRangeX * 2f, Player.tileRangeY) * 16f); + Rectangle validTalkArea = Utils.CenteredRectangle(Main.LocalPlayer.Center, new Vector2(Player.tileRangeX * 3f, Player.tileRangeY * 2f) * 16f); return validTalkArea.Intersects(Main.npc[NPCIndex].Hitbox); } From f0cc1736f9bd70d7fd7aeb38606360098167b6e7 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 3 Oct 2021 17:45:19 -0500 Subject: [PATCH 08/16] Perdition souls are not magic --- Projectiles/Summon/PerditionBeacon.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Projectiles/Summon/PerditionBeacon.cs b/Projectiles/Summon/PerditionBeacon.cs index fdd5ec89b8..c216d38ac1 100644 --- a/Projectiles/Summon/PerditionBeacon.cs +++ b/Projectiles/Summon/PerditionBeacon.cs @@ -152,7 +152,9 @@ namespace CalamityMod.Projectiles.Summon Vector2 spawnPosition = Target.Center + Vector2.UnitY.RotatedByRandom(0.27f) * 1150f; Vector2 shootVelocity = (Target.Center - spawnPosition).SafeNormalize(-Vector2.UnitY).RotatedByRandom(0.09f) * Main.rand.NextFloat(19f, 31f); - Projectile.NewProjectile(spawnPosition, shootVelocity, rng.Get(), projectile.damage, projectile.knockBack, projectile.owner); + int soul = Projectile.NewProjectile(spawnPosition, shootVelocity, rng.Get(), projectile.damage, projectile.knockBack, projectile.owner); + if (Main.projectile.IndexInRange(soul)) + Main.projectile[soul].Calamity().forceMinion = true; } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) From 834c8e52a55a44dd1e68dc0ea1845fd5465bcc5b Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 3 Oct 2021 17:49:12 -0500 Subject: [PATCH 09/16] Lecherous doesn't apply to summon items --- UI/CalamitasEnchantments/EnchantmentManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index d2a42cae4d..c38161c06f 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -288,7 +288,7 @@ namespace CalamityMod.UI.CalamitasEnchants CalamityNetcode.NewNPC_ClientSide(player.Center, orbType, player); } }, - item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None && !item.summon), }; // Special disenchantment thing. This is separated from the list on purpose. From 922524841b71a0c4d89d1202bbbf6b93619e2c13 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 3 Oct 2021 19:04:43 -0500 Subject: [PATCH 10/16] Potential null problem fix in Exo Mech Sky --- Skies/ExoMechsSky.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Skies/ExoMechsSky.cs b/Skies/ExoMechsSky.cs index fb356e5543..dec32d2f8f 100644 --- a/Skies/ExoMechsSky.cs +++ b/Skies/ExoMechsSky.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Skies if (draedon == -1 || !Main.npc[draedon].active) return Draedon.ExoMechIsPresent; - if (Main.npc[draedon].ModNPC().DefeatTimer <= 0 && !Draedon.ExoMechIsPresent) + if ((Main.npc[draedon]?.ModNPC()?.DefeatTimer ?? 0) <= 0 && !Draedon.ExoMechIsPresent) return false; return true; From 81541287fa87bcf4066e99fd422f2e6dd253c126 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 4 Oct 2021 14:56:20 -0500 Subject: [PATCH 11/16] BR doesn't kill enchantment NPCs --- NPCs/CalamityGlobalNPC.cs | 9 ++++++--- NPCs/Other/BrimstoneOrb.cs | 1 + NPCs/Other/CalamitasEnchantDemon.cs | 1 + NPCs/Other/DemonPortal.cs | 2 ++ NPCs/Other/ExhumedHeart.cs | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a08c6d6a55..1862df9451 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -251,8 +251,11 @@ namespace CalamityMod.NPCs // 4 - Check if malice is active and Boss Rush isn't. If so, set this to true. public bool CurrentlyEnraged; - // Collections - public static SortedDictionary BossRushHPChanges = new SortedDictionary + // Other Boss Rush stuff + public bool DoesNotDisappearInBossRush; + + // Collections + public static SortedDictionary BossRushHPChanges = new SortedDictionary { // Tier 1 { NPCID.QueenBee, 315000 }, // 30 seconds @@ -2109,7 +2112,7 @@ namespace CalamityMod.NPCs if (DestroyerIDs.Contains(npc.type) || EaterofWorldsIDs.Contains(npc.type)) npc.buffImmune[BuffType()] = false; - if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC) + if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC && !npc.Calamity().DoesNotDisappearInBossRush) BossRushForceDespawnOtherNPCs(npc, mod); if (NPC.LunarApocalypseIsUp) diff --git a/NPCs/Other/BrimstoneOrb.cs b/NPCs/Other/BrimstoneOrb.cs index bca33658e8..38d8387a7e 100644 --- a/NPCs/Other/BrimstoneOrb.cs +++ b/NPCs/Other/BrimstoneOrb.cs @@ -34,6 +34,7 @@ namespace CalamityMod.NPCs.Other npc.netAlways = true; npc.aiStyle = -1; npc.Calamity().DoesNotGenerateRage = true; + npc.Calamity().DoesNotDisappearInBossRush = true; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 181445; diff --git a/NPCs/Other/CalamitasEnchantDemon.cs b/NPCs/Other/CalamitasEnchantDemon.cs index c07ec611f2..5329685195 100644 --- a/NPCs/Other/CalamitasEnchantDemon.cs +++ b/NPCs/Other/CalamitasEnchantDemon.cs @@ -34,6 +34,7 @@ namespace CalamityMod.NPCs.Other npc.knockBackResist = 0f; npc.netAlways = true; npc.aiStyle = 0; + npc.Calamity().DoesNotDisappearInBossRush = true; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 101010; diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 5eba0752ed..449d20441b 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -24,6 +24,8 @@ namespace CalamityMod.NPCs.Other npc.knockBackResist = 0f; npc.netAlways = true; npc.aiStyle = -1; + npc.Calamity().DoesNotGenerateRage = true; + npc.Calamity().DoesNotDisappearInBossRush = true; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 24660; diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs index bfde229cb5..5b75574529 100644 --- a/NPCs/Other/ExhumedHeart.cs +++ b/NPCs/Other/ExhumedHeart.cs @@ -38,6 +38,7 @@ namespace CalamityMod.NPCs.Other npc.netAlways = true; npc.aiStyle = -1; npc.Calamity().DoesNotGenerateRage = true; + npc.Calamity().DoesNotDisappearInBossRush = true; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 51740; From b9a5e1c7b83eb56e7ce9d4838bcd34191d9aaeb7 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 4 Oct 2021 15:11:49 -0500 Subject: [PATCH 12/16] Aflame does not affect town npc projectiles --- Projectiles/CalamityGlobalProjectile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 255fab5554..5736414aa1 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2255,7 +2255,7 @@ namespace CalamityMod.Projectiles } } - if (modPlayer.flamingItemEnchant && !projectile.minion) + if (modPlayer.flamingItemEnchant && !projectile.minion && !projectile.npcProj) target.AddBuff(BuffType(), 420); if (modPlayer.farProximityRewardEnchant) From 9c24403b63c4880bcfefbbade4bba89a9ce6475a Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 4 Oct 2021 19:34:51 -0500 Subject: [PATCH 13/16] Lecherous Orbs can't be externally healed from --- NPCs/Other/BrimstoneOrb.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NPCs/Other/BrimstoneOrb.cs b/NPCs/Other/BrimstoneOrb.cs index 38d8387a7e..1938c4dac5 100644 --- a/NPCs/Other/BrimstoneOrb.cs +++ b/NPCs/Other/BrimstoneOrb.cs @@ -33,6 +33,7 @@ namespace CalamityMod.NPCs.Other npc.knockBackResist = 0f; npc.netAlways = true; npc.aiStyle = -1; + npc.canGhostHeal = false; npc.Calamity().DoesNotGenerateRage = true; npc.Calamity().DoesNotDisappearInBossRush = true; } From 5be8fda4c9ac676091cb69fc38962793a04b3d83 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:35:14 -0500 Subject: [PATCH 14/16] Index check for BR despawning --- NPCs/CalamityGlobalNPC.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 1862df9451..817bdf5cab 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -2863,6 +2863,9 @@ namespace CalamityMod.NPCs #region Boss Rush Force Despawn Other NPCs private void BossRushForceDespawnOtherNPCs(NPC npc, Mod mod) { + if (BossRushEvent.BossRushStage >= BossRushEvent.Bosses.Count) + return; + if (!BossRushEvent.Bosses[BossRushEvent.BossRushStage].HostileNPCsToNotDelete.Contains(npc.type)) { npc.active = false; From 0023ead8c5b0764e1f1e3deea79bc21ad6065da8 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 5 Oct 2021 22:33:39 -0500 Subject: [PATCH 15/16] Handling some enchantment edge-cases --- Items/CalamityGlobalItem.cs | 5 ++++ .../Weapons/Summon/PrototypeAndromechaRing.cs | 1 + Items/Weapons/Typeless/RelicOfDeliverance.cs | 2 ++ .../EnchantmentManager.cs | 26 +++++++++---------- Utilities/ItemUtils.cs | 23 ++++++++++++++++ 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 020e63fb74..c7a23c8b4b 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -57,6 +57,7 @@ namespace CalamityMod.Items #endregion #region Enchantment Variables + public bool CannotBeEnchanted = false; public Enchantment? AppliedEnchantment = null; public float DischargeEnchantExhaustion = 0; public float DischargeExhaustionRatio @@ -571,6 +572,10 @@ namespace CalamityMod.Items case ItemID.StarCannon: item.UseSound = null; break; + + case ItemID.EoCShield: + CannotBeEnchanted = true; + break; } if (CalamityLists.quadrupleDamageBuffList?.Contains(item.type) ?? false) diff --git a/Items/Weapons/Summon/PrototypeAndromechaRing.cs b/Items/Weapons/Summon/PrototypeAndromechaRing.cs index 72b530db1c..e5208ee7e4 100644 --- a/Items/Weapons/Summon/PrototypeAndromechaRing.cs +++ b/Items/Weapons/Summon/PrototypeAndromechaRing.cs @@ -47,6 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.summon = true; + item.Calamity().CannotBeEnchanted = true; } public override void AddRecipes() diff --git a/Items/Weapons/Typeless/RelicOfDeliverance.cs b/Items/Weapons/Typeless/RelicOfDeliverance.cs index 206c8f88d7..dc05aafe51 100644 --- a/Items/Weapons/Typeless/RelicOfDeliverance.cs +++ b/Items/Weapons/Typeless/RelicOfDeliverance.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Accessories; using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; @@ -31,6 +32,7 @@ namespace CalamityMod.Items.Weapons.Typeless item.value = CalamityGlobalItem.Rarity11BuyPrice; item.rare = ItemRarityID.Purple; item.shoot = ModContent.ProjectileType(); + item.Calamity().CannotBeEnchanted = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index c38161c06f..2ab3cb0464 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -155,14 +155,14 @@ namespace CalamityMod.UI.CalamitasEnchants "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant", null, player => player.Calamity().cursedSummonsEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.summon), + item => item.IsEnchantable() && item.damage > 0 && item.summon), new Enchantment("Aflame", "Lights enemies ablaze on hit but also causes the user to take damage over time when holding this item.", 200, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame", null, player => player.Calamity().flamingItemEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && !item.summon), + item => item.IsEnchantable() && item.damage > 0 && !item.summon), new Enchantment("Oblatory", "Reduces mana cost and greatly increases damage but sometimes causes this item to use your life.", 300, @@ -173,35 +173,35 @@ namespace CalamityMod.UI.CalamitasEnchants item.mana = (int)Math.Ceiling(item.mana * 0.6); }, player => player.Calamity().lifeManaEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.magic && item.mana > 0), + item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), new Enchantment("Resentful", "Makes the damage of projectiles vary based on how far the hit target is from you. The farther, the more damage, and vice versa.", 400, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful", null, player => player.Calamity().farProximityRewardEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None), new Enchantment("Bloodthirsty", "Makes the damage of projectiles vary based on how far the hit target is from you. The closer, the more damage, and vice versa.", 500, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty", null, player => player.Calamity().closeProximityRewardEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None), new Enchantment("Ephemeral", "Causes the damage output of this item to discharge from exhaustive use. Its damage returns naturally when not being used. It starts off with more damage than it normally would have.", 600, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral", null, player => player.Calamity().dischargingItemEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && !item.summon), + item => item.IsEnchantable() && item.damage > 0 && !item.summon), new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer. Once it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.", 700, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound", null, player => player.Calamity().explosiveMinionsEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.summon), + item => item.IsEnchantable() && item.damage > 0 && item.summon), new Enchantment("Tainted", "Removes projectile shooting capabilities of this item. In exchange, two skeletal arms are released on use that slice at the mouse position.", 800, @@ -237,28 +237,28 @@ namespace CalamityMod.UI.CalamitasEnchants Main.projectile[blade].localAI[0] = -80f; } }, - item => item.damage > 0 && item.maxStack == 1 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None), + item => item.IsEnchantable() && item.damage > 0 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None), new Enchantment("Traitorous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.", 900, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous", null, player => player.Calamity().manaMonsterEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.magic && item.mana > 0), + item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), new Enchantment("Withering", "You heal when hurt based on damage you've dealt. After being hurt, the weapon rapidly drains your life to deal massive damage.", 1000, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered", null, player => player.Calamity().witheringWeaponEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && !item.summon), + item => item.IsEnchantable() && item.damage > 0 && !item.summon), new Enchantment("Persecuted", "When attacked, or over time, demon portals appear near you. If sufficiently damaged they are friendly; otherwise they attack you.", 1100, "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted", null, player => player.Calamity().persecutedEnchant = true, - item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None), new Enchantment("Lecherous", "Spawns a resilient brimstone orb that stays between you and your mouse that interferes with your homing weapons. It releases a bunch of hearts on death.", 1200, @@ -288,7 +288,7 @@ namespace CalamityMod.UI.CalamitasEnchants CalamityNetcode.NewNPC_ClientSide(player.Center, orbType, player); } }, - item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None && !item.summon), + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.summon), }; // Special disenchantment thing. This is separated from the list on purpose. @@ -301,7 +301,7 @@ namespace CalamityMod.UI.CalamitasEnchants item.Calamity().AppliedEnchantment = null; item.Calamity().DischargeEnchantExhaustion = 0; }, - item => item.maxStack == 1 && item.shoot >= ProjectileID.None); + item => item.IsEnchantable() && item.shoot >= ProjectileID.None); ItemUpgradeRelationship = new Dictionary() { diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 00b12acb8e..8c2dda41bf 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -198,6 +198,29 @@ namespace CalamityMod return moved; } + public static bool IsEnchantable(this Item item) + { + // If the item is air just immediately return false. + // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it + // would just result in errors. + if (item.IsAir) + return false; + + // Items with a max stack greater than one cannot be enchanted, due to problems with data duplication. + if (item.maxStack > 1) + return false; + + // Ammo cannot be enchanted because it is practically useless when held directly. + if (item.ammo != AmmoID.None) + return false; + + // Ignore items that explicitly say to not be enchanted. + if (item.Calamity().CannotBeEnchanted) + return false; + + return true; + } + /// /// Determines if a given item is enchanted based on Calamitas' special system. /// From dac1958dd890a9fa1cdee891258716db0f8001bc Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 5 Oct 2021 23:51:06 -0500 Subject: [PATCH 16/16] Bezier curve recursion -> while loop --- DataStructures/BezierCurve.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DataStructures/BezierCurve.cs b/DataStructures/BezierCurve.cs index 5bc5fb5efc..d814ab2e43 100644 --- a/DataStructures/BezierCurve.cs +++ b/DataStructures/BezierCurve.cs @@ -25,16 +25,16 @@ namespace CalamityMod.DataStructures private Vector2 PrivateEvaluate(Vector2[] points, float T) { - if (points.Length > 2) + while (points.Length > 2) { Vector2[] nextPoints = new Vector2[points.Length - 1]; for (int k = 0; k < points.Length - 1; k++) nextPoints[k] = Vector2.Lerp(points[k], points[k + 1], T); - return PrivateEvaluate(nextPoints, T); + points = nextPoints; } - else - return Vector2.Lerp(points[0], points[1], T); + + return Vector2.Lerp(points[0], points[1], T); } } }