From da0c91fbb2555d1749bde6a9ace3b73c3474edfd Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sat, 17 Jan 2026 00:56:48 -0500 Subject: [PATCH 1/5] Dubious syncing --- Projectiles/Melee/LightspeedHoldout.cs | 29 +++++++++++++++++++------- Projectiles/Melee/LucreciaHoldout.cs | 25 ++++++++++++++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Projectiles/Melee/LightspeedHoldout.cs b/Projectiles/Melee/LightspeedHoldout.cs index b8e972feb2..b8bbc3ef95 100644 --- a/Projectiles/Melee/LightspeedHoldout.cs +++ b/Projectiles/Melee/LightspeedHoldout.cs @@ -1,18 +1,19 @@ using System; +using System.IO; +using System.Linq; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Particles; -using static Terraria.Player; -using Microsoft.Xna.Framework.Graphics; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Graphics.Primitives; -using System.Linq; -using Terraria.Graphics.Shaders; using static CalamityMod.CalamityUtils; -using CalamityMod.Sounds; +using static Terraria.Player; namespace CalamityMod.Projectiles.Melee @@ -79,6 +80,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.extraUpdates = 1; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(bladeRot); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + bladeRot = reader.ReadSingle(); + } public void Positioning(Vector2 toMouse) // Hand and holdout positioning { @@ -248,6 +258,9 @@ namespace CalamityMod.Projectiles.Melee Owner.SetCompositeArmFront(true, Main.rand.NextBool() ? CompositeArmStretchAmount.ThreeQuarters : CompositeArmStretchAmount.Quarter, Owner.itemRotation); } + if (Main.myPlayer == Projectile.owner) + Projectile.netUpdate = true; + stabSoundTimer++; if (stabSoundTimer % 3 == 0) { diff --git a/Projectiles/Melee/LucreciaHoldout.cs b/Projectiles/Melee/LucreciaHoldout.cs index 16623a3a65..817c37c6fe 100644 --- a/Projectiles/Melee/LucreciaHoldout.cs +++ b/Projectiles/Melee/LucreciaHoldout.cs @@ -9,6 +9,7 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Sounds; +using System.IO; namespace CalamityMod.Projectiles.Melee { @@ -50,6 +51,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.noEnchantmentVisuals = true; Projectile.Opacity = 0.2f; // Starting point, fades in quickly upon startup Projectile.width = Projectile.height = 54; + Projectile.netImportant = true; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + base.ReceiveExtraAI(reader); + } + public override void SendExtraAI(BinaryWriter writer) + { + base.SendExtraAI(writer); } public override void Spawn() @@ -238,15 +249,17 @@ namespace CalamityMod.Projectiles.Melee // Smear fx on swing Vector2 shootDir = player.Center.DirectionTo(mousePosition) * 10f; - int dir = -Math.Sign(mousePosition.X); + int dir = -player.direction; Particle swipe = new CustomSpark(player.Center - shootDir * 4, shootDir.RotatedBy(0.075f * (dir * (modplayer.swingNum % 2 == 0 ? 1 : -1))) * 1.22f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.3f, modplayer.swingNum % 2 == 0 ? Color.CornflowerBlue * 0.85f : Color.MediumPurple * 0.8f, new Vector2(1.1f, 1.3f), true, false, 0, false, false); GeneralParticleHandler.SpawnParticle(swipe); - var fireDirection = Vector2.Normalize(mousePosition - player.Center); - var helixSpeed = 12f; - var helixVelocity = fireDirection * helixSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - + if (Main.myPlayer == Projectile.owner) + { + var fireDirection = Vector2.Normalize(mousePosition - player.Center); + var helixVelocity = fireDirection * 12f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + SoundStyle projectile = new("CalamityMod/Sounds/Item/LucreciaBoltFire"); SoundEngine.PlaySound(projectile with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.06f, 0.1f) }, Projectile.Center); } From 981a48efb5c0f1152fb2998f08dd7f16393a03b8 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sun, 18 Jan 2026 02:02:31 -0500 Subject: [PATCH 2/5] Scorched Earth FX syncing --- Projectiles/Ranged/ScorchedEarthRocket.cs | 58 +++++++++++++---------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/Projectiles/Ranged/ScorchedEarthRocket.cs b/Projectiles/Ranged/ScorchedEarthRocket.cs index 5aa1a6b15f..4313ba0061 100644 --- a/Projectiles/Ranged/ScorchedEarthRocket.cs +++ b/Projectiles/Ranged/ScorchedEarthRocket.cs @@ -148,54 +148,64 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { HasHit = true; + Projectile.netUpdate = true; } public override void OnHitPlayer(Player target, Player.HurtInfo info) { HasHit = true; + Projectile.netUpdate = true; } public override bool OnTileCollide(Vector2 oldVelocity) { HasHit = true; + Projectile.netUpdate = true; return true; } public override void OnKill(int timeLeft) { - if (Projectile.owner == Main.myPlayer && HasHit == true && !BonusEffectMode && Projectile.ai[2] == 0) + if (HasHit == true && !BonusEffectMode && Projectile.ai[2] == 0) { - bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - SoundEngine.PlaySound(RocketExplosion with { MaxInstances = 2}, Projectile.Center); - //If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic - if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); - // Create Blast - float blastSize = 300; - float minMultiplier = 0.25f; - int hitsToMinMult = 4; - int debuff1 = BuffID.Daybreak; - int debuff2 = BuffID.Oiled; - int debuffTime = 360; - //The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. - Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); - blast.localAI[0] = debuff1; - blast.localAI[2] = debuff2; - blast.localAI[1] = debuffTime; - blast.timeLeft = 15; - blast.DamageType = DamageClass.Ranged; - for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) + if (Projectile.owner == Main.myPlayer) { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); + bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); + //If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); + // Create Blast + float blastSize = 300; + float minMultiplier = 0.25f; + int hitsToMinMult = 4; + int debuff1 = BuffID.Daybreak; + int debuff2 = BuffID.Oiled; + int debuffTime = 360; + //The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff1; + blast.localAI[2] = debuff2; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); + } } + + // Handle FX for all clients + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + SoundEngine.PlaySound(RocketExplosion with { MaxInstances = 2 }, Projectile.Center); + for (int i = 0; i < 15; i++) { Vector2 randVel = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.6f); Particle smoke = new HeavySmokeParticle(Projectile.Center + randVel, randVel, Color.Black, Main.rand.Next(20, 25 + 1), Main.rand.NextFloat(0.9f, 2.3f), 0.7f); GeneralParticleHandler.SpawnParticle(smoke); } + for (int i = 0; i < 2; i++) { //Explosion effect From d735f91860bb92faeb5bf08b71593ceee05c50e7 Mon Sep 17 00:00:00 2001 From: Nathanael Overton <146118746+Sagittariod@users.noreply.github.com> Date: Sun, 18 Jan 2026 02:19:09 -0500 Subject: [PATCH 3/5] Acid Rocket --- Projectiles/Ranged/AcidRocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Projectiles/Ranged/AcidRocket.cs b/Projectiles/Ranged/AcidRocket.cs index 213f125cfd..6888d2156a 100644 --- a/Projectiles/Ranged/AcidRocket.cs +++ b/Projectiles/Ranged/AcidRocket.cs @@ -122,6 +122,7 @@ namespace CalamityMod.Projectiles.Ranged stuckInTarget = true; storedVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8; Projectile.velocity = Vector2.Zero; + Projectile.netUpdate = true; } } From d165287df2ad07048a98ee103e0e7a176affbbd4 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Mon, 19 Jan 2026 11:49:27 -0500 Subject: [PATCH 4/5] Pumpkaboom refactoring + bugfixes --- Projectiles/Rogue/PumpkaboomBig.cs | 226 +++++++++++++-------------- Projectiles/Rogue/PumpkaboomSmall.cs | 211 ++++++++++++------------- 2 files changed, 206 insertions(+), 231 deletions(-) diff --git a/Projectiles/Rogue/PumpkaboomBig.cs b/Projectiles/Rogue/PumpkaboomBig.cs index 15499a9604..2bfe1f2e96 100644 --- a/Projectiles/Rogue/PumpkaboomBig.cs +++ b/Projectiles/Rogue/PumpkaboomBig.cs @@ -9,6 +9,7 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Projectiles.Rogue { @@ -17,19 +18,19 @@ namespace CalamityMod.Projectiles.Rogue { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Projectiles/Rogue/PumpkaboomBig"; - public ref float time => ref Projectile.ai[0]; - public ref float skipExplosionSound => ref Projectile.ai[1]; + + public float time = 0; + public ref float stuckNPC => ref Projectile.ai[2]; + public ref float stuckState => ref Projectile.ai[1]; + public ref float flungState => ref Projectile.ai[0]; public Player Owner => Main.player[Projectile.owner]; public int tileHits = 0; - public bool flung = false; public float charge = 0; public bool hasReachedFullCharge = false; public bool hasStoppedHolding = false; public float midAirRot = 0; public int initialCastDirection = 0; - public bool stuck = false; - public int stuckNPC = -1; Vector2 placementDistance; Vector2 placementVelocity; @@ -37,12 +38,10 @@ namespace CalamityMod.Projectiles.Rogue private float progress = -1; public Color mainColor = Color.White; - public Color c1 = new Color(255, 117, 24); // Orange - public Color c2 = new Color(168, 47, 57); // Maroon / Darkish Red - public float glowProgress = -1; - public Color shiftColor; + public Color c1 = new Color(255, 117, 24); + public Color c2 = new Color(168, 47, 57); + private bool hasDealtDamage = false; - public NPC markedTarget; public override void SetDefaults() { Projectile.width = 32; @@ -57,10 +56,9 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 1200; Projectile.DamageType = RogueDamageClass.Instance; } - public override bool ShouldUpdatePosition() => flung && !stuck; - public override bool? CanDamage() => (flung && tileHits == 0 ? null : false); - private bool hasDealtDamage = false; + public override bool ShouldUpdatePosition() => flungState != 0f && stuckState == 0f; + public override bool? CanDamage() => (flungState != 0f && tileHits == 0 ? null : false); public override bool? CanHitNPC(NPC target) { @@ -72,14 +70,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { -            // Outline color shifting -            float rate = (Main.GlobalTimeWrappedHourly * 6); - List eColors = new List() - { - c1, - c2 - }; - + float rate = (Main.GlobalTimeWrappedHourly * 6); + List eColors = new List() { c1, c2 }; int colorIndex = (int)(rate / 2 % eColors.Count); Color currentColor = eColors[colorIndex]; Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; @@ -92,17 +84,13 @@ namespace CalamityMod.Projectiles.Rogue }             // When an NPC is hit by the bomb, stick to it. -            if (stuck) + if (stuckState == 1f) { - if (stuckNPC >= 0 && Main.npc[stuckNPC].active) - { - Projectile.Center = Main.npc[stuckNPC].Center + placementVelocity * placementDistance; - } + if (stuckNPC >= 0 && Main.npc[(int) stuckNPC].active) + Projectile.Center = Main.npc[(int) stuckNPC].Center + placementVelocity * placementDistance; - else - { + else if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.Kill(); - } if (Projectile.timeLeft == 109) { @@ -119,9 +107,8 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target != null && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < maxPullDistance) + if (target != null && target.active && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < maxPullDistance) { - // Avoid pulling the NPC the bomb is stuck to if (target.whoAmI == stuckNPC) continue; @@ -142,7 +129,7 @@ namespace CalamityMod.Projectiles.Rogue return; } - if (flung) + if (flungState != 0f) { if (initialCastDirection == 0) initialCastDirection = Owner.direction; @@ -153,7 +140,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity.Y += 0.22f; - if (!stuck) + if (stuckState == 0f) midAirRot += 0.03f * initialCastDirection; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + midAirRot; @@ -163,89 +150,94 @@ namespace CalamityMod.Projectiles.Rogue else { Projectile.velocity = Owner.velocity; - float completion = time / (Owner.HeldItem.useAnimation * 0.7f); // The completion of the throw animation. Scales with speed. - if (completion >= 1 || hasReachedFullCharge) // The moment of being thrown. + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); + + if (Main.myPlayer == Projectile.owner) { - time = -1; - Projectile.Center = Owner.Center; - Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - Projectile.velocity = velocity * 16; - - Projectile.tileCollide = true; - flung = true; - } - - else - { - if (Main.mouseLeft && !hasStoppedHolding) // The charging up. -                    { - if (completion >= 0.7f && completion <= 0.8f) - { - time--; - if (charge < 1) - charge += 0.5f; - - if (charge >= 1 && !hasReachedFullCharge) - { - SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); - hasReachedFullCharge = true; - } - } + if (completion >= 1 || hasReachedFullCharge) + { + time = -1; + Projectile.Center = Owner.Center; + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + Projectile.velocity = velocity * 16; + Projectile.tileCollide = true; + flungState = 1f; + Projectile.netUpdate = true; } else { - if (!hasReachedFullCharge) + if (Main.mouseLeft && !hasStoppedHolding) { - Projectile.localAI[1] = 5; - Projectile.ai[1] = 1; // Skip explosion fx - Projectile.Kill(); + if (completion >= 0.7f && completion <= 0.8f) + { + time--; + if (charge < 1) + charge += 0.5f; + + if (charge >= 1 && !hasReachedFullCharge) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + hasReachedFullCharge = true; + } + } + } + else + { + if (!hasReachedFullCharge) + { + Projectile.localAI[1] = 5; + flungState = -1f; + Projectile.Kill(); + } + hasStoppedHolding = true; } - hasStoppedHolding = true; } Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); - float grenadeRot = 0; - if (completion >= 0.7f) - { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); - } - else - { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); - } - grenadeRot += Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation(); - Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); - float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); - - Projectile.Center = grenadePos; - Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); - - Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation() - MathHelper.ToRadians(90)); - Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); } + + float grenadeRot = 0; + if (completion >= 0.7f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + } + else + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + + Projectile.Center = grenadePos; + Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, mouseDir.ToRotation() - MathHelper.ToRadians(90)); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); } time++; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - stuck = true; + stuckState = 1f; stuckNPC = target.whoAmI; - - Projectile.localAI[1] = 5; // Reset firing state - - // See PreDraw + Projectile.localAI[1] = 5; beginStretchAnim = true; + Projectile.netUpdate = true; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SoundStyle w = new("CalamityMod/Sounds/Item/WulfrumScrewdriverThud"); SoundEngine.PlaySound(w with { Volume = 0.7f, Pitch = 0f, MaxInstances = 6 }, Projectile.Center); - stuck = true; + stuckState = 1f; stuckNPC = target.whoAmI; placementDistance = new(-Vector2.Distance(target.Center, Projectile.Center)); @@ -254,14 +246,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity = Vector2.Zero; Projectile.tileCollide = false; Projectile.rotation = Projectile.oldVelocity.ToRotation() + MathHelper.PiOver2 + midAirRot; - Projectile.ai[1] = Projectile.rotation; + flungState = Projectile.rotation; hasDealtDamage = true; - Projectile.localAI[1] = 5; // Reset firing state - - glowProgress = 0; // Start glowing until death - - Projectile.timeLeft = 110; // Lasts as long as sfx + Projectile.localAI[1] = 5; + Projectile.timeLeft = 110; for (int i = 0; i < 6; i++) { @@ -285,19 +274,22 @@ namespace CalamityMod.Projectiles.Rogue GeneralParticleHandler.SpawnParticle(spark); } } + Projectile.netUpdate = true; } public override void OnKill(int timeLeft) { Projectile.localAI[1] = 5; // Reset firing state - - if (Projectile.ai[1] != 1) + if (flungState != -1f) { SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/PumpkinExplode1") with { Pitch = 0f, Volume = 0.75f }, Projectile.Center); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") with { Pitch = 0f, Volume = 0.6f }, Projectile.Center); - Owner.SetScreenshake(5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); + if (Main.myPlayer == Projectile.owner) + { + Owner.SetScreenshake(5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); + } float scale = 0.18f; Vector2 spawnPos = Projectile.Center; @@ -320,6 +312,7 @@ namespace CalamityMod.Projectiles.Rogue } } + Projectile.netUpdate = true; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 21, targetHitbox); @@ -379,45 +372,40 @@ namespace CalamityMod.Projectiles.Rogue float drawRotation = Projectile.rotation; Vector2 drawPosition; - if (stuck && glowProgress >= 0f) + if (stuckState == 1f && Projectile.timeLeft <= 110) { - glowProgress += 0.03f; - - float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 25f); // Period of full pulse - float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); // Least protruding to most protruding - float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); // How much the glow overall fades in as it gets closer to exploding + float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 25f); + float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); + float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); float finalGlowIntensity = pulse * lifeFadeIn; drawPosition = Projectile.Center - Main.screenPosition; - - // Create 20 copies of the projectile that draw behind with mainColor to create a glowy outline effect for (int i = 0; i < 20; i++) { float rotationOffset = (MathHelper.TwoPi * i / 15); Vector2 glowOffset = rotationOffset.ToRotationVector2() * (3f + glowSine * 1f) * finalGlowIntensity; - Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, flungState, drawOrigin, drawScale, spriteEffects, 0f); } } - if (!flung) + if (flungState == 0f) { spriteEffects = SpriteEffects.FlipVertically; - float completion = time / (Owner.HeldItem.useAnimation * 0.7f); + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); - grenadeRot += Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation(); - + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); drawPosition = grenadePos - Main.screenPosition; drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); } else { - if (stuck) - { - drawRotation = Projectile.ai[1]; - } + if (stuckState == 1f) + drawRotation = flungState; drawPosition = Projectile.Center - Main.screenPosition; } diff --git a/Projectiles/Rogue/PumpkaboomSmall.cs b/Projectiles/Rogue/PumpkaboomSmall.cs index 63ef6117b5..19708ea60b 100644 --- a/Projectiles/Rogue/PumpkaboomSmall.cs +++ b/Projectiles/Rogue/PumpkaboomSmall.cs @@ -16,19 +16,19 @@ namespace CalamityMod.Projectiles.Rogue { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/Pumpkaboom"; - public ref float time => ref Projectile.ai[0]; - public ref float skipExplosionSound => ref Projectile.ai[1]; + + public float time = 0; + public ref float stuckNPC => ref Projectile.ai[2]; + public ref float stuckState => ref Projectile.ai[1]; + public ref float flungState => ref Projectile.ai[0]; public Player Owner => Main.player[Projectile.owner]; public int tileHits = 0; - public bool flung = false; public float charge = 0; public bool hasReachedFullCharge = false; public bool hasStoppedHolding = false; public float midAirRot = 0; public int initialCastDirection = 0; - public bool stuck = false; - public int stuckNPC = -1; Vector2 placementDistance; Vector2 placementVelocity; @@ -36,12 +36,10 @@ namespace CalamityMod.Projectiles.Rogue private float progress = -1; public Color mainColor = Color.White; - public Color c1 = new Color(255, 117, 24); // Orange - public Color c2 = new Color(168, 47, 57); // Maroon / Darkish Red - public float glowProgress = -1; - public Color shiftColor; + public Color c1 = new Color(255, 117, 24); + public Color c2 = new Color(168, 47, 57); + private bool hasDealtDamage = false; - public NPC markedTarget; public override void SetDefaults() { Projectile.width = 26; @@ -52,14 +50,12 @@ namespace CalamityMod.Projectiles.Rogue Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; Projectile.tileCollide = false; - Projectile.timeLeft = 1200; Projectile.DamageType = RogueDamageClass.Instance; } - public override bool ShouldUpdatePosition() => flung && !stuck; - public override bool? CanDamage() => (flung && tileHits == 0 ? null : false); - private bool hasDealtDamage = false; + public override bool ShouldUpdatePosition() => flungState != 0f && stuckState == 0f; + public override bool? CanDamage() => (flungState != 0f && tileHits == 0 ? null : false); public override bool? CanHitNPC(NPC target) { @@ -71,14 +67,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { -            // Outline color shifting -            float rate = (Main.GlobalTimeWrappedHourly * 6); - List eColors = new List() - { - c1, - c2 - }; - + float rate = (Main.GlobalTimeWrappedHourly * 6); + List eColors = new List() { c1, c2 }; int colorIndex = (int)(rate / 2 % eColors.Count); Color currentColor = eColors[colorIndex]; Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; @@ -90,18 +80,15 @@ namespace CalamityMod.Projectiles.Rogue progress += 0.08f; } -            // When an NPC is hit by the bomb, stick to it. -            if (stuck) + if (stuckState == 1f) { - if (stuckNPC >= 0 && Main.npc[stuckNPC].active) + if (stuckNPC >= 0 && Main.npc[(int) stuckNPC].active) { - Projectile.Center = Main.npc[stuckNPC].Center + placementVelocity * placementDistance; + Projectile.Center = Main.npc[(int) stuckNPC].Center + placementVelocity * placementDistance; } - else - { + else if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.Kill(); - } if (Projectile.timeLeft == 109) { SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/PumpkaboomNormalTicking") with { Pitch = 0f, Volume = 1f, MaxInstances = 4 }, Projectile.Center); @@ -109,7 +96,7 @@ namespace CalamityMod.Projectiles.Rogue return; } - if (flung) + if (flungState != 0f) { if (initialCastDirection == 0) initialCastDirection = Owner.direction; @@ -120,7 +107,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity.Y += 0.22f; - if (!stuck) + if (stuckState == 0f) midAirRot += 0.06f * initialCastDirection; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + midAirRot; @@ -130,89 +117,93 @@ namespace CalamityMod.Projectiles.Rogue else { Projectile.velocity = Owner.velocity; - float completion = time / (Owner.HeldItem.useAnimation * 0.7f); // The completion of the throw animation. Scales with speed. - if (completion >= 1 || hasReachedFullCharge) // The moment of being thrown. - { - time = -1; - Projectile.Center = Owner.Center; - Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - Projectile.velocity = velocity * 16; + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); - Projectile.tileCollide = true; - flung = true; - } - - else + if (Main.myPlayer == Projectile.owner) { - if (Main.mouseLeft && !hasStoppedHolding) // The charging up. -                    { - if (completion >= 0.7f && completion <= 0.8f) + if (completion >= 1 || hasReachedFullCharge) + { + time = -1; + Projectile.Center = Owner.Center; + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + Projectile.velocity = velocity * 16; + Projectile.tileCollide = true; + flungState = 1f; + Projectile.netUpdate = true; + } + else + { + if (Main.mouseLeft && !hasStoppedHolding) { - time--; - if (charge < 1) - charge += 0.5f; - - if (charge >= 1 && !hasReachedFullCharge) + if (completion >= 0.7f && completion <= 0.8f) { - SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); - hasReachedFullCharge = true; + time--; + if (charge < 1) + charge += 0.5f; + + if (charge >= 1 && !hasReachedFullCharge) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + hasReachedFullCharge = true; + } } } - } - else - { - if (!hasReachedFullCharge) + else { - Projectile.localAI[1] = 5; - Projectile.ai[1] = 1; // Skip explosion fx - Projectile.Kill(); + if (!hasReachedFullCharge) + { + Projectile.localAI[1] = 5; + flungState = -1f; + Projectile.Kill(); + } + hasStoppedHolding = true; } - hasStoppedHolding = true; } - Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); - float grenadeRot = 0; - if (completion >= 0.7f) - { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); - } - else - { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); - } - grenadeRot += Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation(); - Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); - float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); - - Projectile.Center = grenadePos; - Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); - - Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation() - MathHelper.ToRadians(90)); - Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); } + + float grenadeRot = 0; + if (completion >= 0.7f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + } + else + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + + Projectile.Center = grenadePos; + Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, mouseDir.ToRotation() - MathHelper.ToRadians(90)); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); } time++; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - stuck = true; + stuckState = 1f; stuckNPC = target.whoAmI; - - Projectile.localAI[1] = 5; // Reset firing state - - // See PreDraw + Projectile.localAI[1] = 5; beginStretchAnim = true; + Projectile.netUpdate = true; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SoundStyle w = new("CalamityMod/Sounds/Item/WulfrumScrewdriverThud"); SoundEngine.PlaySound(w with { Volume = 0.7f, Pitch = 0f, MaxInstances = 6 }, Projectile.Center); - stuck = true; + stuckState = 1f; stuckNPC = target.whoAmI; placementDistance = new(-Vector2.Distance(target.Center, Projectile.Center)); @@ -221,14 +212,12 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity = Vector2.Zero; Projectile.tileCollide = false; Projectile.rotation = Projectile.oldVelocity.ToRotation() + MathHelper.PiOver2 + midAirRot; - Projectile.ai[1] = Projectile.rotation; + flungState = Projectile.rotation; hasDealtDamage = true; - Projectile.localAI[1] = 5; // Reset firing state - - glowProgress = 0; // Start glowing until death - - Projectile.timeLeft = 110; // Lasts as long as sfx + Projectile.localAI[1] = 5; + Projectile.timeLeft = 110; + Projectile.netUpdate = true; for (int i = 0; i < 4; i++) { @@ -258,12 +247,13 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.localAI[1] = 5; // Reset firing state - if (Projectile.ai[1] != 1) + if (flungState != -1f) { SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/PumpkinExplode1") with { Pitch = 0f, Volume = 0.75f }, Projectile.Center); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") with { Pitch = 0f, Volume = 0.4f }, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); float scale = 0.1f; Vector2 spawnPos = Projectile.Center; @@ -345,13 +335,11 @@ namespace CalamityMod.Projectiles.Rogue float drawRotation = Projectile.rotation; Vector2 drawPosition; - if (stuck && glowProgress >= 0f) + if (stuckState == 1f && Projectile.timeLeft <= 110) { - glowProgress += 0.03f; - - float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f); // Period of full pulse - float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); // Least protruding to most protruding - float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); // How much the glow overall fades in as it gets closer to exploding + float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f); + float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); + float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); float finalGlowIntensity = pulse * lifeFadeIn; drawPosition = Projectile.Center - Main.screenPosition; @@ -361,29 +349,28 @@ namespace CalamityMod.Projectiles.Rogue float rotationOffset = (MathHelper.TwoPi * i / 15); Vector2 glowOffset = rotationOffset.ToRotationVector2() * (3f + glowSine * 1f) * finalGlowIntensity; - Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, flungState, drawOrigin, drawScale, spriteEffects, 0f); } } - if (!flung) + if (flungState == 0f) { spriteEffects = SpriteEffects.FlipVertically; - float completion = time / (Owner.HeldItem.useAnimation * 0.7f); + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); - grenadeRot += Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation(); - + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); drawPosition = grenadePos - Main.screenPosition; drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); } else { - if (stuck) - { - drawRotation = Projectile.ai[1]; - } + if (stuckState == 1f) + drawRotation = flungState; drawPosition = Projectile.Center - Main.screenPosition; } From a4cfb38cf21aa92c3cb7c112ab2f571941d52197 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sun, 1 Feb 2026 15:50:29 -0500 Subject: [PATCH 5/5] Revert "Dubious syncing" This reverts commit da0c91fbb2555d1749bde6a9ace3b73c3474edfd. --- Projectiles/Melee/LightspeedHoldout.cs | 29 +++++++------------------- Projectiles/Melee/LucreciaHoldout.cs | 25 ++++++---------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/Projectiles/Melee/LightspeedHoldout.cs b/Projectiles/Melee/LightspeedHoldout.cs index b8bbc3ef95..b8e972feb2 100644 --- a/Projectiles/Melee/LightspeedHoldout.cs +++ b/Projectiles/Melee/LightspeedHoldout.cs @@ -1,19 +1,18 @@ using System; -using System.IO; -using System.Linq; -using CalamityMod.Graphics.Primitives; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; +using CalamityMod.Particles; using static Terraria.Player; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Graphics.Primitives; +using System.Linq; +using Terraria.Graphics.Shaders; +using static CalamityMod.CalamityUtils; +using CalamityMod.Sounds; namespace CalamityMod.Projectiles.Melee @@ -80,15 +79,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.extraUpdates = 1; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(bladeRot); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - bladeRot = reader.ReadSingle(); - } public void Positioning(Vector2 toMouse) // Hand and holdout positioning { @@ -258,9 +248,6 @@ namespace CalamityMod.Projectiles.Melee Owner.SetCompositeArmFront(true, Main.rand.NextBool() ? CompositeArmStretchAmount.ThreeQuarters : CompositeArmStretchAmount.Quarter, Owner.itemRotation); } - if (Main.myPlayer == Projectile.owner) - Projectile.netUpdate = true; - stabSoundTimer++; if (stabSoundTimer % 3 == 0) { diff --git a/Projectiles/Melee/LucreciaHoldout.cs b/Projectiles/Melee/LucreciaHoldout.cs index 817c37c6fe..16623a3a65 100644 --- a/Projectiles/Melee/LucreciaHoldout.cs +++ b/Projectiles/Melee/LucreciaHoldout.cs @@ -9,7 +9,6 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Sounds; -using System.IO; namespace CalamityMod.Projectiles.Melee { @@ -51,16 +50,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.noEnchantmentVisuals = true; Projectile.Opacity = 0.2f; // Starting point, fades in quickly upon startup Projectile.width = Projectile.height = 54; - Projectile.netImportant = true; - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - base.ReceiveExtraAI(reader); - } - public override void SendExtraAI(BinaryWriter writer) - { - base.SendExtraAI(writer); } public override void Spawn() @@ -249,17 +238,15 @@ namespace CalamityMod.Projectiles.Melee // Smear fx on swing Vector2 shootDir = player.Center.DirectionTo(mousePosition) * 10f; - int dir = -player.direction; + int dir = -Math.Sign(mousePosition.X); Particle swipe = new CustomSpark(player.Center - shootDir * 4, shootDir.RotatedBy(0.075f * (dir * (modplayer.swingNum % 2 == 0 ? 1 : -1))) * 1.22f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.3f, modplayer.swingNum % 2 == 0 ? Color.CornflowerBlue * 0.85f : Color.MediumPurple * 0.8f, new Vector2(1.1f, 1.3f), true, false, 0, false, false); GeneralParticleHandler.SpawnParticle(swipe); - if (Main.myPlayer == Projectile.owner) - { - var fireDirection = Vector2.Normalize(mousePosition - player.Center); - var helixVelocity = fireDirection * 12f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - + var fireDirection = Vector2.Normalize(mousePosition - player.Center); + var helixSpeed = 12f; + var helixVelocity = fireDirection * helixSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + SoundStyle projectile = new("CalamityMod/Sounds/Item/LucreciaBoltFire"); SoundEngine.PlaySound(projectile with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.06f, 0.1f) }, Projectile.Center); }