From bbb6cce20601e9eab9882a673d27cd95c12e203c Mon Sep 17 00:00:00 2001 From: Xyk Date: Mon, 21 Apr 2025 17:46:42 -0700 Subject: [PATCH] Flash rounds re-rework Damage increase is either +20% or +2 flat, whichever is stronger Can bounce up to 2 times and pierce once --- Items/Ammo/FlashRound.cs | 14 +- .../en-US/Mods.CalamityMod.Items.Ammo.hjson | 2 +- .../Mods.CalamityMod.Projectiles.Ranged.hjson | 1 + Projectiles/Ranged/FlashRoundFlash.cs | 51 ++++++ Projectiles/Ranged/FlashRoundProj.cs | 172 ++++++++++++------ 5 files changed, 173 insertions(+), 67 deletions(-) create mode 100644 Projectiles/Ranged/FlashRoundFlash.cs diff --git a/Items/Ammo/FlashRound.cs b/Items/Ammo/FlashRound.cs index fbd7778605..64c4e0d5d8 100644 --- a/Items/Ammo/FlashRound.cs +++ b/Items/Ammo/FlashRound.cs @@ -18,23 +18,23 @@ namespace CalamityMod.Items.Ammo { Item.width = 12; Item.height = 18; - Item.damage = 5; + Item.damage = 6; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; - Item.knockBack = 1.15f; - Item.value = Item.sellPrice(copper: 2); + Item.knockBack = 6f; + Item.value = Item.sellPrice(copper: 1); Item.rare = ItemRarityID.Blue; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 10f; Item.ammo = AmmoID.Bullet; } public override void AddRecipes() { - CreateRecipe(10). - AddIngredient(ItemID.Grenade). - AddIngredient(ItemID.Glass, 3). + CreateRecipe(333). + AddRecipeGroup("AnyCopperBar", 7). + AddIngredient(ItemID.Glass, 5). AddTile(TileID.Anvils). Register(); } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson index 052e13b604..6107088ad6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson @@ -58,7 +58,7 @@ ElysianArrow: { FlashRound: { DisplayName: Flash Round - Tooltip: Emits a wide-reaching concussive blast which briefly confuses enemies + Tooltip: A ricocheting bullet that confuses enemies when it flashes and deals more damage with each bounce } GodSlayerSlug: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 1bdcd8d2f4..07a9b5dd8a 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -87,6 +87,7 @@ FlakKrakenProjectile.DisplayName: Flak Kraken FlakToxicannonProjectile.DisplayName: Flak Toxicannon FlareBat.DisplayName: Flare Bat Flash.DisplayName: Flash +FlashRoundFlash.DisplayName: Flash FlashRoundProj.DisplayName: Flash Round FlurrystormIceChunk.DisplayName: Ice Chunk FlurrystormIceShard.DisplayName: Ice Shard diff --git a/Projectiles/Ranged/FlashRoundFlash.cs b/Projectiles/Ranged/FlashRoundFlash.cs new file mode 100644 index 0000000000..ecd6d8841e --- /dev/null +++ b/Projectiles/Ranged/FlashRoundFlash.cs @@ -0,0 +1,51 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class FlashRoundFlash : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Ranged"; + public override void SetDefaults() + { + Projectile.width = 95; + Projectile.height = 95; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.5f); + } + public override bool? CanHitNPC(NPC target) + { + if (Utils.Distance(target.Center, Projectile.Center) <= Projectile.width) + { + Player Owner = Main.player[Projectile.owner]; + target.AddBuff(BuffID.Confused, 180); + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Projectile.Center); + target.MoveNPC(launchVel, 5, false); + + Vector2 dustVel = Utils.DirectionTo(Projectile.Center, target.Center); + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), dustVel.RotatedByRandom(0.7f) * Main.rand.NextFloat(9f, 14f)); + dust.scale = Main.rand.NextFloat(0.45f, 0.75f); + dust.noGravity = true; + dust.color = Color.White; + dust.noLightEmittence = true; + } + } + return false; + } + } +} diff --git a/Projectiles/Ranged/FlashRoundProj.cs b/Projectiles/Ranged/FlashRoundProj.cs index 6eb86ba08f..bd27b0a182 100644 --- a/Projectiles/Ranged/FlashRoundProj.cs +++ b/Projectiles/Ranged/FlashRoundProj.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -9,8 +14,10 @@ namespace CalamityMod.Projectiles.Ranged public class FlashRoundProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public bool Exploding = false; - public float ExplosionPower = 1.5f; + public int bounces = 2; + public float shineRot = 0; + public bool onSpawn = true; + public ref float time => ref Projectile.ai[2]; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 15; @@ -19,15 +26,15 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = 8; + Projectile.height = 8; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; + Projectile.penetrate = 2; Projectile.timeLeft = 600; - Projectile.extraUpdates = 2; + Projectile.extraUpdates = 3; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = -1; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; @@ -37,81 +44,128 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.spriteDirection = Projectile.direction; - Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * (Exploding ? 1.5f : 0.2f)); + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.3f); - Projectile.localAI[0] += 1f; - - if (Exploding) + if (bounces < 2 || Projectile.numHits > 0) { - if (Projectile.timeLeft == 59) - { - SoundEngine.PlaySound(SoundID.Item93 with { Pitch = 0.55f, Volume = 0.4f }, Projectile.Center); - } - Projectile.velocity = Vector2.Zero; + int falloffTime = 7; + if (time > falloffTime) + Projectile.velocity.X *= 0.983f; + if (Projectile.velocity.Y < 15 && time > falloffTime) + Projectile.velocity.Y += 0.16f; + if (Projectile.velocity.Y < 5) + Projectile.velocity.Y *= 0.98f; + } + if (onSpawn) + { + Projectile.knockBack = 0; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10; + shineRot = Main.rand.NextFloat(-5, 5); + onSpawn = false; + } + shineRot += Math.Sign(shineRot) * 0.05f; - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, (new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.2f)) * ExplosionPower); - dust.scale = Main.rand.NextFloat(0.75f, 0.9f) * ExplosionPower; + if (time > 2 && time % 2 == 0) + { + float trailSize = Utils.GetLerpValue(2, 5, Projectile.velocity.Length(), true); + Particle trail = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.5f, "CalamityMod/Particles/BloomCircle", false, 5, 0.13f, Color.White * 0.6f, new Vector2(1f - 0.2f * trailSize, 1 + 2f * trailSize), true, false, shrinkSpeed: 0.8f * trailSize); + GeneralParticleHandler.SpawnParticle(trail); + } + if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.5f, 0.9f)); + dust.scale = Main.rand.NextFloat(0.55f, 0.7f); dust.noGravity = true; - - if (Projectile.timeLeft <= 50 && ExplosionPower > 0.5f) - ExplosionPower -= 0.015f; - } - else - { - if (Projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool()) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 63, -Projectile.velocity * Main.rand.NextFloat(0.9f, 1.1f)); - dust.scale = Main.rand.NextFloat(0.7f, 0.85f); - dust.noGravity = true; - } - } } + time++; } public override bool PreDraw(ref Color lightColor) { - if (Projectile.localAI[0] > 6f && !Exploding) - CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, Color.White); + float sine = (float)Math.Sin(Projectile.timeLeft * 0.175f / MathHelper.Pi); + float trueSine = MathHelper.Lerp(sine, Math.Sign(sine) * 0.5f, 0.6f); + Asset trail = ModContent.Request("CalamityMod/Particles/BloomLineSoftEdge"); + Asset shine = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * 0.6f, Projectile.rotation + shineRot, shine.Size() / 2f, new Vector2(1 + 0.9f * trueSine, 1 + 0.9f * -trueSine) * Projectile.scale * 0.13f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * 0.6f, Projectile.rotation + shineRot, shine.Size() / 2f, new Vector2(1 + 0.9f * -trueSine, 1 + 0.9f * trueSine) * Projectile.scale * 0.13f, SpriteEffects.None, 0); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (!Exploding) + time = 0; + Projectile.velocity = Vector2.Lerp(Utils.DirectionFrom(Projectile.Center, target.Center) * 12, Vector2.UnitY * -7, 0.75f).RotatedByRandom(0.25f); + makeDust(false); + } + public void makeDust(bool onlyFlash) // This is basically the tile/hit effects + { + if (!onlyFlash) { - Projectile.timeLeft = 60; - Exploding = true; - Projectile.damage = (int)(Projectile.damage * 0.15f); - Projectile.ExpandHitboxBy(100); - Projectile.alpha = 255; + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.6f) * Main.rand.NextFloat(8.5f, 12f)); + dust.scale = Main.rand.NextFloat(0.75f, 1.1f); + dust.noGravity = true; + } + //SoundEngine.PlaySound(SoundID.Shatter with { Volume = 0.4f, Pitch = 0.1f + 0.1f * bounces }, Projectile.Center); + SoundEngine.PlaySound(SoundID.Item50 with { Volume = 0.3f, Pitch = -0.2f + 0.4f * bounces, MaxInstances = 15 }, Projectile.Center); } - target.AddBuff(BuffID.Confused, 300); + for (int i = 0; i < 2; i++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f * (i), 0.45f * (i), 9, true); + GeneralParticleHandler.SpawnParticle(blastRing); + } + float rot = Main.rand.NextFloat(-5, 5); + for (int i = 0; i < 5; i++) + { + Vector2 dustVel = ((MathHelper.TwoPi * i / 5f) + rot).ToRotationVector2() * 5; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), dustVel); + dust.scale = 1.1f; + dust.fadeIn = 1.5f; + dust.noGravity = true; + dust.color = Color.White; + } + // Doesn't actually do damage, just an aoe for confustion infliction and knockback + Projectile flash = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 5, 0f, Projectile.owner); } public override bool OnTileCollide(Vector2 oldVelocity) { - if (!Exploding) + time = 0; + if (Projectile.velocity.X != oldVelocity.X) { - Projectile.timeLeft = 60; - Exploding = true; - Projectile.damage = (int)(Projectile.damage * 0.15f); - Projectile.ExpandHitboxBy(100); - Projectile.alpha = 255; - Projectile.tileCollide = false; + Projectile.velocity.X = -oldVelocity.X; } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + if (Projectile.velocity.X < 2 && Projectile.velocity.X > 0) + Projectile.velocity.X = 2; + if (Projectile.velocity.X > -2 && Projectile.velocity.X < 0) + Projectile.velocity.X = -2; + if (Projectile.velocity.Y < 2 && Projectile.velocity.Y > 0) + Projectile.velocity.Y = 2; + if (Projectile.velocity.Y > -2 && Projectile.velocity.Y < 0) + Projectile.velocity.Y = -2; + + Projectile.velocity *= 0.97f; + + int expectedDamage = Math.Max((int)(Projectile.damage * 1.2f), Projectile.damage + 2); + Projectile.damage = expectedDamage; + + makeDust(false); + if (bounces <= 0) + { + Projectile.Kill(); + return false; + } + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + bounces--; return false; } public override void OnKill(int timeLeft) { - if (!Exploding) - { - for (int k = 0; k < 9; k++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 63, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.1f)); - dust.scale = Main.rand.NextFloat(0.6f, 0.75f); - dust.noGravity = true; - } - } } } }