diff --git a/Particles/SparkParticle.cs b/Particles/SparkParticle.cs index 6ce225db8e..f40ab9b4c1 100644 --- a/Particles/SparkParticle.cs +++ b/Particles/SparkParticle.cs @@ -10,26 +10,47 @@ namespace CalamityMod.Particles { public Color InitialColor; public bool AffectedByGravity; + public bool FadeIn = false; + public float FadeInScale = 0f; public override bool SetLifetime => true; public override bool UseCustomDraw => true; public override bool UseAdditiveBlend => true; public override string Texture => "CalamityMod/Projectiles/StarProj"; - public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool fadeIn = false) { Position = relativePosition; Velocity = velocity; AffectedByGravity = affectedByGravity; Scale = scale; + FadeInScale = scale; Lifetime = lifetime; Color = InitialColor = color; + FadeIn = fadeIn; + + if (FadeIn) + Scale = 0f; } public override void Update() { - Scale *= 0.95f; - Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + if (!FadeIn) + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + } + else + { + if ((float)Time / (float)Lifetime < 0.5f) + { + Scale = MathHelper.Lerp(Scale, FadeInScale, 0.2f); + } + else + { + Scale = MathHelper.Lerp(Scale, FadeInScale, -0.21f); + } + } Velocity *= 0.95f; if (Velocity.Length() < 12f && AffectedByGravity) { diff --git a/Projectiles/Rogue/TurbulanceProjectile.cs b/Projectiles/Rogue/TurbulanceProjectile.cs index 64daab5422..ce23643eea 100644 --- a/Projectiles/Rogue/TurbulanceProjectile.cs +++ b/Projectiles/Rogue/TurbulanceProjectile.cs @@ -5,11 +5,15 @@ using Microsoft.Xna.Framework; using CalamityMod.Particles; using Terraria.Audio; using CalamityMod.Items.Weapons.Rogue; +using Terraria.DataStructures; namespace CalamityMod.Projectiles.Rogue { public class TurbulanceProjectile : ModProjectile, ILocalizedModType { + NPC npcToStickTo = null; + Vector2 stickOffset; + public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/Turbulance"; @@ -25,13 +29,32 @@ namespace CalamityMod.Projectiles.Rogue Projectile.friendly = true; Projectile.timeLeft = 600; Projectile.extraUpdates = 2; + Projectile.penetrate = 3; Projectile.ignoreWater = true; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.tileCollide = false; + Projectile.tileCollide = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + public override void OnSpawn(IEntitySource source) + { + stickOffset = Vector2.Zero; + } + + public override bool? CanHitNPC(NPC target) + { + return base.CanHitNPC(target); } public override void AI() { + if (npcToStickTo != null) + { + Projectile.position = npcToStickTo.Center + (stickOffset * npcToStickTo.scale) + (Projectile.Size / 2); + } + if (!Projectile.Calamity().stealthStrike) { Projectile.velocity.Y += 0.05f; @@ -40,32 +63,31 @@ namespace CalamityMod.Projectiles.Rogue else { Projectile.velocity *= 1.05f; + + if (Projectile.velocity == Vector2.Zero) + { + if (Projectile.ai[2] % 6 == 0) + GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Projectile.Center, CalamityUtils.RandomVelocity(1, 10, 20), Color.LightSkyBlue, 100, 2f, 1f, MathHelper.ToRadians(Main.rand.NextFloat(-3f, 3f)))); + Projectile.ai[2]++; + } + } + + if (Projectile.velocity != Vector2.Zero) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); + if (Main.rand.NextBool(5)) + { + Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 187, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255)); + dust.noGravity = true; + } + if (Main.rand.NextBool(5)) + { + Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 16, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + dust.noGravity = true; + } } Projectile.ai[0]++; - Projectile.tileCollide = Projectile.ai[0] >= 2f; - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - - if (Main.rand.NextBool(5)) - { - Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 187, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255)); - dust.noGravity = true; - } - if (Main.rand.NextBool(5)) - { - Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 16, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - dust.noGravity = true; - } - - if (Projectile.Calamity().stealthStrike) //Stealth strike - { - if (Projectile.ai[0] % 4 == 1) - { - Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack / 2, Projectile.owner, 1f, 1f); - proj.Calamity().stealthStrike = true; - } - } } public override void OnKill(int timeLeft) @@ -78,23 +100,19 @@ namespace CalamityMod.Projectiles.Rogue { GeneralParticleHandler.SpawnParticle(new ImpactParticle( Projectile.Center + new Vector2(Main.rand.NextFloat(20, 50), 0).RotatedByRandom(MathHelper.TwoPi), MathHelper.ToRadians(Main.rand.NextFloat(-2, 2)), 20, 0.5f, Color.SkyBlue)); - } - - if (Projectile.Calamity().stealthStrike) - { - SoundEngine.PlaySound(Turbulance.LightningStrike, Projectile.Center); - - for (int i = 0; i <= 10; i++) - { - GeneralParticleHandler.SpawnParticle( - new CrackParticle(Projectile.Center + new Vector2(Main.rand.NextFloat(20, 50), 0).RotatedByRandom(MathHelper.TwoPi), Vector2.Zero, Color.Gold, new Vector2(Main.rand.NextFloat(1f, 2f), Main.rand.NextFloat(2f)), Main.rand.NextFloat(MathHelper.TwoPi), 1f, 0.5f, 30) - ); - } } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + if (Projectile.Calamity().stealthStrike) + { + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact.WithPitchOffset(-0.9f), Projectile.Center); + + npcToStickTo = target; + stickOffset = target.DirectionTo(Projectile.Center) * ((target.width + target.height) / 4); + Projectile.velocity = Vector2.Zero; + } OnHitEffects(hit.Crit); } @@ -106,7 +124,17 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { OnHitEffects(false); - return true; + if (Projectile.Calamity().stealthStrike) + { + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact.WithPitchOffset(-0.7f), Projectile.Center);; + Projectile.velocity = Vector2.Zero; + stickOffset = oldVelocity * 1.7f; + } + else + { + return true; + } + return false; } private void OnHitEffects(bool homeIn) diff --git a/Projectiles/Rogue/TurbulanceWindSlash.cs b/Projectiles/Rogue/TurbulanceWindSlash.cs index 559cf17b35..37f2f8acad 100644 --- a/Projectiles/Rogue/TurbulanceWindSlash.cs +++ b/Projectiles/Rogue/TurbulanceWindSlash.cs @@ -32,6 +32,9 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { + + float rot = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile.velocity *= 0.9f; if (Projectile.localAI[0] == 0f) { @@ -57,13 +60,24 @@ namespace CalamityMod.Projectiles.Rogue } if (Projectile.Calamity().stealthStrike) //stealth strike { - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 450f, 8f, 20f); + Projectile.ai[1]++; + if (Projectile.ai[1] % 3 == 1) + { + GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Projectile.Center, CalamityUtils.RandomVelocity(1f, 2, 5), Color.SkyBlue, 50, 1f, 255)); + } + if (Projectile.ai[1] > 10) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 450f, 8f, 20f); + } + else + { + if (Projectile.ai[1] % 8 == 1) + GeneralParticleHandler.SpawnParticle(new SparkParticle( + Projectile.Center + new Vector2(50, 0).RotatedBy(rot + MathHelper.ToRadians(180f)), new Vector2(10, 0).RotatedBy(rot), false, 10, 2f, Color.LightSkyBlue, true + )); } } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; }