diff --git a/Items/Weapons/Rogue/Supernova.cs b/Items/Weapons/Rogue/Supernova.cs index abcaa7fee0..0f67b61514 100644 --- a/Items/Weapons/Rogue/Supernova.cs +++ b/Items/Weapons/Rogue/Supernova.cs @@ -14,14 +14,20 @@ namespace CalamityMod.Items.Weapons.Rogue { public class Supernova : RogueWeapon { + public static float StealthTimeInSeconds => 2f; public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Item/SupernovaBoom") { Volume = 0.9f }; public static readonly SoundStyle StealthExplosionSound = new("CalamityMod/Sounds/Item/SupernovaStealthExplode") { Volume = 1f }; public static readonly SoundStyle StealthChargeSound = new("CalamityMod/Sounds/Item/SupernovaStealthCharge") { Volume = 1f }; + + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } public override void SetDefaults() { Item.width = 106; Item.height = 112; - Item.damage = 5036; + Item.damage = 5200; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 70; @@ -31,26 +37,21 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.DamageType = RogueDamageClass.Instance; Item.rare = ModContent.RarityType(); + Item.channel = true; } - public override float StealthDamageMultiplier => 0.7f; + public override bool AltFunctionUse(Player player) => true; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + public override float StealthDamageMultiplier => 0.8f; + + public override void HoldItem(Player player) { - if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike - { - int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - else - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - return false; + if (player.ownedProjectileCounts[Item.shoot] <= 0) + player.Calamity().rogueStealth = 0; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index c975fffb81..2f8e923e30 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -1161,6 +1161,8 @@ Supernova: { DisplayName: Supernova Tooltip: ''' + Disables normal stealth generation + Hold to generate stealth, or hold to toss the bomb without generating stealth Tosses a smart bomb that locks onto and tracks targets If no target is found it will return to you Each bomb creates a miniature supernova that drags in weak enemies and chases strong enemies diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index e8d01b227f..069e84ecc4 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -290,6 +290,7 @@ Stormfrontspark.DisplayName: Stormfront Spark SubductionFlameburst.DisplayName: Flame Pillar SubductionSlicerProj.DisplayName: Subduction Slicer SulphuricNukesplosion.DisplayName: Nuke +SupernovaHoldout.DisplayName: Supernova SupernovaBomb.DisplayName: Supernova Bomb SupernovaBoom.DisplayName: Micro Supernova SupernovaStealthBoom.DisplayName: Exo Supernova diff --git a/Projectiles/Rogue/SupernovaHoldout.cs b/Projectiles/Rogue/SupernovaHoldout.cs new file mode 100644 index 0000000000..8236645ea8 --- /dev/null +++ b/Projectiles/Rogue/SupernovaHoldout.cs @@ -0,0 +1,130 @@ +using System; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class SupernovaHoldout : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Supernova"; + public override bool useMeleeSpeed => false; + public override bool useMeleeSize => false; + public override int swingWidth => 180; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 0; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + int explodeTimer = 0; + + public override void Defaults() + { + Projectile.width = 106; + Projectile.height = 112; + Projectile.MaxUpdates = 4; + Projectile.noEnchantmentVisuals = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.ContinuouslyUpdateDamageStats = true; + } + + public Color randomColor => Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + public override void Spawn() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 50; + CooldownTime = 10; + swingTime -= StartupTime + CooldownTime; + OffsetDistance = 48; + modplayer.swingNum = 0; + RotateInStartup = 1; + Projectile.scale = 0.4f; + } + + public override void AdditionalAI() + { + Lighting.AddLight(Projectile.Center, new Vector3(1, 1, 1)); + var player = Main.player[Projectile.owner]; + var cplayer = player.Calamity(); + if (Projectile.Opacity > 0) + { + cplayer.temporaryStealthMax = 1.3f; + cplayer.temporaryStealthTimer = 2; + } + + var avgStealth = 0.8f * cplayer.stealthGenMoving + 0.2f * cplayer.stealthGenStandstill; + var explodeTimeGoal = CalamityUtils.SecondsToFrames(Supernova.StealthTimeInSeconds) / avgStealth + 30; + var stealthTime = explodeTimeGoal - 30; + + + cplayer.rogueStealth = Projectile.Opacity <= 0 ? 0 : Math.Max(cplayer.temporaryStealthMax, cplayer.rogueStealthMax) * MathHelper.Clamp(explodeTimer / stealthTime, 0f, 1f); + + if (player.channel && inStartup) + { + + if (timer >= StartupTime - 1) + { + if (Projectile.FinalExtraUpdate() && explodeTimer < explodeTimeGoal) + explodeTimer++; + timer--; + Projectile.timeLeft++; + } + } + if (explodeTimer >= explodeTimeGoal && inCooldown && !Projectile.FinalExtraUpdate()) + { + timer--; + Projectile.timeLeft++; + } + + if (inSwing) + { + if (swingTimer == (int)(swingTime * 0.75f)) + { + if (Projectile.owner == Main.myPlayer && Projectile.Opacity > 0) + { + var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, angle * -16 * cplayer.rogueVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + if (player.Calamity().StealthStrikeAvailable()) + { + p.Calamity().stealthStrike = true; + } + } + Projectile.Opacity = 0; + } + } + } + + public override float SwingFunction() + { + if (inStartup) + { + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * -0.2f, swingWidth * -0.5f, StartupCompletion)); + } + if (inCooldown) + return MathHelper.ToRadians(MathHelper.Lerp(swingWidth * 0.2f, swingWidth * 0.33f, 1 - MathF.Pow(1 - CooldownCompletion, 3f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * -0.7f, swingWidth * 0.2f, SwingCompletion)); + } + + public override bool? CanHitNPC(NPC target) + { + return false; + } + + public override bool CanHitPlayer(Player target) + { + return false; + } + } +}