diff --git a/Items/Weapons/Melee/MantisClaws.cs b/Items/Weapons/Melee/MantisClaws.cs index 4c8cc3be64..0eb10635df 100644 --- a/Items/Weapons/Melee/MantisClaws.cs +++ b/Items/Weapons/Melee/MantisClaws.cs @@ -2,54 +2,43 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using CalamityMod.Items.BaseItems; using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using CalamityMod.Balancing; +using Terraria.Audio; +using CalamityMod.Projectiles.Melee; +using System; +using CalamityMod.Particles; namespace CalamityMod.Items.Weapons.Melee { - public class MantisClaws : ModItem, ILocalizedModType + public class MantisClaws : CustomUseProjItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetDefaults() { + base.SetDefaults(); Item.width = 26; Item.height = 20; - Item.damage = 144; + Item.damage = 125; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 8; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 8; - Item.useTurn = true; - Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; + Item.useStyle = ItemUseStyleID.HiddenAnimation; + Item.noUseGraphic = true; + Item.useAnimation = 25; + Item.noMelee = true; + Item.useTime = 25; + Item.shoot = ModContent.ProjectileType(); Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; } - public override void MeleeEffects(Player player, Rectangle hitbox) + public override bool AltFunctionUse(Player player) { - if (Main.rand.NextBool(4)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.Water); - } - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - var source = player.GetSource_ItemUse(Item); - - //does no damage. Explosion is visual - Projectile.NewProjectile(source, target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - target.AddBuff(BuffID.OnFire3, 300); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - var source = player.GetSource_ItemUse(Item); - - //does no damage. Explosion is visual - Projectile.NewProjectile(source, target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - target.AddBuff(BuffID.OnFire3, 300); + return true; } } } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 7f67419027..d8e919cb41 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -304,3 +304,6 @@ WulfrumScrew.DisplayName: Wulfrum Screw WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard +MantisClawHoldout.DisplayName: Mantis Claw Holdout +MantisClawSlash.DisplayName: Mantis Claw Slash +MantisClawJet.DisplayName: Mantis Claw Jet diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 6791e8a9ed..9f8a4c652f 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -165,8 +165,14 @@ namespace CalamityMod.Particles particle.CustomDraw(sb); else { + Color lightColor = particle.Color; + if (particle.AffectedByLight) + { + lightColor = particle.Color.MultiplyRGB(Lighting.GetColor((particle.Position / 16).ToPoint())); + } + Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, + sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); } } diff --git a/Particles/MantisPunch.cs b/Particles/MantisPunch.cs new file mode 100644 index 0000000000..4f948f02e3 --- /dev/null +++ b/Particles/MantisPunch.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using ReLogic.Content; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class MantisPunch : Particle + { + int Frame = 0; + int FrameTimer = 0; + + public override string Texture => "CalamityMod/Particles/MantisPunch"; + public override bool UseCustomDraw => true; + public override void CustomDraw(SpriteBatch spriteBatch) + { + Asset tex = ModContent.Request(Texture); + + Main.EntitySpriteDraw(tex.Value, Position - Main.screenPosition, tex.Frame(1, 6, 0, Frame), Lighting.GetColor((Position / 16).ToPoint()), Rotation, Origin, 1f, SpriteEffects.None); + } + public MantisPunch(Vector2 position, float rotation) + { + Position = position; + Rotation = rotation; + + Origin = new Vector2(32, 56); + + AffectedByLight = true; + } + public override void Update() + { + FrameTimer++; + if (FrameTimer % 3 == 0) + { + Frame++; + } + if (Frame >= 6) + { + Kill(); + } + } + } +} diff --git a/Particles/MantisPunch.png b/Particles/MantisPunch.png new file mode 100644 index 0000000000..605bcea928 Binary files /dev/null and b/Particles/MantisPunch.png differ diff --git a/Particles/WaterFlavoredParticle.cs b/Particles/WaterFlavoredParticle.cs index 58dcf1b993..edd3458e2a 100644 --- a/Particles/WaterFlavoredParticle.cs +++ b/Particles/WaterFlavoredParticle.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Renderers; using Terraria.ModLoader; namespace CalamityMod.Particles @@ -44,8 +45,14 @@ namespace CalamityMod.Particles Vector2 scale = new Vector2(0.65f, 1f) * Scale; Texture2D texture = ModContent.Request(Texture).Value; - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + Color lightColor = Color; + if (AffectedByLight) + { + lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint())); + } + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, lightColor, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, lightColor, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); } } } diff --git a/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs b/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs index b07847957b..bdab30559d 100644 --- a/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs @@ -166,6 +166,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void AI() { + bool ItemAnimationActive = Owner.ItemAnimationActive; + if (Owner.HeldItem.type != AssignedItemID) { Projectile.Kill(); @@ -174,7 +176,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Owner.Calamity().mouseWorldListener = true; Owner.Calamity().rightClickListener = true; - if (Owner.ItemAnimationActive) + if (ItemAnimationActive) { Animation++; @@ -210,18 +212,19 @@ namespace CalamityMod.Projectiles.BaseProjectiles Projectile.position = AbsolutePosition - (Projectile.Size / 2) + Offset; } - if (Owner.itemAnimation == 1) + if (AnimationProgress == Owner.itemAnimationMax - 1) { OnEndUse(); NumberOfAnimations++; } - if (Owner.ItemAnimationJustStarted) + if (Owner.itemAnimation == Owner.itemAnimationMax - 1) { Projectile.timeLeft = Owner.HeldItem.useAnimation + 1; - if (DrawUnconditionally) Projectile.timeLeft = 100; OnBeginUse(); } + + if (DrawUnconditionally) Projectile.timeLeft = Math.Max(Projectile.timeLeft, 2); } public override bool? CanHitNPC(NPC target) diff --git a/Projectiles/Melee/MantisClawHoldout.cs b/Projectiles/Melee/MantisClawHoldout.cs new file mode 100644 index 0000000000..2fb789f01a --- /dev/null +++ b/Projectiles/Melee/MantisClawHoldout.cs @@ -0,0 +1,274 @@ +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using CalamityMod.Items.BaseItems; +using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using CalamityMod.Balancing; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Melee; +using System; +using CalamityMod.Particles; +using Terraria.DataStructures; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Projectiles.Melee +{ + public class MantisClawHoldout : BaseCustomUseStyleProjectile, ILocalizedModType + { + bool AnimationCooldown = false; + + int JetDamage => 900; + int SlashDamage => 125; + int SlashSpeed => 6; + + int BlastChargeUses => 3; + float SlashTimer = 0; + + public override Vector2 SpriteOrigin => new(0, 20); + + public override int AssignedItemID => ModContent.ItemType(); + + public float ClawOpenness = MathHelper.ToRadians(80); + public float BubbleSize = 0f; + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Items/Weapons/Melee/MantisClaws"; + public override void ResetStyle() + { + if (AnimationCooldown) + { + if (NumberOfAnimations % 5 <= BlastChargeUses) + { + ClawOpenness = MathHelper.Lerp(ClawOpenness, MathHelper.ToRadians(80f), 0.15f); + + BubbleSize *= 0.85f; + + if (BubbleSize < 0.05f) + { + Projectile.scale -= 0.1f; + + if (Projectile.scale < 0.1f) + Projectile.active = false; + } + } + else + { + Clamp(); + } + Offset = new Vector2(MathHelper.Lerp(0, 12, BubbleSize / 2), 0).RotatedBy(Projectile.rotation); + } + } + + public void Clamp() + { + if (BubbleSize != 0f) + { + Owner.Calamity().mouseWorldListener = true; + + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center + new Vector2(20, 0).RotatedBy(Projectile.rotation), + Owner.DirectionTo(Owner.Calamity().mouseWorld) * 30, ModContent.ProjectileType(), JetDamage, 7, Owner.whoAmI); + + for (int i = 0; i < 9; i++) + { + WaterFlavoredParticle waterFlavored = new WaterFlavoredParticle(Owner.Center, new Vector2(Main.rand.NextFloat(15, 25), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-45, 45))), true, 40, Main.rand.NextFloat(0.5f, 1.2f), MantisClawJet.WaterColor); + waterFlavored.AffectedByLight = true; + GeneralParticleHandler.SpawnParticle(waterFlavored); + } + + SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset(-0.5f), Owner.Center); + SoundEngine.PlaySound(SoundID.NPCDeath14.WithPitchOffset(1f), Owner.Center); + + Owner.Calamity().GeneralScreenShakePower = 2.5f; + + GeneralParticleHandler.SpawnParticle(new MantisPunch(Owner.Center + new Vector2(26, 0).RotatedBy(Projectile.rotation), Projectile.rotation)); + } + + ClawOpenness = MathHelper.ToRadians(80); + BubbleSize = 0f; + } + + public override void UseStyle() + { + if (Owner.altFunctionUse != 2) + { + if (AnimationCooldown) + { + if (!Owner.Calamity().mouseRight) + { + if (Owner.itemAnimation > 0) + { + Projectile.Kill(); + } + DrawUnconditionally = true; + AnimationCooldown = true; + Owner.itemAnimation = 0; + Owner.itemTime = 0; + } + } + + Projectile.scale = 1f; + + DrawUnconditionally = false; + + Owner.Calamity().mouseWorldListener = true; + + { + if (SlashTimer % SlashSpeed == 0) + { + SoundStyle SlashStyle = new SoundStyle("CalamityMod/Sounds/Item/MantisSwipe" + (Main.rand.Next(2) + 1).ToString()); + SlashStyle.PitchVariance = 0.3f; + SlashStyle.Volume = 0.7f; + + SoundEngine.PlaySound(SlashStyle.WithPitchOffset(0.2f), Owner.Center); + + Owner.Calamity().mouseWorldListener = true; + + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center, Owner.DirectionTo(Owner.Calamity().mouseWorld) * 6f, ModContent.ProjectileType(), SlashDamage, 4f, Owner.whoAmI).rotation = Owner.AngleTo(Owner.Calamity().mouseWorld) + MathHelper.ToRadians(Main.rand.NextFloat(-25, 25)); + } + + SlashTimer++; + } + + Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X); + Projectile.rotation = Owner.AngleTo(Owner.Calamity().mouseWorld); + + Projectile.ai[2] = MathHelper.Lerp(Projectile.ai[2], MathHelper.ToRadians(135f * (SlashTimer % (SlashSpeed * 2) < SlashSpeed ? 1 : -1)), 0.2f); + + ArmRotationOffset = MathHelper.ToRadians(-90f) - (Projectile.ai[2]) * Owner.direction; + ArmRotationOffsetBack = MathHelper.ToRadians(-90f) + (Projectile.ai[2]) * Owner.direction; + } + else + { + Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.15f); + Projectile.scale = MathHelper.Clamp(Projectile.scale, 0f, 1f); + if (Owner.Calamity().mouseRight) + { + Owner.itemAnimation = 3; + + float chargeFactor = (float)(NumberOfAnimations % 5f) / 3f; + + DrawUnconditionally = true; + + ArmRotationOffset = MathHelper.ToRadians(-90f) - (ClawOpenness / 5) * Owner.direction; + ArmRotationOffsetBack = MathHelper.ToRadians(-90f) + (ClawOpenness / 5) * Owner.direction; + if (NumberOfAnimations % 5 > BlastChargeUses) + { + Clamp(); + } + else + { + Owner.Calamity().mouseWorldListener = true; + + Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X); + Projectile.rotation = Owner.AngleTo(Owner.Calamity().mouseWorld); + + Projectile.ai[0]++; + + if (AnimationProgress == 1) + { + if (NumberOfAnimations % 5 == 0) + { + ClawOpenness = MathHelper.ToRadians(80); + BubbleSize = 0f; + } + + SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset((float)NumberOfAnimations % 5 / (float)BlastChargeUses), Owner.Center); + + Projectile.ai[1] = MathHelper.Lerp(0.5f, 2f, chargeFactor); + Projectile.ai[2] = MathHelper.Lerp(MathHelper.ToRadians(100f), MathHelper.ToRadians(180f), chargeFactor); + } + + BubbleSize = MathHelper.Lerp(BubbleSize, Projectile.ai[1], 0.2f); + ClawOpenness = MathHelper.Lerp(ClawOpenness, Projectile.ai[2], 0.2f); + } + + Offset = new Vector2(MathHelper.Lerp(0, 12, BubbleSize / 2), 0).RotatedBy(Projectile.rotation); + } + else + { + if (Owner.controlUseItem) + { + Projectile.Kill(); + } + DrawUnconditionally = true; + AnimationCooldown = true; + Owner.itemAnimation = 0; + Owner.itemTime = 0; + } + } + } + public override bool PreDraw(ref Color lightColor) + { + { + FlipAsSword = false; + float rot = 0f; + if (Owner.altFunctionUse != 2 && !AnimationCooldown) + { + rot = Projectile.ai[2]; + if (Owner.direction == -1) + { + FlipAsSword = true; + + RotationOffset = MathHelper.ToRadians(-90f); + + Owner.compositeFrontArm.rotation -= RotationOffset; + Owner.compositeBackArm.rotation -= RotationOffset; + } + } + else + { + RotationOffset = 0f; + } + + // Bubble texture drawing + + Asset Bubble = ModContent.Request("CalamityMod/Particles/Bubble"); + + Main.EntitySpriteDraw(Bubble.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY) + new Vector2(20, 0).RotatedBy(Projectile.rotation + RotationOffset), Bubble.Frame(), lightColor, 0f, Bubble.Size() / 2, BubbleSize, SpriteEffects.None); + + // Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to. + if (Owner.itemAnimation > 0 || DrawUnconditionally) + { + Asset tex = ModContent.Request(Texture); + + float r = FlipAsSword ? 0f : MathHelper.ToRadians(90); + + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation - ClawOpenness + rot + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + } + if (Owner.itemAnimation > 0 || DrawUnconditionally) + { + + if (Owner.altFunctionUse == 2 || AnimationCooldown) + { + Asset tex = ModContent.Request(Texture); + + float r = FlipAsSword ? 0f : MathHelper.ToRadians(90); + + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + ClawOpenness + RotationOffset + r, !FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.None : SpriteEffects.FlipHorizontally)); + } + else + { + Asset tex = ModContent.Request(Texture); + + float r = FlipAsSword ? 0f : MathHelper.ToRadians(90); + + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation - ClawOpenness - rot + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + } + } + } + + return false; + } + + public override void OnSpawn(IEntitySource source) + { + Projectile.scale = 0f; + Projectile.damage = 0; + } + } +} diff --git a/Projectiles/Melee/MantisClawJet.cs b/Projectiles/Melee/MantisClawJet.cs new file mode 100644 index 0000000000..671feec242 --- /dev/null +++ b/Projectiles/Melee/MantisClawJet.cs @@ -0,0 +1,120 @@ +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using CalamityMod.Items.BaseItems; +using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using CalamityMod.Balancing; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Melee; +using System; +using CalamityMod.Particles; +using Terraria.DataStructures; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Projectiles.Melee +{ + public class MantisClawJet : ModProjectile, ILocalizedModType + { + int TimerCap = 70; + + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Particles/ThunderBolt"; + + public static Color WaterColor = new Color(114, 197, 255, 0); + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 40; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + + public override void SetDefaults() + { + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 60; + Projectile.timeLeft = TimerCap; + Projectile.knockBack = 2; + Projectile.tileCollide = false; + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 4; + Projectile.DamageType = DamageClass.Melee; + Projectile.ai[1] = 40; + } + + int dir = 1; + + public override void OnSpawn(IEntitySource source) + { + Projectile.ai[1] = 40; + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + + } + + public override void AI() + { + Projectile.velocity *= 0.97f; + + if (Projectile.ai[0] < 16) Projectile.ai[1] -= 2; + + Projectile.ai[0]++; + } + + public override bool? CanDamage() + { + return true; + } + + public override bool PreDraw(ref Color lightColor) + { + for (int i = 0; i < 6; i++) + { + float ii = ((float)i) / 6f; + Vector2 position = Vector2.Lerp(Projectile.position, Projectile.oldPos[5], ii); + + float Prog = MathHelper.Lerp(3, 1, (float)Projectile.timeLeft / (float)TimerCap); + + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(1f, 1f) * Prog, 411); + bubble.timeLeft = 8 + Main.rand.Next(6); + bubble.scale = Main.rand.NextFloat(0.6f, 1f) * (1 + Prog * 0.4f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + + for (int i = 0; i < 3; i++) + { + float ii = ((float)i) / 3f; + Vector2 position = Vector2.Lerp(Projectile.position, Projectile.oldPos[5], ii); + + float Prog = MathHelper.Lerp(3, 10, (float)Projectile.timeLeft / (float)TimerCap); + + GeneralParticleHandler.SpawnParticle(new WaterFoamParticle(position, Projectile.velocity * 0.4f, 10 - (i * 2), Prog, WaterColor)); + } + + Asset tex = ModContent.Request(Texture); + + List positions = new(); + + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + positions.Add(Projectile.oldPos[i]); + } + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request(Texture)); + + PrimitiveRenderer.RenderTrail(positions, new PrimitiveSettings(AA => { return Projectile.ai[1]; }, CC => { return Lighting.GetColor(Vector2.Lerp(Projectile.oldPos[Projectile.oldPos.Length - 1], Projectile.position, CC).ToPoint()).MultiplyRGBA(WaterColor); }, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + + return false; + } + } +} diff --git a/Projectiles/Melee/MantisClawSlash.cs b/Projectiles/Melee/MantisClawSlash.cs new file mode 100644 index 0000000000..db79a3a927 --- /dev/null +++ b/Projectiles/Melee/MantisClawSlash.cs @@ -0,0 +1,113 @@ +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using CalamityMod.Items.BaseItems; +using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using CalamityMod.Balancing; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Melee; +using System; +using CalamityMod.Particles; +using Terraria.DataStructures; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Projectiles.Melee +{ + public class MantisClawSlash : ModProjectile, ILocalizedModType + { + public int TimerCap => 20; + + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Particles/SlashSmear"; + + Color startColor; + Color endColor; + + public override void SetDefaults() + { + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 60; + Projectile.timeLeft = TimerCap; + Projectile.knockBack = 2; + Projectile.tileCollide = false; + Projectile.width = 256; + Projectile.height = 256; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Melee; + } + + int dir = 1; + + public override void OnSpawn(IEntitySource source) + { + Projectile.scale = 0f; + Projectile.ai[2] = Main.rand.NextFloat(0.5f, 1.25f); + + if (Main.rand.NextBool(2)) dir = -1; + + // i cherry picked five specific colors to make a similar but different palette to the claws themselves + // of those five, the projectile lerps between two, randomly chosen when the projectile is spawned + List ColorList = + [ + new Color(248, 197, 58), + new Color(143, 208, 50), + new Color(69, 114, 227), + new Color(212, 128, 187), + new Color(255, 140, 82), + ]; + + startColor = ColorList[Main.rand.Next(ColorList.Count)]; + endColor = ColorList[Main.rand.Next(ColorList.Count)]; + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + hitbox = new Rectangle((int)Projectile.Center.X - 65, (int)Projectile.Center.Y - 65, 130, 130); + } + + public override void AI() + { + Projectile.velocity *= 0.9f; + + if (Projectile.timeLeft > (TimerCap / 2)) + { + Projectile.scale = MathHelper.Lerp(Projectile.scale, Projectile.ai[2], 0.1f); + } + else + { + Projectile.scale = MathHelper.Lerp(Projectile.scale, Projectile.ai[2], -0.1f); + } + + Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(3f) * dir); + + Projectile.ai[1]++; + + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], MathHelper.TwoPi * dir, 0.15f); + } + + public override bool? CanDamage() + { + return true; + } + + public override bool PreDraw(ref Color lightColor) + { + Asset tex = ModContent.Request(Texture); + + for (float i = 0; i < 1; i += 0.33f) + { + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), Color.Lerp(startColor, endColor, Projectile.ai[1] / TimerCap).MultiplyRGBA(new Color(255, 255, 255, 0f)), + Projectile.rotation - (dir == -1 ? MathHelper.ToRadians(-135f) : MathHelper.ToRadians(180f)) + Projectile.ai[0], tex.Size() / 2, MathHelper.Lerp(0.6f, 1f, i) * Projectile.scale, dir == 1 ? SpriteEffects.None : SpriteEffects.FlipVertically); + } + + return false; + } + } +} diff --git a/Sounds/Item/MantisSwipe1.ogg b/Sounds/Item/MantisSwipe1.ogg new file mode 100644 index 0000000000..59ca52080c Binary files /dev/null and b/Sounds/Item/MantisSwipe1.ogg differ diff --git a/Sounds/Item/MantisSwipe2.ogg b/Sounds/Item/MantisSwipe2.ogg new file mode 100644 index 0000000000..b0e0945c36 Binary files /dev/null and b/Sounds/Item/MantisSwipe2.ogg differ