diff --git a/Items/Weapons/Magic/Thunderstorm.cs b/Items/Weapons/Magic/Thunderstorm.cs index d4704eb504..ec6c3bde1c 100644 --- a/Items/Weapons/Magic/Thunderstorm.cs +++ b/Items/Weapons/Magic/Thunderstorm.cs @@ -15,20 +15,22 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 220; Item.height = 60; - Item.damage = 132; - Item.mana = 50; + Item.damage = 400; Item.DamageType = DamageClass.Magic; + Item.mana = 50; Item.useTime = Item.useAnimation = 80; // 42 frames of firing animation + Item.knockBack = 2f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 16f; + Item.useStyle = ItemUseStyleID.Shoot; + Item.autoReuse = true; + Item.channel = true; Item.noMelee = true; Item.noUseGraphic = true; - Item.channel = true; - Item.knockBack = 2f; + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - Item.autoReuse = true; - Item.shootSpeed = 6f; - Item.shoot = ModContent.ProjectileType(); } // Cancels out the mana used to summon the holdout diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 59574316af..82d340cf97 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -630,7 +630,7 @@ PlasmaRifle: { DisplayName: Plasma Rifle Tooltip: ''' - Fires an explosive plasma blast + Fires an explosive plasma blast with pinpoint accuracy Press to rapidly fire non-explosive blasts ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 5866319d66..7e2f3a37c4 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -220,7 +220,6 @@ TacticiansTrumpCardProj.DisplayName: Trump Beam TearsofHeavenProjectile.DisplayName: Tears of Heaven Teslabeam.DisplayName: Teslabeam ThunderstormShot.DisplayName: Thunderous Shot -ThunderstormShotSplit.DisplayName: Thunderous Shot TradewindsProjectile.DisplayName: Tradewinds Feather TridentIcicle.DisplayName: Trident Icicle UberBubble.DisplayName: Bubble diff --git a/Projectiles/Magic/PlasmaRifleShot.cs b/Projectiles/Magic/PlasmaRifleShot.cs index d122ea2fd1..e3f148857f 100644 --- a/Projectiles/Magic/PlasmaRifleShot.cs +++ b/Projectiles/Magic/PlasmaRifleShot.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Magic // Meanwhile, this is for the shorter trail at the head public override void SetStaticDefaults() { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000; ProjectileID.Sets.TrailCacheLength[Type] = 12; ProjectileID.Sets.TrailingMode[Type] = 2; } @@ -49,7 +50,7 @@ namespace CalamityMod.Projectiles.Magic else { if (Projectile.FinalExtraUpdate() || TrailPos.Count < 15) - TrailPos.Add(Projectile.position); + TrailPos.Add(Projectile.Center); if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything Explode(); @@ -77,7 +78,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 50; Projectile.velocity = Vector2.Zero; Projectile.netUpdate = true; - TrailPos.Add(Projectile.position); // Final position update + TrailPos.Add(Projectile.Center); // Final position update // Right click can not explode if (Projectile.ai[0] > 0f) @@ -97,14 +98,17 @@ namespace CalamityMod.Projectiles.Magic } } - internal float HeadWidthFunction(float completionRatio) => Projectile.scale * 4f * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true); + internal float HeadWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f) * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true); internal Color HeadColorFunction(float completionRatio) => Color.LightSlateGray * Projectile.Opacity; - internal float TrailWidthFunction(float completionRatio) => Projectile.scale * 4f; + internal float TrailWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f); internal Color TrailColorFunction(float completionRatio) => Color.Lerp(Color.Chartreuse, Color.SlateGray, Utils.Remap(Projectile.Opacity, 0.5f, 1f, 0f, 0.8f)) * Projectile.Opacity * 0.3f; public override bool PreDraw(ref Color lightColor) { - PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, (_) => Projectile.Size * 0.5f), 30); + if (TrailPos == null) + return false; + + PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction), 30); PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(HeadWidthFunction, HeadColorFunction, (_) => Projectile.Size * 0.5f), 12); return false; } diff --git a/Projectiles/Magic/ThunderstormHoldout.cs b/Projectiles/Magic/ThunderstormHoldout.cs index 80f7915454..57788f2e3a 100644 --- a/Projectiles/Magic/ThunderstormHoldout.cs +++ b/Projectiles/Magic/ThunderstormHoldout.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Sounds; using Microsoft.Xna.Framework; @@ -31,6 +32,16 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() => Main.projFrames[Projectile.type] = 15; + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + public override void KillHoldoutLogic() { // Only times out if at the final frame (post-firing resting time) @@ -86,7 +97,19 @@ namespace CalamityMod.Projectiles.Magic { FlashTimer = 4f; SoundEngine.PlaySound(CommonCalamitySounds.PlasmaBlastSound, GunTipPosition); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + + // Start from slightly behind the tip + Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f; + Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), offsetPos, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + + for (int i = 0; i < 8; i++) + { + float scale = Main.rand.NextFloat(0.6f, 1.25f); + Vector2 randVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(8f, 12f); + Particle point = new PointParticle(offsetPos, randVelocity, false, 15, scale, new Color(51, 197, 255)); + GeneralParticleHandler.SpawnParticle(point); + } } } // The firing animation @@ -101,6 +124,11 @@ namespace CalamityMod.Projectiles.Magic } } + // Muzzle flash can deal damage + public override bool? CanDamage() => FlashTimer > 0f; + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.4f, 64f, targetHitbox); + public override bool PreDraw(ref Color lightColor) { Texture2D texture = TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Magic/ThunderstormShot.cs b/Projectiles/Magic/ThunderstormShot.cs index b5b06e5ebd..79dfa71758 100644 --- a/Projectiles/Magic/ThunderstormShot.cs +++ b/Projectiles/Magic/ThunderstormShot.cs @@ -1,6 +1,12 @@ -using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -10,72 +16,104 @@ namespace CalamityMod.Projectiles.Magic public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + // Due to how far/fast this thing moves, it'd require way too many points for a smooth long trail using oldPos + public List TrailPos = new List(); + public const int TrailLength = 50; + + public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000; + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 18; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.timeLeft = 600; - Projectile.MaxUpdates = 30; + Projectile.MaxUpdates = 15; + Projectile.timeLeft = 24 * Projectile.MaxUpdates; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Projectile.ai[0] += 1f; - if (Projectile.ai[0] > 9f) + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Projectile.numHits > 0) { - for (int i = 0; i < 5; i++) + Projectile.scale -= 0.01f; + Projectile.Opacity -= 0.01f; + if (Projectile.Opacity <= 0f) + Projectile.Kill(); + } + else + { + // Update a bit more frequently than the update count for better point distribution + if (Projectile.FinalExtraUpdate() || Projectile.numUpdates % 3 == 2 || TrailPos == null) { - Dust greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - greenDust.velocity = Vector2.Zero; - greenDust.position -= Projectile.velocity / 5f * (float)i; - greenDust.noGravity = true; - greenDust.noLight = true; - Dust lightningDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Vortex, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - lightningDust.velocity = Vector2.Zero; - lightningDust.position -= Projectile.velocity / 5f * (float)i; - lightningDust.noGravity = true; - lightningDust.noLight = true; + // Initialize 15 points immediately + if (TrailPos == null) + { + TrailPos = new List(15); + for (int i = 0; i < 15; ++i) + TrailPos.Add(Projectile.Center); + } + + // Add some random value for the natural lightning look + Vector2 randOffset = (Vector2.UnitY * Main.rand.NextFloat(-24f, 24f)).RotatedBy(Projectile.rotation); + TrailPos.Insert(0, Projectile.Center + randOffset); + + while (TrailPos.Count > TrailLength) + TrailPos.RemoveAt(TrailPos.Count - 1); } + + if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything + Decay(); } } - public override void OnKill(int timeLeft) + public override bool? CanDamage() => Projectile.numHits == 0 ? null : false; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - var source = Projectile.GetSource_FromThis(); - SoundEngine.PlaySound(SoundID.Item125, Projectile.Center); - for (int n = 0; n < 5; n++) - { - CalamityUtils.ProjectileRain(source, Projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - Projectile.ExpandHitboxBy(36); - int dustAmt = 36; - for (int j = 0; j < dustAmt; j++) - { - Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 1f; //0.75 - dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 dustDirection = dustRotate - Projectile.Center; - int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.Vortex, dustDirection.X, dustDirection.Y, 100, default, 1.2f); - Main.dust[killDust].noGravity = true; - Main.dust[killDust].noLight = true; - Main.dust[killDust].velocity = dustDirection; - } - for (int j = 0; j < dustAmt; j++) - { - Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 dustDirection = dustRotate - Projectile.Center; - int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.TerraBlade, dustDirection.X, dustDirection.Y, 100, default, 1.2f); - Main.dust[killDust].noGravity = true; - Main.dust[killDust].noLight = true; - Main.dust[killDust].velocity = dustDirection; - } - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); + if (Projectile.numHits == 0) + Decay(); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.numHits == 0) + Decay(); + return false; + } + + public void Decay() + { + Projectile.numHits++; // Ensure this can only happen once + Projectile.timeLeft = 100; + Projectile.velocity = Vector2.Zero; + Projectile.netUpdate = true; + + // Final position update + TrailPos.Insert(0, Projectile.Center); + + while (TrailPos.Count > TrailLength) + TrailPos.RemoveAt(TrailPos.Count - 1); + + SoundEngine.PlaySound(AnomalysNanogunMPFBBoom.MPFBExplosion, Projectile.Center); + } + + internal float TrailWidthFunction(float completionRatio) => Projectile.scale * 12f * Utils.GetLerpValue(0.5f, 0.4f, MathF.Abs(0.5f - completionRatio), true); + internal Color TrailColorFunction(float completionRatio) => Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + if (TrailPos == null) + return false; + + GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply(); + PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, smoothen: false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), TrailLength); + return false; } } } diff --git a/Projectiles/Magic/ThunderstormShotSplit.cs b/Projectiles/Magic/ThunderstormShotSplit.cs deleted file mode 100644 index bb8fd4fc86..0000000000 --- a/Projectiles/Magic/ThunderstormShotSplit.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class ThunderstormShotSplit : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.tileCollide = false; - Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.timeLeft = 600; - Projectile.MaxUpdates = 20; - } - - public override void AI() - { - if (Projectile.timeLeft < 420) - { - Projectile.tileCollide = true; - } - Projectile.ai[0] += 1f; - if (Projectile.ai[0] > 6f) - { - for (int i = 0; i < 5; i++) - { - Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)]; - dust.velocity = Vector2.Zero; - dust.position -= Projectile.velocity / 5f * (float)i; - dust.noGravity = true; - dust.noLight = true; - Dust dust2 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Vortex, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)]; - dust2.velocity = Vector2.Zero; - dust2.position -= Projectile.velocity / 5f * (float)i; - dust2.noGravity = true; - dust2.noLight = true; - } - } - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item125, Projectile.Center); - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 16; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - int dustAmt = 36; - for (int j = 0; j < dustAmt; j++) - { - Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; //0.75 - dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 dustDirection = dustRotate - Projectile.Center; - int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.Vortex, dustDirection.X, dustDirection.Y, 100, default, 0.6f); - Main.dust[killDust].noGravity = true; - Main.dust[killDust].noLight = true; - Main.dust[killDust].velocity = dustDirection; - } - for (int j = 0; j < dustAmt; j++) - { - Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; - dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 dustDirection = dustRotate - Projectile.Center; - int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.TerraBlade, dustDirection.X, dustDirection.Y, 100, default, 0.6f); - Main.dust[killDust].noGravity = true; - Main.dust[killDust].noLight = true; - Main.dust[killDust].velocity = dustDirection; - } - Projectile.Damage(); - } - } -}