diff --git a/Particles/CircularSmear.png b/Particles/CircularSmear.png new file mode 100644 index 0000000000..d2b9bdd19c Binary files /dev/null and b/Particles/CircularSmear.png differ diff --git a/Particles/CircularSmearVFX.cs b/Particles/CircularSmearVFX.cs new file mode 100644 index 0000000000..e890ba908c --- /dev/null +++ b/Particles/CircularSmearVFX.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class CircularSmearVFX : Particle //Also check out Split mod! + { + public override string Texture => "CalamityMod/Particles/CircularSmear"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => false; + + public override bool SetLifetime => true; + public float opacity; + + public CircularSmearVFX(Vector2 position, Color color, float rotation, float scale) + { + Position = position; + Velocity = Vector2.Zero; + Color = color; + Scale = scale; + Rotation = rotation; + Lifetime = 2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = GeneralParticleHandler.GetTexture(Type); + + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity * 0.5f, 0, tex.Size()/2f, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs b/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs index f849d47d31..712a2b658a 100644 --- a/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Purity Projection"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; } public override void SetDefaults() diff --git a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs index 68a7ab15a5..7b5ac9fb62 100644 --- a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs @@ -1534,17 +1534,35 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMight"; private bool initialized = false; Vector2 direction = Vector2.Zero; + Vector2 oldDirection = Vector2.Zero; public ref float CurrentState => ref projectile.ai[0]; public Player Owner => Main.player[projectile.owner]; private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; - public float throwOutTime = 60f; + public float throwOutTime = 90f; public float throwOutDistance = 440f; //Turn these into constants when im doine tweakin em - public float maxEmpowerment = 1.7f; - public float Empowerment => (projectile.scale - 1f) / (maxEmpowerment - 1f); + + public static float snapPoint = 0.45f; + public float snapTimer => (throwTimer / throwOutTime) < snapPoint ? 0 : ((throwTimer / throwOutTime) - snapPoint) / (1f - snapPoint); + public static float retractionPoint = 0.6f; + public float retractionTimer => (throwTimer / throwOutTime) < retractionPoint ? 0 : ((throwTimer / throwOutTime) - retractionPoint) / (1f - retractionPoint); + public ref float Empowerment => ref projectile.ai[1]; + public ref float hasMadeSound => ref projectile.localAI[0]; + public ref float hasMadeChargeSound => ref projectile.localAI[1]; + + public float maxEmpowerment = 600f; + //How much damage reduction applies on uncharged attacks + public float initialDamage = 0.2f; + //How much extra damage applies when fully charged. This goes ontop of the initial damage, so a max empowerment boost of 2 with an initial damage of 0.1 makes the total damage multiplier be 1.9 + public float maxEmpowermentBoost = 2f; + public float throwTimer => throwOutTime - projectile.timeLeft; + + public Particle smear; public override void SetStaticDefaults() { DisplayName.SetDefault("Heaven's Might"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; } public override void SetDefaults() { @@ -1563,15 +1581,14 @@ namespace CalamityMod.Projectiles.Melee float collisionPoint = 0f; float bladeLenght = 100 * projectile.scale; float bladeWidth = 20 * projectile.scale; - - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center, Owner.Center + (direction * bladeLenght), bladeWidth, ref collisionPoint); + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + (direction * bladeLenght), bladeWidth, ref collisionPoint); } public CurveSegment launch = new CurveSegment(EasingType.CircOut, 0f, 0f, 1f, 4); - public CurveSegment hold = new CurveSegment(EasingType.SineBump, 0.5f, 1f, 0.2f); - public CurveSegment retract = new CurveSegment(EasingType.PolyInOut, 0.6f, 1f, -1.05f, 3); - internal float ThrowCurve() => PiecewiseAnimation((throwOutTime - projectile.timeLeft) / throwOutTime, new CurveSegment[] { launch , retract}); + public CurveSegment hold = new CurveSegment(EasingType.Linear, snapPoint, 1f, 0f); + public CurveSegment retract = new CurveSegment(EasingType.PolyInOut, retractionPoint, 1f, -1.05f, 3); + internal float ThrowCurve() => PiecewiseAnimation((throwOutTime - projectile.timeLeft) / throwOutTime, new CurveSegment[] { launch , hold, retract }); public override void AI() { @@ -1581,13 +1598,17 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity = Vector2.Zero; direction = Owner.DirectionTo(Main.MouseWorld); direction.Normalize(); + oldDirection = direction; initialized = true; } + projectile.rotation = direction.ToRotation(); //Only done for afterimages + if (!OwnerCanShoot) { - if (CurrentState == 2f) + if (CurrentState == 2f || (CurrentState == 0f && Empowerment / maxEmpowerment < 0.5)) { + Main.PlaySound(SoundID.Item77, projectile.Center); projectile.Kill(); return; } @@ -1595,35 +1616,84 @@ namespace CalamityMod.Projectiles.Melee else if (CurrentState == 0f) { CurrentState = 1f; + Main.PlaySound(SoundID.Item80, projectile.Center); direction = Owner.DirectionTo(Main.MouseWorld); + //PARTICLES LOTS OF PARTICLES LOTS OF SPARKLES YES YES MH YES YES + for (int i = 0; i <= 8; i++) + { + float variation = Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4); + float strength = (float)Math.Sin(variation * 2f + MathHelper.PiOver2); + Particle Sparkle = new CritSpark(projectile.Center, Owner.velocity + direction.RotatedBy(variation) * (1 + strength) * 2f * Main.rand.NextFloat(7.5f, 20f), Color.White, Color.HotPink, 2f + Main.rand.NextFloat(0f, 1.5f), 20 + Main.rand.Next(30), 1, 2f); + GeneralParticleHandler.SpawnParticle(Sparkle); + } + for (int i = 0; i <= 8; i++) + { + float variation = Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4); + float strength = (float)Math.Sin(variation * 2f + MathHelper.PiOver2); + Particle Sparkle = new CritSpark(projectile.Center, Owner.velocity + direction.RotatedBy(variation) * (1 + strength) * Main.rand.NextFloat(7.5f, 20f), Color.White, Color.Cyan, 2f + Main.rand.NextFloat(0f, 1.5f), 20 + Main.rand.Next(30), 1, 2f); + GeneralParticleHandler.SpawnParticle(Sparkle); + } } } if (CurrentState == 0f) { - //Manage position and rotation - projectile.scale *= 1.01f; - if (projectile.scale > maxEmpowerment) - projectile.scale = maxEmpowerment; + if (Owner.whoAmI == Main.myPlayer) + { + if (hasMadeChargeSound == 0f && Empowerment / maxEmpowerment >= 0.5) + { + hasMadeChargeSound = 1f; + Main.PlaySound(SoundID.Item76); + } - direction = direction.RotatedBy((Empowerment) * MathHelper.PiOver4 * 0.25); + float rotation = direction.ToRotation(); + if (rotation > -MathHelper.PiOver2 - MathHelper.PiOver4 && rotation < -MathHelper.PiOver2 + MathHelper.PiOver4 && hasMadeSound == 1f) + hasMadeSound = 0f; + + else if (rotation > MathHelper.PiOver2 - MathHelper.PiOver4 && rotation < MathHelper.PiOver2 + MathHelper.PiOver4 && hasMadeSound == 0f) + { + hasMadeSound = 1f; + Main.PlaySound(SoundID.Item71); + } + } + + if (Empowerment/maxEmpowerment >= 0.75) + { + if (smear == null) + { + smear = new CircularSmearVFX(Owner.Center, Color.HotPink, direction.ToRotation(), projectile.scale * 1.5f); + GeneralParticleHandler.SpawnParticle(smear); + } + //Update the variables of the smear + else + { + smear.Rotation = direction.ToRotation() + MathHelper.PiOver2 ; + smear.Time = 0; + smear.Position = Owner.Center; + smear.Scale = projectile.scale * 1.5f; + smear.Color = Color.Lerp(Color.HotPink, Color.Cyan, (float)Math.Sin(Main.GlobalTime * 2f)) * (((Empowerment / maxEmpowerment) - 0.75f) / 0.25f * 0.8f); + } + } + + + //Manage position and rotation + projectile.scale = 1 + Empowerment/maxEmpowerment * 1.5f; + + oldDirection = direction; + direction = direction.RotatedBy(MathHelper.Clamp(Empowerment / maxEmpowerment, 0.4f, 1f) * MathHelper.PiOver4 * 0.20f); direction.Normalize(); projectile.rotation = direction.ToRotation(); projectile.Center = Owner.Center + (direction * projectile.scale * 10); projectile.timeLeft = (int)throwOutTime + 1; - - //if (Main.rand.NextBool()) - //{ - // Particle foam = new SeaFoamParticle(Owner.Center + direction * 40 + Main.rand.NextVector2Circular(30f, 30f), Vector2.Zero, Color.White, new Color(65, 129, 192), Main.rand.NextFloat(0.5f, 1.5f), 245 - Main.rand.Next(50), 0.04f); - // foam.Velocity = (foam.Position - Owner.Center) * 0.01f + Owner.velocity; - // GeneralParticleHandler.SpawnParticle(foam); - //} - + Empowerment++; + if (Empowerment > maxEmpowerment) + Empowerment = maxEmpowerment; } if (CurrentState == 1f) { projectile.Center = Owner.Center + (direction * projectile.scale * 10) + ( direction * throwOutDistance * ThrowCurve()); + projectile.scale = (1 + Empowerment / maxEmpowerment * 1.5f) * MathHelper.Clamp(1 - retractionTimer, 0.3f, 1f); } //Make the owner look like theyre holding the sword bla bla @@ -1639,9 +1709,20 @@ namespace CalamityMod.Projectiles.Melee Owner.itemAnimation = 2; } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + damage = (int)(damage * (initialDamage + (maxEmpowermentBoost * Empowerment / maxEmpowerment))); + } + + public override void Kill(int timeLeft) + { + if (smear != null) + smear.Kill(); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D handle = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade"); + Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/TrueBiomeBlade"); Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMight"); float drawAngle = direction.ToRotation(); @@ -1650,6 +1731,31 @@ namespace CalamityMod.Projectiles.Melee Vector2 drawOrigin = new Vector2(0f, handle.Height); Vector2 drawOffset = projectile.Center - Main.screenPosition; + //Afterimages + if (CalamityConfig.Instance.Afterimages && CurrentState == 0f && Empowerment / maxEmpowerment > 0.4f) + { + for (int i = 0; i < projectile.oldRot.Length; ++i) + { + Color color = projectile.GetAlpha(lightColor) * (1f - (i / (float)projectile.oldRot.Length)); + float afterimageRotation = projectile.oldRot[i] + MathHelper.PiOver4; + Main.spriteBatch.Draw(handle, drawOffset, null, color * MathHelper.Lerp(0f, 0.5f, MathHelper.Clamp(Empowerment / maxEmpowerment - 0.4f / 0.1f, 0f, 1f) ), afterimageRotation, drawOrigin, projectile.scale - 0.2f * ((i / (float)projectile.oldRot.Length)), 0f, 0f); + } + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Vector2 afterimageDrawOrigin = new Vector2(0f, blade.Height); + for (int i = 0; i < projectile.oldRot.Length; ++i) + { + Color color = projectile.GetAlpha(lightColor) * (1f - (i / (float)projectile.oldRot.Length)); + float afterimageRotation = projectile.oldRot[i] + MathHelper.PiOver4; + Main.spriteBatch.Draw(blade, drawOffset, null, color * MathHelper.Lerp(0f, 0.5f, MathHelper.Clamp((Empowerment / maxEmpowerment - 0.4f) / 0.1f, 0f, 1f)), afterimageRotation, afterimageDrawOrigin, projectile.scale - 0.2f * ((i / (float)projectile.oldRot.Length)), 0f, 0f); + } + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + + spriteBatch.Draw(handle, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, 0f, 0f); //Turn on additive blending @@ -1658,7 +1764,22 @@ namespace CalamityMod.Projectiles.Melee //Update the parameters drawOrigin = new Vector2(0f, blade.Height); - spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 0f); + //Don't draw the glowing blade after the retraction + float opacityFade = CurrentState == 0f ? 1f : 1f - retractionTimer; + //Add basic tint (my beloved) during the snap + if (snapTimer > 0 && retractionTimer <= 0) + { + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(MathHelper.Clamp(0.8f - snapTimer, 0f, 1f)); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Color.White); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + } + + spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f * opacityFade, drawRotation, drawOrigin, projectile.scale, 0f, 0f); + + if (CurrentState == 1f && snapTimer > 0) + { + drawChain(spriteBatch, snapTimer, retractionTimer); + } //Back to normal spriteBatch.End(); @@ -1667,6 +1788,35 @@ namespace CalamityMod.Projectiles.Melee return false; } + public void drawChain(SpriteBatch spriteBatch, float snapProgress, float retractProgress) + { + Texture2D chainTex = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMightChain"); + + float opacity = retractProgress < 0.5 ? 1 : (retractProgress - 0.5f) / 0.5f; + + Vector2 Shake = retractProgress > 0 ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (1f - snapProgress) * 10f; + + int dist = (int)Vector2.Distance(Owner.Center, projectile.Center) / 16; + Vector2[] Nodes = new Vector2[dist + 1]; + Nodes[0] = Owner.Center; + Nodes[dist] = projectile.Center; + + for (int i = 1; i < dist + 1; i++) + { + Rectangle frame = new Rectangle(0, 0 + 18 * (i % 2), 12, 18); + Vector2 positionAlongLine = Vector2.Lerp(Owner.Center, projectile.Center, i / (float)dist); //Get the position of the segment along the line, as if it were a flat line + Nodes[i] = positionAlongLine + Shake * (float)Math.Sin(i / (float)dist * MathHelper.Pi); + + float rotation = (Nodes[i] - Nodes[i - 1]).ToRotation() - MathHelper.PiOver2; //Calculate rotation based on direction from last point + float yScale = Vector2.Distance(Nodes[i], Nodes[i - 1]) / frame.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points + Vector2 scale = new Vector2(1, yScale); + + Color chainLightColor = Lighting.GetColor((int)Nodes[i].X / 16, (int)Nodes[i].Y / 16); //Lighting of the position of the chain segment + + Vector2 origin = new Vector2(frame.Width / 2, frame.Height); //Draw from center bottom of texture + spriteBatch.Draw(chainTex, Nodes[i] - Main.screenPosition, frame, chainLightColor * opacity * 0.7f, rotation, origin, scale, SpriteEffects.None, 0); + } + } } } diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png index 3e41ca145a..16ff22f0e6 100644 Binary files a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png and b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png differ diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMightAfterimage.png b/Projectiles/Melee/MendedBiomeBlade_HeavensMightAfterimage.png new file mode 100644 index 0000000000..83a6325ff4 Binary files /dev/null and b/Projectiles/Melee/MendedBiomeBlade_HeavensMightAfterimage.png differ diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMightChain.png b/Projectiles/Melee/MendedBiomeBlade_HeavensMightChain.png new file mode 100644 index 0000000000..70bee87d0b Binary files /dev/null and b/Projectiles/Melee/MendedBiomeBlade_HeavensMightChain.png differ