diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index ddb7152309..14b873d37b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -205,15 +205,24 @@ namespace CalamityMod.CalPlayer if (Player.HeldItem.type != ModContent.ItemType()) saharaSlicersBolts = 0; - if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && (Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) && !Player.dead && !Main.mapFullscreen && !Player.mouseInterface) + // Spawning for items that have holdouts active when held + if (Player.whoAmI == Main.myPlayer && !Player.dead && !Main.mapFullscreen && !Player.mouseInterface) { - 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.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && (Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) && !Player.dead && !Main.mapFullscreen && !Player.mouseInterface) - { - 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); + } + 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); + } + 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/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index c75db9fbc2..62313a8039 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -950,6 +950,7 @@ namespace CalamityMod.Items public override void ModifyItemScale(Item item, Player player, ref float scale) { + // Xyk 3MARCH2026: Doesn't work on any non use style 1 items currently, Doze will fix it if (item.CountsAsClass() && player.HasBuff(BuffID.Tipsy)) scale += 0.15f; } diff --git a/Items/Weapons/Melee/Basher.cs b/Items/Weapons/Melee/Basher.cs index 4920f4ff29..0c51b82f38 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Projectiles.Melee; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 60; - Item.damage = 40; + Item.damage = 70; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; @@ -30,6 +31,13 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ItemRarityID.Blue; } public override bool MeleePrefix() => true; + public override bool CanUseItem(Player player) => false; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } public override void AddRecipes() { CreateRecipe(). diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 320793dbdd..ee39a9879c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -166,11 +166,7 @@ BansheeHook: { Basher: { DisplayName: Basher - Tooltip: - ''' - Swings a rotten club that poisons and irradiates enemies on hit - Holding while swinging will increase the club's damage, but will also knock you back on hit - ''' + Tooltip: Swings a rotten club that irradiates enemies on hit while knocking you back in the process } BladecrestOathsword: { diff --git a/Particles/VerticalSmear.png b/Particles/VerticalSmear.png index 74d237ccaa..b7dbc5945c 100644 Binary files a/Particles/VerticalSmear.png and b/Particles/VerticalSmear.png differ diff --git a/Particles/VerticalSmearThin.png b/Particles/VerticalSmearThin.png new file mode 100644 index 0000000000..7f60001d96 Binary files /dev/null and b/Particles/VerticalSmearThin.png differ diff --git a/Projectiles/Melee/BasherHoldout.cs b/Projectiles/Melee/BasherHoldout.cs index ff82182a62..37c1181f30 100644 --- a/Projectiles/Melee/BasherHoldout.cs +++ b/Projectiles/Melee/BasherHoldout.cs @@ -1,250 +1,290 @@ -using CalamityMod.Buffs.StatDebuffs; +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs; -using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; 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 BasherHoldout : BaseCustomUseStyleProjectile, ILocalizedModType + public class BasherHoldout : ModProjectile, ILocalizedModType { - public override int AssignedItemID => ModContent.ItemType(); - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override string Texture => "CalamityMod/Items/Weapons/Melee/Basher"; - public override float HitboxOutset => 60; - - public override Vector2 HitboxSize => new Vector2(80, 80); - public override float HitboxRotationOffset => MathHelper.ToRadians(-45); - - public override Vector2 SpriteOrigin => new(-7, 65); - 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 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 rumble = 0; + public override bool? CanDamage() => enabledHitbox > 0 ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float outset = 15 * Projectile.scale; + Vector2 hitboxPosition = Owner.Center + toMouse * outset; + float hitboxSize = 70 * Projectile.scale; + return CalamityUtils.CircularHitboxCollision(hitboxPosition, hitboxSize, targetHitbox); + } public override void SetDefaults() { - base.SetDefaults(); + Projectile.width = Projectile.height = 100; + Projectile.friendly = true; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.timeLeft = 5; + Projectile.penetrate = -1; + Projectile.extraUpdates = 2; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.DamageType = TrueMeleeDamageClass.Instance; } - public override void WhenSpawned() + public void OnSpawn() { - Projectile.knockBack = 0; - Projectile.scale = 1; - Projectile.ai[1] = 1; - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - 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 ? true : false; - } - - 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; } + } + 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; + Projectile.ForceNetUpdate(); + } + public void Positioning(Vector2 toMouse) // Hand and holdout positioning + { + Owner.heldProj = Projectile.whoAmI; + Owner.itemRotation = (Projectile.velocity * Owner.direction).ToRotation(); - if (CanHit && Owner.Calamity().mouseRight) - fadeIn = MathHelper.Lerp(fadeIn, 1, 0.1f); - else - fadeIn = MathHelper.Lerp(fadeIn, 0, 0.15f); + float angleVariation = (float)Math.Sin(time * 0.06f / Projectile.MaxUpdates) * 0.1f; + float outwardDistance = 5 * Projectile.scale; + Owner.ChangeDir(Math.Sign(toMouse.X)); + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, (toMouse.ToRotation() + (bladeRot + 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 + angleVariation + angledHold) * Owner.direction); + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Center = handPos; + } + public override void AI() + { + if (!Owner.CantUseHoldout(false)) + Projectile.timeLeft = 5; + + Projectile.scale = Owner.GetMeleeScale(); + toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld()); + + Positioning(toMouse); + + OnSpawn(); + + if (enabledHitbox > 0) { - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; - - Projectile.numHits = 0; - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - 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 ? true : false; - doSwing = true; - swingCount++; - finalFlip = false; + bladefx = MathHelper.Lerp(bladefx, 1, 0.6f / Projectile.MaxUpdates); + if (Projectile.FinalExtraUpdate()) + enabledHitbox--; } else + bladefx = MathHelper.Lerp(bladefx, 0, 0.7f / Projectile.MaxUpdates); + + if (attackTimer == -1 || time < 25) { - if (!CanHit && !postSwing) + if (Owner.HeldItem.type != ItemType() || Main.mapFullscreen || Owner.mouseInterface || Owner.dead) { - if (mousePos.X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; + Projectile.Kill(); + return; } + } + else + Owner.itemTime = Owner.itemAnimation = 5; + #region Not Swinging + if (attackTimer < 0) // When the sword isn't swinging + { + Timers(); + + float lerp = Utils.GetLerpValue(cooldown, -1, attackTimer, true); + + float lerpSpeed = 0.2f / Projectile.MaxUpdates; + float maxAngle = MathHelper.PiOver4; + if (swingCount % 2 == 0) + angledHold = MathHelper.Lerp(angledHold, maxAngle, lerpSpeed); else + angledHold = MathHelper.Lerp(angledHold, -maxAngle, lerpSpeed); + + 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 ((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 = -MathHelper.Pi * swingDir; + float end = -MathHelper.PiOver4 * 3 * swingDir; + bladeRot = MathHelper.Lerp(start, end, CalamityUtils.EaseInOutExp(lerp2, 2f, 2f)); + + if (Owner.controlUseItem && lerp > 0.9f) + performSwing = true; } - - - Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f), 0.1f); + return; + } + #endregion - if (AnimationProgress < (useAnim / 3)) + 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 = -MathHelper.PiOver4 * 3 * swingDir; + float end = MathHelper.Pi * swingDir; + bladeRot = MathHelper.Lerp(start, end, CalamityUtils.EaseInOutExp(lerp, 5f, 3f)); + + if (lerp > 0.3f && lerp < 0.8f) { - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; - CanHit = false; - postSwing = false; - if (AnimationProgress == 0) - { - doSwing = false; - Projectile.ai[1] = -Projectile.ai[1]; - } - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction), 0.2f); - } - else - { - if (!finalFlip) - { - FlipAsSword = Owner.direction < 0 ? true : false; - } + Vector2 dustPosition = Projectile.Center + Projectile.velocity * 78 * Projectile.scale; + Vector2 swingVel = Projectile.velocity.RotatedBy(MathHelper.PiOver2 * (swingCount % 2 == 0 ? -1 : 1) * Owner.direction); + Dust dust = Dust.NewDustPerfect(dustPosition, DustID.Pearlwood); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.85f, 1.3f); + dust.velocity = swingVel.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.5f, 2.5f); - float time = (AnimationProgress) - (useAnim / 3); - float timeMax = useAnim - (useAnim / 3); - - if (time == (int)(timeMax * 0.4f)) - { - SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.35f, -0.55f) }, Projectile.Center); - } - if ( time > (int)(timeMax * 0.2f) && time < (int)(timeMax * 0.85f)) - { - CanHit = true; - - Vector2 particleVel = new Vector2(0, 7 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)); - Vector2 particlePos = Owner.Center + (new Vector2(Main.rand.Next(10, 90), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))); - - Dust dust = Dust.NewDustPerfect(particlePos, DustID.Pearlwood); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.85f, 1.3f); - dust.velocity = -particleVel.RotatedByRandom(0.2f); - } + bool fall = Main.rand.NextBool(8); + Dust dust2 = Dust.NewDustPerfect(dustPosition, ModContent.DustType(), swingVel * Main.rand.NextFloat(3.5f, 5.5f)); + dust2.scale = Main.rand.NextFloat(0.65f, 0.85f); + dust2.noGravity = fall ? false : true; + dust2.color = Color.Chartreuse; + if (!fall) + dust2.fadeIn = 0.9f; 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 < (Owner.Calamity().mouseRight ? 3 : 2); i++) - { - Vector2 dustPos = Owner.Center + (new Vector2(90, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)); - Dust dust2 = Dust.NewDustPerfect(dustPos, i == 2 ? 278 : DustID.JungleTorch, Utils.DirectionTo(Owner.Center, dustPos) * Main.rand.NextFloat(1.2f, 2.5f)); - dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * (Owner.Calamity().mouseRight ? 1.3f : 1); - dust2.noGravity = i == 2 ? false : true; - dust2.color = i == 2 ? Color.Chartreuse : default; - } - } + dust.velocity.Y = 1.5f; + dust2.fadeIn = -0.5f; + } + } - } - ArmRotationOffset = MathHelper.ToRadians(-140f); - ArmRotationOffsetBack = MathHelper.ToRadians(-140f); - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) - Projectile.numHits -= 1; - - SoundStyle fire = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 3); - SoundEngine.PlaySound(fire with { Volume = 0.65f, Pitch = -0.2f }, Projectile.Center); - SoundEngine.PlaySound(SoundID.DrumTomHigh with { Volume = 0.45f, Pitch = -0.9f }, Projectile.Center); - - target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(BuffID.Poisoned, 90); - - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 7.5f * (Owner.Calamity().mouseRight ? 2.5f : 1), true); - - if (Owner.Calamity().mouseRight) - { - Owner.SetScreenshake(1.2f); - - SoundStyle fire3 = new("CalamityMod/Sounds/Item/DampExplosion"); - SoundEngine.PlaySound(fire3 with { Volume = 0.35f, Pitch = 0.7f }, Projectile.Center); - for (int i = 0; i < MathHelper.Clamp(15 - Projectile.numHits * 3, 2, 15); i++) + if (lerp > 0.5f) // Halfway through make the hitbox and sound { - bool dType = i % 4 == 0; - Dust dust2 = Dust.NewDustPerfect(target.Center, dType ? 278 : DustID.JungleTorch, launchVel.RotatedByRandom(0.5f) * Main.rand.NextFloat(3.5f, 7f) * (dType ? 2 : 1)); - dust2.scale = Main.rand.NextFloat(0.65f, 1.35f) * (dType ? 0.7f : 1f); - dust2.noGravity = true; - dust2.color = dType ? Color.Chartreuse : default; + if (makeSound) + { + enabledHitbox = 10; + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.35f, -0.55f) }, Projectile.Center); + makeSound = false; + } } - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 playerLaunchVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * 10; - Owner.velocity = playerLaunchVel; - } - - for (int i = 0; i < MathHelper.Clamp(6 - Projectile.numHits * 2, 2, 6); i++) - { - Dust dust2 = Dust.NewDustPerfect(target.Center, Main.rand.NextBool(5) ? DustID.JungleTorch : 79, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.7f)); - dust2.scale = Main.rand.NextFloat(0.75f, 1.25f); - dust2.noGravity = true; + #endregion } + Timers(); + } + public void Timers() + { + time++; + // Only increment the attack animation when on cooldown or when allowed to swing + if ((attackTimer < fireRate && performSwing) || attackTimer < -1) + attackTimer++; + if (rumble > 0) + rumble -= 0.2f; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + if (Projectile.numHits == 0) + { + Owner.SetScreenshake(2f); + + SoundStyle bash1 = new("CalamityMod/Sounds/Item/DampExplosion"); + SoundEngine.PlaySound(bash1 with { Volume = 0.35f, Pitch = 0.7f }, Projectile.Center); + SoundStyle bash2 = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 3); + SoundEngine.PlaySound(bash2 with { Volume = 0.65f, Pitch = -0.2f }, Projectile.Center); + SoundEngine.PlaySound(SoundID.DrumTomHigh with { Volume = 0.45f, Pitch = -0.9f }, Projectile.Center); + + Vector2 playerLaunchVel = -toMouse * 10; + Owner.velocity = playerLaunchVel; + rumble = 20; + } + + target.AddBuff(ModContent.BuffType(), 300); + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + target.MoveNPC(launchVel, 14f, true); + + for (int i = 0; i < MathHelper.Clamp(15 - Projectile.numHits * 3, 2, 15); i++) + { + bool dType = i % 4 == 0; + Dust dust = Dust.NewDustPerfect(target.Center, !dType ? DustID.Pearlwood : ModContent.DustType(), launchVel.RotatedByRandom(dType ? 0.2f : 0.5f) * Main.rand.NextFloat(2.5f, 7f) * (dType ? 3 : 1)); + dust.scale = Main.rand.NextFloat(0.65f, 1.05f) * ((dType || Main.rand.NextBool(3)) ? 2.2f : 1f); + dust.noGravity = true; + dust.color = dType ? Color.Chartreuse : default; + if (dType) + dust.fadeIn = 1.7f; + } + float minMult = 0.3f; int hitsToMinMult = 5; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult * (Owner.Calamity().mouseRight ? 2f : 1); + 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) - { - Asset tex = ModContent.Request(Texture); + if (time < 3) + return false; - float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Melee/Basher").Value; + Texture2D swoosh = ModContent.Request("CalamityMod/Particles/VerticalSmearThin").Value; - for (int i = 0; i < 8; i++) - { - Color auraColor = Color.Chartreuse with { A = 0 } * 0.35f * fadeIn; - Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 8 * fadeIn; - Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset + new Vector2(0, Owner.gfxOffY), tex.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)); - } + 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; - 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)); - } + Vector2 placeAdjust = (drawRotation + MathHelper.PiOver2).ToRotationVector2() * 2.5f; + Color clr = Color.Tan; + int swingCountFlip = (swingCount % 2 == 0 ? 1 : 3) + Owner.direction == 0 ? 2 : 0; + Vector2 vel2 = Projectile.velocity.RotatedBy(MathHelper.PiOver2); + float extraRot = MathHelper.PiOver4 * 1.2f * (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)); + + Main.EntitySpriteDraw(swoosh, drawPosition + Projectile.velocity.RotatedBy(extraRot) * 12.5f, null, clr with { A = 0 } * bladefx * 0.4f, swooshDrawRotation, swoosh.Size() * 0.5f, Projectile.scale * 0.5f, swooshFlipSprite); //flipSprite | (swingCount % 2 == 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally) + + Main.EntitySpriteDraw(texture, drawPosition + placeAdjust + Main.rand.NextVector2Circular(rumble, rumble), null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); // The holdout + return false; } - public override void ResetStyle() + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) { + overPlayers.Add(index); } } } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 20c261a77e..0db89dd408 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -134,7 +134,26 @@ namespace CalamityMod ret += best - 1f; return ret; } + /// + /// Calculates and returns the player's total melee scale boosts. This is used mostly for melee holdouts. + /// + /// If the item scale of the players held item should be added to the calculation.
+ /// Should be disabled for anything that doesn't lock you into holding one item. + /// + public static float GetMeleeScale(this Player player, bool addHeldItemScale = true) + { + float baseScale = 1; + player.ApplyMeleeScale(ref baseScale); // Gets vanilla's glove scale boosts + // Xyk 3MARCH2026: Will be implemented better by Doze eventually + if (addHeldItemScale) + baseScale += (player.HeldItem.scale - 1); + if (player.HasBuff(BuffID.Tipsy)) + baseScale += 0.15f; + + + return baseScale; + } public static float GetAmmoCostReduction(this Player player) { // Tally up all possible vanilla effects.