diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index f1eaf63cee..d9dd7d8531 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -1,31 +1,77 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Melee; +using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; namespace CalamityMod.Items.Weapons.Melee { public class GreatswordofJudgement : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + private float swingRoatation = 0; + private int time = 0; + private Color mainColor; + private int swordDirection; public override void SetDefaults() { Item.width = 78; Item.height = 78; Item.damage = 40; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 18; + Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 18; + Item.useTime = 25; Item.useTurn = true; Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/TerratomereSwing") with { Volume = 0.3f, Pitch = 0.5f }; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; Item.rare = ItemRarityID.Red; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; + Item.shootSpeed = 5f; } + public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) + { + float scale = 1.1f; + Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * scale; + hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y); + } + public override void UseAnimation(Player player) + { + swordDirection = player.direction; + time = 0; + swingRoatation = 0; + mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + time++; + swingRoatation += swordDirection == 1 ? 0.13f : -0.13f; + float Rot = (swordDirection == -1 ? 1.8f : -1.8f) + swingRoatation; + if (swordDirection != player.direction) + { + swingRoatation *= -1; + swordDirection = player.direction; + } + Particle Smear = new SemiCircularSmearFade(player.Center, Vector2.Zero, mainColor * 0.8f, Rot, Main.rand.NextFloat(1.75f, 1.8f), new Vector2(1, 1), 2, true, false, true, player.direction); + GeneralParticleHandler.SpawnParticle(Smear); + + if (Main.rand.NextBool(3)) + { + Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f); + Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, 278); + dust.scale = Main.rand.NextFloat(0.4f, 0.55f); + dust.velocity = dustVel * 0.55f; + dust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + dust.noGravity = true; + } + } public override void AddRecipes() { CreateRecipe(). diff --git a/Particles/SemiCircularSmearFade.cs b/Particles/SemiCircularSmearFade.cs new file mode 100644 index 0000000000..246f05581d --- /dev/null +++ b/Particles/SemiCircularSmearFade.cs @@ -0,0 +1,62 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class SemiCircularSmearFade : Particle + { + public override string Texture => "CalamityMod/Particles/SemiCircularSmearVertical"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + public Player player = Main.player[Main.myPlayer]; + public Color InitialColor; + public bool PlayerCentered; + public bool RotateToVelocity; + public Vector2 Squish; + public bool ProduceLight; + public int Direction; + public SemiCircularSmearFade(Vector2 position, Vector2 velocity, Color color, float rotation, float scale, Vector2 squish, int lifetime, bool playerCentered = false, bool rotateToVelocity = false, bool produceLight = true, int direction = 1) + { + Position = position; + Velocity = velocity; + Color = InitialColor = color; + Scale = scale; + Squish = squish; + Rotation = rotation; + Lifetime = lifetime; + PlayerCentered = playerCentered; + RotateToVelocity = rotateToVelocity; + ProduceLight = produceLight; + Direction = direction; + + } + public override void Update() + { + if (PlayerCentered) + Position = player.MountedCenter; + if (RotateToVelocity) + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + if (ProduceLight) + { + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + } + + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + + } + + //Use custom draw for the squish + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, tex.Size() * 0.5f, Scale * Squish, Direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + } + } +} diff --git a/Particles/SemiCircularSmearVertical.png b/Particles/SemiCircularSmearVertical.png new file mode 100644 index 0000000000..cf9a7c4edc Binary files /dev/null and b/Particles/SemiCircularSmearVertical.png differ diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index a6edb0c8b9..293721ef40 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -9,69 +9,71 @@ namespace CalamityMod.Projectiles.Melee public class JudgementProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - int whiteLightTimer = 5; - + public ref float time => ref Projectile.ai[0]; + public float hitboxSize = 10; + public Color mainColor; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 132; + Projectile.height = 30; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.timeLeft = 60; + Projectile.tileCollide = false; + Projectile.timeLeft = 450; Projectile.DamageType = DamageClass.Melee; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.extraUpdates = 15; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - whiteLightTimer--; - if (whiteLightTimer == 0) + if (time == 0) { - float spread = 180f * 0.0174f; - double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int i; - if (Projectile.owner == Main.myPlayer) - { - for (i = 0; i < 1; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - int projectile2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - Main.projectile[projectile1].velocity.X *= 0.1f; - Main.projectile[projectile1].velocity.Y *= 0.1f; - Main.projectile[projectile2].velocity.X *= 0.1f; - Main.projectile[projectile2].velocity.Y *= 0.1f; - } - } - whiteLightTimer = 5; + Projectile.scale = 0.25f; + Projectile.velocity *= 0.75f; + mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); - - for (int i = 0; i < 2; i++) + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + if (time < 200) { - int shinyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.GemDiamond, 0f, 0f, 100, default, 1.25f); - Main.dust[shinyDust].noGravity = true; - Main.dust[shinyDust].velocity *= 0.5f; - Main.dust[shinyDust].velocity += Projectile.velocity * 0.1f; + Projectile.scale += 0.008f; + hitboxSize += 0.55f; + } + Projectile.velocity *= 0.995f; + + if (time < 300 && time > 20 && Main.rand.NextBool(3)) + { + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize, hitboxSize), 66); + trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f); + trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.85f, 1.5f); + trailDust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + trailDust.noGravity = true; } - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 9f, 20f); + time++; } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item122, Projectile.position); - if (Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - } + //Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); } + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, mainColor == Color.MediumPurple ? Color.MediumOrchid : Color.MediumPurple); + return true; + } + public override Color? GetAlpha(Color lightColor) + { + return mainColor; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, hitboxSize, targetHitbox); } } diff --git a/Projectiles/Melee/JudgementProj.png b/Projectiles/Melee/JudgementProj.png new file mode 100644 index 0000000000..8b6d16ae6c Binary files /dev/null and b/Projectiles/Melee/JudgementProj.png differ