diff --git a/Effects/ExobladeSlashShader.fx b/Effects/ExobladeSlashShader.fx index 2372fdae28..66ba42b214 100644 --- a/Effects/ExobladeSlashShader.fx +++ b/Effects/ExobladeSlashShader.fx @@ -76,7 +76,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 color = lerp(color, float4(uSecondaryColor, 1), darkColorWeight); // Create a fire streak. - float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 2); + float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 0.5); color = lerp(color, float4(fireColor, 1), fireColorWeight); float4 noiseColor = color * opacity * (noise3 * 2.4 + 2.4); diff --git a/Effects/ExobladeSlashShader.xnb b/Effects/ExobladeSlashShader.xnb index a7ccfcac02..2b150ad514 100644 Binary files a/Effects/ExobladeSlashShader.xnb and b/Effects/ExobladeSlashShader.xnb differ diff --git a/Items/Weapons/Melee/Exoblade.cs b/Items/Weapons/Melee/Exoblade.cs index 4d26681c9f..564eff6791 100644 --- a/Items/Weapons/Melee/Exoblade.cs +++ b/Items/Weapons/Melee/Exoblade.cs @@ -31,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.height = 114; Item.damage = 900; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 35; - Item.useAnimation = 35; + Item.useTime = 49; + Item.useAnimation = 49; Item.useTurn = true; Item.DamageType = DamageClass.Melee; Item.knockBack = 9f; diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 246e55c512..8b9047b06b 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -12,6 +12,7 @@ using Terraria.Audio; using System.Collections.Generic; using CalamityMod.DataStructures; using System.Linq; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { @@ -44,6 +45,16 @@ namespace CalamityMod.Projectiles.Melee public const float StartingSwingRotation = -0.72f; public const float EndingSwingRotation = StartingSwingRotation + MathHelper.TwoPi - 0.33f; + + // Starts at 0.125 and reels back. + public static CurveSegment Anticipation => new(EasingType.PolyInOut, 0f, 0.27f, -0.27f); + + public static CurveSegment SlashWait => new(EasingType.Linear, 0.37f, 0f, 0f); + + // After reeling back, a powerful slash happens. + public static CurveSegment Slash => new(EasingType.PolyOut, 0.51f, 0f, 1f); + + public static CurveSegment HoldBladeInPlace => new(EasingType.Linear, 0.7f, 1f, 0f); public override string Texture => "CalamityMod/Items/Weapons/Melee/Exoblade"; @@ -135,35 +146,27 @@ namespace CalamityMod.Projectiles.Melee { // Decide the swing direction. if (Owner.itemAnimation == Owner.itemAnimationMax) - { - if (SwingDirection == 0f) - SwingDirection = Main.rand.NextBool().ToDirectionInt(); - SwingDirection *= -1f; - } + SwingDirection = 1f; float exactSwingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax; float directionalSwingCompletion = exactSwingCompletion; - if (SwingDirection == -1f) - directionalSwingCompletion = 1f - directionalSwingCompletion; - - directionalSwingCompletion = MathHelper.Clamp(directionalSwingCompletion, 0f, 1f); + directionalSwingCompletion = MathHelper.Clamp(directionalSwingCompletion, 0f, 1f); + // TODO -- Make this better. // Hi Iban! Good luck :) - float swingCompletion; - if (directionalSwingCompletion < 0.3f) - swingCompletion = Utils.Remap(directionalSwingCompletion, 0f, 0.3f, 0.12f, 0f); - else if (directionalSwingCompletion < 0.54f) - swingCompletion = (float)Math.Pow(Utils.GetLerpValue(0.3f, 0.54f, directionalSwingCompletion, true), 0.75); - else - swingCompletion = 1f; + float swingCompletion = PiecewiseAnimation(directionalSwingCompletion, Anticipation, SlashWait, Slash, HoldBladeInPlace); // Clear the rotation cache after enough time has passed. - if (directionalSwingCompletion >= 0.74f) + if (directionalSwingCompletion < 0.45f) Projectile.oldRot = new float[Projectile.oldRot.Length]; // Decide the swing direction. - Projectile.rotation = MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, swingCompletion) * Direction - MathHelper.PiOver4; + Projectile.rotation = MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, swingCompletion); + Projectile.rotation = Projectile.rotation.AngleLerp(MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, 0.27f), Utils.GetLerpValue(0.8f, 1f, directionalSwingCompletion, true)); + Projectile.rotation = Projectile.rotation * Direction - MathHelper.PiOver4; + if (Direction == -1) + Projectile.rotation -= MathHelper.PiOver2; VerticalStretchFactor = Utils.Remap(swingCompletion, 0f, 0.5f, 0f, 0.4f); @@ -173,12 +176,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.scale = Utils.GetLerpValue(0f, 0.2f, exactSwingCompletion, true) * Utils.GetLerpValue(1f, 0.8f, exactSwingCompletion, true); // Create a bunch of homing beams. - int beamShootRate = (Projectile.MaxUpdates * 3); - if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && directionalSwingCompletion < 0.33f) + int beamShootRate = Projectile.MaxUpdates * 2; + if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && swingCompletion > 0.2f && swingCompletion < 0.9f) { int boltDamage = Projectile.damage / 2; Vector2 boltVelocity = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2(); - boltVelocity = Vector2.Lerp(boltVelocity, Projectile.SafeDirectionTo(Main.MouseWorld), 0.6f).SafeNormalize(Vector2.UnitY) * 9f; + boltVelocity = Vector2.Lerp(boltVelocity, Vector2.UnitX * Direction, 0.8f).SafeNormalize(Vector2.UnitY); + boltVelocity *= 9f; Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + boltVelocity * 5f, boltVelocity, ModContent.ProjectileType(), boltDamage, Projectile.knockBack / 3f, Projectile.owner); } @@ -213,7 +217,7 @@ namespace CalamityMod.Projectiles.Melee public float SlashWidthFunction(float completionRatio) => Projectile.scale * 43.5f; - public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(1f, 0.6f, completionRatio, true) * Projectile.Opacity; + public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; public IEnumerable GenerateSlashPoints() { @@ -265,7 +269,7 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.EnterShaderRegion(); var texture = ModContent.Request(Texture).Value; - CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix); + CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix); GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f)); GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f); GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix); diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index 76999f398f..9560497603 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -206,16 +206,16 @@ namespace CalamityMod /// /// This indicates when the segment starts on the animation /// - public float originX; + public float startingX; /// /// This indicates what the starting height of the segment is /// - public float originY; + public float startingHeight; /// /// This represents the elevation shift that will happen during the segment. Set this to 0 to turn the segment into a flat line. /// Usually this elevation shift is fully applied at the end of a segment, but the sinebump easing type makes it be reached at the apex of its curve. /// - public float displacement; + public float elevationShift; /// /// This is the degree of the polynomial, if the easing mode chosen is a polynomial one /// @@ -224,22 +224,17 @@ namespace CalamityMod /// /// Legacy constructor /// - public CurveSegment(EasingType MODE, float ORGX, float ORGY, float DISP, int DEG = 1) - { - easing = EasingTypeToFunction[(int)MODE]; - originX = ORGX; - originY = ORGY; - displacement = DISP; - degree = DEG; - } + public CurveSegment(EasingType MODE, float startX, float startHeight, float elevationShift, int degree = 1) : + this(EasingTypeToFunction[(int)MODE], startX, startHeight, elevationShift, degree) + { } - public CurveSegment(EasingFunction MODE, float ORGX, float ORGY, float DISP, int DEG = 1) + public CurveSegment(EasingFunction MODE, float startX, float startHeight, float elevationShift, int degree = 1) { easing = MODE; - originX = ORGX; - originY = ORGY; - displacement = DISP; - degree = DEG; + startingX = startX; + startingHeight = startHeight; + this.elevationShift = elevationShift; + this.degree = degree; } } @@ -250,13 +245,13 @@ namespace CalamityMod /// How far along the curve you are. Automatically clamped between 0 and 1 /// An array of curve segments making up the full animation curve /// - public static float PiecewiseAnimation(float progress, CurveSegment[] segments) + public static float PiecewiseAnimation(float progress, params CurveSegment[] segments) { if (segments.Length == 0) return 0f; - if (segments[0].originX != 0) //If for whatever reason you try to not play by the rules, get fucked - segments[0].originX = 0; + if (segments[0].startingX != 0) //If for whatever reason you try to not play by the rules, get fucked + segments[0].startingX = 0; progress = MathHelper.Clamp(progress, 0f, 1f); //Clamp the progress float ratio = 0f; @@ -264,29 +259,29 @@ namespace CalamityMod for (int i = 0; i <= segments.Length - 1; i++) { CurveSegment segment = segments[i]; - float startPoint = segment.originX; + float startPoint = segment.startingX; float endPoint = 1f; - if (progress < segment.originX) //Too early. This should never get reached, since by the time you'd have gotten there you'd have found the appropriate segment and broken out of the for loop + if (progress < segment.startingX) //Too early. This should never get reached, since by the time you'd have gotten there you'd have found the appropriate segment and broken out of the for loop continue; if (i < segments.Length - 1) { - if (segments[i + 1].originX <= progress) //Too late + if (segments[i + 1].startingX <= progress) //Too late continue; - endPoint = segments[i + 1].originX; + endPoint = segments[i + 1].startingX; } float segmentLenght = endPoint - startPoint; - float segmentProgress = (progress - segment.originX) / segmentLenght; //How far along the specific segment - ratio = segment.originY; + float segmentProgress = (progress - segment.startingX) / segmentLenght; //How far along the specific segment + ratio = segment.startingHeight; //Failsafe because somehow it can fail? what if (segment.easing != null) - ratio += segment.easing(segmentProgress, segment.degree) * segment.displacement; + ratio += segment.easing(segmentProgress, segment.degree) * segment.elevationShift; else - ratio += LinearEasing(segmentProgress, segment.degree) * segment.displacement; + ratio += LinearEasing(segmentProgress, segment.degree) * segment.elevationShift; break; }