From 7bf997e9eae084c0642a356766a57dccd8fe4f71 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Tue, 23 Nov 2021 15:29:27 -0500 Subject: [PATCH 1/4] Defense damage on a single hit has an upper cap at 25% of original defense. --- CalPlayer/CalamityPlayer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index cbf72f7279..6a2cb317af 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -10646,6 +10646,11 @@ namespace CalamityMod.CalPlayer defenseDamageTaken = defenseDamageFloor; } + // There is also a cap on defense damage: 25% of the player's original defense. + int cap = player.statDefense / 4; + if (defenseDamageTaken > cap) + defenseDamageTaken = cap; + // Apply that defense damage on top of whatever defense damage the player currently has. int previousDefenseDamage = CurrentDefenseDamage; totalDefenseDamage = previousDefenseDamage + defenseDamageTaken; From 5b90276628c4201bab4aa9afa071540ac376da6a Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:02:06 -0600 Subject: [PATCH 2/4] Fusable particle collection check fix --- Particles/FusableParticleManager.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Particles/FusableParticleManager.cs b/Particles/FusableParticleManager.cs index 59a32da998..a981918daf 100644 --- a/Particles/FusableParticleManager.cs +++ b/Particles/FusableParticleManager.cs @@ -92,13 +92,13 @@ namespace CalamityMod.Particles /// internal static void PrepareFusableParticleTargets() { - // Don't attempt to prepare anything serverside or if the particle sets are unloaded. - if (Main.netMode == NetmodeID.Server || ParticleSets is null) + // Don't attempt to prepare anything serverside, if the particle sets are unloaded, or if on the menu. + if (Main.netMode == NetmodeID.Server || ParticleSets is null || Main.gameMenu) return; // Prepare the render target for all fusable particles. - foreach (FusableParticleRenderCollection particleSet in ParticleSets) - particleSet.ParticleSet.PrepareRenderTargetForDrawing(); + for (int i = 0; i < ParticleSets.Count; i++) + ParticleSets[i].ParticleSet.PrepareRenderTargetForDrawing(); } /// @@ -106,13 +106,13 @@ namespace CalamityMod.Particles /// internal static void RenderAllFusableParticles(FusableParticleRenderLayer renderLayer) { - // Don't attempt to render anything serverside. - if (Main.netMode == NetmodeID.Server) + // Don't attempt to render anything serverside or on the menu. + if (Main.netMode == NetmodeID.Server || Main.gameMenu) return; - foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) + for (int i = 0; i < ParticleSets.Count; i++) { - BaseFusableParticleSet particleSet = particleRenderSet.ParticleSet; + BaseFusableParticleSet particleSet = ParticleSets[i].ParticleSet; // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. if (particleSet.Particles.Count <= 0) @@ -132,10 +132,10 @@ namespace CalamityMod.Particles // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - for (int i = 0; i < particleSet.LayerCount; i++) + for (int j = 0; j < particleSet.LayerCount; j++) { - Effect shader = particleSet.BackgroundShaders[i]; - Texture2D backgroundTexture = particleSet.BackgroundTextures[i]; + Effect shader = particleSet.BackgroundShaders[j]; + Texture2D backgroundTexture = particleSet.BackgroundTextures[j]; // Draw the current target with the specified shader. shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); @@ -144,7 +144,7 @@ namespace CalamityMod.Particles shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); - shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[i].Width, backgroundTargets[i].Height)); + shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[j].Width, backgroundTargets[j].Height)); shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); shader.Parameters["upscaleFactor"].SetValue(Vector2.One); shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); @@ -154,13 +154,13 @@ namespace CalamityMod.Particles shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); // Do any optional shader operations prior to applying the shader. - particleSet.PrepareOptionalShaderData(shader, i); + particleSet.PrepareOptionalShaderData(shader, j); // Apply the shader. This is what is used to connect separated blobs together. shader.CurrentTechnique.Passes[0].Apply(); // And draw the particle set's render target with said shader. - Main.spriteBatch.Draw(backgroundTargets[i], Vector2.Zero, Color.White); + Main.spriteBatch.Draw(backgroundTargets[j], Vector2.Zero, Color.White); } Main.spriteBatch.End(); From 8cec5c49e3c2c548700ee0661d7365032f68059a Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Tue, 23 Nov 2021 16:05:46 -0500 Subject: [PATCH 3/4] 1 - Removed Shiny Red Balloon and Moon Charm affecting jumpHeight. 2 - jumpSpeed is now actually boosted by Shiny Red Balloon instead of hardcoded. --- CalPlayer/CalamityPlayer.cs | 33 +++++++------ ILEditing/ILChanges.cs | 99 +++++++++++++++++++++---------------- 2 files changed, 75 insertions(+), 57 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 6a2cb317af..8b75126e28 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -133,6 +133,24 @@ namespace CalamityMod.CalPlayer public float SmoothenedMinecartRotation; #endregion + #region IL Editing Constants + // These values are referenced by IL edits but don't fit into any other category. + public const float BalloonJumpSpeedBoost = 0.75f; + + // Shield slam stats + public const int ShieldOfCthulhuIFrames = 6; + public const int ShieldOfCthulhuBonkNoCollideFrames = 6; + public const int SolarFlareIFrames = 12; + public const float SolarFlareBaseDamage = 400f; + + // Dodge stats + public const int BeltDodgeCooldown = 5400; + public const int MirrorDodgeCooldown = 5400; + public const int DaedalusReflectCooldown = 5400; + public const int ArcanumReflectCooldown = 5400; + public const int EvolutionReflectCooldown = 7200; + #endregion + #region Speedrun Timer // The Calamity Speedrun Timer uses the highest precision timing available to .NET and thus to the system hardware. // Current session time is maintained by CalamityMod.SpeedrunTimer, which is a C# Stopwatch running constantly while a player is loaded. @@ -254,18 +272,7 @@ namespace CalamityMod.CalPlayer public int spiritOriginBullseyeShootCountdown = 0; public int spiritOriginConvertedCrit = 0; - // Shield slam stats - public const int ShieldOfCthulhuIFrames = 6; - public const int ShieldOfCthulhuBonkNoCollideFrames = 6; - public const int SolarFlareIFrames = 12; - public const float SolarFlareBaseDamage = 400f; - - // Dodge stats - public const int BeltDodgeCooldown = 5400; - public const int MirrorDodgeCooldown = 5400; - public const int DaedalusReflectCooldown = 5400; - public const int ArcanumReflectCooldown = 5400; - public const int EvolutionReflectCooldown = 7200; + private const int DashDisableCooldown = 12; public int dodgeCooldownTimer = 0; public bool disableAllDodges = false; @@ -7093,8 +7100,6 @@ namespace CalamityMod.CalPlayer { player.wingTimeMax = 0; } - - private const int DashDisableCooldown = 12; private void DisableDashes() { // Set the player to have no registered dashes. diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 1915a43a90..b0b3c63253 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -152,10 +152,10 @@ namespace CalamityMod.ILEditing IL.Terraria.Projectile.Damage += RemoveAerialBaneDamageBoost; IL.Terraria.Projectile.AI_001 += AdjustChlorophyteBullets; - // Movement speed balance - IL.Terraria.Player.UpdateJumpHeight += BalloonAdjustment; - IL.Terraria.Player.Update += JumpSpeedAdjustment; - IL.Terraria.Player.Update += MaxRunSpeedAdjustment; + // Movement speed balance + IL.Terraria.Player.UpdateJumpHeight += FixJumpHeightBoosts; + IL.Terraria.Player.Update += JumpSpeedAdjustment; + IL.Terraria.Player.Update += MaxRunSpeedAdjustment; IL.Terraria.Player.Update += RunSpeedAdjustments; IL.Terraria.Player.Update += ReduceWingHoverVelocities; @@ -224,10 +224,10 @@ namespace CalamityMod.ILEditing IL.Terraria.Projectile.Damage -= RemoveAerialBaneDamageBoost; IL.Terraria.Projectile.AI_001 -= AdjustChlorophyteBullets; - // Movement speed balance - IL.Terraria.Player.UpdateJumpHeight -= BalloonAdjustment; - IL.Terraria.Player.Update -= JumpSpeedAdjustment; - IL.Terraria.Player.Update -= MaxRunSpeedAdjustment; + // Movement speed balance + IL.Terraria.Player.UpdateJumpHeight -= FixJumpHeightBoosts; + IL.Terraria.Player.Update -= JumpSpeedAdjustment; + IL.Terraria.Player.Update -= MaxRunSpeedAdjustment; IL.Terraria.Player.Update -= RunSpeedAdjustments; IL.Terraria.Player.Update -= ReduceWingHoverVelocities; @@ -947,45 +947,58 @@ namespace CalamityMod.ILEditing cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, 150f); // Reduce homing range by 50%. } - #endregion + #endregion - #region Movement speed balance - private static void BalloonAdjustment(ILContext il) - { - // Remove the jump height boosts of balloons to make balancing them easier. - var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(20))) // The jump height variable is set to this specific value by the balloons. - { - LogFailure("Balloon Jump Height Removal", "Could not locate the balloon jump height buff variable."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 15); // Reduce to base jump height. + #region Movement speed balance + private static void FixJumpHeightBoosts(ILContext il) + { + // Remove the code that makes Shiny Red Balloon SET jump height to a specific value to make balancing jump speed easier. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(20))) + { + LogFailure("Jump Height Boost Fixes", "Could not locate Shiny Red Balloon jump height assignment value."); + return; + } - // Decrease the jump speed given by balloons. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(6.51f))) // The jumpSpeed variable is set to this specific value by the balloons. - { - LogFailure("Balloon Jump Speed Nerf", "Could not locate the balloon jump speed buff variable."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 6.26f); // Reduce by 5%. - } + // Delete both the ldc.i4 20 AND the store that assigns it to Player.jumpHeight. + cursor.RemoveRange(2); - private static void JumpSpeedAdjustment(ILContext il) - { - // Increase the base jump speed of the player to make early game less of a slog. - var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(5.01f))) // The jumpSpeed variable is set to this specific value before anything else occurs. - { - LogFailure("Base Jump Speed Buff", "Could not locate the jump speed variable."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 5.51f); // Increase by 10%. - } + // Change the jump speed from Shiny Red Balloon to be an actual boost instead of a hardcoded replacement. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcR4(6.51f))) + { + LogFailure("Jump Height Boost Fixes", "Could not locate Shiny Red Balloon jump speed assignment value."); + return; + } - private static void MaxRunSpeedAdjustment(ILContext il) + // Replace the hardcoded 6.51 with a balanceable value in CalamityPlayer. + cursor.Prev.Operand = CalamityPlayer.BalloonJumpSpeedBoost; + // Load the player's current jumpSpeed onto the stack and add the boost to it. + cursor.Emit(OpCodes.Ldsfld, typeof(Player).GetField("jumpSpeed")); + cursor.Emit(OpCodes.Add); + + // Remove the jump height addition from the Werewolf buff (Moon Charm). + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(2))) + { + LogFailure("Jump Height Boost Fixes", "Could not locate Moon Charm jump height boost value."); + return; + } + cursor.Next.Operand = 0; + } + + private static void JumpSpeedAdjustment(ILContext il) + { + // Increase the base jump speed of the player to make early game less of a slog. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(5.01f))) // The jumpSpeed variable is set to this specific value before anything else occurs. + { + LogFailure("Base Jump Speed Buff", "Could not locate the jump speed variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 5.51f); // Increase by 10%. + } + + private static void MaxRunSpeedAdjustment(ILContext il) { // Increase the base max run speed of the player to make early game less of a slog. var cursor = new ILCursor(il); From 58035d871ebd7e45cb47c203234c6bad79269c03 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 23 Nov 2021 17:21:35 -0600 Subject: [PATCH 4/4] Fixed a hitbox oddity --- Projectiles/Boss/SupremeCataclysmFist.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/Boss/SupremeCataclysmFist.cs b/Projectiles/Boss/SupremeCataclysmFist.cs index 3dac1bfafe..4c4f93941c 100644 --- a/Projectiles/Boss/SupremeCataclysmFist.cs +++ b/Projectiles/Boss/SupremeCataclysmFist.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Boss texture = ModContent.GetTexture("CalamityMod/Projectiles/Boss/SupremeCataclysmFistAlt"); Vector2 drawPosition = projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY; - drawPosition -= projectile.velocity * 3.3f; + drawPosition.X -= Math.Sign(projectile.velocity.X) * 40f; Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); return false;