From 72231ac12397ddee67a34b545a54f57792fec764 Mon Sep 17 00:00:00 2001 From: Nathanael Overton Date: Sun, 12 Oct 2025 21:21:33 -0400 Subject: [PATCH] m1 functionality --- CalPlayer/CalamityPlayer.cs | 5 + CalPlayer/CalamityPlayerMiscEffects.cs | 45 +++++ Cooldowns/ElementalMastery.cs | 75 +++++++ Cooldowns/ElementalMastery.png | Bin 0 -> 312 bytes Cooldowns/ElementalMasteryOutline.png | Bin 0 -> 161 bytes Cooldowns/ElementalMasteryOverlay.png | Bin 0 -> 130 bytes Items/Weapons/Melee/StarburstShiv.cs | 50 +++-- .../Mods.CalamityMod.Projectiles.Melee.hjson | 1 + .../Mods.CalamityMod.Projectiles.Misc.hjson | 1 + .../Melee/Shortswords/StarburstShivProj.cs | 67 ------- Projectiles/Melee/StarburstBeam.cs | 76 ------- Projectiles/Melee/StarburstBeam.png | Bin 741 -> 0 bytes Projectiles/Melee/StarburstSHIV.cs | 54 ----- Projectiles/Melee/StarburstSHIV.png | Bin 741 -> 0 bytes Projectiles/Melee/StarburstShivHoldout.cs | 189 ++++++++++++++++++ Projectiles/Melee/StarburstShivM1Hitbox.cs | 44 ++++ 16 files changed, 397 insertions(+), 210 deletions(-) create mode 100644 Cooldowns/ElementalMastery.cs create mode 100644 Cooldowns/ElementalMastery.png create mode 100644 Cooldowns/ElementalMasteryOutline.png create mode 100644 Cooldowns/ElementalMasteryOverlay.png delete mode 100644 Projectiles/Melee/Shortswords/StarburstShivProj.cs delete mode 100644 Projectiles/Melee/StarburstBeam.cs delete mode 100644 Projectiles/Melee/StarburstBeam.png delete mode 100644 Projectiles/Melee/StarburstSHIV.cs delete mode 100644 Projectiles/Melee/StarburstSHIV.png create mode 100644 Projectiles/Melee/StarburstShivHoldout.cs create mode 100644 Projectiles/Melee/StarburstShivM1Hitbox.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c320662bf5..264cc92733 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -298,6 +298,10 @@ namespace CalamityMod.CalPlayer public bool lucreciaEnergyPaused = false; public bool lucreciaEnergyMaxSFXPlayed = false; private int lucreciaParticleTimer = 0; + public int starburstShivElementalMastery = 0; + public int starburstShivElementalMasteryTimer = 0; + public bool starburstShivElementalMasteryPaused = false; + public bool starburstShivElementalMasteryMaxSFXPlayed = false; public float unstableCastersGauntletVis = 0; public int unstableCastersGauntletVisTimer = 0; public int PhotoAudioCooldown = 0; @@ -3264,6 +3268,7 @@ namespace CalamityMod.CalPlayer flareGunOverheat = 0; hellbornShots = 0; lucreciaEnergy = 0; + starburstShivElementalMastery = 0; garandShots = 0; searedPanCounter = 0; searedPanTimer = 0; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index c189d1cac8..5651211de2 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -431,6 +431,51 @@ namespace CalamityMod.CalPlayer lucreciaEnergyPaused = false; } + if (Player.HeldItem.type == ModContent.ItemType() && starburstShivElementalMastery > 0) + { + if (starburstShivElementalMastery == StarburstShiv.MaxEnergy && !starburstShivElementalMasteryPaused) + { + starburstShivElementalMasteryPaused = true; + starburstShivElementalMasteryTimer = 0; + } + + starburstShivElementalMasteryTimer++; + + // If the mastery is at max, pause for 180 ticks + if (starburstShivElementalMasteryPaused) + { + if (starburstShivElementalMasteryTimer >= 1 && !starburstShivElementalMasteryMaxSFXPlayed) + { + SoundEngine.PlaySound(SoundID.Item79 with { Volume = 1.6f, Pitch = 0.4f }, Player.Center); + starburstShivElementalMasteryMaxSFXPlayed = true; + + } + // If the pause is Done, resume decrementing. + if (starburstShivElementalMasteryTimer >= 180) + { + starburstShivElementalMasteryPaused = false; + starburstShivElementalMasteryTimer = 0; + starburstShivElementalMastery--; + } + } + else // Decrementing + { + starburstShivElementalMasteryMaxSFXPlayed = false; + // Once every 8 ticks + if (starburstShivElementalMasteryTimer >= 8) + { + starburstShivElementalMastery--; + starburstShivElementalMasteryTimer = 0; + } + } + } + else + { + // Reset the timer and pause state if the player isn't holding the weapon. + starburstShivElementalMasteryTimer = 0; + starburstShivElementalMasteryPaused = false; + } + if (Player.HeldItem.type == ModContent.ItemType() && unstableCastersGauntletVis < 100) { diff --git a/Cooldowns/ElementalMastery.cs b/Cooldowns/ElementalMastery.cs new file mode 100644 index 0000000000..3af29545be --- /dev/null +++ b/Cooldowns/ElementalMastery.cs @@ -0,0 +1,75 @@ +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.Graphics.Shaders; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class ElementalMastery : CooldownHandler + { + private float AdjustedCompletion => instance.timeLeft / (float) StarburstShiv.MaxEnergy; + private Color TextColor => Color.AliceBlue; + private Color TextBorderColor = Color.AntiqueWhite; + + public static new string ID => "ElementalMastery"; + public override bool CanTickDown => false; + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => $"CalamityMod/Cooldowns/{ID}"; + public override string OutlineTexture => $"CalamityMod/Cooldowns/{ID}Outline"; + public override string OverlayTexture => $"CalamityMod/Cooldowns/{ID}Overlay"; + + public override Color OutlineColor => Color.SlateGray; + public override Color CooldownStartColor => Color.Lerp(Color.OrangeRed, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => Color.Lerp(Color.AliceBlue, Color.SlateGray, instance.Completion); + + public override void ApplyBarShaders(float opacity) + { + // Use the adjusted completion + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = Request(Texture).Value; + Texture2D outline = Request(OutlineTexture).Value; + Texture2D overlay = Request(OverlayTexture).Value; + + // Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + } +} diff --git a/Cooldowns/ElementalMastery.png b/Cooldowns/ElementalMastery.png new file mode 100644 index 0000000000000000000000000000000000000000..fb98df7f28c33a3cca7aac44fef312d7ca223cb8 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^B0wy}!3-pG`1q876k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(Kn*g5>SCituty%M5-Fo|e>*XVxuRQ}`VR-Lq*SwDdW{56Yx1EfSsg8YL2V*&<$|L1~0dCmfl$YKTt zzQZ8Qcszea3Q#cB)5S4FBe?e5X`u!M4u?SR%_rQI{{LUkc+1a8=`LpvIS2PRY lren``2)6drE_YR_Vw`Fru-C};v>4Dr22WQ%mvv4FO#t4;groof literal 0 HcmV?d00001 diff --git a/Cooldowns/ElementalMasteryOutline.png b/Cooldowns/ElementalMasteryOutline.png new file mode 100644 index 0000000000000000000000000000000000000000..775f2540bb53edd8a4d37d28cdc4ff5589382a84 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^504PXF?M{~o`I7j(Xeyj59Z*Pd3Oq?o$x(X!yAufgW7XN4E-RQ8&c@Wk$W z=M=R+0SpWZ?{CkrG(FV&=)T;S4S(5pybduBQ?C%;yt!za8c#rn7Vp{VdSyUs7(8A5 KT-G@yGywp$x;do) literal 0 HcmV?d00001 diff --git a/Cooldowns/ElementalMasteryOverlay.png b/Cooldowns/ElementalMasteryOverlay.png new file mode 100644 index 0000000000000000000000000000000000000000..d52f9503915b67a7b103d72295498a569b771bd5 GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0vp^B0wy}!2%>d-ZYyHq!^2X+?^QKos)S9;o)_;H&A-b0GMi1uuxVk(#1P?+Gr79oGnOcG>zOaS b?X;znA%>AhK`CDqWDA3*tDnm{r-UW|`jsb? literal 0 HcmV?d00001 diff --git a/Items/Weapons/Melee/StarburstShiv.cs b/Items/Weapons/Melee/StarburstShiv.cs index 88897649f7..90f5c58885 100644 --- a/Items/Weapons/Melee/StarburstShiv.cs +++ b/Items/Weapons/Melee/StarburstShiv.cs @@ -1,4 +1,8 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.DraedonsArsenal; +using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Melee.Shortswords; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,33 +17,53 @@ namespace CalamityMod.Items.Weapons.Melee { public new string LocalizationCategory => "Items.Weapons.Melee"; + public static int MaxEnergy = 100; + public override void SetDefaults() { Item.width = 74; Item.height = 94; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 138; + Item.useStyle = ItemUseStyleID.Shoot; + Item.damage = 183; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 13; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 2.4f; - Item.knockBack = 8.5f; - Item.UseSound = SoundID.Item1; + Item.useAnimation = Item.useTime = 20; + Item.shootSpeed = 10f; + Item.knockBack = 9f; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; + Item.shoot = ModContent.ProjectileType(); + + + Item.noMelee = true; + Item.noUseGraphic = true; + + Item.autoReuse = true; + Item.channel = true; + base.SetDefaults(); } - public override bool MeleePrefix() => true; + public override bool AltFunctionUse(Player player) + { + return true; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/StarburstShivGlow").Value); + public override void HoldItem(Player player) + { + if (player.Calamity().cooldowns.TryGetValue(ElementalMastery.ID, out var cooldown)) + { + cooldown.timeLeft = player.Calamity().starburstShivElementalMastery; + } + else + { + player.AddCooldown(ElementalMastery.ID, 0); + } + } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.PiercingStarlight). + AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentSolar, 5). diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 95c7ba3d4f..b1100eca96 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -309,3 +309,4 @@ WulfrumScrew.DisplayName: Wulfrum Screw WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard +StarburstShivM1Hitbox.DisplayName: Lightspeed Stab diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson index da430c0950..eda44bf91f 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson @@ -85,3 +85,4 @@ PlagueShotBuffer.DisplayName: Plague Shot WaterShot.DisplayName: Water Shot WaterShotBuffer.DisplayName: Water Shot FrequencyManipulatorEnergy.DisplayName: Frequency Manipulator Energy +StarburstShivHoldout.DisplayName: Starburst Shiv Holdout diff --git a/Projectiles/Melee/Shortswords/StarburstShivProj.cs b/Projectiles/Melee/Shortswords/StarburstShivProj.cs deleted file mode 100644 index 8293e62d06..0000000000 --- a/Projectiles/Melee/Shortswords/StarburstShivProj.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -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 StarburstShivProj : BaseShortswordProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/StarburstShiv"; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 44; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.scale = 1f; - Projectile.DamageType = TrueMeleeDamageClass.Instance; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.extraUpdates = 1; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override Action EffectBeforePullback => (proj) => - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 14f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f); - }; - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 37; - const int HalfSpriteHeight = 47; - - int HalfProjWidth = Projectile.width / 2; - int QuarterProjHeight = Projectile.height / 4; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - QuarterProjHeight); - } - - public override void ExtraBehavior() - { - if (Main.rand.NextBool(5)) - { - int rainbowDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbowDust].velocity *= 0.2f; - Main.dust[rainbowDust].noGravity = true; - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Melee/StarburstBeam.cs b/Projectiles/Melee/StarburstBeam.cs deleted file mode 100644 index 788aa3c149..0000000000 --- a/Projectiles/Melee/StarburstBeam.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class StarburstBeam : 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.DamageType = DamageClass.Melee; - Projectile.penetrate = 2; - Projectile.tileCollide = false; - Projectile.timeLeft = 60; - Projectile.aiStyle = ProjAIStyleID.Beam; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbow].noGravity = true; - Main.dust[rainbow].velocity = Vector2.Zero; - - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f); - } - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.timeLeft > 50) - return false; - - return true; - } - - public override void OnKill(int timeLeft) - { - for (int k = 0; k < 2; k++) - { - int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[rainbow].noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 30); - OnHitEffects(target.Center); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - OnHitEffects(target.Center); - } - - private void OnHitEffects(Vector2 targetPos) - { - var source = Projectile.GetSource_FromThis(); - for (int x = 0; x < 3; x++) - { - if (Projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 20f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, false, 50f); - } - } - } - } -} diff --git a/Projectiles/Melee/StarburstBeam.png b/Projectiles/Melee/StarburstBeam.png deleted file mode 100644 index 01a8a875ef9a8a09eaf87b9cfafda7711d6cbb3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 741 zcmV!Yx12sf>GEh zCeVZLnUZI*Nk1yb?}>Cc2(5oBytg@UOc5mU%sq>45Hq622vrHe zdb&TG2px>4+TN`Je?O+*h56E z6?#%Bh$PR5st&H~P#g}FP;^g;_0tBij}vT|zZLZ``Jb+msIfv(O#NBn2F|^TXB?pK zneZ@3#+o4aYFO19D-_Dn_&qmsX$e)&NpjEf*{>V9s;btlhYW9xP)?S&E95z8bOYp7 zcLNw`ANBFQGD2^x*O<->GE2l#t7wA$~^|5s&0Thyvn "Projectiles.Melee"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 15; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 1; - Projectile.tileCollide = false; - Projectile.timeLeft = 90; - Projectile.aiStyle = ProjAIStyleID.Beam; - Projectile.extraUpdates = 1; - } - - public override void AI() - { - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f); - - int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbow].noGravity = true; - Main.dust[rainbow].velocity = Vector2.Zero; - } - - public override void OnKill(int timeLeft) - { - int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[rainbow].noGravity = true; - } - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.timeLeft > 85) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Melee/StarburstSHIV.png b/Projectiles/Melee/StarburstSHIV.png deleted file mode 100644 index 01a8a875ef9a8a09eaf87b9cfafda7711d6cbb3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 741 zcmV!Yx12sf>GEh zCeVZLnUZI*Nk1yb?}>Cc2(5oBytg@UOc5mU%sq>45Hq622vrHe zdb&TG2px>4+TN`Je?O+*h56E z6?#%Bh$PR5st&H~P#g}FP;^g;_0tBij}vT|zZLZ``Jb+msIfv(O#NBn2F|^TXB?pK zneZ@3#+o4aYFO19D-_Dn_&qmsX$e)&NpjEf*{>V9s;btlhYW9xP)?S&E95z8bOYp7 zcLNw`ANBFQGD2^x*O<->GE2l#t7wA$~^|5s&0Thyvn "Projectiles.Misc"; + + public override string Texture => "CalamityMod/Items/Weapons/Melee/StarburstShiv"; + public ref float attackTimer => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + + // Sprite visuals + public float scaleFx = 0.6f; // Default that looks reasonable size-wise, changes on some attacks + + public Vector2 innateOffset = new(23f, -5f); + public Vector2 handPos; + + public int primaryStabfireRate => 2; + public int time = 0; + + public float bladeRot = 0; + public bool pressedRight = false; + + // Internal control + private int stabTimer; + + public override bool? CanDamage() => false; + + public override void SetDefaults() + { + Projectile.width = 74; + Projectile.height = 94; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 5; + Projectile.extraUpdates = 1; + } + public void Positioning(Vector2 toMouse) // Hand and holdout positioning + { + + Owner.ChangeDir(Math.Sign(toMouse.X)); + + // Calculate the angle for the arm holding the weapon + float baseArmRotation = toMouse.ToRotation(); + float compositeArmRotation = baseArmRotation + bladeRot - MathHelper.PiOver2; + + // Set the front composite arm to point towards the correct direction. + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, compositeArmRotation); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, 0f); + + Vector2 actualInnateOffset = innateOffset; + if (Owner.direction == -1) + { + actualInnateOffset.X += 1f; + actualInnateOffset.Y += 10f; + + } + + handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.Full, compositeArmRotation) + actualInnateOffset.RotatedBy(baseArmRotation); + + // Set properties based on the mouse direction + Projectile.velocity = toMouse; + Projectile.rotation = toMouse.ToRotation() + bladeRot; + Projectile.Center = handPos; + + // Same for the owner + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + + // Item rotation for the player's sprite display + Owner.itemRotation = Projectile.rotation; + if (Owner.direction != 1) + { + Owner.itemRotation -= MathHelper.Pi; + } + + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + } + + + public override void AI() + { + Projectile.scale = 1f; + + if (Owner.channel) + { + Projectile.timeLeft = 2; + } + else + { + Projectile.Kill(); + } + + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld()); + Positioning(toMouse); + + if (Owner.altFunctionUse == 0) + { + UsePrimary(toMouse); + + Vector2 currOffset = Projectile.Center + new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-1f, 7f)); + Projectile.Center = currOffset; + } + + else if (Owner.altFunctionUse == 2) + { + // Dash functionality + } + } + + // -- BASIC M1 -- + private void UsePrimary(Vector2 toMouse) + { + stabTimer++; + if (stabTimer % primaryStabfireRate != 0) + return; + + float offset = Main.rand.NextFloat(-MathHelper.ToRadians(6f), MathHelper.ToRadians(6f)); + Vector2 stabDir = toMouse.RotatedBy(offset); + + // SoundEngine.PlaySound(SoundID.Item1 with { Volume = 0.8f, Pitch = 0.1f, MaxInstances = 6, PitchVariance = 0.1f }, Owner.Center); + + Vector2 stabOrigin = Owner.MountedCenter; + Vector2 stabTip = stabOrigin + stabDir * 100f; + + for (int i = 0; i < 4; i++) + { + Vector2 spawnPos = stabTip + Main.rand.NextVector2Circular(18f, 12f); + + Vector2 vel = stabDir * Main.rand.NextFloat(5f, 19f); + Color color = Color.Lerp(Color.AliceBlue, Color.OrangeRed, Main.rand.NextFloat(1f)); + Particle spark = new GlowSparkParticle(spawnPos, vel, false, Main.rand.Next(5, 8), Main.rand.NextFloat(0.02f, 0.07f), color * 0.55f, new Vector2(0.5f, 1.3f), true, false); + GeneralParticleHandler.SpawnParticle(spark); + } + + + // Drawing randomness + bladeRot = Main.rand.NextFloat(-0.25f, 0.5f) * Owner.direction; + Projectile.scale *= Main.rand.NextFloat(0.88f, 1.04f); + if (Main.rand.NextBool()) + { + Owner.SetCompositeArmFront(true, Main.rand.NextBool() ? CompositeArmStretchAmount.ThreeQuarters : CompositeArmStretchAmount.Quarter, Owner.itemRotation - (Owner.direction == 1 ? MathHelper.PiOver2 : MathHelper.TwoPi * 0.75f) + Main.rand.NextFloat(-0.22f, 0.22f)); + } + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + toMouse * 20 * (float)Math.Pow(scaleFx, 4), toMouse * 25, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + + } + + // -- DASH -- + private void UseSecondary(Vector2 toMouse) + { + + } + + public override bool PreDraw(ref Color lightColor) + { + // Un-jand the rotation that the sprite is drawn to actually point toward the mouse cursor + float drawRotation = Projectile.rotation + MathHelper.PiOver4; + if (Owner.direction == -1) + { + drawRotation += MathHelper.PiOver2; + } + + Texture2D texture = ModContent.Request(Texture).Value; + int frameHeight = texture.Height / Main.projFrames[Projectile.type]; + Rectangle frame = new Rectangle(0, Projectile.frame * frameHeight, texture.Width, frameHeight); + Vector2 origin = new Vector2(texture.Width / 2f, frameHeight / 2f); + + SpriteEffects spriteEffects = Owner.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, lightColor, drawRotation, origin, Projectile.scale * scaleFx, spriteEffects, 0); + return false; + } + } +} diff --git a/Projectiles/Melee/StarburstShivM1Hitbox.cs b/Projectiles/Melee/StarburstShivM1Hitbox.cs new file mode 100644 index 0000000000..7378726b7f --- /dev/null +++ b/Projectiles/Melee/StarburstShivM1Hitbox.cs @@ -0,0 +1,44 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Projectiles.Melee +{ + [PierceResistExceptionAttribute(true)] + public class StarburstShivM1Hitbox : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + + public override void SetDefaults() + { + Projectile.width = 84; + Projectile.height = 64; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 6; + Projectile.DamageType = DamageClass.Melee; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 4; + } + + public override void AI() + { + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld() + MathHelper.Pi.ToRotationVector2()); + + float rotation = toMouse.ToRotation(); + + Projectile.rotation = rotation; + Projectile.velocity = toMouse * 34; + } + } +}