From dc57a9a89d0565227a8b24842efed934209d0023 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sat, 23 Aug 2025 14:16:51 -0400 Subject: [PATCH] Initial --- Balancing/BalancingChangesManager.cs | 3 - CalPlayer/CalamityPlayer.cs | 7 + CalPlayer/CalamityPlayerMiscEffects.cs | 90 +++++ Cooldowns/LucreciaEnergy.cs | 46 +++ Cooldowns/LucreciaEnergy.png | Bin 0 -> 385 bytes Cooldowns/LucreciaEnergyOutline.png | Bin 0 -> 179 bytes Cooldowns/LucreciaEnergyOverlay.png | Bin 0 -> 163 bytes Items/Weapons/Melee/Lucrecia.cs | 53 ++- ...Mods.CalamityMod.Items.Weapons.Melee.hjson | 6 +- .../Mods.CalamityMod.Projectiles.Melee.hjson | 3 + Localization/en-US/Mods.CalamityMod.UI.hjson | 1 + Particles/RoundedStar.png | Bin 0 -> 10680 bytes Particles/RoundedStarParticle.cs | 82 +++++ Projectiles/Melee/DNA.cs | 86 ----- Projectiles/Melee/DNA.png | Bin 678 -> 0 bytes Projectiles/Melee/LucreciaDNATrailCreator.cs | 119 +++++++ Projectiles/Melee/LucreciaDoubleHelix.cs | 153 +++++++++ Projectiles/Melee/LucreciaProj.cs | 314 ++++++++++++++++++ Projectiles/Melee/Shortswords/LucreciaProj.cs | 57 ---- en-US.hjson | 1 + 20 files changed, 859 insertions(+), 162 deletions(-) create mode 100644 Cooldowns/LucreciaEnergy.cs create mode 100644 Cooldowns/LucreciaEnergy.png create mode 100644 Cooldowns/LucreciaEnergyOutline.png create mode 100644 Cooldowns/LucreciaEnergyOverlay.png create mode 100644 Particles/RoundedStar.png create mode 100644 Particles/RoundedStarParticle.cs delete mode 100644 Projectiles/Melee/DNA.cs delete mode 100644 Projectiles/Melee/DNA.png create mode 100644 Projectiles/Melee/LucreciaDNATrailCreator.cs create mode 100644 Projectiles/Melee/LucreciaDoubleHelix.cs create mode 100644 Projectiles/Melee/LucreciaProj.cs delete mode 100644 Projectiles/Melee/Shortswords/LucreciaProj.cs create mode 100644 en-US.hjson diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 03a1819d1b..064a534dba 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -176,9 +176,6 @@ namespace CalamityMod.Balancing // 35% resist to Flying Dragon. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2SquireSonicBoom)))); - // 25% resist to Lucrecia. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); - // 20% resist to Aurora Blazer. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 20a6b950aa..6c34854321 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -273,6 +273,12 @@ namespace CalamityMod.CalPlayer public int deadSunCounter = 6; public int DragonsBreathAudioCooldown = 0; public int DragonsBreathAudioCooldown2 = 0; + public int lucreciaEnergy = 0; + public int lucreciaEnergyTimer = 0; + public bool lucreciaEnergyPaused = false; + public int lucreciaEnergyMax = 100; + public bool lucreciaEnergyMaxSFXPlayed = false; + private int lucreciaParticleTimer = 0; public int PhotoAudioCooldown = 0; public int PhotoTimer = 90; /// Cooldown variable used to add a delay between Anahita's Arpeggio uses. @@ -3220,6 +3226,7 @@ namespace CalamityMod.CalPlayer burningSeaBurnOut = 0; flareGunOverheat = 0; hellbornShots = 0; + lucreciaEnergy = 0; searedPanCounter = 0; searedPanTimer = 0; potionTimer = 0; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 9116c9adbb..28ef6c6a61 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -162,6 +162,9 @@ namespace CalamityMod.CalPlayer // Drawing parameters UpdateDrawingParameters(); + // Handle Lucrecia's passive energy effects + HandleLucreciaEffects(); + // Update all particle sets for items. // This must be done here instead of in the item logic because these sets are not properly instanced // in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items. @@ -367,6 +370,52 @@ namespace CalamityMod.CalPlayer Lighting.AddLight(Player.Center, Color.MediumOrchid.ToVector3()); } + if (Player.HeldItem.type == ModContent.ItemType() && lucreciaEnergy > 0) + { + if (lucreciaEnergy == lucreciaEnergyMax && !lucreciaEnergyPaused) + { + lucreciaEnergyPaused = true; + lucreciaEnergyTimer = 0; + } + + lucreciaEnergyTimer++; + + // If the energy is at max, pause for 180 ticks + if (lucreciaEnergyPaused) + { + if (lucreciaEnergyTimer >= 1 && !lucreciaEnergyMaxSFXPlayed) + { + SoundEngine.PlaySound(SoundID.Item79 with { Volume = 1.6f, Pitch = 0.4f }, Player.Center); + lucreciaEnergyMaxSFXPlayed = true; + + } + // If the pause is Done, resume decrementing. + if (lucreciaEnergyTimer >= 180) + { + lucreciaEnergyPaused = false; + lucreciaEnergyTimer = 0; + lucreciaEnergy--; + } + } + else // Decrementing + { + lucreciaEnergyMaxSFXPlayed = false; + // Once every 6 ticks + if (lucreciaEnergyTimer >= 6) + { + lucreciaEnergy--; + lucreciaEnergyTimer = 0; + } + } + } + else + { + // Reset the timer and pause state if the player isn't holding the weapon. + lucreciaEnergyTimer = 0; + lucreciaEnergyPaused = false; + } + + if (lAmbergris) { if (dashStart) @@ -4509,6 +4558,47 @@ namespace CalamityMod.CalPlayer } #endregion + #region Lucrecia Effects + + public void HandleLucreciaEffects() + { + int lucreciaItemID = ModContent.ItemType(); + if (Player.HeldItem.type == lucreciaItemID && lucreciaEnergy > 0) + { + lucreciaParticleTimer--; + + // If the timer is at or below zero, spawn a particle. + if (lucreciaParticleTimer <= 0) + { + // Reset the timer (spawn rate depends on energy) + lucreciaParticleTimer = (int)(20 - 15 * (lucreciaEnergy / 60)); + + float radius = Main.rand.NextFloat(160f, 190f); // Distance from center + float spawnAngle = Main.rand.NextFloat(MathHelper.TwoPi); // Random angle along the whole radius + + Vector2 spawnPosition = Player.Center + spawnAngle.ToRotationVector2() * radius; + + // Scale opacity with energy + float opacity = lucreciaEnergy / (float)lucreciaEnergyMax; + Color color = Main.rand.NextBool() ? Color.MediumPurple : Color.CornflowerBlue; + color *= opacity; + + if (lucreciaEnergy >= 100) + { + color *= 1.6f; // Brighter + } + + Vector2 dummyVelocity = Vector2.Zero; // We dont want the argument where this is used to have influence on the actual path + float rotationSpeed = 0.04f; + + var particle = new RoundedStarParticle(spawnPosition, dummyVelocity, color, Main.rand.NextFloat(0.05f, 0.065f), Main.rand.Next(30, 60), rotationSpeed, 1f, true, Player.Center, Player.whoAmI); + GeneralParticleHandler.SpawnParticle(particle); + } + } + } + #endregion + + #region Energy Shields private void EnergyShields() { diff --git a/Cooldowns/LucreciaEnergy.cs b/Cooldowns/LucreciaEnergy.cs new file mode 100644 index 0000000000..d783b1e6a5 --- /dev/null +++ b/Cooldowns/LucreciaEnergy.cs @@ -0,0 +1,46 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; +using Terraria; +using Terraria.GameContent; +using Terraria.Localization; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class LucreciaEnergy : CooldownHandler + { + public float CompletionPercentage => MathF.Round(instance.Completion * 100); + private bool IsEmpty => CompletionPercentage == 100; + private float TextXOffset => -5.8f; + private Vector2 TextPosition => new(TextXOffset, 15); + private Color TextColor => Color.MediumPurple; + private Color TextBorderColor = Color.AntiqueWhite; + + public static new string ID => "LucreciaEnergy"; + public override bool CanTickDown => false; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override string Texture => "CalamityMod/Cooldowns/" + ID; + + public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.Purple, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.DarkBlue, Color.SlateGray, instance.Completion); + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().lucreciaEnergy.ToString(), position + TextPosition, TextColor, TextBorderColor); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().lucreciaEnergy.ToString(), position + TextPosition, TextColor, TextBorderColor); + } + } +} diff --git a/Cooldowns/LucreciaEnergy.png b/Cooldowns/LucreciaEnergy.png new file mode 100644 index 0000000000000000000000000000000000000000..9891d6fd0b58093803a9e13976bc94ccb9298ed6 GIT binary patch literal 385 zcmV-{0e=38P)Px$J4r-AR7i=$Vq_!0}Rv_?XMgIZh{s%QRMIljOYKm?GKY)aPAc5d3 zDs~+LY!eW7?k4-%EsL0e>)y`n%$fJz+yN?TIX;}0}$ErMrr>(`4N2d;tKmT^j%}TK@n5rtghE*9b?P=d?>g#4$dRhGESUUnF6}db>eJxp1J0AW8v2WeWCvTo|EB$i6;KWkj f`L5jUZeHm#zW9|C8OpW#00000NkvXXu0mjf1F5cV literal 0 HcmV?d00001 diff --git a/Cooldowns/LucreciaEnergyOutline.png b/Cooldowns/LucreciaEnergyOutline.png new file mode 100644 index 0000000000000000000000000000000000000000..247f332da8e9e3ef339e3cf58eadaf91069df809 GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^Qb4T0!3HFGR%fsRDaPU;cPEB*=VV?2Ik}!Ljv*eM zZ>Kp5ISBGNAN~9O%(L4YI%*cbFv-r{Bc-Go_;hmA^s7y8UwMXXs_wXPF8$;=;g#tJ zuFY5eRqY?K*Y=_o=j(L0C+9hG`xrJHUhwt1`7Q&l#epBM#b%qF@IUme>YKQWamKW+ cr!yr3S+8+SURcK}1#%LDr>mdKI;Vst0H;PqH2?qr literal 0 HcmV?d00001 diff --git a/Cooldowns/LucreciaEnergyOverlay.png b/Cooldowns/LucreciaEnergyOverlay.png new file mode 100644 index 0000000000000000000000000000000000000000..851597883bf2d1c124aea92897c89d454e24f0c9 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Vn8gz!3HE#_5EXk6k~CayA#8@b22Z1oLEm6#}JRs zw^JRt7!){I?*9A#d{@QE6(&YPcQ*4LX7gI&^EBgmci9E0H*9Is7^dalm(Kn@XXbw6 zZGURmg`WL8wtN}$gtK>h9yb=Qj-FW&s$yYaQQm5A@qu;X&u?Dl2?`p@*9)7E04-wh MboFyt=akR{0C8kIOaK4? literal 0 HcmV?d00001 diff --git a/Items/Weapons/Melee/Lucrecia.cs b/Items/Weapons/Melee/Lucrecia.cs index e9a0937621..221727ee90 100644 --- a/Items/Weapons/Melee/Lucrecia.cs +++ b/Items/Weapons/Melee/Lucrecia.cs @@ -1,41 +1,66 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Shortswords; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Lucrecia : ModItem, ILocalizedModType + public class Lucrecia : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); + public override void SetDefaults() { Item.width = 54; Item.height = 54; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 90; + Item.useStyle = ItemUseStyleID.Shoot; + Item.damage = 67; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 30; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 4.2f; + Item.useAnimation = Item.useTime = 34; + Item.shootSpeed = 10f; Item.knockBack = 8.25f; - Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; + + Item.autoReuse = true; + Item.channel = true; + // Item.noMelee = true; + // Item.noUseGraphic = true; + base.SetDefaults(); + } - public override bool MeleePrefix() => true; + public override bool AltFunctionUse(Player player) + { + return true; + } + + + public override void HoldItem(Player player) + { + if (player.Calamity().cooldowns.TryGetValue(LucreciaEnergy.ID, out var cooldown)) + { + cooldown.timeLeft = player.Calamity().lucreciaEnergy; + } + else + { + player.AddCooldown(LucreciaEnergy.ID, 0); + } + } + + // public override bool MeleePrefix() => true; public override void AddRecipes() { CreateRecipe(). AddIngredient(5). - AddIngredient(). + AddIngredient(ItemID.FallenStar, 10). AddIngredient(ItemID.SoulofLight, 5). AddIngredient(ItemID.SoulofNight, 5). AddTile(TileID.MythrilAnvil). diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 12dfdc08ba..b1ec177391 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -800,8 +800,10 @@ Lucrecia: { DisplayName: Lucrecia Tooltip: ''' - Fires a DNA chain - Finesse + [c/9370db:Fires a spiraling darklight shard when swung] + [c/837ce4:Hits with the blade itself build energy] + [c/7489ee:Energy is lost over time but briefly stops depleting after reaching its maximum] + [c/6495f7:Press with maximum energy to fire a double helix comet] ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index cf9b90ba21..235098e2e1 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -306,3 +306,6 @@ MirrorBladeProjectile.DisplayName: Mirror Blade MirrorBladeSlash.DisplayName: Mirror Blade Slash MirrorBladeSlashCreator.DisplayName: Mirror Blade Slash Creator GildedProboscisProj.DisplayName: Gilded Proboscis +LucreciaProj.DisplayName: Lucrecia Proj +LucreciaDoubleHelix.DisplayName: Lucrecia Double Helix +LucreciaSmallProjectile.DisplayName: Lucrecia Small Projectile diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index c18834ec19..503f870d8e 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -119,6 +119,7 @@ Cooldowns: { KillModeCooldown: Kill Mode Cooldown LifeSteal: Life Steal Cooldown LionHeartShield: Energy Shell Cooldown + LucreciaEnergy: Lucrecia Energy MasterChefShieldDurability: MJOLNIR Shield Level MasterChefShieldRecharge: MJOLNIR Shield Recharge NebulousCore: Nebulous Core Cooldown diff --git a/Particles/RoundedStar.png b/Particles/RoundedStar.png new file mode 100644 index 0000000000000000000000000000000000000000..f88faa56012d1ca48188e8179c53f0027f6cb841 GIT binary patch literal 10680 zcmbt)gNFc-Uom0`xm@i*DfwTyHDKbe9pNa&i$awP4(y@To3>N=neGYHvxbm#~Zn%Gh`K4HBs3i~a1 ze8~7SlmpNhGEd}#1!MnxU-gat(<8h?%cXWFhJhvkCL& z?i7WWYe$!zg~(GB02`M}v$7bS8K1Mp7u&^?3Fm03!6*tq;IDtXNwd97+m(=V24PR%`QG9Cu16p!edhW-yjw}|!&;(wg_dq-^6FdNnQ}mht9j|+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;x{iFDw@8SvWs1_W=D;sj>T;>uRbVK?7gdq z4|?IglbD90zsN1mxvke~Pm%-fa>j&~Q7~N2dqZ)xO zNwCyW2FGY?=ZKcc+NE*wX2D+k+Pp+rwc>0xuTzP&oakD2*XiBKeFguS8xUF#E_^{t z+C16#KtoSt29f$@yW%O|^nnTvPY+{e`=+|YAYW)(Q(R#&;@-}PR5(`M=;vZ9YS>~V z>W}qwZ}zG054^gS((4;nqI_#g@oy*i{+z~qg!;2t_C@vVy*!C!)-Qjxa987kxA07{=**XSNn=NGotSJa8 zYHSF12@U6QPOZKQTJqgGMjR}NS34yM+;om`n{Os>^Dhlt5^Anp)QX$kF=;JI$2fNk zJ<>vJx|YPexr9;uI33hm^C^kZ>k4qg*|_Z>=qD6B`IYJP{y*MP1Vz7pJ*CaGE|2$t RQY4>gGSD%F*J!yW{vXZOb>9F0 literal 0 HcmV?d00001 diff --git a/Particles/RoundedStarParticle.cs b/Particles/RoundedStarParticle.cs new file mode 100644 index 0000000000..fbb55e8e3b --- /dev/null +++ b/Particles/RoundedStarParticle.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using CalamityMod.Particles; +using Terraria.ModLoader; +using System; + +namespace CalamityMod.Particles +{ + public class RoundedStarParticle : Particle + { + public override string Texture => "CalamityMod/Particles/RoundedStar"; + + public float RotationSpeed; + public float Deceleration; + + public bool UseSpiralAI; + private int OwnerIndex; + private float InitialRadius; + private float OrbitalAngle; + + public override bool UseCustomDraw => true; + public RoundedStarParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, float rotationSpeed, float deceleration, bool useSpiralAI, Vector2 spiralTarget, int ownerIndex) + { + Position = position; + Velocity = velocity; + Color = color; + Scale = scale; + Lifetime = lifetime; + RotationSpeed = rotationSpeed; + Deceleration = deceleration; + UseSpiralAI = useSpiralAI; + OwnerIndex = ownerIndex; + + if (UseSpiralAI) + { + // Store the initial radius and angle relative to the player + Vector2 directionToPlayer = Position - Main.player[OwnerIndex].Center; + InitialRadius = directionToPlayer.Length(); + OrbitalAngle = directionToPlayer.ToRotation(); + } + } + + public override void Update() + { + if (UseSpiralAI) + { + OrbitalAngle += RotationSpeed; + + float fadeScale = 1f - (Time / (float)Lifetime); + float currentRadius = InitialRadius * fadeScale; + + Vector2 playerCenter = Main.player[OwnerIndex].Center; + + Vector2 newRelativePosition = OrbitalAngle.ToRotationVector2() * currentRadius; + + // Update the particle's position. + Position = playerCenter + newRelativePosition; + } + else + { + // If not using the spiral AI, apply deceleration + Velocity *= Deceleration; + Position += Velocity; + } + + Rotation += RotationSpeed; + Time++; + if (Time >= Lifetime) + Kill(); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + float fade = 1f - (Time / (float)Lifetime); + float scaleFade = Scale * fade; + + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * fade, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0f); + } + } +} diff --git a/Projectiles/Melee/DNA.cs b/Projectiles/Melee/DNA.cs deleted file mode 100644 index 671209f27b..0000000000 --- a/Projectiles/Melee/DNA.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class DNA : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - public static int TotalSegments = 10; - - public override void SetDefaults() - { - Projectile.width = 22; - Projectile.height = 72; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 6; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.ai[1] == 0f) - { - Projectile.alpha -= 100; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.ai[1] = 1f; - - // This projectile normally does not move by itself, so this will manually move it one time only - // This is only for the first segment - if (Projectile.ai[0] == 0f) - { - Projectile.ai[0]++; - Projectile.position += Projectile.velocity; - } - - // Spawn the next segment - if (Main.myPlayer == Projectile.owner && Projectile.ai[0] < TotalSegments) - { - int nextSegment = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Projectile.velocity, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.ai[0] + 1f); - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, nextSegment); - } - } - } - else // Begin fading out - { - int AlphaPerFrame = 15; - Projectile.alpha += AlphaPerFrame; - if (Projectile.alpha == AlphaPerFrame * 14) - { - for (int i = 0; i < 3; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f, 200, default, 1f); - dust.noGravity = true; - dust.velocity *= 0.5f; - } - } - - if (Projectile.alpha >= 255) - Projectile.Kill(); - } - if (Main.rand.NextBool(10)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f); - } - - // This is essential for Vilethorn-type projectiles, as velocity is a stored parameter and isn't supposed to actually move the projectile - public override bool ShouldUpdatePosition() => false; - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); - - public override void OnKill(int timeLeft) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.oldVelocity.X * 0.005f, Projectile.oldVelocity.Y * 0.005f); - } - } -} diff --git a/Projectiles/Melee/DNA.png b/Projectiles/Melee/DNA.png deleted file mode 100644 index 67167a046b78efa07a63ed839bedcb34ae46b5ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 678 zcmV;X0$KfuP)k01`AaAV48eAixYw0zZIc3WG!}^9aP|AOTAPS=-ZO zr#oqRuO-ZMyp{7#Z%^;Jx6MZ4=i&V0dp33ZWTlz%FG-VTK-qx-*gIY}M28ojW{fe9 zGR_VRz)s6XwAFbr<8-`X#tk$m8D`LvKe{lF_<}vf((5eOc_KdRw$3nn5_IX06 z18ulIiD(W0b|Gg0TFqZmBFeQPwfnS z@^S;mb{W|X%uhFMmIG7#j?E6Tn-Y9wU@%e4`#0-z`55z=DV|FQVdk}g@kZob#4^?E zB;#Vh><}Ew!R4xbG#Z(KokKFt4$LuSeS(SiI#55mo5&hRKa;!=~^<*2kdl-nvETSnL?g%#(xDIQw6Hf z!T#&qV#2zD7}o}7=iq*hEh)$uRN2dummN5843`5`4+87L3S?bT3|LwcF=ss|yL60s zW#D3FS`0X9rtYN0ZUKTyC_AvKd~o(F_tM3HmG`Cg(vMHJm)`0NmyTT*s3tuC4q9HP zxBuHUsV2R6%gece6Mf|-JzvY~E;ta1?7(o2e7&?|TpJjh5xZ>SP5gZ?Ew0BZ1II3% zD!07FfP;#NZet-o#FqO%mSys7Y;9mRQ~V7^NSpkeH&@ oldPositionsLeft = new List(); + private List oldPositionsRight = new List(); + private int trailTimer = 0; + // The timer is initialized with a delay. It will reset to 6 after the first shot. + private int middleStreakTimer = 40; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 200; + Projectile.height = 170; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.hostile = false; + Projectile.friendly = true; + Projectile.extraUpdates = 12; + Projectile.timeLeft = 2400; + Projectile.minion = true; // Scuffed but it prevents the projectile from being culled in a few situations + Projectile.alpha = 255; + } + + public override void AI() + { + Player owner = Main.player[Projectile.owner]; + trailTimer++; + + // Very volatile values... + float amplitude = 86f; + float frequency = 0.039f; + + // Makes a perpendicular/mirrored trail, AKA a double helix + Vector2 perpendicular = Vector2.Normalize(new Vector2(-Projectile.velocity.Y, Projectile.velocity.X)); + + // Calculate the sine wave value. + float sineWave = (float)Math.Cos(trailTimer * frequency); + + // Calculate offset based on the pattern of the sinewave and subtract the proj's dimensions to be accurate + Vector2 offsetLeft = (perpendicular * amplitude * sineWave) - new Vector2(Projectile.width, Projectile.height); + Vector2 offsetRight = (-perpendicular * amplitude * sineWave) - new Vector2(Projectile.width, Projectile.height); + + oldPositionsLeft.Add(Projectile.Center + offsetLeft); + oldPositionsRight.Add(Projectile.Center + offsetRight); + + // The timer will now correctly decrease once per AI update. + middleStreakTimer--; + + if (middleStreakTimer <= 0) + { + // Reset the timer for the next shot. + middleStreakTimer = 6; + + // Spawn the main trail + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.24f, Color.MediumPurple * 1.3f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.25f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(spark); + Particle spark2 = new CustomSpark(Projectile.Center + perpendicular, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.24f, Color.CornflowerBlue * 1.3f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.25f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(spark2); + } + + + // Remove old positions after 120 + int maxTrailLength = 120; + if (oldPositionsLeft.Count > maxTrailLength) + oldPositionsLeft.RemoveAt(0); + if (oldPositionsRight.Count > maxTrailLength) + oldPositionsRight.RemoveAt(0); + } + + private float WidthFunction(float completionRatio) + { + return MathHelper.Lerp(12f, 0f, completionRatio); + } + + + private Color LeftColorFunction(float completionRatio) + { + Color baseColor = Color.MediumPurple * 1.3f; + + float alphaScaling = -4 * completionRatio * (completionRatio - 1); + return baseColor * alphaScaling; + } + private Color RightColorFunction(float completionRatio) + { + Color baseColor = Color.CornflowerBlue * 1.3f; + + float alphaScaling = -4 * completionRatio * (completionRatio - 1); + return baseColor * alphaScaling; + } + + + public override bool PreDraw(ref Color lightColor) + { + MiscShaderData trailShader = GameShaders.Misc["CalamityMod:TrailStreak"]; + trailShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + + // Use the separate color functions for each trail + PrimitiveRenderer.RenderTrail(oldPositionsLeft, new PrimitiveSettings(WidthFunction, LeftColorFunction, (_) => Projectile.Size * 1f, pixelate: false, shader: trailShader)); + PrimitiveRenderer.RenderTrail(oldPositionsRight, new PrimitiveSettings(WidthFunction, RightColorFunction, (_) => Projectile.Size * 1f, pixelate: false, shader: trailShader)); + return false; + } + } +} diff --git a/Projectiles/Melee/LucreciaDoubleHelix.cs b/Projectiles/Melee/LucreciaDoubleHelix.cs new file mode 100644 index 0000000000..1633470300 --- /dev/null +++ b/Projectiles/Melee/LucreciaDoubleHelix.cs @@ -0,0 +1,153 @@ +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Melee +{ + public class LucreciaSmallProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int TargetIndex = -1; + + public static float MaxWidth = 30; + public ref float Time => ref Projectile.ai[0]; + + public static Asset BloomTex; + public static Asset SlashTex; + public static Asset TrailTex; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 13; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 19; + Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.ignoreWater = true; + Projectile.tileCollide = true; + Projectile.penetrate = 1; + Projectile.extraUpdates = 1; + Projectile.alpha = 255; + Projectile.timeLeft = 420; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 12; + } + + public override void AI() + { + // Little bit of ambient lighting as it travels + Lighting.AddLight(Projectile.Center, Color.WhiteSmoke.ToVector3() * 0.4f); + + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.velocity *= 1.01f; + Projectile.scale = Utils.GetLerpValue(0f, 0.1f, Projectile.timeLeft / 600f, true); + + if (Projectile.FinalExtraUpdate()) + Time++; + + // CRUCIAL so that oldPos isnt initialized incorrectly when drawing + if (Projectile.localAI[0] == 0f) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Projectile.oldPos[i] = Projectile.position; + } + Projectile.localAI[0] = 1f; + } + } + + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + for (int i = 0; i < 6; i++) + { + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle); + dust2.scale = Main.rand.NextFloat(1.2f, 1.6f) - Math.Abs(variance); + dust2.velocity = (Projectile.velocity * 1.5f).RotatedBy(variance) * Main.rand.NextFloat(1.2f, 1.5f) * (1 - Math.Abs(variance)); + dust2.noGravity = true; + dust2.color = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, Main.rand.NextFloat(0f, 1f)); + } + } + + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, 0.5f) with { A = 0 } * Projectile.Opacity; + + public float TrailWidth(float completionRatio) + { + float width = Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * (float)Math.Sin(Math.Acos(1 - Utils.GetLerpValue(0f, 0.08f, completionRatio, true))); + + width *= Utils.GetLerpValue(0f, 0.1f, Projectile.timeLeft / 600f, true); + + return width * (MaxWidth * .265f); + } + public Color TrailColor(float completionRatio) + { + Color baseColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, completionRatio); + + return baseColor * 0.2f; + } + + public float MiniTrailWidth(float completionRatio) => TrailWidth(completionRatio) * 5.5f; + public Color MiniTrailColor(float completionRatio) => Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, completionRatio); + + public override bool PreDraw(ref Color lightColor) + { + if (Projectile.timeLeft > 412) + return false; + + Color mainColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f) % 1); + Color secondaryColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f + 0.2f) % 1); + + Main.spriteBatch.EnterShaderRegion(); + + if (TrailTex == null) + TrailTex = Request("CalamityMod/ExtraTextures/Trails/BasicTrail"); + + GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(TrailTex); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189"); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); + + Vector2 offset = Projectile.Size * 0.5f; + + // Apply the offset to the projectile's old position + Vector2[] oldPosWithOffset = Projectile.oldPos.Select(p => p - offset).ToArray(); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(TrailWidth, TrailColor, (_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(MiniTrailWidth, MiniTrailColor, (_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Melee/LucreciaProj.cs b/Projectiles/Melee/LucreciaProj.cs new file mode 100644 index 0000000000..46c9bfcd87 --- /dev/null +++ b/Projectiles/Melee/LucreciaProj.cs @@ -0,0 +1,314 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using CalamityMod.CalPlayer; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Projectiles.Melee.Shortswords; +using System.Runtime.InteropServices; + +namespace CalamityMod.Projectiles.Melee +{ + public class LucreciaProj : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override bool useMeleeSpeed => true; + public override bool useMeleeSize => false; + public override int swingWidth => 310; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override string Texture => "CalamityMod/Items/Weapons/Melee/Lucrecia"; + public override SoundStyle? UseSound => SoundID.Item71 with { Volume = 0.9f }; + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + public override int swingTime { get; set; } = 15; + public override bool AlternateSwings { get => base.AlternateSwings; set => base.AlternateSwings = value; } + public override float lineCollisionLength => 82; + + // Boolshit + public bool helixFired = false; + public bool gotEnergyThisSwing = false; + public bool trailFXTriggered = false; + public bool particlesSpawned = false; + public bool sparkTriggered = false; + private bool IsThrusting => Projectile.localAI[0] == 1; + + public bool IsAlternateThrust { get; set; } + public int thrustPullbackTime = 26; + public int thrustForwardTime = 13; + public int thrustCooldownTime = 20; + + public override void Defaults() + { + Projectile.extraUpdates = 6; + Projectile.noEnchantmentVisuals = true; + Projectile.Opacity = 0.2f; // Starting point, fades in quickly upon startup + Projectile.width = Projectile.height = 54; + } + + public override void Spawn(IEntitySource source) + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + var calamityPlayer = player.Calamity(); + + if (player.altFunctionUse == 2) + { + // Check for energy before the projectile exists + if (calamityPlayer.lucreciaEnergy < 100) + { + Projectile.Kill(); + return; + } + + IsAlternateThrust = true; + StartupTime = thrustPullbackTime; + swingTime = thrustForwardTime; + CooldownTime = thrustCooldownTime; + Projectile.DamageType = DamageClass.Melee; + Projectile.width = Projectile.height = 36; + useMeleeSize = true; + UseSound = SoundID.DD2_JavelinThrowersAttack; + OffsetDistance = -30; + RotateInStartup = 0.8f; + RotateInCooldown = 1f; + Projectile.knockBack = 15f; + + calamityPlayer.lucreciaEnergy = 0; // Remove energy for startup + } + else + { + IsAlternateThrust = false; + StartupTime = 8; + CooldownTime = 5; + swingTime = 15; + OffsetDistance = 36; + RotateInStartup = 0.8f; + RotateInCooldown = 0; + } + + if (swingTime > 0) + swingTime = (int)(swingTime / player.GetAttackSpeed(DamageClass.Melee)); + + // rest of the original Spawn method + if (AlternateSwings) + modplayer.swingNum = (modplayer.swingNum + 1) % 2; + } + + public override void AdditionalAI() + { + if (IsAlternateThrust) + { + if (inStartup) + { + trailFXTriggered = false; // Reset bool just in case + Projectile.Opacity += 0.01f; // Fade in + + // Pullback + float eased = MathF.Pow(StartupCompletion, 0.3f); + OffsetDistance = (int)MathHelper.Lerp(44, 34, eased); + Projectile.scale = baseScale * MathHelper.Lerp(1f, 0.85f, eased); + + + if (!sparkTriggered && Projectile.scale < 0.96f) // Right before thrusting forward + { + // Won't happen again this right-click + sparkTriggered = true; + + GenericSparkle sparker = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.AntiqueWhite, Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, 0.5f) * 0.3f, 2f, 8, Projectile.velocity.ToRotation() + (Main.rand.NextBool() ? -0.25f : 0.25f), 1f); + GeneralParticleHandler.SpawnParticle(sparker); + } + } + + else if (timer < StartupTime + swingTime) + { + Projectile.extraUpdates = 18; + + // Thrust forward + OffsetDistance = (int)MathHelper.Lerp(34, 60, SwingCompletion); + Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 3; + + // Scaling adjustments + var t = MathHelper.Clamp(SwingCompletion, 0f, 1f); + var eased = MathF.Pow(t, 0.125f); + Projectile.scale = baseScale * MathHelper.Lerp(0.9f, 1.6f, eased); + + // VFX vars + Player player = Main.player[Projectile.owner]; + Vector2 mousePosition = Main.MouseWorld; + Vector2 fireDirection = Vector2.Normalize(mousePosition - player.Center); + + // Fire the bigass projectile + if (!trailFXTriggered) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, fireDirection * 5, ModContent.ProjectileType(), Projectile.damage * 21, Projectile.knockBack, Projectile.owner, 0f, 0f); + + SoundStyle swish = new("CalamityMod/Sounds/Custom/MeatySlash"); + SoundEngine.PlaySound(swish with { Volume = 0.45f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + + SoundStyle projectile = new("CalamityMod/Sounds/Item/OmicronBeam"); + SoundEngine.PlaySound(projectile with { Volume = 0.75f, Pitch = Main.rand.NextFloat(0.15f, 0.2f) }, Projectile.Center); + } + + trailFXTriggered = true; + + // Some sparks from the blade + if (!particlesSpawned) + { + for (int i = 0; i < 6; i++) + { + Vector2 particleOrigin = Projectile.Center; + Vector2 particleSpeed = fireDirection.RotatedByRandom(MathHelper.ToRadians(46f)) * Main.rand.NextFloat(20f, 37f); + Particle sparks = new CritSpark(particleOrigin, particleSpeed, Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat(0f, 1f)), Color.NavajoWhite * 0.7f, Main.rand.NextFloat(0.9f, 2f), Main.rand.Next(38, 50), 0.1f, 1.5f, hueShift: 0.01f); + GeneralParticleHandler.SpawnParticle(sparks); + } + particlesSpawned = true; + } + + } + + else + { + Projectile.extraUpdates = 7; + Projectile.Opacity -= 0.012f; + + // During cooldown, pull back slightly + Projectile.scale = baseScale * MathHelper.Lerp(1.6f, 1.55f, CooldownCompletion); + OffsetDistance = (int)MathHelper.Lerp(60, 52, CooldownCompletion); + } + } + + else // Primary + { + Projectile.Opacity += 0.03f; //fade in effect to look smoother for repeated use + + if (inStartup) + { + gotEnergyThisSwing = false; + helixFired = false; + AfterImageLength = 0; + Projectile.scale = baseScale * MathHelper.Lerp(0.625f, 0.8f, StartupCompletion); + } + + else if (inCooldown) + { + helixFired = false; + Projectile.Opacity -= 0.09f; + AfterImageLength = 0; + Projectile.extraUpdates = 6; + Projectile.scale = baseScale * MathHelper.Lerp(0.85f, 0.625f, CooldownCompletion); + } + + else if (inSwing) + { + if (!helixFired) + { + helixFired = true; + var player = Main.player[Projectile.owner]; + var mousePosition = Main.MouseWorld; + var fireDirection = Vector2.Normalize(mousePosition - player.Center); + var helixSpeed = 12f; + var helixVelocity = fireDirection * helixSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage * 3, Projectile.knockBack, Projectile.owner); + } + AfterImageLength = 32; + Projectile.extraUpdates = 10; + var t = MathHelper.Clamp(SwingCompletion, 0f, 1f); + var parabola = 1f - MathF.Pow(t - 0.5f, 2f) * 4f; + OffsetDistance = (int)MathHelper.Lerp(36 * 1f, 36 * 1.435f, parabola); + var upPhase = t <= 0.5f ? t / 0.5f : (1f - t) / 0.5f; + var eased = MathF.Pow(upPhase, 2.6f); + Projectile.scale = baseScale * MathHelper.Lerp(0.8f, 1.4f, eased); + + } + } + base.AdditionalAI(); + } + + public override float SwingFunction() + { + var player = Main.player[Projectile.owner]; + + if (IsAlternateThrust) + { + var modplayer = player.GetModPlayer(); + float swingDirection = Projectile.spriteDirection; + + if (inStartup) + { + return 0f; + } + + if (timer < StartupTime + swingTime) + { + return 0f; + } + + else + return 0f; // Just retract and fade out without moving the angle + } + + else // Primary swing + { + var modplayer = player.GetModPlayer(); + float swingDirection = Projectile.spriteDirection; + if (modplayer.swingNum == 1) + swingDirection *= -1; + + var parabolicFactorPrimary = 1f - MathF.Pow(SwingCompletion - 0.5f, 2f) * 4f; + parabolicFactorPrimary = MathHelper.Clamp(parabolicFactorPrimary, 0f, 1f); + Projectile.localAI[0] = parabolicFactorPrimary; + + var startAnglePrimary = -swingWidth / 2.15f; + var endAnglePrimary = swingWidth / 2.15f; + var trueAnglePrimary = MathHelper.Lerp(startAnglePrimary, endAnglePrimary, SwingCompletion); + + return MathHelper.ToRadians(trueAnglePrimary * -swingDirection); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Add energy for the primary attack + if (!IsAlternateThrust && !gotEnergyThisSwing) + { + gotEnergyThisSwing = true; + var player = Main.player[Projectile.owner]; + var modPlayer = player.Calamity(); + + // +22 energy on hit + modPlayer.lucreciaEnergy += 22; + modPlayer.lucreciaEnergy = Math.Min(modPlayer.lucreciaEnergy, modPlayer.lucreciaEnergyMax); + + // On-hit cut FX + int points = 2; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)).RotatedByRandom(100); + + var modplayer = player.GetModPlayer(); + Color useColor = modplayer.swingNum == 1 ? Color.CornflowerBlue : Color.MediumPurple; // Alternate each swing + + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f); + Particle spark = new GlowSparkParticle((target.Center + velocity * 7.5f), velocity * 0.5f, false, 9, 0.05f, useColor, new Vector2(0.5f, 0.4f), true, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + + // Draw fullbright + public override bool PreDraw(ref Color lightColor) + { + lightColor = Color.White; + return base.PreDraw(ref lightColor); + } + } +} diff --git a/Projectiles/Melee/Shortswords/LucreciaProj.cs b/Projectiles/Melee/Shortswords/LucreciaProj.cs deleted file mode 100644 index 2517332b34..0000000000 --- a/Projectiles/Melee/Shortswords/LucreciaProj.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Shortswords -{ - public class LucreciaProj : BaseShortswordProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/Lucrecia"; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 28; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Melee; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; - } - - public override Action EffectBeforePullback => (proj) => - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 10f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - }; - - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 62 / 2; - const int HalfSpriteHeight = 62 / 2; - - int HalfProjWidth = Projectile.width / 2; - int HalfProjHeight = Projectile.height / 2; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); - } - - public override void ExtraBehavior() - { - if (Main.rand.NextBool(5)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch); - } - } -} diff --git a/en-US.hjson b/en-US.hjson new file mode 100644 index 0000000000..a95d61a6de --- /dev/null +++ b/en-US.hjson @@ -0,0 +1 @@ +Mods.CalamityMod.Projectiles.LucreciaDNATrailCreator.DisplayName: Lucrecia D N A Trail Creator