From db5150ff88c8d4f090ca9d85569fdc0f368d855e Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Thu, 25 Apr 2024 22:11:21 -0400 Subject: [PATCH] More Elemental Saw changes: * Saws now slightly home towards the cursor while empowered * Added a burst of homing bolts when the saw starts returning * Continuous bolts when returning now only spawn while empowered * Saw now deals 33% damage while returning after exhausting its pierce, instead of not dealing damage at all --- ...ods.CalamityMod.Items.Weapons.Ranged.hjson | 4 +- Projectiles/Ranged/ElementalSawBullet.cs | 2 + Projectiles/Ranged/ElementalSawHoldout.cs | 6 +- Projectiles/Ranged/ElementalSawProj.cs | 79 +++++++++++++------ 4 files changed, 64 insertions(+), 27 deletions(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 8949bd1990..37c647445d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -448,10 +448,10 @@ ElementalSaw: { Hold to charge up a powerful elemental buzzsaw that deals close-range damage Fired buzzsaws lacerate foes and inflict Elemental Mix, and can bounce off tiles The longer it is charged, the more damage and pierce the buzzsaw has - Buzzsaws return to the player after exhausting their pierce, releasing homing bolts + Buzzsaws return to the player after exhausting their pierce Press to propel a short distance and fire a lingering buzzsaw towards the cursor This dash has a {0} second cooldown - While on cooldown, buzzsaws slightly home to the cursor and release homing bolts faster while returning + While on cooldown, buzzsaws slightly home towards the cursor and release homing bolts while returning Does not consume ammo ''' } diff --git a/Projectiles/Ranged/ElementalSawBullet.cs b/Projectiles/Ranged/ElementalSawBullet.cs index 2ebd26b980..10dc7bb0c0 100644 --- a/Projectiles/Ranged/ElementalSawBullet.cs +++ b/Projectiles/Ranged/ElementalSawBullet.cs @@ -37,6 +37,8 @@ namespace CalamityMod.Projectiles.Ranged CalamityUtils.HomeInOnNPC(Projectile, true, 480f, 13f, 20f); } + public override bool? CanDamage() => Projectile.ai[0] > 20; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 45); public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/ElementalSawHoldout.cs b/Projectiles/Ranged/ElementalSawHoldout.cs index 7e88b7f86f..ee06104a49 100644 --- a/Projectiles/Ranged/ElementalSawHoldout.cs +++ b/Projectiles/Ranged/ElementalSawHoldout.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.DD2_BallistaTowerShot, GunTipPosition); // Placeholder? float sawDamageMult = MathHelper.Clamp(MathHelper.Lerp(1f, 5f, Time / ChargeupTime), 1f, 5f) / 2f; // The damage must be divided by 2 to offset the holdout having 2x base damage. - int sawPierce = (int)MathHelper.Clamp(MathHelper.Lerp(2f, 6f, Time / ChargeupTime), 2f, 6f); + int sawPierce = (int)MathHelper.Clamp(MathHelper.Lerp(2f, 7f, Time / ChargeupTime), 2f, 7f); bool useSmallSlash = (Time / ChargeupTime) >= 0.25f; bool useLargeSlash = (Time / ChargeupTime) >= 1f; @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Ranged Owner.AddCooldown(ElementalSawBoost.ID, ElementalSaw.DashCooldown); Owner.Calamity().sBlasterDashActivated = true; - // TODO - Lingering saw on right click, and empowering saws + // TODO - Lingering saw on right click // If moving, make particle effects when the dash activates if (Owner.velocity != Vector2.Zero) @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Ranged Particle spark = new CritSpark(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, sparkColor, 2f, 45, 2.25f, 2f); GeneralParticleHandler.SpawnParticle(spark); } - for (int e = 0; e < particleAmt; e++) + for (int e = 0; e < particleAmt * 2; e++) { Color sparkColor2 = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), e / (particleAmt - 1)); Particle spark2 = new NanoParticle(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(-MathHelper.PiOver4)) * Main.rand.NextFloat(2.5f, 4.5f), sparkColor2, 1f, 45, Main.rand.NextBool(3)); diff --git a/Projectiles/Ranged/ElementalSawProj.cs b/Projectiles/Ranged/ElementalSawProj.cs index f441555bee..f6bff6eb18 100644 --- a/Projectiles/Ranged/ElementalSawProj.cs +++ b/Projectiles/Ranged/ElementalSawProj.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Ranged // Controls if the saw is returning to the player. public bool Returning = false; public int ReturnTimer = 0; + public const int ReturnDelay = 90; // Whether the saw is empowered by right click. public bool Empowered = false; @@ -53,26 +54,58 @@ namespace CalamityMod.Projectiles.Ranged else Empowered = false; + // While empowered, the saws while slightly home in on the cursor + if (Empowered && !Returning && Projectile.ai[1] > 30) + { + float homingTurnSpeed = 0.09f; + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Main.MouseWorld).ToRotation(), homingTurnSpeed).ToRotationVector2() * ElementalSaw.ShootSpeed; + } // Saws automatically return 2 seconds after hitting an enemy - if (ReturnTimer > 0 && ReturnTimer < 90) + if (ReturnTimer > 0 && ReturnTimer < ReturnDelay) { ReturnTimer++; - if (ReturnTimer == 90) + if (ReturnTimer == ReturnDelay) Returning = true; } if (Returning) { Projectile.tileCollide = false; - if (ReturnTimer < 90) - ReturnTimer = 90; + if (ReturnTimer < ReturnDelay) + ReturnTimer = ReturnDelay; ReturnTimer++; - if (ReturnTimer < 120) + if (ReturnTimer < ReturnDelay + 30) Projectile.velocity *= 0.95f; else { + // Spawns a burst of homing bolts when it starts returning, based on how many tiles and enemies it hit + if (ReturnTimer == ReturnDelay + 30) + { + int boltPairs = Projectile.numHits; + for (int b = 0; b < boltPairs; b++) + { + for (int p = 0; p < 2; p++) + { + Vector2 randBoltVelocity = Main.rand.NextVector2CircularEdge(1f, 1f); + randBoltVelocity.SafeNormalize(Vector2.Zero); + randBoltVelocity *= 8f; + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randBoltVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + } + } + + // Continously spawn homing bolts as it returns while empowered + if (ReturnTimer % 8 == 0 && Empowered) + { + Vector2 randVelocity = -Projectile.velocity.RotatedByRandom(MathHelper.PiOver2) / 2; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + float returnSpeed = (ElementalSaw.ShootSpeed * 0.66f) + (0.05f * (ReturnTimer - 120)); Vector2 ownerDist = Owner.Center - Projectile.Center; if (ownerDist.Length() > 3000f) @@ -81,7 +114,7 @@ namespace CalamityMod.Projectiles.Ranged ownerDist.Normalize(); ownerDist *= returnSpeed; - // Home back in on the player. + // Home back in on the player; accelerates over time if (Projectile.velocity.X < ownerDist.X) Projectile.velocity.X = ownerDist.X; else if (Projectile.velocity.X > ownerDist.X) @@ -92,20 +125,12 @@ namespace CalamityMod.Projectiles.Ranged else if (Projectile.velocity.Y > ownerDist.Y) Projectile.velocity.Y = ownerDist.Y; - // Delete the saw if it touches its owner. + // Delete the saw if it touches its owner if (Main.myPlayer == Projectile.owner) { if (Projectile.Hitbox.Intersects(Owner.Hitbox)) Projectile.Kill(); } - - // Spawn homing bolts as it returns. These bolts spawn more often while empowered. - int boltFrequency = Empowered ? 7 : 10; - if (ReturnTimer % boltFrequency == 0) - { - Vector2 randVelocity = -Projectile.velocity.RotatedByRandom(MathHelper.PiOver2) / 2; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); - } } } } @@ -137,17 +162,17 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.velocity.Y != oldVelocity.Y) Projectile.velocity.Y = -oldVelocity.Y; - Projectile.ai[2]--; - if (Projectile.ai[2] <= 0) + if (Projectile.ai[2] > 0) { - Returning = true; + Projectile.ai[2]--; + Projectile.numHits++; + if (Projectile.ai[2] <= 0) + Returning = true; } return false; } - public override bool? CanDamage() => !(Returning && Projectile.ai[2] == 0); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); @@ -157,9 +182,19 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.numHits < 1) ReturnTimer = 1; - Projectile.ai[2]--; + if (Projectile.ai[2] > 0) + { + Projectile.ai[2]--; + if (Projectile.ai[2] <= 0) + Returning = true; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // The saw deals less damage while returning, to prevent its damage being too crazy if (Projectile.ai[2] <= 0) - Returning = true; + modifiers.SourceDamage *= 0.33f; } public override void OnKill(int timeLeft)