diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 2a86309ad8..11fa4bf835 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -361,6 +361,9 @@ namespace CalamityMod.CalPlayer public int amputatorBuff = 0; /// Variable used to track the current fuel amount for Pristine Fury's right-click. public int furyFuel = 1800; + /// Variable to track the healing over time gained from Grand Dad. + public int grandDadHealPool = 0; + public int grandDadHealTimer = 0; public const int FuryFuelMax = 1800; public float furyRefuelTimer = 0; /// Variable used to track if Auger can do its big slash attack. diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 474f490c02..6ea725299d 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -342,6 +342,15 @@ namespace CalamityMod.CalPlayer Player.lifeRegen += 6; } + if (grandDadHealTimer == 0 && grandDadHealPool >= 7) + { + Player.HealPlayer(7, HealTextType.Broadcast); + grandDadHealPool -= 7; + grandDadHealTimer = (int)(30 * Utils.GetLerpValue(260, 60, grandDadHealPool, true)); + } + else if (grandDadHealTimer > 0) + grandDadHealTimer--; + // Grant life regen based on missing health for Radiant Ooze, Ambrosial Ampule, and purity if (rOoze || aAmpoule || purity) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 085ae24558..9bf6d8f9f3 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -222,6 +222,11 @@ namespace CalamityMod.CalPlayer int damage = (int)Player.GetTotalDamage().ApplyTo(Player.HeldItem.damage); Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), damage, Player.HeldItem.knockBack, Player.whoAmI); } + if (Player.HeldItem.type == ModContent.ItemType() && (Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0)) + { + int damage = (int)Player.GetTotalDamage().ApplyTo(Player.HeldItem.damage); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), damage, Player.HeldItem.knockBack, Player.whoAmI); + } } // De-equipping Gael's Greatsword deletes all rage. diff --git a/Dusts/SquashDust.cs b/Dusts/SquashDust.cs index a0d5160f88..425763512a 100644 --- a/Dusts/SquashDust.cs +++ b/Dusts/SquashDust.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Dusts public override bool PreDraw(Dust dust) { Vector2 baseSize = Vector2.One; - if (dust.customData != null) + if (dust.customData != null && dust.customData is Vector2) baseSize = (Vector2)dust.customData; Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1 * baseSize.X, 0.5f * baseSize.X), Utils.Remap(dust.velocity.Length(), 2, 7, 1 * baseSize.Y, 2.5f * baseSize.Y)); @@ -87,7 +87,7 @@ namespace CalamityMod.Dusts private static void DrawPixelated(Dust dust) { Vector2 baseSize = Vector2.One; - if (dust.customData != null) + if (dust.customData != null && dust.customData is Vector2) baseSize = (Vector2)dust.customData; Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1 * baseSize.X, 0.5f * baseSize.X), Utils.Remap(dust.velocity.Length(), 2, 7, 1 * baseSize.Y, 2.5f * baseSize.Y)); diff --git a/Dusts/VoidDust.cs b/Dusts/VoidDust.cs index e66a8f3bf4..22eeafbd4c 100644 --- a/Dusts/VoidDust.cs +++ b/Dusts/VoidDust.cs @@ -31,30 +31,51 @@ namespace CalamityMod.Dusts public override bool Update(Dust dust) { - dust.rotation += MathF.Sign(dust.velocity.X); - dust.velocity *= 0.98f; + float fade = (1 + dust.fadeIn); + dust.velocity *= 0.96f; if (dust.noGravity) - dust.scale += 0.02f; + dust.scale -= 0.05f * fade; else - dust.scale -= 0.01f; + dust.scale -= 0.065f * fade; float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); if (!dust.noLightEmittence) Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; - return true; + dust.position += dust.velocity; + return false; + } + public override bool MidUpdate(Dust dust) + { + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + return false; } public override bool PreDraw(Dust dust) { + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + Vector2 baseSize = Vector2.One; + bool useSquash = false; + float squashMaxSpeed = 0; + if (dust.customData != null && dust.customData is int) + { + useSquash = true; + squashMaxSpeed = (float)dust.customData; + } + + Vector2 squash = useSquash ? new Vector2(Utils.Remap(dust.velocity.Length(), squashMaxSpeed / 4, squashMaxSpeed, 1 * baseSize.X, 0.5f * baseSize.X), Utils.Remap(dust.velocity.Length(), squashMaxSpeed / 4, squashMaxSpeed, 1 * baseSize.Y, 2.5f * baseSize.Y)) : baseSize; + if (!dust.noLight) { // Glow Orb - Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); } - Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } @@ -65,20 +86,32 @@ namespace CalamityMod.Dusts public override bool PreDraw(Dust dust) { + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); return false; } private static void DrawPixelated(Dust dust) { + Vector2 baseSize = Vector2.One; + bool useSquash = false; + float squashMaxSpeed = 0; + if (dust.customData != null && dust.customData is int) + { + useSquash = true; + squashMaxSpeed = (int)dust.customData; + } + + Vector2 squash = useSquash ? new Vector2(Utils.Remap(dust.velocity.Length(), squashMaxSpeed / 4, squashMaxSpeed, 1 * baseSize.X, 0.5f * baseSize.X), Utils.Remap(dust.velocity.Length(), squashMaxSpeed / 4, squashMaxSpeed, 1 * baseSize.Y, 2.5f * baseSize.Y)) : baseSize; + if (!dust.noLight) { // Glow Orb - Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); } - Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); } } } diff --git a/Items/Weapons/Melee/GrandDad.cs b/Items/Weapons/Melee/GrandDad.cs index fab3876b27..c22652b727 100644 --- a/Items/Weapons/Melee/GrandDad.cs +++ b/Items/Weapons/Melee/GrandDad.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 124; Item.height = 124; - Item.damage = 2407; // Feel free to change these 7s as balance requires. The other 7s should stay - Update: no more 2777... :( + Item.damage = 3777; // Feel free to change these 7s as balance requires. The other 7s should stay - Update: no more 2777... :( Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = 77; Item.useTime = 77; @@ -56,14 +56,6 @@ namespace CalamityMod.Items.Weapons.Melee { list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal"))); } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(3). - AddTile(TileID.MythrilAnvil). - Register(); - } public override void OnSpawn(IEntitySource source) { time = 0; @@ -95,11 +87,21 @@ namespace CalamityMod.Items.Weapons.Melee int particleNumber = (int)Math.Max(15 * power, 2); for (int i = -particleNumber; i <= particleNumber; i++) { - Particle sparks = new AltSparkParticle(place, (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, false, Main.rand.Next(17, 30 + 1), Main.rand.NextFloat(0.2f, 0.8f), Main.rand.NextBool() ? Color.Lerp(Color.Blue, Color.DodgerBlue, 0.3f) : Color.Gold); - GeneralParticleHandler.SpawnParticle(sparks); - Dust dust = Dust.NewDustPerfect(place, ModContent.DustType(), (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, 0, default, Main.rand.NextFloat(0.85f, 1.2f) * power); + if (i % 2 == 0) + { + Vector2 vel = (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power; + Dust dust2 = Dust.NewDustPerfect(place + vel * 13, ModContent.DustType(), + vel, 0, default, Main.rand.NextFloat(1.3f, 1.2f)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + dust2.customData = new Vector2(0.2f, 1.6f); + dust2.fadeIn = 2.5f; + } + + Dust dust = Dust.NewDustPerfect(place, ModContent.DustType(), (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, 0, default, Main.rand.NextFloat(0.85f, 1.2f) * power); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Blue : Color.DodgerBlue; + dust.customData = 7; } SoundStyle sound = new("CalamityMod/Sounds/NPCHit/ExoHit3"); @@ -130,10 +132,11 @@ namespace CalamityMod.Items.Weapons.Melee maxFallSpeed = 75; oldVel = Item.velocity; } - public override void OnCreated(ItemCreationContext context) + public override bool OnPickup(Player player) { if (Main.zenithWorld) SoundEngine.PlaySound(GrandDadEasterEggSound, Main.LocalPlayer.MountedCenter); + return true; } } } diff --git a/Items/Weapons/Melee/VoidEdge.cs b/Items/Weapons/Melee/VoidEdge.cs index 7ac33fbcb3..f7134929dd 100644 --- a/Items/Weapons/Melee/VoidEdge.cs +++ b/Items/Weapons/Melee/VoidEdge.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -104,5 +105,14 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(player.GetSource_ItemUse(Item), target.Center + new Vector2(0, 1300f), velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), soulDamage, 0f, player.whoAmI, 0f, ai1); Projectile.NewProjectile(player.GetSource_ItemUse(Item), target.Center + new Vector2(0, 1300f), velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), soulDamage, 0f, player.whoAmI, 0f, ai1); } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(15). + AddIngredient(3). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index cda4323410..77d8aa7a5e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -146,6 +146,7 @@ TarraEnergy.DisplayName: Tarra Energy TarragonAura.DisplayName: Tarragon Aura TatteredFairyDust.DisplayName: Tattered Fairy Dust TeslaAura.DisplayName: Tesla's Electricity +TileSlamDamage.DisplayName: Grand Damage TitanHeartBoom.DisplayName: Titan Heart Boom TransformerAura.DisplayName: Transformer Aura TransformerBlob.DisplayName: Transformer Shard diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 52c405524e..06341b7b05 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -462,9 +462,9 @@ namespace CalamityMod.NPCs.Abyss // Post-Polterghast: Soul Edge, Eidolic Wail, Stardust Staff LeadingConditionRule postPolter = new LeadingConditionRule(DropHelper.If(() => DownedBossSystem.downedPolterghast)); aewMinionCondition.Add(postPolter); - postPolter.Add(ModContent.ItemType(), 3); postPolter.Add(ModContent.ItemType(), 3); postPolter.Add(ModContent.ItemType(), 3); + postPolter.Add(ModContent.ItemType(), 3); // Post-Leviathan: 6-8 Lumenyl (8-11 on Expert) LeadingConditionRule postLevi = new LeadingConditionRule(DropHelper.If(() => DownedBossSystem.downedLeviathan)); diff --git a/NPCs/CalamityTileCollisionHarmNPC.cs b/NPCs/CalamityTileCollisionHarmNPC.cs index e8c8ce2d34..4a7ed2fecc 100644 --- a/NPCs/CalamityTileCollisionHarmNPC.cs +++ b/NPCs/CalamityTileCollisionHarmNPC.cs @@ -1,7 +1,12 @@ using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Enums; +using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.NPCs @@ -78,10 +83,6 @@ namespace CalamityMod.NPCs /// Will check for tiles in the collision instead of velocity public void ApplyCollisionDamage(NPC npc, Player player, int potentialDamage, Vector2 forcedVel, float terminalVelocityForFullDamage = 10f, bool checkTiles = false) { - //NPCs that don't collide with tiles simply don't get fall damage, lol. - if (npc.noTileCollide) - return; - PotentialEnergyDamage = potentialDamage; OldVelocity = npc.velocity; OlderVelocity = npc.velocity; @@ -100,10 +101,6 @@ namespace CalamityMod.NPCs /// Will check for tiles in the collision instead of velocity public void ApplyForcedVelocity(NPC npc, Player player, Vector2 forcedVel, bool checkTiles = false) { - // NPCs that don't collide with tiles simply don't get velocity, lol. - if (npc.noTileCollide) - return; - OldVelocity = npc.velocity; OlderVelocity = npc.velocity; CheckTiles = checkTiles; @@ -116,21 +113,71 @@ namespace CalamityMod.NPCs { if (FallDamageSusceptible) { - if (CheckTiles) + if (CheckTiles) // Grand Dad { + float scale = (npc.boss ? 1.35f : 1) + Utils.GetLerpValue(20, 800, Math.Max(npc.width, npc.height)); float oldVelocity = OldVelocity.Length(); npc.Center += ForcedVel; ForcedVel *= 0.995f; - if (Collision.SolidCollision(npc.Center, (int)(npc.width * 0.5f), (int)(npc.height * 0.5f)) || !WorldGen.InWorld(npc.Center.ToTileCoordinates().X, npc.Center.ToTileCoordinates().Y, 40)) + Vector2 safeVel = ForcedVel.SafeNormalize(Vector2.UnitX); + + if (npc.velocity == Vector2.Zero || ForcedVel.Length() < 2 || Collision.SolidCollision(npc.Center, (int)(npc.width * 0.5f), (int)(npc.height * 0.5f)) || !WorldGen.InWorld(npc.Center.ToTileCoordinates().X, npc.Center.ToTileCoordinates().Y, 40)) { - if (!ForceVelocityOnly) + if (!ForceVelocityOnly && potentialEnergyDamage > 0) { + attacker.SetScreenshake(7f * scale); + if (!CalamityClientConfig.Instance.Photosensitivity) + { + Vector2 pulseVel = -safeVel; + Particle pulse1 = new CustomSpark(npc.Center, pulseVel * 2, "CalamityMod/Particles/BloomCircle", false, (int)(23 * MathF.Pow(scale, 2)), 0.6f * MathF.Pow(scale, 2), Color.DodgerBlue, new Vector2(2f, 1f), shrinkSpeed: -0.1f / scale, noShrink: true, glowCenter: true, glowOpacity: 0.8f); + GeneralParticleHandler.SpawnParticle(pulse1); + pulse1.Pixelate = true; + Particle pulse2 = new CustomSpark(npc.Center, pulseVel, "CalamityMod/Particles/BloomRing", false, (int)(18 * MathF.Pow(scale, 2)), 0.5f * MathF.Pow(scale, 2), Color.Blue, new Vector2(4f, 0.7f), shrinkSpeed: -0.3f / scale, noShrink: true); + GeneralParticleHandler.SpawnParticle(pulse2); + pulse2.Pixelate = true; + } + + + for (int i = 0; i < 2; i++) + { + SoundStyle die = new("CalamityMod/Sounds/Item/HolyFireBulletExplosion"); + SoundEngine.PlaySound(die with { Pitch = 0.5f, Volume = Math.Min(0.6f * scale, 1f), MaxInstances = 2 }, npc.Center); + if (npc.boss) + { + SoundStyle dieHard = new("CalamityMod/Sounds/Item/HellkiteSmallHit3"); + SoundEngine.PlaySound(dieHard with { Pitch = -1f, Volume = Math.Min(0.5f * scale, 1f), MaxInstances = 2 }, npc.Center); + } + SoundStyle dieHarder = new("CalamityMod/Sounds/Item/HeliumFlashCoreImpact"); + SoundEngine.PlaySound(dieHarder with { Pitch = -1.8f, Volume = Math.Min(0.6f * scale, 1f), MaxInstances = 2 }, npc.Center); + } + for (int i = 0; i < 30; i++) + { + float variance = Main.rand.NextFloat(-0.8f, 0.8f); + Dust dust = Dust.NewDustPerfect(npc.Center, ModContent.DustType(), + -safeVel.RotatedBy(variance * 2).RotatedByRandom(MathF.Abs(variance) / 3) * scale * Main.rand.NextFloat(30.0f, 33.0f) * MathF.Pow((1 - MathF.Abs(variance)), 2), 0, default, scale * Main.rand.NextFloat(2.3f, 3.2f) - MathF.Abs(variance)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; + dust.customData = 2; + dust.fadeIn = 0.5f * scale; + } + for (int i = 0; i < 15; i++) + { + float variance = Main.rand.NextFloat(-0.8f, 0.8f); + Vector2 vel = -safeVel.RotatedBy(variance / 2).RotatedByRandom(MathF.Abs(variance) / 3) * Main.rand.NextFloat(20.0f, 23.0f) * MathF.Pow((1 - MathF.Abs(variance)), 2); + Dust dust2 = Dust.NewDustPerfect(npc.Center + vel * 13, ModContent.DustType(), + vel, 0, default, 2 * Main.rand.NextFloat(2.3f, 3.2f) - MathF.Abs(variance)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + dust2.customData = new Vector2(0.2f, 1.6f); + dust2.fadeIn = 2.5f; + + } + int wallImpactDamage = (int)(PotentialEnergyDamage * Math.Clamp(oldVelocity / terminalVelocityForFullFallDamage, (ForcedVel.Length() > 0 ? 1f : 0f), 1f)); - Projectile wallImpact = Projectile.NewProjectileDirect(attacker.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), wallImpactDamage, 0f, attacker.whoAmI, npc.whoAmI); + Projectile wallImpact = Projectile.NewProjectileDirect(attacker.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), wallImpactDamage, 0f, attacker.whoAmI, npc.whoAmI); wallImpact.DamageType = DamageClass.Melee; - wallImpact.CritChance = (int)attacker.GetCritChance(DamageClass.Melee) + attacker.HeldItem.crit; } PotentialEnergyDamage = 0; diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index 2bc598ef88..32adbb354a 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -1492,7 +1492,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType()); - npcLoot.Add(ModContent.ItemType()); + npcLoot.Add(ModContent.ItemType()); npcLoot.Add(ModContent.ItemType()); npcLoot.Add(ModContent.ItemType()); npcLoot.Add(ModContent.ItemType(), 1, 80, 100); diff --git a/Particles/CircularSmearLarge.png b/Particles/CircularSmearLarge.png new file mode 100644 index 0000000000..d9d51baaef Binary files /dev/null and b/Particles/CircularSmearLarge.png differ diff --git a/Particles/CustomSpark.cs b/Particles/CustomSpark.cs index 72087bb46b..295709d63d 100644 --- a/Particles/CustomSpark.cs +++ b/Particles/CustomSpark.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -22,13 +23,14 @@ namespace CalamityMod.Particles public bool FlipHorizontal = false; public bool NoShrink = false; public float Spin = 0; + public float ColorFadeSpeed = 0; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public bool AltVisual = true; public override bool UseAdditiveBlend => AltVisual; public override bool SetLifetime => true; public override bool UseCustomDraw => true; - public CustomSpark(Vector2 relativePosition, Vector2 velocity, string texture, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool useAddativeBlend = true, bool glowCenter = false, float extraRotation = 0, bool fadeIn = false, bool affectedByLight = false, float shrinkSpeed = 0, float glowCenterScale = 1, float glowOpacity = 1, bool flipHorizontal = false, bool noShrink = false, float spin = 0) + public CustomSpark(Vector2 relativePosition, Vector2 velocity, string texture, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool useAddativeBlend = true, bool glowCenter = false, float extraRotation = 0, bool fadeIn = false, bool affectedByLight = false, float shrinkSpeed = 0, float glowCenterScale = 1, float glowOpacity = 1, bool flipHorizontal = false, bool noShrink = false, float spin = 0, float colorFadeSpeed = 3) { Position = relativePosition; Velocity = velocity; @@ -55,6 +57,7 @@ namespace CalamityMod.Particles if (FadeIn) Scale = 0f; Spin = spin; + ColorFadeSpeed = colorFadeSpeed; } public override void Update() @@ -63,7 +66,7 @@ namespace CalamityMod.Particles { if (!NoShrink) Scale *= 0.95f; - Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, ColorFadeSpeed)); } else { @@ -114,9 +117,21 @@ namespace CalamityMod.Particles col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color); } - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); - if (GlowCenter) - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + if (Pixelate) + { + PixelationManager.AddPixelatedDrawer((_) => + { + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + if (GlowCenter) + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + }, Enums.GeneralDrawLayer.AfterProjectiles, UseAdditiveBlend ? BlendState.Additive : null); + } + else + { + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + if (GlowCenter) + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } } } } diff --git a/Projectiles/Melee/BasherHoldout.cs b/Projectiles/Melee/BasherHoldout.cs index 0050590376..7f8ad74901 100644 --- a/Projectiles/Melee/BasherHoldout.cs +++ b/Projectiles/Melee/BasherHoldout.cs @@ -56,6 +56,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.noEnchantmentVisuals = true; + Projectile.scale = 0; } public void OnSpawn() { @@ -99,7 +101,7 @@ namespace CalamityMod.Projectiles.Melee if (!Owner.CantUseHoldout(false)) Projectile.timeLeft = 5; - Projectile.scale = Owner.GetMeleeScale() + 0.1f; + Projectile.scale = MathHelper.Lerp(Projectile.scale, Owner.GetMeleeScale() + 0.1f, 0.3f / Projectile.MaxUpdates); toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld()); Positioning(toMouse); @@ -125,6 +127,7 @@ namespace CalamityMod.Projectiles.Melee } else Owner.itemTime = Owner.itemAnimation = 5; + #region Not Swinging if (attackTimer < 0) // When the sword isn't swinging { diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs index cd7d39d564..0ded93f6cd 100644 --- a/Projectiles/Melee/GrandDadHoldout.cs +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -1,9 +1,16 @@ -using CalamityMod.Dusts; +using System; +using System.Collections.Generic; +using System.Runtime.ConstrainedExecution; +using CalamityMod.Dusts; +using CalamityMod.Enums; +using CalamityMod.Items.Tools; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs; using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -12,212 +19,257 @@ using Terraria.Audio; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; +using static Terraria.Player; namespace CalamityMod.Projectiles.Melee { [PierceResistException] - public class GrandDadHoldout : BaseCustomUseStyleProjectile, ILocalizedModType + public class GrandDadHoldout : ModProjectile, ILocalizedModType { - public override int AssignedItemID => ModContent.ItemType(); - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override string Texture => "CalamityMod/Items/Weapons/Melee/GrandDad"; - public override float HitboxOutset => 125; - public override Vector2 HitboxSize => new Vector2(190, 190); - public override float HitboxRotationOffset => MathHelper.ToRadians(-45); - - public override Vector2 SpriteOrigin => new(0, 124); - public Vector2 mousePos; - public Vector2 aimVel; - public bool doSwing = true; - public bool postSwing = false; - public float fadeIn = 0; - public int useAnim; - public int swingCount; - public bool finalFlip = false; - public bool swingSound = true; + public ref float attackTimer => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + public int fireRate => (int)((Owner.HeldItem.useAnimation * Owner.inverseMeleeSpeed * Projectile.MaxUpdates) / 2.75f); + public int time = 0; + public Vector2 toMouse = Vector2.Zero; + public int cooldown => (int)(-Owner.HeldItem.useAnimation * Owner.inverseMeleeSpeed * Projectile.MaxUpdates); + public float bladeRot = 0; // Rotation of the blade + public int swingCount = 0; // Increases at the start of a swing + public float bladefx = 0; // Visual effects of the blade + // Checks to make sure sounds only happen once per swing + public bool makeSound = true; + public bool performSwing = false; + public float enabledHitbox = 0; // Deals damage when above 0, ticks down quickly + public float angledHold = 0; // Adds some angle based on swing direction + public float angleArmHold = 0; + public static int hitboxFramesMax = 11; + public bool canReleaseHoldout = false; public int armoredHits = 0; - private NPC target => Main.npc[(int)Projectile.ai[0]]; - + public float startAngle = MathHelper.Pi * 0.9f; + public float endAngle = -MathHelper.PiOver4 * 3 * 0.9f; + public override bool? CanDamage() => enabledHitbox > 0 ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float outset = 40 * Projectile.scale; + Vector2 hitboxPosition = Owner.Center + toMouse * outset; + float hitboxSize = 155 * Projectile.scale; + return CalamityUtils.CircularHitboxCollision(hitboxPosition, hitboxSize, targetHitbox); + } public override void SetDefaults() { - base.SetDefaults(); + Projectile.width = Projectile.height = 124; + Projectile.friendly = true; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.timeLeft = 5; + Projectile.penetrate = -1; + Projectile.extraUpdates = 8; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.noEnchantmentVisuals = true; + Projectile.scale = 0; } - - public override void WhenSpawned() + public void OnSpawn() { - Projectile.timeLeft = Owner.HeldItem.useAnimation + 1; - Projectile.knockBack = 0; - Projectile.scale = 1; - Projectile.ai[1] = -1; - - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, as Grand Dad has no projectiles - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; - useAnim = Owner.itemAnimationMax; - - if (mousePos.X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; - - FlipAsSword = Owner.direction == -1; - } - - public override void UseStyle() - { - AnimationProgress = Animation % useAnim; - DrawUnconditionally = false; - - if (CanHit || postSwing) - mousePos = Owner.Center - aimVel; - else + if (time == 0) { - mousePos = Owner.Calamity().mouseWorld; + Projectile.knockBack = 0; + attackTimer = cooldown; + swingCount = 1; } + } + public void ResetVariables() // After a swing, reset/adjust many stats + { + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + Projectile.numHits = 0; + swingCount++; + makeSound = true; + enabledHitbox = 0; + canReleaseHoldout = false; + armoredHits = 0; + Projectile.ForceNetUpdate(); + } + public void Positioning(Vector2 toMouse) // Hand and holdout positioning + { + Owner.heldProj = Projectile.whoAmI; + Owner.itemRotation = (Projectile.velocity * Owner.direction).ToRotation(); - if (CanHit) - fadeIn = MathHelper.Lerp(fadeIn, 1, 0.3f); - else - fadeIn = MathHelper.Lerp(fadeIn, 0, 0.35f); + angleArmHold = MathHelper.Lerp(angleArmHold, angledHold * MathF.Pow(Utils.GetLerpValue(cooldown, cooldown * 0.35f, attackTimer, true), 5), 0.12f / Projectile.MaxUpdates * Owner.meleeSpeed); + float angleVariation = (float)Math.Sin(time * 0.04f / Projectile.MaxUpdates) * 0.05f; + float outwardDistance = 5; + Owner.ChangeDir(Math.Sign(toMouse.X)); + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, (toMouse.ToRotation() + (bladeRot + angleArmHold + angleVariation) * Owner.direction + MathHelper.PiOver2 * -Owner.direction) + (Owner.direction == -1 ? MathHelper.Pi : 0)); + Vector2 handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.None, Owner.compositeFrontArm.rotation) + (Owner.compositeFrontArm.rotation + MathHelper.PiOver2).ToRotationVector2() * outwardDistance; + float armRotation = (Utils.DirectionTo(Owner.Center, handPos).ToRotation() - MathHelper.PiOver2) * Owner.gravDir + (Owner.gravDir == -1 ? MathHelper.Pi : 0f); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, armRotation); - if (!doSwing) + Projectile.velocity = toMouse.RotatedBy((bladeRot + angledHold + angleVariation) * Owner.direction); + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Center = handPos; + } + public override void AI() + { + if (!Owner.CantUseHoldout(false)) + Projectile.timeLeft = 5; + + Projectile.scale = MathHelper.Lerp(Projectile.scale, Owner.GetMeleeScale(), 0.3f / Projectile.MaxUpdates); + toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld()); + + Positioning(toMouse); + + OnSpawn(); + + bool fadeInFX = enabledHitbox > (int)(hitboxFramesMax / 3f); + if (enabledHitbox > 0) { - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; + if (Projectile.FinalExtraUpdate()) + enabledHitbox--; + } + if (fadeInFX) + bladefx = MathHelper.Lerp(bladefx, 1, 0.25f / Projectile.MaxUpdates * Owner.meleeSpeed); + else + bladefx = MathHelper.Lerp(bladefx, 0, 0.15f / Projectile.MaxUpdates * Owner.meleeSpeed); - Projectile.numHits = 0; - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; - CanHit = false; - if (mousePos.X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; - FlipAsSword = Owner.direction == -1; - - doSwing = true; - swingCount++; - finalFlip = false; - swingSound = true; - armoredHits = 0; + if (canReleaseHoldout || time < 25) + { + if (Owner.HeldItem.type != ItemType() || Main.mapFullscreen || Owner.mouseInterface || Owner.dead) + { + Projectile.Kill(); + return; + } } else + Owner.itemTime = Owner.itemAnimation = 5; + + + float lerpSpeed = 0.1f / Projectile.MaxUpdates * Owner.meleeSpeed; + float maxAngle = MathHelper.PiOver4 * 0.8f; + if (swingCount % 2 == 0) + angledHold = MathHelper.Lerp(angledHold, maxAngle, lerpSpeed); + else + angledHold = MathHelper.Lerp(angledHold, -maxAngle, lerpSpeed); + + + #region Not Swinging + if (attackTimer < 0) // When the sword isn't swinging { - if (!CanHit && !postSwing) + Timers(); + + float lerp = Utils.GetLerpValue(cooldown, -1, attackTimer, true); + + if (attackTimer == 0) // Reset a few things in prep for the next swing + ResetVariables(); + else // Wind up animation in prep for the next swing { - if (mousePos.X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; - } - else - { - if ((Owner.Center - aimVel).X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; - } + int swingDir = (swingCount % 2 != 0 ? 1 : -1); + float lerp2 = Utils.GetLerpValue(cooldown, -1, attackTimer, true); + float start = -startAngle * swingDir; + float end = endAngle * swingDir; + bladeRot = MathHelper.Lerp(start, end, CalamityUtils.EaseInOutExp(lerp2, 2f, 2f)); - - Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f), 0.1f); - - if (AnimationProgress < (useAnim / 1.5f)) - { - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; - CanHit = false; - postSwing = false; - if (AnimationProgress == 0) + if (lerp >= 0.85f) { - doSwing = false; - Projectile.ai[1] = -Projectile.ai[1]; - } - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction * (1 + (Utils.GetLerpValue(useAnim * 0.8f, useAnim, Animation, true)) * 0.35f)), 0.2f); - } - else - { - if (!finalFlip) - { - FlipAsSword = Owner.direction < 0; - } - - float time = (AnimationProgress) - (useAnim / 3); - float timeMax = useAnim - (useAnim / 3); - - if (time >= (int)(timeMax * 0.4f) && swingSound) - { - SoundStyle fire = new("CalamityMod/Sounds/Item/HeavySwing"); - SoundEngine.PlaySound(fire with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.2f, 0.32f) }, Projectile.Center); - swingSound = false; - } - if (time > (int)(timeMax * 0.4f) && time < (int)(timeMax * 0.7f)) - { - CanHit = true; - - for (int i = 0; i < 3; i++) + if (Owner.controlUseItem || performSwing) + performSwing = true; + else { - Vector2 particleVel = new Vector2(0, 10 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)); - Vector2 particlePos = Owner.Center + (new Vector2(Main.rand.Next(30, 165), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))); - GeneralParticleHandler.SpawnParticle(new LineParticle(particlePos, -particleVel.RotatedByRandom(0.2f) * 2, false, 19, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue)); - GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(particlePos, -particleVel.RotatedByRandom(0.2f) * 2, Main.rand.NextBool(4) ? Color.Black : Color.DarkBlue, 23, Main.rand.NextFloat(0.5f, 1f), 0.65f)); - } - } - else - CanHit = false; - - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(150f * Projectile.ai[1] * Owner.direction, 120f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time / timeMax, 1))), - 0.2f); - - if (time >= timeMax) - doSwing = false; - if (time < (int)(timeMax * 0.7f)) - postSwing = true; - - if (CanHit) - { - for (int i = 0; i < 6; i++) - { - if (Main.rand.NextBool(3)) - { - Dust dust = Dust.NewDustPerfect(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), ModContent.DustType(), Vector2.Zero, 0, default, Main.rand.NextFloat(1.15f, 1.5f)); - dust.noGravity = true; - dust.color = Color.DodgerBlue; - GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), Vector2.Zero, false, 23, Main.rand.NextFloat(0.5f, 1f), Color.Black, false, false, false)); - } - else - { - Dust dust = Dust.NewDustPerfect(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), ModContent.DustType(), Vector2.Zero, 0, default, Main.rand.NextFloat(1.15f, 1.5f)); - dust.noGravity = true; - dust.color = Color.Blue; - GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), Vector2.Zero, false, 23, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue)); - } - } - for (int i = 0; i < 3; i++) - { - float randRot = Main.rand.NextFloat(-30, -60); - Vector2 dustVel = (new Vector2(0, 15 * -Projectile.ai[1] * Owner.direction)).RotatedBy(FinalRotation + MathHelper.ToRadians(randRot)); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(185, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, dustVel * Main.rand.NextFloat(0.1f, 0.5f)); - dust2.scale = Main.rand.NextFloat(0.55f, 1.05f); - dust2.noGravity = true; - dust2.color = Main.rand.NextBool(3) ? Color.Goldenrod : Color.Gold; + canReleaseHoldout = true; + attackTimer--; + lerp = 0.85f; } } } + if (lerp > 0.85f) + { + angledHold = MathHelper.Lerp(angledHold, maxAngle * 3.5f * (swingCount % 2 == 0 ? 1 : -1), lerpSpeed * 1.5f); + } + + return; } + #endregion - ArmRotationOffset = MathHelper.ToRadians(-140f); - ArmRotationOffsetBack = MathHelper.ToRadians(-140f); + if (attackTimer >= fireRate) // Once the swing is done, put it on cooldown + { + attackTimer = cooldown; + performSwing = false; + } + else // Do the swing + { + #region Swinging + int swingDir = (swingCount % 2 != 0 ? -1 : 1); + float lerp = Utils.GetLerpValue(0, fireRate - 1, attackTimer, true); + float start = endAngle * swingDir; + float end = startAngle * swingDir; + bladeRot = MathHelper.Lerp(start, end, CalamityUtils.EaseInOutExp(lerp, 11f, 11f)); + + if (lerp > 0.3f && lerp < 0.8f && Main.rand.NextBool((int)(1 + 4 * Projectile.MaxUpdates * Math.Abs(Utils.GetLerpValue(0.5f, 1.2f, lerp))))) + { + Vector2 dustPosition = Projectile.Center + Projectile.velocity * 170 * Projectile.scale; + Vector2 dustPosition2 = Projectile.Center + Projectile.velocity.RotatedByRandom(0.3f) * 170 * Projectile.scale; + Vector2 swingVel = Projectile.velocity.RotatedBy(MathHelper.PiOver2 * (swingCount % 2 == 0 ? 1 : -1) * Owner.direction); + + Dust dust = Dust.NewDustPerfect(dustPosition, ModContent.DustType(), + swingVel.RotatedByRandom(0.1f) * Main.rand.NextFloat(9.5f, 15.5f), 0, default, Main.rand.NextFloat(1.55f, 2.2f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; + dust.customData = 7; + + if (Main.rand.NextBool(3, 4)) + { + Vector2 vel = swingVel.RotatedByRandom(0.1f) * Main.rand.NextFloat(9.5f, 15.5f); + Dust dust2 = Dust.NewDustPerfect(dustPosition2, ModContent.DustType(), + vel, 0, default, 2 * Main.rand.NextFloat(1.0f, 1.3f)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + dust2.customData = new Vector2(0.2f, 1.0f); + dust2.fadeIn = 0.2f; + } + + } + if (lerp > 0.4f) // Partway through make the hitbox and sound + { + if (makeSound) + { + enabledHitbox = hitboxFramesMax; + SoundStyle swing1 = new("CalamityMod/Sounds/Item/HeavySwing"); + SoundEngine.PlaySound(swing1 with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.2f, 0.32f) }, Projectile.Center); + makeSound = false; + } + } + #endregion + } + Timers(); } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public void Timers() { - if ((target.life <= 0 && target.realLife == -1) && Projectile.numHits > 0) - Projectile.numHits -= 1; - if (damageDone <= 2) + time++; + // Only increment the attack animation when on cooldown or when allowed to swing + if ((attackTimer < fireRate && performSwing) || attackTimer < -1) + attackTimer++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Dont increment numHits on armored targets or kills + if (((target.life <= 0 && target.realLife == -1) || target.Calamity().IsArmored())) armoredHits++; - if (Main.zenithWorld && Projectile.numHits == 0 && target.type != ModContent.NPCType() && Main.rand.NextBool(5)) + float distanceToTiles = -100; + bool canBeLaunched = false; + bool lowEnoughToExecute = target.life <= Projectile.damage * 15; + bool jared = target.type == ModContent.NPCType(); + Vector2 launchVel = Utils.DirectionTo(Owner.Center, (lowEnoughToExecute ? Owner.Calamity().mouseWorld : target.Center)); + + if (lowEnoughToExecute) { - SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8); - SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center); + distanceToTiles = CalamityUtils.DistanceToTileCollisionHit(target.Center, launchVel, 200) ?? -100; + canBeLaunched = jared || ((distanceToTiles == -100 ? false : distanceToTiles < 200 ? true : false) && target.realLife == -1); } if (Projectile.numHits == 0) { @@ -227,60 +279,82 @@ namespace CalamityMod.Projectiles.Melee SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); } - - int heal = (int)(MathHelper.Clamp(20 - Projectile.numHits * 12, 1, 20)); + int heal = (int)(MathHelper.Clamp(18 - Projectile.numHits * 13, 1, 20)); if (Projectile.numHits < 10) { - Owner.DoLifestealDirect(target, heal, 0.5f); + Owner.Calamity().grandDadHealPool += heal; + // Give partial Grand Dad healing to all nearby players + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float targetDist = player.Center.DistanceSQ(Owner.Center); + + if (targetDist < 500f && player.team == Owner.team && player != Owner) + { + player.Calamity().grandDadHealPool += (int)(heal / 2); + } + } } - if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs)) + if (canBeLaunched) // launches/executes enemies { - if (target.type == ModContent.NPCType()) + if (jared) { CombatText.NewText(target.Hitbox, Color.Aqua, CalamityUtils.GetTextValue("Misc.HecBoop")); SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped"); SoundEngine.PlaySound(boop with { Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center); } - bool rightClicked = Owner.Calamity().mouseRight; - - // Make all hit enemies able to hit tiles, so you can dunk them - target.noTileCollide = false; + target.Calamity().pacified = true; // Launch the suckers - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - float launchPower = 30 * (rightClicked ? 2 : 1); + float launchPower = 60; target.MoveNPC(launchVel, launchPower * 0.5f, true); - - // Remove knockback resist, just like it used to - target.knockBackResist = 1; - - // Apply tile collison damage (is boosted even further if both final bosses are gone) - float damageMults = ((DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) ? 5 : 1) * (rightClicked ? 3 : 1); - int damage = (int)(Projectile.damage * damageMults); - target.GetGlobalNPC().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true); + + // Apply tile collison damage + // This always kills (unless it's Jared) + int damage = (int)(Projectile.damage); + target.GetGlobalNPC().ApplyCollisionDamage(target, Owner, (jared && !lowEnoughToExecute) ? 0 : damage, launchVel * launchPower, 5f, true); } if (Projectile.numHits < 3) { - Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (-45 + Projectile.numHits * 5), false, (int)(16 - Projectile.numHits * 3), 0.6f - Projectile.numHits * 0.15f, Color.DodgerBlue, 0.45f); - GeneralParticleHandler.SpawnParticle(spark); + for (int i = 0; i < 2; i++) + { + Particle spark = new CustomSpark(target.Center, launchVel * 65, "CalamityMod/Particles/GlowSpark2", false, (int)(16 - Projectile.numHits * 3), 0.145f - Projectile.numHits * 0.015f, Color.Black, new Vector2(2f, 1f), false, shrinkSpeed: 1f, colorFadeSpeed: 10); + GeneralParticleHandler.SpawnParticle(spark); + spark.Pixelate = true; + Particle spark2 = new CustomSpark(target.Center, launchVel * 65, "CalamityMod/Particles/GlowSpark", false, (int)(16 - Projectile.numHits * 3), 0.105f - Projectile.numHits * 0.015f, Color.Lerp(Color.Blue, Color.DodgerBlue, 0.65f), new Vector2(2f, 1f), true, false, shrinkSpeed: 1f, colorFadeSpeed: 10); + GeneralParticleHandler.SpawnParticle(spark2); + spark2.Pixelate = true; + spark2.DrawLayer = GeneralDrawLayer.AfterEverything; + } + + for (int i = 0; i < 25 - Projectile.numHits * 3; i++) + { + float hitMult = 1 - 0.15f * Projectile.numHits; + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), + launchVel.RotatedBy(variance / 2).RotatedByRandom(MathF.Abs(variance) / 3) * Main.rand.NextFloat(30.0f, 33.0f) * hitMult * MathF.Pow((1 - MathF.Abs(variance)), 2), 0, default, 3 * hitMult * Main.rand.NextFloat(2.3f, 3.2f) - MathF.Abs(variance)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; + dust.customData = 3; + dust.fadeIn = 2.1f; + + if (i % 2 == 0) + { + Vector2 vel = launchVel.RotatedBy(variance / 2).RotatedByRandom(MathF.Abs(variance) / 3) * Main.rand.NextFloat(20.0f, 23.0f) * hitMult * MathF.Pow((1 - MathF.Abs(variance)), 2); + Dust dust2 = Dust.NewDustPerfect(target.Center + vel * 13, ModContent.DustType(), + vel, 0, default, 2 * hitMult * Main.rand.NextFloat(2.3f, 3.2f) - MathF.Abs(variance)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + dust2.customData = new Vector2(0.2f, 1.6f); + dust2.fadeIn = 2.5f; + } + } } - for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) - { - Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue); - GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(1.55f, 2.2f)); - dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; - } - } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (Owner.Calamity().mouseRight) + if (canBeLaunched) { modifiers.SourceDamage *= 0; modifiers.FinalDamage.Flat = 0.1f; @@ -293,34 +367,61 @@ namespace CalamityMod.Projectiles.Melee modifiers.SourceDamage *= damageMult; } } - public override bool PreDraw(ref Color lightColor) { - // Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to. - if ((useAnim > 0 || DrawUnconditionally) && Owner.ItemAnimationActive) + if (time < 3) + return false; + + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D swoosh = ModContent.Request("CalamityMod/Particles/CircularSmearLarge").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 vel = Projectile.rotation.ToRotationVector2(); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + ((Owner.direction == -1) ? MathHelper.Pi - MathHelper.PiOver4 : MathHelper.PiOver4); + Vector2 rotationPoint = (Owner.direction == -1) ? new Vector2(texture.Width, texture.Height) : new Vector2(0, texture.Height); + SpriteEffects flipSprite = (Owner.direction == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 handLatchingAdjustments = (swingCount % 2 == 0 ? new Vector2(-6, 0) : new Vector2(-2, 0)); + Vector2 placeAdjust = (drawRotation + MathHelper.PiOver2).ToRotationVector2() * 2.5f + (handLatchingAdjustments.RotatedBy(drawRotation) * Owner.direction); + + float lerp = 1 - bladefx; + int swingCountFlip = (swingCount % 2 == 0 ? 1 : 3) + Owner.direction == 0 ? 2 : 0; + Vector2 vel2 = Vector2.Lerp(Projectile.velocity.RotatedBy(MathHelper.PiOver2), Owner.Center.DirectionTo(Owner.ClampedMouseWorld()).RotatedBy(-MathHelper.PiOver2), 0f); + float extraRot = MathHelper.PiOver4 * MathHelper.Lerp(3, 1.9f, lerp) * (swingCount % 2 == 0 ? (Owner.direction == -1 ? 1 : -1) : (Owner.direction == -1 ? -1 : 1)); + float swooshDrawRotation = vel2.ToRotation() + extraRot; + SpriteEffects swooshFlipSprite = (swingCount % 2 == 0 ? (Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None) : (Owner.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally)); + if (bladefx > 0.02f) { - Asset tex = ModContent.Request(Texture); - Asset glowTex = ModContent.Request("CalamityMod/Items/Weapons/Melee/GrandDadGlow"); - - float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; - - Asset swoosh = ModContent.Request("CalamityMod/Particles/VerticalSmearLarge"); - if (Animation > useAnim * 0.2f) - Main.EntitySpriteDraw(swoosh.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), null, Color.DodgerBlue with { A = 0 } * fadeIn * 0.65f, (FinalRotation + MathHelper.ToRadians(45)) + MathHelper.ToRadians(Projectile.ai[1] == 1 ? -90 : 90) * -Owner.direction, swoosh.Size() * 0.5f, Projectile.scale * 0.6f, SpriteEffects.None); - - for (int i = 0; i < 25; i++) + PixelationManager.AddPixelatedDrawer((_) => { - Texture2D centerTexture = ModContent.Request("CalamityMod/Projectiles/Melee/GrandDadGhost").Value; - Color auraColor = Color.Gold with { A = 0 } * 0.15f * fadeIn; - Vector2 drawOffset = (MathHelper.TwoPi * i / 25f).ToRotationVector2() * 6 * fadeIn; - Main.EntitySpriteDraw(centerTexture, Projectile.Center - Main.screenPosition + drawOffset + new Vector2(0, Owner.gfxOffY), centerTexture.Frame(1, FrameCount, 0, Frame), auraColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + int draws = 15; + for (int i = 0; i < draws; i++) + { + Color clr = Color.Black; + Vector2 outlineOffset = (MathHelper.TwoPi / draws * i).ToRotationVector2() * 3.5f; + Main.EntitySpriteDraw(swoosh, drawPosition + Projectile.velocity.RotatedBy(extraRot) * 12.5f + outlineOffset, null, clr * MathF.Pow(bladefx, 3) * 0.4f, swooshDrawRotation, swoosh.Size() * 0.5f, Projectile.scale * 0.6f, swooshFlipSprite); + Main.EntitySpriteDraw(texture, drawPosition + placeAdjust + outlineOffset * 2 * bladefx, null, clr * 0.2f * bladefx, drawRotation, rotationPoint, Projectile.scale, flipSprite); + } + }, Enums.GeneralDrawLayer.AfterProjectiles, BlendState.AlphaBlend); + if (!CalamityClientConfig.Instance.Photosensitivity) + { + PixelationManager.AddPixelatedDrawer((_) => + { + Color clrCenter = Color.DodgerBlue; + Main.EntitySpriteDraw(swoosh, drawPosition + Projectile.velocity.RotatedBy(extraRot) * 12.5f, null, clrCenter * MathF.Pow(bladefx, 0.6f), swooshDrawRotation, swoosh.Size() * 0.5f, Projectile.scale * 0.6f, swooshFlipSprite); + Main.EntitySpriteDraw(texture, drawPosition + placeAdjust, null, clrCenter * bladefx, drawRotation, rotationPoint, Projectile.scale, flipSprite); + }, Enums.GeneralDrawLayer.AfterEverything, BlendState.Additive); + } - - Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); - Main.EntitySpriteDraw(glowTex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), glowTex.Frame(1, FrameCount, 0, Frame), Color.White, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(glowTex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); - } + + Main.EntitySpriteDraw(texture, drawPosition + placeAdjust, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); // The holdout + return false; } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } } } diff --git a/Projectiles/Typeless/TileSlamDamage.cs b/Projectiles/Typeless/TileSlamDamage.cs new file mode 100644 index 0000000000..45184ff8ed --- /dev/null +++ b/Projectiles/Typeless/TileSlamDamage.cs @@ -0,0 +1,17 @@ +using CalamityMod.Buffs.DamageOverTime; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class TileSlamDamage : DirectStrike, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetInstantKill(); + } + + } +}