From ca03359569bbc7ba3169818d91fe059d6d415984 Mon Sep 17 00:00:00 2001 From: Doze-Zoze Date: Tue, 22 Jul 2025 11:20:20 -0500 Subject: [PATCH] SoC has more recoil and iframes --- ILEditing/BalancingILChanges.cs | 69 ++++++++++++++++++++++++++++++++- ILEditing/ILChangesLoading.cs | 2 +- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 20b45bc28c..cd24057eb9 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -1,6 +1,8 @@ using System; using CalamityMod.Balancing; using CalamityMod.Enums; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; @@ -526,9 +528,72 @@ namespace CalamityMod.ILEditing } #endregion - #region Vortex Booster Keeps Vortex Stealth When Dashing - private static void VortexBoosterKeepsVortexStealthWhenDashing(On_Player.orig_DashMovement orig, Player self) + #region SoC Buffs & Vortex Booster keeping stealth + private static void DashMovementEdits(On_Player.orig_DashMovement orig, Player self) { + //This is a modified version of Vanilla's Shield of Cthulhu dash collision checks + //This is done to be able to adjust values as needed. Here we change the iframe amount and recoil velocity + if (self.dash == 2 && self.eocDash > 0 && self.eocHit < 0) + { + Rectangle DashHitbox = new Rectangle((int)(self.position.X + self.velocity.X * 0.5 - 4.0), (int)(self.position.Y + self.velocity.Y * 0.5 - 4.0), self.width + 8, self.height + 8); + for (int i = 0; i < 200; i++) + { + NPC hitNPC = Main.npc[i]; + if (!hitNPC.active || hitNPC.dontTakeDamage || hitNPC.friendly || (hitNPC.aiStyle == 112 && !(hitNPC.ai[2] <= 1f)) || !self.CanNPCBeHitByPlayerOrPlayerProjectile(hitNPC)) + { + continue; + } + Rectangle npcHitbox = hitNPC.getRect(); + if (DashHitbox.Intersects(npcHitbox) && (hitNPC.noTileCollide || self.CanHit(hitNPC))) + { + float dmg = self.GetTotalDamage(DamageClass.Melee).ApplyTo(30f); + float kb = self.GetTotalKnockback(DamageClass.Melee).ApplyTo(9f); + bool crit = false; + if (Main.rand.Next(100) < self.GetTotalCritChance(DamageClass.Melee)) + { + crit = true; + } + int direction = self.direction; + if (self.velocity.X < 0f) + { + direction = -1; + } + if (self.velocity.X > 0f) + { + direction = 1; + } + self.eocHit = i; + if (self.whoAmI == Main.myPlayer) + { + self.ApplyDamageToNPC(hitNPC, (int)dmg, kb, direction, crit, DamageClass.Melee); + } + self.eocDash = 10; + self.dashDelay = 30; + self.velocity.X = -direction * 9; + self.velocity.Y = -4f; + self.GiveImmuneTimeForCollisionAttack(8); //This is normally 4 in vanilla + int heldDir = 0; + if (self.controlLeft) + heldDir--; + if (self.controlRight) + heldDir++; + int dirSum = Math.Abs(direction + heldDir); + switch (dirSum) + { + case 0: //Holding in direction of recoil + self.velocity.X *= 1.75f; + break; + case 1: //Neutral direction + self.velocity.X *= 1.5f; + break; + case 2: //Holding in direction of enemy + self.velocity.X *= 1.25f; + break; + } + } + } + } + // Allows for Vortex Booster to automatically re-engage Vortex armor's stealth after a delay when dashing bool vortexStealth = self.vortexStealthActive; orig(self); diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 728d7d7894..288c10dc1a 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -74,7 +74,7 @@ namespace CalamityMod.ILEditing IL_Player.Hurt_PlayerDeathReason_int_int_refHurtInfo_bool_bool_int_bool_float_float_float += DodgeMechanicAdjustments; On_Player.PutHallowedArmorSetBonusOnCooldown += AddHolyProtectionCooldown; IL_Player.DashMovement += FixAllDashMechanics; - On_Player.DashMovement += VortexBoosterKeepsVortexStealthWhenDashing; + On_Player.DashMovement += DashMovementEdits; On_Player.DoCommonDashHandle += ApplyDashKeybind; IL_Player.GiveImmuneTimeForCollisionAttack += MakeShieldSlamIFramesConsistent; IL_Player.Update_NPCCollision += NerfShieldOfCthulhuBonkSafety;