diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 2aa2e72970..2a5c4cd5f2 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Effects // Clips a sprite along a fixed plane. Used by Stream Gouge to have half-spears come out of portals. internal static Effect IntersectionClipShader; - // Used by Dom's Bladecrest Oathsword. Appears to govern the swing animation. + // Was previously used by Dom's Bladecrest Oathsword. Appears to govern the swing animation. internal static Effect LocalLinearTransformationShader; // UNUSED -- Probably leftover from Dominic's experiments with applying shaders to primitives (arbitrary GPU-rendered triangles) diff --git a/Items/Weapons/Melee/BladecrestOathsword.cs b/Items/Weapons/Melee/BladecrestOathsword.cs index c2b4558133..24ede5b31f 100644 --- a/Items/Weapons/Melee/BladecrestOathsword.cs +++ b/Items/Weapons/Melee/BladecrestOathsword.cs @@ -37,7 +37,10 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { throwCount++; - Projectile.NewProjectile(source, player.MountedCenter, velocity, type, damage, knockback, player.whoAmI, 0, throwCount); + int useSpeed = (int)MathHelper.Clamp((Item.useTime / 3.5f), 1, 100); + Projectile blade = Projectile.NewProjectileDirect(source, player.MountedCenter, velocity, type, damage, knockback, player.whoAmI, 0, throwCount); + blade.localAI[2] = useSpeed; + blade.timeLeft += useSpeed; return false; } } diff --git a/Items/Weapons/Melee/OldLordClaymore.cs b/Items/Weapons/Melee/OldLordClaymore.cs index 21913884b1..8765142213 100644 --- a/Items/Weapons/Melee/OldLordClaymore.cs +++ b/Items/Weapons/Melee/OldLordClaymore.cs @@ -1,39 +1,36 @@ -using Terraria; +using CalamityMod.Items.BaseItems; +using CalamityMod.Projectiles.Melee; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { [LegacyName("OldLordOathsword")] - public class OldLordClaymore : ModItem, ILocalizedModType + public class OldLordClaymore : CustomUseProjItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public bool RMBchannel = false; public override void SetDefaults() { Item.width = 70; Item.height = 70; - Item.damage = 60; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 34; - Item.useTime = 34; - Item.channel = true; - Item.useStyle = ItemUseStyleID.Swing; + Item.damage = 202; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = Item.useTime = 90; // Yes it's actually supposed to be this slow + + Item.useStyle = ItemUseStyleID.Shoot; + Item.shoot = ModContent.ProjectileType(); Item.useTurn = true; - Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; + Item.knockBack = 10f; Item.autoReuse = true; Item.noUseGraphic = true; + Item.noMelee = true; Item.channel = true; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; } - - public override bool AltFunctionUse(Player player) => true; - - public override bool? CanHitNPC(Player player, NPC target) => false; - - public override bool CanHitPvp(Player player, Player target) => false; + public override bool MeleePrefix() => true; } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index d84a5780e5..f11f26fa65 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -191,12 +191,12 @@ Basher: { BladecrestOathsword: { DisplayName: Bladecrest Oathsword Tooltip: -''' -Throw a sharp blade that impales and slows enemies -Up to three blades can impale an enemy at a time -Hitting impaled guys with a sword beyond the max amount launches the oldest one out -[c/df0049:'Secret Stone? Demon King?] -''' + ''' + Throw a sharp blade that impales and slows enemies + Up to three blades can impale an enemy at a time + Hitting impaled guys with a sword beyond the max amount launches the oldest one out + [c/df0049:'Secret Stone? Demon King?] + ''' } BlightedCleaver: { @@ -898,9 +898,8 @@ OldLordClaymore: { DisplayName: Old Lord Claymore Tooltip: ''' - Holding rapidly absorbs energy into the blade until it is charged - Press while charged to fly in the direction of the cursor - Using the lunge resets the blade's charge to zero +Swings a slow powerful sword that sets enemies ablaze and greatly knocks them back +[c/df4420:'My ultra for fuuuuu YEAAAAAAAAAAAAAAA And my father sucks rmembamebamema that one whfngmssjjamhrhrh] ''' } diff --git a/Particles/SemiCircularSmearVertical2.png b/Particles/SemiCircularSmearVertical2.png new file mode 100644 index 0000000000..75d343938e Binary files /dev/null and b/Particles/SemiCircularSmearVertical2.png differ diff --git a/Projectiles/Melee/BladecrestOathswordThrownBlade.cs b/Projectiles/Melee/BladecrestOathswordThrownBlade.cs index 37683617c0..10088a4f6f 100644 --- a/Projectiles/Melee/BladecrestOathswordThrownBlade.cs +++ b/Projectiles/Melee/BladecrestOathswordThrownBlade.cs @@ -1,19 +1,11 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; -using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee @@ -23,7 +15,7 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Items/Weapons/Melee/BladecrestOathsword"; - public int ChargeupTime = 15; + public int ChargeupTime => (int)Projectile.localAI[2]; public int Lifetime = 100; public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime; public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime); @@ -264,13 +256,13 @@ namespace CalamityMod.Projectiles.Melee stuckInTarget = true; impalePos = Projectile.Center - stabbedTarget.Center; - stuckTimer = 1500; + stuckTimer = 3600; } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - float minMult = 0.25f; - int hitsToMinMult = 6; + float minMult = 0.4f; + int hitsToMinMult = 8; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult * (exitedTarget ? 1.15f : 1f); } diff --git a/Projectiles/Melee/OathswordFlame.cs b/Projectiles/Melee/OathswordFlame.cs deleted file mode 100644 index 54f9ef08c1..0000000000 --- a/Projectiles/Melee/OathswordFlame.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class OathswordFlame : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.tileCollide = true; - Projectile.timeLeft = 240; - Projectile.Opacity = 0f; - Projectile.DamageType = DamageClass.Melee; - } - - public override void AI() - { - Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.08f, 0f, 1f); - CalamityUtils.HomeInOnNPC(Projectile, false, 700f, 15f, 10f); - } - - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, Projectile.alpha) * Projectile.Opacity; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.OnFire, 180); - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - - Projectile.ExpandHitboxBy(100); - for (int k = 0; k < 10; k++) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PinkFairy, Projectile.oldVelocity.X * 2.5f, Projectile.oldVelocity.Y * 2.5f); - } - } -} diff --git a/Projectiles/Melee/OathswordFlame.png b/Projectiles/Melee/OathswordFlame.png deleted file mode 100644 index 53c0486b31..0000000000 Binary files a/Projectiles/Melee/OathswordFlame.png and /dev/null differ diff --git a/Projectiles/Melee/OldLordClaymoreHoldout.cs b/Projectiles/Melee/OldLordClaymoreHoldout.cs new file mode 100644 index 0000000000..3893e6d9d7 --- /dev/null +++ b/Projectiles/Melee/OldLordClaymoreHoldout.cs @@ -0,0 +1,258 @@ +using System; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class OldLordClaymoreHoldout : BaseCustomUseStyleProjectile, ILocalizedModType + { + public override int AssignedItemID => ModContent.ItemType(); + + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Melee/OldLordClaymore"; + public float hitboxMult = 1.3f; + public override float HitboxOutset => 60; + + public override Vector2 HitboxSize => new Vector2(105, 105) * hitboxMult * Projectile.scale; + public override float HitboxRotationOffset => MathHelper.ToRadians(-45); + + public override Vector2 SpriteOrigin => new(-3, 70); + 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 playSwingSound = true; + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + } + public override void OnSpawn(IEntitySource source) + { + CanHit = false; + Projectile.knockBack = 0; + Projectile.scale = 1; + Projectile.ai[1] = -1; + base.OnSpawn(source); + // 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 + { + mousePos = Owner.Calamity().mouseWorld; + } + + if (CanHit) + fadeIn = MathHelper.Lerp(fadeIn, 1, 0.5f); + else + fadeIn = MathHelper.Lerp(fadeIn, 0, 0.4f); + + + if (!doSwing) + { + 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; + playSwingSound = true; + } + else + { + if (!CanHit && !postSwing) + { + 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; + } + + + Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f), 0.1f); + + if (AnimationProgress < (useAnim / 1.5f)) + { + // 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 * (1 + (Utils.GetLerpValue(useAnim * 0.7f, useAnim, Animation, true)) * 0.35f)), 0.2f); + } + else + { + if (!finalFlip) + { + FlipAsSword = Owner.direction < 0 ? true : false; + } + + float time = (AnimationProgress) - (useAnim / 3); + float timeMax = useAnim - (useAnim / 3); + + if (time >= (int)(timeMax * 0.4f) && playSwingSound) + { + SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordSwing", 2); + SoundEngine.PlaySound(swing with { Volume = 0.85f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); + SoundStyle swing2 = new("CalamityMod/Sounds/Item/HeavySwing"); + SoundEngine.PlaySound(swing2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(0.4f, 0.5f) }, Projectile.Center); + playSwingSound = false; + } + if (time > (int)(timeMax * 0.2f) && time < (int)(timeMax * 0.75f)) + { + CanHit = true; + + 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(10, 90), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))); + + Dust dust = Dust.NewDustPerfect(particlePos, 79); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.85f, 1.3f); + dust.velocity = -particleVel.RotatedByRandom(0.2f); + } + 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 < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Owner.Center + (new Vector2(100, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), ModContent.DustType(), Vector2.One.RotatedByRandom(MathHelper.Pi) * 0.6f, 0, default, Main.rand.NextFloat(1.15f, 1.5f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Orange :Color.OrangeRed; + } + float randRot = Main.rand.NextFloat(-30, -60); + Vector2 dustVel = (new Vector2(0, 8 * -Projectile.ai[1] * Owner.direction)).RotatedBy(FinalRotation + MathHelper.ToRadians(randRot)); + + GeneralParticleHandler.SpawnParticle(new SparkParticle(Owner.Center + (new Vector2(100, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), dustVel, false, 23, Main.rand.NextFloat(0.4f, 0.8f), Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed)); + } + } + } + + 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; + + target.AddBuff(BuffID.OnFire3, 180); + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + CalamityUtils.MoveNPC(target, launchVel, 12, true); + + int dustNum = (int)MathHelper.Clamp(12 - Projectile.numHits * 3, 3, 12); + for (int i = 0; i < dustNum; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + int dustStyle = 278; + Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle, Projectile.velocity); + dust2.scale = Main.rand.NextFloat(1.2f, 1.4f) - Math.Abs(variance); + dust2.velocity = (launchVel * 25).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool() ? Color.Orange : Color.OrangeRed; + } + + if (Projectile.numHits == 0) + { + Owner.Calamity().GeneralScreenShakePower = 5f; + + SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordStrongImpact"); + SoundEngine.PlaySound(swing with { Volume = 0.95f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.3f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult * (Owner.Calamity().mouseRight ? 2.5f : 1); + } + 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); + Asset swoosh = ModContent.Request("CalamityMod/Particles/VerticalSmearLarge"); + + float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; + + for (int i = 0; i < 20; i++) + { + Color auraColor = Color.OrangeRed with { A = 0 } * 0.18f * fadeIn; + Vector2 drawOffset = (MathHelper.TwoPi * i / 20f).ToRotationVector2() * 4 * 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)); + } + + Main.EntitySpriteDraw(swoosh.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), null, Color.Orange with { A = 0 } * fadeIn * 0.2f, (FinalRotation + MathHelper.ToRadians(45)) + MathHelper.ToRadians(Projectile.ai[1] == 1 ? -95 : 95) * -Owner.direction, swoosh.Size() * 0.5f, Projectile.scale * 0.33f * hitboxMult, SpriteEffects.None); + Main.EntitySpriteDraw(swoosh.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), null, Color.OrangeRed with { A = 0 } * fadeIn * 0.5f, (FinalRotation + MathHelper.ToRadians(45)) + MathHelper.ToRadians(Projectile.ai[1] == 1 ? -70 : 70) * -Owner.direction, swoosh.Size() * 0.5f, Projectile.scale * 0.25f * hitboxMult, 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)); + } + return false; + } + public override void ResetStyle() + { + } + } +} diff --git a/Projectiles/Melee/OldLordClaymoreProj.cs b/Projectiles/Melee/OldLordClaymoreProj.cs deleted file mode 100644 index 4a0e371bd9..0000000000 --- a/Projectiles/Melee/OldLordClaymoreProj.cs +++ /dev/null @@ -1,343 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class OldLordClaymoreProj : BaseIdleHoldoutProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public enum SwingState : byte - { - Default, - Swinging, - Channeling, - Spinning - } - - public int Direction = 1; - public SwingState CurrentState; - public ref float ChargeTime => ref Projectile.ai[0]; - public ref float GeneralTime => ref Projectile.ai[1]; - public ref float PostSwingRepositionDelay => ref Projectile.localAI[0]; - public ref bool RMBChannel => ref (Owner.HeldItem.ModItem as OldLordClaymore).RMBchannel; - public bool LMBUse => Owner.altFunctionUse != 2 && !RMBChannel && Owner.itemAnimation > 0; - public ref float ChargePower => ref Projectile.localAI[1]; - - public const int MaxChargeTime = 90; - public override string Texture => "CalamityMod/Items/Weapons/Melee/OldLordClaymore"; - public override int AssociatedItemID => ModContent.ItemType(); - public override int IntendedProjectileType => ModContent.ProjectileType(); - public override bool? CanDamage() => (CurrentState == SwingState.Default || CurrentState == SwingState.Channeling) ? false : base.CanDamage(); - - public override void SetStaticDefaults() - { - base.SetStaticDefaults(); // DO NOT REMOVE THIS - - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 70; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = 90000; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 12; - Projectile.noEnchantmentVisuals = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Direction); - writer.Write(PostSwingRepositionDelay); - writer.Write(ChargePower); - writer.Write((byte)CurrentState); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - Direction = reader.ReadInt32(); - PostSwingRepositionDelay = reader.ReadSingle(); - ChargePower = reader.ReadSingle(); - CurrentState = (SwingState)reader.ReadByte(); - } - - public override void SafeAI() - { - // Handle right click behaviors. - if (Main.myPlayer == Projectile.owner) - Owner.Calamity().rightClickListener = true; - - if (!Owner.Calamity().mouseRight) - RMBChannel = false; - else - RMBChannel = true; - - // Initialize the animation max time if necessary. - if (Owner.itemAnimationMax == 0) - Owner.itemAnimationMax = (int)(Owner.ActiveItem().useAnimation * Owner.GetAttackSpeed()); - - // Decide the current phase state of the blade. - DecideCurrentState(); - - // Glue the sword to its owner. - Projectile.position = Owner.RotatedRelativePoint(Owner.MountedCenter, true) - Projectile.Size / 2f; - - // Use the direction of the owner when not spinning. - if (CurrentState != SwingState.Spinning) - Direction = Owner.direction; - - float swingCompletion = Owner.itemAnimation / (float)Owner.itemAnimationMax; - float swingSpeedInterpolant = Utils.GetLerpValue(1f, 0.8f, swingCompletion, true) * Utils.GetLerpValue(-0.11f, 0.12f, swingCompletion, true); - float swingInterpolant = (float)Math.Sin(Math.Pow(swingCompletion, 1.15) * MathHelper.TwoPi); - if (swingInterpolant < 0f) - { - swingInterpolant = -(float)Math.Pow(-swingInterpolant, 0.9); - swingInterpolant = MathHelper.Lerp(swingInterpolant, -1f, 0.7f); - } - else - { - swingInterpolant = (float)Math.Pow(swingInterpolant, 0.9); - swingInterpolant = MathHelper.Lerp(swingInterpolant, 1f, 0.7f); - } - - float baseRotation = swingInterpolant * Direction * 0.96f; - - // Reset the owner's rotation. - Owner.fullRotation = 0f; - - // Do a spin dash if a swing is done with full power. - if (CurrentState == SwingState.Spinning) - { - swingSpeedInterpolant = 1f; - baseRotation = MathHelper.WrapAngle(swingCompletion * Direction * MathHelper.Pi * -3f); - Owner.fullRotation = baseRotation; - Owner.fullRotationOrigin = Owner.Center - Owner.position; - - // Emit fire dust. - for (int i = 0; i < 4; i++) - { - Vector2 dustSpawnPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Main.rand.NextFloat(Projectile.width) + Main.rand.NextVector2Circular(6f, 6f); - Vector2 dustVelocity = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Main.rand.NextFloat(6f) + Main.rand.NextVector2Circular(2.4f, 2.4f); - - Dust fire = Dust.NewDustPerfect(dustSpawnPosition, 6, dustVelocity); - fire.scale = 1.7f; - fire.noGravity = true; - } - - // Release flames. - if (Main.myPlayer == Projectile.owner && GeneralTime % 6f == 5f) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2CircularEdge(8f, 8f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); - - if (Main.myPlayer == Projectile.owner) - { - // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Owner.velocity = Vector2.Lerp(Owner.velocity, Owner.SafeDirectionTo(Main.MouseWorld) * 16f, 0.125f); - NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, Main.myPlayer); - } - - // Stop charging once the item animation has completed. - if (Owner.itemAnimation <= 1) - { - ChargePower = 0f; - CurrentState = 0f; - } - } - - // Hold the blade upwards if not firing. - if (CurrentState == SwingState.Default) - { - Projectile.Opacity = 0f; - - if (PostSwingRepositionDelay > 0f) - PostSwingRepositionDelay--; - else - baseRotation = (MathHelper.PiOver2 + 0.36f) * -Direction; - - // Disable afterimages. - Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - } - else - { - PostSwingRepositionDelay = PostSwingRepositionDelay == -1f ? 0f : 12f; - - // See the Bladecrest Oathsword Projectile code. - Projectile.Opacity = 1f; - } - - // Raise the blade and do charge effects upwards if channeling. - float horizontalBladeOffset = -4f; - float chargeInterpolant = Utils.GetLerpValue(0f, 65f, ChargeTime, true); - if (CurrentState == SwingState.Channeling) - { - baseRotation = MathHelper.PiOver2 * -Direction; - horizontalBladeOffset = MathHelper.Lerp(horizontalBladeOffset, 6f, (float)Math.Pow(chargeInterpolant, 0.3)); - if (Owner.itemAnimation < 2) - Owner.itemAnimation = 2; - PostSwingRepositionDelay = -1f; - - ChargePower = MathHelper.Clamp(ChargePower + 1f, 0f, MaxChargeTime); - - // Disable afterimages. - Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - - ChargeTime++; - } - else - ChargeTime = 0f; - - float idealRotation = baseRotation; - Owner.itemRotation = idealRotation; - - idealRotation += MathHelper.PiOver4; - if (Direction == -1) - idealRotation += MathHelper.Pi; - - // Define rotation. - Projectile.rotation = Projectile.rotation.AngleTowards(idealRotation, swingSpeedInterpolant * 0.45f).AngleLerp(idealRotation, swingSpeedInterpolant * 0.2f); - - // Decide how far out the blade should go. - float bladeOffsetFactor = 0.5f + chargeInterpolant * 0.3f; - if (chargeInterpolant <= 0f) - bladeOffsetFactor += Utils.GetLerpValue(0.5f, 0.7f, swingCompletion, true) * Utils.GetLerpValue(1f, 0.7f, swingCompletion, true) * 0.45f; - - // Offset the blade so that the handle is attached to the owner's hand. - Vector2 bladeOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.width * bladeOffsetFactor; - if (Owner.itemAnimation <= 0 || chargeInterpolant > 0f) - bladeOffset += new Vector2(Direction * horizontalBladeOffset, 8f).RotatedBy(Owner.fullRotation) * (1f - PostSwingRepositionDelay / 12f); - Projectile.position += bladeOffset; - - // Create charge dust. - if (CurrentState == SwingState.Channeling) - { - int chargeDustCount = (int)Math.Round(MathHelper.Lerp(1f, 3f, ChargePower / MaxChargeTime)); - if (ChargePower >= MaxChargeTime) - chargeDustCount = 0; - - for (int i = 0; i < chargeDustCount; i++) - { - Vector2 dustSpawnPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Main.rand.NextFloat(Projectile.width) + Main.rand.NextVector2Circular(6f, 6f); - Vector2 dustVelocity = bladeOffset.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(6f) + Main.rand.NextVector2Circular(2.4f, 2.4f); - - Dust dust = Dust.NewDustPerfect(dustSpawnPosition, 267, dustVelocity); - dust.color = Main.rand.NextBool(4) ? Color.Purple : Color.Red; - dust.scale = Main.rand.NextFloat(0.85f, 1.2f); - dust.noGravity = true; - } - - // Create a burst of charge dust before becoming fully charged. - if (ChargePower == MaxChargeTime - 1f) - { - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int i = 0; i < 30; i++) - { - Vector2 dustSpawnPosition = Projectile.Center; - Vector2 dustVelocity = (MathHelper.TwoPi * i / 30f).ToRotationVector2() * 5f; - Dust dust = Dust.NewDustPerfect(dustSpawnPosition, 267, dustVelocity); - dust.color = Color.Violet; - dust.scale = 1.4f; - dust.noGravity = true; - } - } - } - - GeneralTime++; - } - - public void DecideCurrentState() - { - // Reset the state of the weapon if the player stops using it. This cannot reset a dash. - if ((Owner.itemAnimation <= 0 || (!RMBChannel && CurrentState == SwingState.Channeling)) && CurrentState != SwingState.Spinning) - { - Owner.itemAnimation = 0; - CurrentState = SwingState.Default; - } - - // Switch to the swing state as necessary. This cannot happen while channeling or spinning. - if (CurrentState == 0f && !RMBChannel && Owner.itemAnimation > 0 && ChargePower < MaxChargeTime) - CurrentState = SwingState.Swinging; - - // Switch to the channel state as necessary. This cannot happen while swinging or spinning. - if ((CurrentState == SwingState.Default || CurrentState == SwingState.Swinging) && RMBChannel) - CurrentState = SwingState.Channeling; - - // Switch to the spinning charge state. This can only be done while in the default state. - if (CurrentState == 0f && Owner.itemAnimation > 0 && ChargePower >= MaxChargeTime) - { - Owner.fallStart = (int)(Owner.position.Y / 16f); - - if (CurrentState != SwingState.Spinning) - { - SoundEngine.PlaySound(SoundID.DD2_BookStaffCast, Owner.Center); - CurrentState = SwingState.Spinning; - Projectile.netUpdate = true; - } - } - } - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.Opacity <= 0f) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, 2, lightColor); - - Main.spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f)); - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(0f); - if (ChargePower >= MaxChargeTime) - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(0.7f - ((Main.GlobalTimeWrappedHourly * (int)(MaxChargeTime * 0.5f)) % (MaxChargeTime * 0.5f) / MaxChargeTime)); - GameShaders.Misc["CalamityMod:BasicTint"].Apply(); - - var texture = ModContent.Request("CalamityMod/Items/Weapons/Melee/OldLordClaymore").Value; - - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, Projectile.Size / 2f, Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); - Main.spriteBatch.ExitShaderRegion(); - - return false; - } - - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - if (CurrentState == SwingState.Spinning) - hitbox = new Rectangle((int)Owner.position.X - 35, (int)Owner.position.Y - 35, 102, 118); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone); - NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone); - PlayerLoader.OnHitNPC(Owner, target, hit, damageDone); - - if (CurrentState == SwingState.Spinning) - { - Owner.immuneNoBlink = true; - Owner.immune = true; - Owner.immuneTime = 12; - for (int k = 0; k < Owner.hurtCooldowns.Length; k++) - Owner.hurtCooldowns[k] = Owner.immuneTime; - } - } - - public override void OnKill(int timeLeft) => Owner.fullRotation = 0f; - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); - } - } -} diff --git a/Sounds/Item/DemonSwordInsaneImpact.ogg b/Sounds/Item/DemonSwordInsaneImpact.ogg index a45250d980..4d4315b2a7 100644 Binary files a/Sounds/Item/DemonSwordInsaneImpact.ogg and b/Sounds/Item/DemonSwordInsaneImpact.ogg differ diff --git a/Sounds/Item/DemonSwordStrongImpact.ogg b/Sounds/Item/DemonSwordStrongImpact.ogg index f732f17efd..b349e0a947 100644 Binary files a/Sounds/Item/DemonSwordStrongImpact.ogg and b/Sounds/Item/DemonSwordStrongImpact.ogg differ diff --git a/Systems/Collections/PierceResistExceptionList.cs b/Systems/Collections/PierceResistExceptionList.cs index 493e12a388..dc85e6fabe 100644 --- a/Systems/Collections/PierceResistExceptionList.cs +++ b/Systems/Collections/PierceResistExceptionList.cs @@ -68,6 +68,7 @@ namespace CalamityMod.Systems.Collections ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), diff --git a/Systems/Collections/ProjectileDestroyExceptionsList.cs b/Systems/Collections/ProjectileDestroyExceptionsList.cs index 6dab54e61f..10d8eca909 100644 --- a/Systems/Collections/ProjectileDestroyExceptionsList.cs +++ b/Systems/Collections/ProjectileDestroyExceptionsList.cs @@ -65,6 +65,7 @@ namespace CalamityMod.Systems.Collections ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 83aad329f8..b8070b7235 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -740,7 +740,21 @@ namespace CalamityMod return true; return false; } - + /// + /// Moves an NPC, usually used as custom knockback + /// + /// The NPC being moved. + /// Whether or not NPC's that normally have knockback immunity can be moved around. + public static void MoveNPC(this NPC target, Vector2 direction, float strength, bool ignoreKBImmune = false) + { + if (target.CanBeMoved(ignoreKBImmune)) + { + // Launch + Vector2 launchVel = direction.SafeNormalize(Vector2.UnitX) * strength; + float knockbackMult = Utils.Remap(target.knockBackResist, 0, 1, 0.5f, 1f, false); + target.velocity = launchVel * (knockbackMult > 1 ? (float)Math.Pow(knockbackMult, 10) : knockbackMult); + } + } public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) { if (Main.rand.NextBool(4))