diff --git a/Items/Weapons/Melee/OmegaBiomeBlade.cs b/Items/Weapons/Melee/OmegaBiomeBlade.cs index b102e56eab..5ae05bf7ae 100644 --- a/Items/Weapons/Melee/OmegaBiomeBlade.cs +++ b/Items/Weapons/Melee/OmegaBiomeBlade.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Melee public static int FlailBladeAttunement_BaseDamage = 320; public static int FlailBladeAttunement_MaxFlails = 3; - public static int FlailBladeAttunement_FlailTime = 30; + public static int FlailBladeAttunement_FlailTime = 10; public static float FlailBladeAttunement_ChainDamageReduction = 0.5f; public static float FlailBladeAttunement_GhostChainDamageReduction = 0.5f; @@ -450,8 +450,8 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale; AttunementInfo info = GetAttunementInfo(mainAttunement); - BiomeEnergyParticles.EdgeColor = Color.Lerp(info.color2, Color.Black, 0.5f); - BiomeEnergyParticles.CenterColor = Color.Lerp(info.color, Color.White, 0.5f); + BiomeEnergyParticles.EdgeColor = info.color2; + BiomeEnergyParticles.CenterColor = info.color; BiomeEnergyParticles.InterpolationSpeed = 0.1f; BiomeEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition); diff --git a/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs b/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs index 58ddcf994f..f4b0c8aa58 100644 --- a/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/BrokenBiomeBladeProjectiles.cs @@ -807,8 +807,6 @@ namespace CalamityMod.Projectiles.Melee projectile.Center = Owner.MountedCenter + SwingPosition(ratio); projectile.direction = projectile.spriteDirection = -Owner.direction; - //MessWithTiles(); - Owner.itemRotation = MathHelper.WrapAngle(Owner.AngleTo(Main.MouseWorld) - (Owner.direction < 0 ? MathHelper.Pi : 0)); } public void HookToTile() @@ -825,108 +823,6 @@ namespace CalamityMod.Projectiles.Melee } } - public void MessWithTiles() //This DESTROYS the grass growing meta and shall remain sealed away - { - BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, controlPoint1, controlPoint2, projectile.Center }); - int numPoints = 30; - Vector2[] chainPositions = curve.GetPoints(numPoints).ToArray(); - - for (int i = 0; i < numPoints; i++) - { - Vector2 position = chainPositions[i]; - Tile targetTile = Main.tile[(int)position.X / 16, (int)position.Y / 16]; //Grab the tile - - if ((targetTile.type == TileID.Dirt || targetTile.type == TileID.Mud) && targetTile.active()) - { - if (targetTile.type == TileID.Dirt) - { - targetTile.active(true); - targetTile.type = TileID.Grass; - - if (Owner.ZoneCorrupt) - targetTile.type = TileID.CorruptGrass; - if (Owner.ZoneCrimson) - targetTile.type = TileID.FleshGrass; - if (Owner.ZoneHoly) - targetTile.type = TileID.HallowedGrass; - } - if (targetTile.type == TileID.Mud) - { - targetTile.active(true); - targetTile.type = TileID.JungleGrass; - if (Owner.ZoneGlowshroom) - { - targetTile.type = TileID.MushroomGrass; - } - } - - WorldGen.SquareTileFrame((int)position.X / 16, (int)position.Y / 16, true); //Update the tile framing - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, (int)position.X / 16, (int)position.Y / 16, 1, TileChangeType.None); - } - - Tile targetTileAbove = Main.tile[(int)position.X / 16, (int)position.Y / 16 - 1]; - if (!targetTileAbove.active() && ((targetTile.type == TileID.Grass || targetTile.type == TileID.HallowedGrass || targetTile.type == TileID.JungleGrass) && targetTile.active())) //If theres air above - { - if (targetTile.type == TileID.Grass) - { - if (Main.rand.NextBool(2)) - { - targetTileAbove.active(true); - targetTileAbove.type = TileID.Plants; - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 11)); - while (targetTileAbove.frameX == 144) //Exclude the mushroom - { - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 11)); - } - } - else - { - targetTileAbove.active(true); - targetTileAbove.type = TileID.Plants2; - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 21)); - while (targetTileAbove.frameX == 144) - { - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 21)); - } - } - } - //On hallowed grass, grow hallowed plants - else if (targetTile.type == TileID.Grass) - { - if (Main.rand.NextBool(2)) - { - targetTileAbove.active(true); - targetTileAbove.type = TileID.HallowedPlants; - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 7)); - } - else - { - targetTileAbove.active(true); - targetTileAbove.type = TileID.HallowedPlants2; - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 8)); - while (targetTileAbove.frameX == 90) - { - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 8)); - } - } - } - //On jungle grass, grow jungle flowers - else if (targetTile.type == TileID.JungleGrass) - { - targetTileAbove.active(true); - targetTileAbove.type = TileID.JunglePlants2; - targetTileAbove.frameX = (short)(18 * Main.rand.Next(0, 17)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, (int)position.X / 16, (int)position.Y / 16 - 1, 1, TileChangeType.None); - } - - } - - } - internal float EaseInFunction(float progress) => progress == 0 ? 0f : (float)Math.Pow(2, 10 * progress - 10); //Potion seller i need your strongest easeIns private float GetSwingRatio() diff --git a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs index 30276f3259..517c04a945 100644 --- a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs @@ -564,7 +564,7 @@ namespace CalamityMod.Projectiles.Melee case 2: projectile.width = projectile.height = 170; Main.PlaySound(SoundID.DD2_PhantomPhoenixShot, projectile.Center); - projectile.damage *= (int)(projectile.damage * TrueBiomeBlade.ColdAttunement_ThirdSwingBoost); + projectile.damage = (int)(projectile.damage * TrueBiomeBlade.ColdAttunement_ThirdSwingBoost); break; } @@ -1934,6 +1934,7 @@ namespace CalamityMod.Projectiles.Melee { SlamDown(); projectile.timeLeft = 0; + Owner.Calamity().LungingDown = false; projectile.active = false; projectile.netUpdate = true; projectile.netSpam = 0; diff --git a/Projectiles/Melee/TrueBiomeBladeProjectiles.cs b/Projectiles/Melee/TrueBiomeBladeProjectiles.cs index db99f61704..5a5a048b6d 100644 --- a/Projectiles/Melee/TrueBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/TrueBiomeBladeProjectiles.cs @@ -1118,6 +1118,7 @@ namespace CalamityMod.Projectiles.Melee { SlamDown(); projectile.timeLeft = 0; + Owner.Calamity().LungingDown = false; projectile.active = false; projectile.netUpdate = true; projectile.netSpam = 0; @@ -1594,8 +1595,6 @@ namespace CalamityMod.Projectiles.Melee } } - - //Lamentations of the Chained aka FlailBlade attunement public class LamentationsOfTheChained : ModProjectile @@ -1622,15 +1621,9 @@ namespace CalamityMod.Projectiles.Melee const float MaxTangleReach = 400f; //How long can tangling vines from crits be + //Doing your mom. Be warned that the X value of these vectors represents the angle of the whip while the Y value represents its RNG seed public Vector2 whip1; - public BezierCurve curve1; - private Vector2 controlPoint11; - private Vector2 controlPoint12; - public Vector2 whip2; - public BezierCurve curve2; - private Vector2 controlPoint21; - private Vector2 controlPoint22; internal bool ReelingBack => Timer / MaxTime > SnappingPoint; @@ -1651,24 +1644,23 @@ namespace CalamityMod.Projectiles.Melee public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { - BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, controlPoint1, controlPoint2, projectile.Center }); - int numPoints = 32; - Vector2[] chainPositions = curve.GetPoints(numPoints).ToArray(); - float collisionPoint = 0; - for (int i = 1; i < numPoints; i++) - { - Vector2 position = chainPositions[i]; - Vector2 previousPosition = chainPositions[i - 1]; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), position, previousPosition, 6, ref collisionPoint)) - return true; - if (i == numPoints - 1) //Extra lenght collision for the blade itself - { - Vector2 projectileHalfLenght = 85 * projectile.rotation.ToRotationVector2(); - return (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center - projectileHalfLenght, projectile.Center + projectileHalfLenght, 32, ref collisionPoint)); - } + //int numPoints = 32; + //Vector2[] chainPositions = curve.GetPoints(numPoints).ToArray(); + //float collisionPoint = 0; + //for (int i = 1; i < numPoints; i++) + //{ + // Vector2 position = chainPositions[i]; + // Vector2 previousPosition = chainPositions[i - 1]; + // if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), position, previousPosition, 6, ref collisionPoint)) + // return true; + // if (i == numPoints - 1) //Extra lenght collision for the blade itself + // { + // Vector2 projectileHalfLenght = 85 * projectile.rotation.ToRotationVector2(); + // return (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center - projectileHalfLenght, projectile.Center + projectileHalfLenght, 32, ref collisionPoint)); + // } - } + //} return base.Colliding(projHitbox, targetHitbox); } @@ -1741,12 +1733,6 @@ namespace CalamityMod.Projectiles.Melee { Main.PlaySound(SoundID.DD2_OgreSpit, projectile.Center); - controlPoint11 = projectile.Center; - controlPoint12 = projectile.Center; - - controlPoint21 = projectile.Center; - controlPoint22 = projectile.Center; - projectile.timeLeft = (int)MaxTime; initialized = true; projectile.netUpdate = true; @@ -1797,13 +1783,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/OmegaBiomeBlade"); Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained"); - - //Vector2 projBottom = projectile.Center + new Vector2(-handle.Width / 2, handle.Height / 2).RotatedBy(projectile.rotation + MathHelper.PiOver4) * 0.75f; - //DrawChain(spriteBatch, projBottom, out Vector2[] chainPositions); + DrawChain(spriteBatch, out Vector2[] chainPositions1, out Vector2[] chainPositions2); //float drawRotation = (projBottom - chainPositions[chainPositions.Length - 2]).ToRotation() + MathHelper.PiOver4; //Face away from the last point of the bezier curve @@ -1821,6 +1804,15 @@ namespace CalamityMod.Projectiles.Melee spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); //Draw the tip of the flails here + Texture2D flailBlade = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail"); + Rectangle bladeFrame = new Rectangle(0, 0, 24, 48); + Vector2 flailOrigin = new Vector2(bladeFrame.Width / 2, bladeFrame.Height); //Draw from center bottom of texture + + if (chainPositions1.Length > 1) + { + float flailRotation = (chainPositions1[chainPositions1.Length - 1] - chainPositions1[chainPositions1.Length - 2]).ToRotation() + MathHelper.PiOver2; + spriteBatch.Draw(flailBlade, chainPositions1[chainPositions1.Length - 1] - Main.screenPosition, bladeFrame, Color.White, flailRotation, flailOrigin, 1, SpriteEffects.None, 0); + } drawOrigin = new Vector2(0f, blade.Height); spriteBatch.Draw(blade, drawPos - Main.screenPosition, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 0f); @@ -1831,41 +1823,96 @@ namespace CalamityMod.Projectiles.Melee return false; } - private void DrawChain(SpriteBatch spriteBatch, Vector2 projBottom, out Vector2[] chainPositions1 out Vector2) + //TLDR : https://media.discordapp.net/attachments/659100646397575208/933521303443501136/placeholder.gif + private void GenerateCurve(float seed, Vector2 direction, out Vector2 control0, out Vector2 control1, out Vector2 control2, out Vector2 control3, float angleShift = 0f) { - Texture2D chainTex = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain"); + float randomNumber = 0.5f + ((float)Math.Sin(seed * 17.07947) + (float)Math.Sin(seed * 0.2f * 25.13274)) * 0.25f ; //Ty dom for the awesome pseudo rng - float ratio = GetSwingRatio(); + float flip = randomNumber >= 0.5 ? 1f : -1f; - float rotationAngle = MathHelper.PiOver4 * Math.Sign(projectile.velocity.X) * flipped; + + control0 = Owner.MountedCenter + direction.RotatedBy(MathHelper.ToRadians(MathHelper.Lerp(MathHelper.PiOver4 * 0.3f * flip, MathHelper.PiOver4 * flip, randomNumber))) * MathHelper.Lerp(50f, 130f, (float)Math.Sin(randomNumber * MathHelper.Pi)); + + float Reach = MaxReach * (1f + 0.5f * randomNumber); + control3 = Owner.MountedCenter + direction * Reach; // The last point of the curve gets put straight at the front + + //Over the double fucking bezier rainbow + Vector2 point1 = control3 + direction.RotatedBy(MathHelper.PiOver2) * 50; + Vector2 point2 = control3 + direction.RotatedBy(MathHelper.PiOver2) * 50 + direction * 250; + Vector2 point3 = control3 + direction.RotatedBy(-MathHelper.PiOver2) * 50 + direction * 250; + Vector2 point4 = control3 + direction.RotatedBy(-MathHelper.PiOver2) * 50; + BezierCurve curve = new BezierCurve(new Vector2[] { point1, point2, point3, point4 }); + control3 = curve.Evaluate(randomNumber); + + Vector2 directionFromHead = direction.RotatedBy(MathHelper.ToRadians(MathHelper.Lerp(0, 160f * flip, (float)Math.Sin(randomNumber * MathHelper.Pi)))) * MathHelper.Lerp(130f, 200f, MathHelper.Clamp((float)Math.Sin(randomNumber * MathHelper.Pi) - 0.5f, 0f, 1f) * 2f); + control2 = control3 + directionFromHead; + + Vector2 directionFromSecondToLastPoint = Vector2.Normalize(directionFromHead.RotatedBy(MathHelper.Pi - MathHelper.ToRadians(MathHelper.Lerp(80f * flip, 110f * flip, (float)Math.Sin(randomNumber * MathHelper.Pi))))) * MathHelper.Lerp(120f, 280f, (float)Math.Sin(randomNumber * MathHelper.Pi)); + control1 = control2 + directionFromSecondToLastPoint; + + //Get new random numbers based on the same seed + float seed1 = 0.5f + ((float)Math.Sin(randomNumber * 100f * 17.07947) + (float)Math.Sin(randomNumber * 100f * 0.2f * 25.13274)) * 0.25f; + float seed2 = 0.5f + ((float)Math.Sin(seed1 * 50f * 17.07947) + (float)Math.Sin(seed1 * 50f * 0.2f * 25.13274)) * 0.25f; + float seed3 = 0.5f + ((float)Math.Sin(seed2 * 17.07947) + (float)Math.Sin(seed2 * 0.2f * 25.13274)) * 0.25f; + + control3 += Vector2.UnitX.RotatedBy(MathHelper.TwoPi * seed1) * seed3 * 30f; + control2 += Vector2.UnitX.RotatedBy(MathHelper.TwoPi * seed2) * seed1 * 30f; + control1 += Vector2.UnitX.RotatedBy(MathHelper.TwoPi * seed3) * seed2 * 30f; + } + + private void DrawChain(SpriteBatch spriteBatch, out Vector2[] chainPositions1, out Vector2[] chainPositions2) + { + + Texture2D tex = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail"); + Rectangle chainFrame = new Rectangle(0, 70, 24, 14); + Rectangle guardFrame = new Rectangle(0, 50, 24, 18); //Set the first whip - if (ChainSwapTimer % OmegaBiomeBlade.FlailBladeAttunement_FlailTime == 0) - whip1 = projectile.velocity.RotatedBy(Main.rand.NextFloat(MathHelper.Pi / 8f, MathHelper.Pi / 8f)); + if (ChainSwapTimer % 6 == 0 || whip1.Y == 0) + { + whip1.X = projectile.velocity.RotatedBy(Main.rand.NextFloat(MathHelper.Pi / 16f, -MathHelper.Pi / 16f)).ToRotation(); //X is the orientation + whip1.Y = Main.rand.NextFloat(0.2f, 100f);//Y is the "seed" - //Set the second whip - if ((ChainSwapTimer - OmegaBiomeBlade.FlailBladeAttunement_FlailTime * 0.5f) % OmegaBiomeBlade.FlailBladeAttunement_FlailTime == 0) - whip2 = projectile.velocity.RotatedBy(Main.rand.NextFloat(MathHelper.Pi / 8f, MathHelper.Pi / 8f)); + ChainSwapTimer++; + } - //Watch this randomness float offsetBase = (sin(frameY * 17.07947 + uTime * 16) + sin(coords.y * 25.13274)) * 0.5 + GenerateCurve(whip1.Y, projectile.velocity, out Vector2 control0, out Vector2 control1, out Vector2 control2, out Vector2 control3); - int numPoints = 30; - chainPositions = curve.GetPoints(numPoints).ToArray(); + //First chain + BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, control0, control1, control2, control3 }); + int numPoints = 40; + chainPositions1 = curve.GetPoints(numPoints).ToArray(); //Draw each chain segment bar the very first one for (int i = 1; i < numPoints; i++) { - Vector2 position = chainPositions[i]; - float rotation = (chainPositions[i] - chainPositions[i - 1]).ToRotation() - MathHelper.PiOver2; //Calculate rotation based on direction from last point - float yScale = Vector2.Distance(chainPositions[i], chainPositions[i - 1]) / chainTex.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points - Vector2 scale = new Vector2(1, yScale); + Vector2 position = chainPositions1[i]; + + float rotation = (chainPositions1[i] - chainPositions1[i - 1]).ToRotation() + MathHelper.PiOver2; //Calculate rotation based on direction from last point Color chainLightColor = Lighting.GetColor((int)position.X / 16, (int)position.Y / 16); //Lighting of the position of the chain segment - Vector2 origin = new Vector2(chainTex.Width / 2, chainTex.Height); //Draw from center bottom of texture - spriteBatch.Draw(chainTex, position - Main.screenPosition, null, chainLightColor, rotation, origin, scale, SpriteEffects.None, 0); + + if (i < numPoints - 1) + { + float yScale = Vector2.Distance(chainPositions1[i], chainPositions1[i - 1]) / chainFrame.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points + Vector2 scale = new Vector2(1, yScale); //Remember to make it get thicker and thinner based on whatever + Vector2 origin = new Vector2(chainFrame.Width / 2, chainFrame.Height); //Draw from center bottom of texture + spriteBatch.Draw(tex, chainPositions1[i] - Main.screenPosition, chainFrame, chainLightColor, rotation, origin, scale, SpriteEffects.None, 0); + } + else + { + Vector2 origin = new Vector2(guardFrame.Width / 2, guardFrame.Height); //Draw from center bottom of texture + spriteBatch.Draw(tex, chainPositions1[i] - Main.screenPosition, guardFrame, chainLightColor, rotation, origin, 1, SpriteEffects.None, 0); + } } + + chainPositions2 = new Vector2[1]; + chainPositions2[0] = Owner.Center; + + //Second chain } + public override void SendExtraAI(BinaryWriter writer) { writer.Write(initialized); diff --git a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail.png b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail.png index 1bc8a39aae..9a457c39eb 100644 Binary files a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail.png and b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedFlail.png differ