diff --git a/Items/Weapons/Melee/Excelsus.cs b/Items/Weapons/Melee/Excelsus.cs index 28f35fe250..92d533b6ab 100644 --- a/Items/Weapons/Melee/Excelsus.cs +++ b/Items/Weapons/Melee/Excelsus.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -10,20 +11,22 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Excelsus : ModItem, ILocalizedModType + public class Excelsus : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); public override void SetStaticDefaults() { ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + base.SetStaticDefaults(); } public override void SetDefaults() { Item.width = 78; Item.height = 94; - Item.damage = 206; + Item.damage = 2006; Item.DamageType = DamageClass.Melee; - Item.useTime = Item.useAnimation = 15; + Item.useTime = Item.useAnimation = 33; Item.useStyle = ItemUseStyleID.Swing; Item.useTurn = true; Item.knockBack = 8f; @@ -33,34 +36,12 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; + base.SetDefaults(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/ExcelsusGlow").Value); } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 3; ++index) - { - float SpeedX = velocity.X + Main.rand.NextFloat(-1.5f, 1.5f); - float SpeedY = velocity.Y + Main.rand.NextFloat(-1.5f, 1.5f); - switch (index) - { - case 0: - type = ModContent.ProjectileType(); - break; - case 1: - type = ModContent.ProjectileType(); - break; - case 2: - type = ModContent.ProjectileType(); - break; - } - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } - return false; - } } } diff --git a/Items/Weapons/Melee/GildedProboscis.cs b/Items/Weapons/Melee/GildedProboscis.cs index c51ec4f628..2509d0da5d 100644 --- a/Items/Weapons/Melee/GildedProboscis.cs +++ b/Items/Weapons/Melee/GildedProboscis.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; diff --git a/Items/Weapons/Melee/TheObliterator.cs b/Items/Weapons/Melee/TheObliterator.cs index 067943429e..774d0f716b 100644 --- a/Items/Weapons/Melee/TheObliterator.cs +++ b/Items/Weapons/Melee/TheObliterator.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { public new string LocalizationCategory => "Items.Weapons.Melee"; - public static float Reach = 600f; + public static float Reach = 720f; public static float Speed = 54f; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(Reach.ToTiles(), Speed); diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs index 13461ac424..efcb77c1bd 100644 --- a/Items/Weapons/Ranged/Deathwind.cs +++ b/Items/Weapons/Ranged/Deathwind.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; diff --git a/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs index d9d042c6df..8eb698f71f 100644 --- a/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs @@ -321,10 +321,14 @@ namespace CalamityMod.Projectiles.BaseProjectiles player.direction = -1; Projectile.spriteDirection = -1 * (int)player.gravDir; } - if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 0) + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 1) { Projectile.spriteDirection *= -1; } + if (AlternateSwings) + { + player.GetModPlayer().swingNum++; + } swingTime = Main.player[Projectile.owner].HeldItem.useTime; Spawn(source); StartupTime *= Projectile.MaxUpdates; @@ -384,6 +388,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles player.direction = -1; Projectile.spriteDirection = -1 * (int)player.gravDir; } + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 1) + { + Projectile.spriteDirection *= -1; + } } if (Projectile.spriteDirection == -1) { @@ -404,10 +412,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles { SoundEngine.PlaySound((SoundStyle)UseSound,player.Center); } - var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : SwingFunction()); + var angle2 = (AlternateSwings && modplayer.swingNum % 2 == 1 ? SwingFunction() : SwingFunction()); Projectile.Center = armCenter - (angle * OffsetDistance * (1 + (Projectile.scale - 1) * 0.75f)).RotatedBy(Projectile.spriteDirection * angle2); Projectile.rotation = angle.RotatedBy(Projectile.spriteDirection * angle2).ToRotation() + adust; AdditionalAI(); + if (!Projectile.active) + return; oldPlayerOffset = Projectile.Center - player.Center; player.itemTime = ExistsTime + 2 - timer; player.itemAnimation = ExistsTime + 2 - timer; diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index 7ef4d96d03..167cf95bfd 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -40,6 +40,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.extraUpdates = 1; Projectile.penetrate = -1; Projectile.timeLeft = 300; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 15; CooldownSlot = ImmunityCooldownID.Bosses; } diff --git a/Projectiles/Melee/ExcelsusMain.cs b/Projectiles/Melee/ExcelsusMain.cs index 4b86ba15d7..eb52b2fe1d 100644 --- a/Projectiles/Melee/ExcelsusMain.cs +++ b/Projectiles/Melee/ExcelsusMain.cs @@ -1,99 +1,128 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ExcelsusMain : ModProjectile, ILocalizedModType + public class ExcelsusMain : BaseSwordHoldoutProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() + public override bool useMeleeSpeed => true; + public override bool useMeleeSize => false; + public override int swingWidth => 270; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 0; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + public override string Texture => ModContent.GetModItem(BaseItem.type).Texture; + + public override float lineCollisionLength => 232; + public override bool AlternateSwings => true; + + public override void Defaults() { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.timeLeft = 300; - Projectile.alpha = 100; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.width = 78; + Projectile.height = 94; + Projectile.extraUpdates = 5; //ExtraUpdates help make the VFX smoother + Projectile.noEnchantmentVisuals = true; + } + public override void Spawn(IEntitySource source) + { + //This sets variables for the spear in general, as well as the secondary attack + //The secondary attack is the "default" because it was coded first + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 10; + CooldownTime = 10; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = modplayer.swingNum++ % 3; + OffsetDistance = 70; + RotateInStartup = 0.2f; + RotateInCooldown = 0f; + + UseSound = SoundID.DD2_MonkStaffSwing; } - public override void AI() + public override void AdditionalAI() { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 20f && Projectile.timeLeft > 85) + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + switch (modplayer.swingNum) { - Projectile.velocity *= 1.05f; - } - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 0f && Projectile.timeLeft <= 85) - { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f; - if (Main.rand.NextBool(8)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + case 1: + break; + case 2: + if (swingTimer == (int)(swingTime*0.5f)) + { + if (Main.myPlayer == Projectile.owner) + { + for (var i = -1; i < 2; i++) + { + var p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, -angle.RotatedBy(0.2f * i) * 16, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, player.whoAmI, 2); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].hostile = false; + Main.projectile[p].friendly = true; + Main.projectile[p].DamageType = DamageClass.Melee; + Main.projectile[p].timeLeft = 120; + } + } + } + } + break; + case 0: + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, -angle * 3, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, player.whoAmI); + player.itemAnimation = BaseItem.useAnimation; + player.itemTime = BaseItem.useTime; + Projectile.Kill(); + return; } } - public override bool OnTileCollide(Vector2 oldVelocity) + public override float SwingFunction() { - Projectile.tileCollide = false; - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - return false; - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return default(Color); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.6f, -swingWidth * 0.5f, MathF.Pow(StartupCompletion, 2f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.Lerp(swingWidth * 0.5f, swingWidth * 0.6f, 1 - MathF.Pow(1 - CooldownCompletion, 2f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.5f, swingWidth * 0.5f, SwingCompletion)); } public override void PostDraw(Color lightColor) { - Color color; - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - color = new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - else - { - color = new Color(255, 255, 255, 100); - } - Vector2 origin = new Vector2(39f, 46f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ExcelsusMainGlow").Value, Projectile.Center - Main.screenPosition, null, color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + if (modplayer.swingNum == 0) + return; + var tex = ModContent.Request("CalamityMod/Particles/Jaws").Value; + float jawScaleMult = 1f; + if (inStartup) + jawScaleMult = StartupCompletion; + if (inCooldown) + jawScaleMult = 1-CooldownCompletion; + jawScaleMult = MathF.Pow(jawScaleMult, 3); + float rotation = Projectile.rotation - (Projectile.spriteDirection == -1 ? MathHelper.PiOver2: 0); + Vector2 DrawPos = Projectile.Center + Projectile.scale * new Vector2(50,10 * Projectile.spriteDirection).RotatedBy(Projectile.rotation - MathHelper.PiOver2 + (Projectile.spriteDirection == -1 ? -MathHelper.PiOver4 : MathHelper.PiOver4)); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex, DrawPos - Main.screenPosition, tex.Frame(2,1,0,0), modplayer.swingNum == 1 ? Color.Fuchsia : Color.Cyan, rotation + MathHelper.PiOver4, new Vector2(tex.Width * 0.25f,tex.Height * 0.5f), Projectile.scale * jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/Projectiles/Melee/ExcelsusPink.cs b/Projectiles/Melee/ExcelsusPink.cs index 5bf63ee24e..e0d4cf381f 100644 --- a/Projectiles/Melee/ExcelsusPink.cs +++ b/Projectiles/Melee/ExcelsusPink.cs @@ -1,8 +1,12 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -13,32 +17,64 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override void SetDefaults() { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; + Projectile.width = 250; + Projectile.height = 250; Projectile.DamageType = DamageClass.Melee; Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.timeLeft = 300; + Projectile.penetrate = -1; + Projectile.timeLeft = 35; Projectile.alpha = 100; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; } + Vector2 GoalPos = Vector2.Zero; + Vector2 StartPos = Vector2.Zero; + float offset = 0; + public override void AI() { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 24f && Projectile.timeLeft > 85) + var player = Main.player[Projectile.owner]; + if (GoalPos == Vector2.Zero) { - Projectile.velocity *= 1.05f; + GoalPos = player.Calamity().mouseWorld; + StartPos = Projectile.Center; } - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 0f && Projectile.timeLeft <= 85) + Projectile.Center = Vector2.Lerp(StartPos, GoalPos, MathHelper.Min(1,MathF.Pow(1 - (Projectile.timeLeft - 5) / 30f,0.5f))); + Projectile.rotation = StartPos.DirectionTo(GoalPos).ToRotation(); + offset = 200*MathHelper.Min(1-(Projectile.timeLeft-5)/30f, (Projectile.timeLeft - 5) / 5f); + if (offset < 16) + offset = 16; + if (Projectile.timeLeft == 5) { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f; - if (Main.rand.NextBool(8)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PinkTorch, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Projectile.friendly = true; + + SoundEngine.PlaySound(new("CalamityMod/Sounds/NPCKilled/DevourerSegmentBreak1") { Volume = 0.3f, PitchVariance = 0.3f }, Projectile.position); + SoundEngine.PlaySound(SoundID.Item62 with { Volume = 0.5f, PitchVariance = 0.3f }, Projectile.position); + for (int i = 0; i < 35; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 181, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.9f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + dust.noGravity = true; + } + for (int j = 0; j < 14; j++) + { + Vector2 dustVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f); + + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, 272, dustVel, 0, default, 1f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, 226, dustVel, 0, default, 1f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + } + Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 5; + + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Aqua, new Vector2(2f, 2f), 0, 0.1f, 0.85f, 36); + GeneralParticleHandler.SpawnParticle(pulse); + + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Magenta, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 0.65f, 26); + GeneralParticleHandler.SpawnParticle(explosion2); + } } @@ -65,13 +101,24 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + var tex = ModContent.Request("CalamityMod/Particles/Jaws").Value; + float jawScaleMult = 1f; + jawScaleMult = MathF.Pow(jawScaleMult, 3); + float rotationOff = 0.5f * MathHelper.Min(MathF.Pow(MathHelper.Clamp(1 - (Projectile.timeLeft - 5) / 30f,0,1),0.5f), MathF.Pow(MathHelper.Clamp((Projectile.timeLeft - 5) / 10f,0,1),0.5f)); + if (rotationOff < 0.01f) + rotationOff = 0.01f; + float drawRot = Projectile.rotation;// - MathHelper.PiOver2 + (Projectile.spriteDirection == -1 ? -MathHelper.PiOver4 : MathHelper.PiOver4); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex, Projectile.Center + new Vector2(0, offset).RotatedBy(drawRot) - Main.screenPosition, tex.Frame(2, 1, 0, 0), Color.Fuchsia, Projectile.rotation + rotationOff + MathHelper.PiOver2, new Vector2(tex.Width * 0.25f, tex.Height * 0.5f), jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + Main.spriteBatch.Draw(tex, Projectile.Center + new Vector2(0, -offset).RotatedBy(drawRot) - Main.screenPosition, tex.Frame(2, 1, 1, 0), Color.Aqua, Projectile.rotation - rotationOff + MathHelper.PiOver2, new Vector2(tex.Width * 0.25f, tex.Height * 0.5f), jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } public override void PostDraw(Color lightColor) { + return; Color color; if (Projectile.timeLeft < 85) { diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 88f24502a4..9e653f588b 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Systems.Collections NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(),