diff --git a/Effects/ExobladeSlashShader.fx b/Effects/ExobladeSlashShader.fx index 66ba42b214..45044b6323 100644 --- a/Effects/ExobladeSlashShader.fx +++ b/Effects/ExobladeSlashShader.fx @@ -66,7 +66,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 float noise = tex2D(uImage1, noiseCoords).r; float noise2 = pow(tex2D(uImage1, noiseCoords * 2.2).r, 1.6); float noise3 = pow(tex2D(uImage1, noiseCoords * 1.1).r, 1.3); - float opacity = noise * pow(saturate((1 - coords.x) - noise * coords.x * 0.45), 0.8); + float opacity = noise * pow(saturate((1 - coords.x) - noise * coords.y * 0.54), 3); // Fade to the second primary color. color = lerp(color, float4(uColor, 1), noise2); diff --git a/Effects/ExobladeSlashShader.xnb b/Effects/ExobladeSlashShader.xnb index 2b150ad514..65fc72dd88 100644 Binary files a/Effects/ExobladeSlashShader.xnb and b/Effects/ExobladeSlashShader.xnb differ diff --git a/Projectiles/Melee/Exobeam.cs b/Projectiles/Melee/Exobeam.cs index 6b86724f37..151efb8843 100644 --- a/Projectiles/Melee/Exobeam.cs +++ b/Projectiles/Melee/Exobeam.cs @@ -4,31 +4,33 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Items.Weapons.Typeless; namespace CalamityMod.Projectiles.Melee { public class Exobeam : ModProjectile { - private int counter = 0; - public override void SetStaticDefaults() { - DisplayName.SetDefault("Beam"); - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + DisplayName.SetDefault("Exobeam"); + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 3; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; } public override void SetDefaults() { - Projectile.width = 16; - Projectile.height = 16; + Projectile.width = 106; + Projectile.height = 106; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.penetrate = 1; Projectile.extraUpdates = 1; Projectile.alpha = 255; Projectile.timeLeft = 600; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 12; Projectile.light = 1f; } @@ -37,22 +39,35 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.localAI[1] == 0f) { SoundEngine.PlaySound(SoundID.Item60, Projectile.position); - Projectile.localAI[1] += 1f; + Projectile.localAI[1] = 1f; } // Aim very, very quickly at targets. NPC potentialTarget = Projectile.Center.ClosestNPCAt(1600f, false); if (potentialTarget != null) { - Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * (Projectile.velocity.Length() + 2f); - Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.1f); + Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * (Projectile.velocity.Length() + 3.5f); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.08f); + } + + // Dissipate if colliding with tiles. + if (Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + Projectile.Opacity -= 0.08f; + if (Projectile.Opacity <= 0f) + Projectile.Kill(); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.1f, 0f, 1f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { + SoundEngine.PlaySound(YanmeisKnife.HitSound, target.Center); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromAI(), target.Center, Projectile.velocity * 0.1f, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, target.whoAmI); + target.ExoDebuffs(); } @@ -61,45 +76,15 @@ namespace CalamityMod.Projectiles.Melee target.ExoDebuffs(); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 255, 255, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => Color.White with { A = 0 } * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { if (Projectile.timeLeft > 595) return false; - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 4); return false; } - - public override void Kill(int timeLeft) - { - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 192; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - SoundEngine.PlaySound(SoundID.Zombie103, Projectile.Center); - for (int num193 = 0; num193 < 3; num193++) - { - Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 30; num194++) - { - int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - } } } diff --git a/Projectiles/Melee/Exobeam.png b/Projectiles/Melee/Exobeam.png index b35841741b..78bd48076f 100644 Binary files a/Projectiles/Melee/Exobeam.png and b/Projectiles/Melee/Exobeam.png differ diff --git a/Projectiles/Melee/ExobeamSlash.cs b/Projectiles/Melee/ExobeamSlash.cs new file mode 100644 index 0000000000..12b6c6266b --- /dev/null +++ b/Projectiles/Melee/ExobeamSlash.cs @@ -0,0 +1,77 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ExobeamSlash : ModProjectile + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Exobeam Slash"); + + public override void SetDefaults() + { + Projectile.width = 512; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.timeLeft = 35; + Projectile.MaxUpdates = 2; + Projectile.scale = 0.75f; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 12; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Opacity = Projectile.timeLeft / 35f; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return Projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } + + public override bool ShouldUpdatePosition() => true; + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.Cyan, Color.Lime, Projectile.identity / 7f % 1f) * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + if (Projectile.timeLeft > 33) + return false; + + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 origin = texture.Size() * 0.5f; + Vector2 scale = new Vector2(1f, 0.75f) * Projectile.scale; + Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); + Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; + Main.spriteBatch.Draw(bloomTexture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); + Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); + Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + } +} diff --git a/Projectiles/Melee/ExobeamSlash.png b/Projectiles/Melee/ExobeamSlash.png new file mode 100644 index 0000000000..ab9cfc8e8f Binary files /dev/null and b/Projectiles/Melee/ExobeamSlash.png differ diff --git a/Projectiles/Melee/ExobeamSlashCreator.cs b/Projectiles/Melee/ExobeamSlashCreator.cs new file mode 100644 index 0000000000..6547f5074c --- /dev/null +++ b/Projectiles/Melee/ExobeamSlashCreator.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ExobeamSlashCreator : ModProjectile + { + public NPC Target => Main.npc[(int)Projectile.ai[0]]; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Anime Sword Effect"); + } + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 45; + Projectile.MaxUpdates = 2; + } + + public override void AI() + { + if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % 20 == 19) + { + float maxOffset = Target.width * 0.4f; + if (maxOffset > 300f) + maxOffset = 300f; + Vector2 baseDirection = Vector2.UnitX; + if (Projectile.timeLeft <= 20) + baseDirection = -Vector2.UnitY; + + Vector2 spawnOffset = baseDirection.RotatedBy(Main.rand.NextFloatDirection() * 0.63f).SafeNormalize(Vector2.UnitY); + spawnOffset *= Main.rand.NextFloatDirection() * maxOffset; + Vector2 sliceVelocity = spawnOffset.SafeNormalize(Vector2.UnitY) * 0.1f; + + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Target.Center + spawnOffset, sliceVelocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); + } + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 8b9047b06b..d5c403ee82 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using CalamityMod.DataStructures; using System.Linq; using static CalamityMod.CalamityUtils; +using CalamityMod.Sounds; namespace CalamityMod.Projectiles.Melee { @@ -46,7 +47,7 @@ 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. + // Starts at 0.27 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); @@ -54,6 +55,7 @@ namespace CalamityMod.Projectiles.Melee // After reeling back, a powerful slash happens. public static CurveSegment Slash => new(EasingType.PolyOut, 0.51f, 0f, 1f); + // Manual easing code handles this, due to a 0-1 clamp within the piecewise curve function generator. public static CurveSegment HoldBladeInPlace => new(EasingType.Linear, 0.7f, 1f, 0f); public override string Texture => "CalamityMod/Items/Weapons/Melee/Exoblade"; @@ -146,7 +148,13 @@ namespace CalamityMod.Projectiles.Melee { // Decide the swing direction. if (Owner.itemAnimation == Owner.itemAnimationMax) + { + Direction = Owner.direction; SwingDirection = 1f; + } + + if (Owner.itemAnimation == (int)(Owner.itemAnimationMax * 0.6)) + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound, Projectile.Center); float exactSwingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax; float directionalSwingCompletion = exactSwingCompletion; @@ -163,7 +171,9 @@ namespace CalamityMod.Projectiles.Melee // Decide the swing direction. 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)); + + float returnToAnticiation = (float)Math.Pow(Utils.GetLerpValue(0.8f, 0.9f, directionalSwingCompletion, true), 2D); + Projectile.rotation = Projectile.rotation.AngleLerp(MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, 0.27f), returnToAnticiation); Projectile.rotation = Projectile.rotation * Direction - MathHelper.PiOver4; if (Direction == -1) Projectile.rotation -= MathHelper.PiOver2; @@ -177,7 +187,7 @@ namespace CalamityMod.Projectiles.Melee // Create a bunch of homing beams. int beamShootRate = Projectile.MaxUpdates * 2; - if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && swingCompletion > 0.2f && swingCompletion < 0.9f) + if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && swingCompletion > 0.3f && swingCompletion < 0.9f) { int boltDamage = Projectile.damage / 2; Vector2 boltVelocity = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2(); @@ -223,7 +233,7 @@ namespace CalamityMod.Projectiles.Melee { List result = new(); - for (int i = 0; i < Owner.itemAnimationMax; i++) + for (int i = 0; i < Owner.itemAnimationMax * 0.45; i++) { if (Projectile.oldRot[i] == 0f) continue;