diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index b9fd74ee14..b1e904ec2a 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -2,7 +2,9 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using rail; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,6 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class TheStorm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public int shots = 0; public override void SetStaticDefaults() { @@ -22,19 +25,18 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 54; Item.height = 90; - Item.damage = 35; + Item.damage = 23; Item.DamageType = DamageClass.Ranged; - Item.useTime = 7; - Item.useAnimation = 14; + Item.useTime = 2; + Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item122; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 28f; + Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; } @@ -45,62 +47,29 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int i = Main.myPlayer; - float arrowSpeed = Main.rand.Next(25, 30); - player.itemTime = Item.useTime; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = arrowSpeed; - } - else - { - mouseDistance = arrowSpeed / mouseDistance; - } + if (shots % 2 == 0) + SoundEngine.PlaySound(SoundID.Item122 with { Volume = 0.6f, PitchVariance = 0.2f }, position); - for (int j = 0; j < 3; j++) + for (int i = 0; i < 2; i++) { - realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - realPlayerPos.Y -= (float)(100 * j); - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = arrowSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - float speedX4 = mouseXDist + (float)Main.rand.Next(-120, 121) * 0.01f; - float speedY5 = mouseYDist + (float)Main.rand.Next(-120, 121) * 0.01f; + float arrowVelAdjust = Main.rand.NextFloat(-40, 40); + Vector2 arrowSpawnPos = new Vector2(MathHelper.Lerp(player.Calamity().mouseWorld.X, player.Center.X, 0.5f), player.Center.Y) + new Vector2(arrowVelAdjust, Main.rand.NextFloat(-560, -660)); + Vector2 velAdjust = (player.Calamity().mouseWorld - arrowSpawnPos).SafeNormalize(velocity); + Vector2 arrowVel = (velAdjust).RotatedBy(arrowVelAdjust * -0.004f) * Item.shootSpeed; + if (CalamityUtils.CheckWoodenAmmo(type, player)) { - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, knockback, i); - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, knockback, i); + Projectile.NewProjectileDirect(source, arrowSpawnPos, arrowVel, ModContent.ProjectileType(), (int)(damage * (i == 0 ? 1.5f : 1f)), knockback, -1, i == 0 ? 5 : 0); } else { - int arrow1 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, type, damage, knockback, i); - Main.projectile[arrow1].noDropItem = true; - int arrow2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, type, damage, knockback, i); - Main.projectile[arrow2].noDropItem = true; + Projectile arrow1 = Projectile.NewProjectileDirect(source, arrowSpawnPos, arrowVel, i == 0 ? ModContent.ProjectileType() : type, damage, knockback); + arrow1.noDropItem = true; + arrow1.tileCollide = false; } } + + shots++; return false; } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index f1d71fb188..304b0db738 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -1339,8 +1339,8 @@ TheStorm: { DisplayName: The Storm Tooltip: ''' - Fires a spread of arrows from the sky - Converts wooden arrows into lightning bolts + Fires a spread of homing lightning bolts and arrows from the sky + Converts wooden arrows into powerful electric beams ''' } diff --git a/Particles/BoltParticle.cs b/Particles/BoltParticle.cs index a83ee88aea..1301d565e4 100644 --- a/Particles/BoltParticle.cs +++ b/Particles/BoltParticle.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Particles public Vector2 Stretch = new Vector2(0.5f, 1.6f); public float ShrinkSpeed = 0; public bool Fliped = false; + public bool GlowFade = false; public override int FrameVariants => 3; public override string Texture => "CalamityMod/Particles/Bolt2"; @@ -23,7 +24,7 @@ namespace CalamityMod.Particles public override bool SetLifetime => true; public override bool UseCustomDraw => true; - public BoltParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool glowCenter = false, bool fadeIn = false, float shrinkSpeed = 0) + public BoltParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool glowCenter = false, bool glowFade = false, bool fadeIn = false, float shrinkSpeed = 0) { Position = relativePosition; Velocity = velocity; @@ -42,6 +43,8 @@ namespace CalamityMod.Particles if (FadeIn) Scale = 0f; + + GlowFade = glowFade; } public override void Update() @@ -85,7 +88,7 @@ namespace CalamityMod.Particles spriteBatch.Draw(texture, Position - Main.screenPosition, frame, col, Rotation, origin, scale, Fliped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); if (GlowCenter) - spriteBatch.Draw(texture, Position - Main.screenPosition, frame, Color.Lerp(col, Color.White, 0.8f), Rotation, origin, scale * 0.8f, Fliped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, frame, Color.Lerp(col, Color.White, 0.8f) * (GlowFade ? Utils.GetLerpValue(Lifetime, 0, Time, true) : 1), Rotation, origin, scale * 0.8f, Fliped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); } } } diff --git a/Projectiles/Ranged/Bolt.cs b/Projectiles/Ranged/Bolt.cs index e45cd19672..24813da156 100644 --- a/Projectiles/Ranged/Bolt.cs +++ b/Projectiles/Ranged/Bolt.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -10,86 +12,115 @@ namespace CalamityMod.Projectiles.Ranged public class Bolt : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public bool homing = true; + public bool hasZaged = false; + public int zagDirection = 1; + public Vector2 effectVel; + public NPC closestTarget; + public float colorValue = 0; public override void SetDefaults() { - Projectile.width = 8; - Projectile.height = 8; + Projectile.width = 60; + Projectile.height = 60; Projectile.friendly = true; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.alpha = 255; - Projectile.penetrate = 4; - Projectile.extraUpdates = 1; + Projectile.penetrate = 3; + Projectile.extraUpdates = 4; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.timeLeft = 600; + Projectile.ArmorPenetration = 20; // Fast weapon go brr + Projectile.timeLeft = 300; } public override void AI() { - Projectile.velocity *= 1.015f; - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.timeLeft % 30 == 0) + if (time == 0) { - for (int l = 0; l < 12; l++) + if (Projectile.ai[0] == 5) + { + Projectile.extraUpdates = 60; + Projectile.penetrate = -1; + } + colorValue += Main.rand.Next(0, 20); + zagDirection = Main.rand.NextBool() ? 1 : -1; + effectVel = Projectile.velocity; + } + colorValue = MathHelper.Lerp(colorValue, 50, 0.035f); + Color usedColor = Color.Lerp(Color.Cyan, Color.Orchid, Utils.GetLerpValue(0, 50, colorValue)); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (targetDist < 1400f) + { + if (Projectile.timeLeft % 2 == 0) { - Vector2 rotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - rotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - rotate = rotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int blueDust = Dust.NewDust(Projectile.Center, 0, 0, DustID.FireworkFountain_Blue, 0f, 0f, 160, default, 1f); - Main.dust[blueDust].scale = 1.1f; - Main.dust[blueDust].noGravity = true; - Main.dust[blueDust].position = Projectile.Center + rotate; - Main.dust[blueDust].velocity = Projectile.velocity * 0.1f; - Main.dust[blueDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[blueDust].position) * 1.25f; + Particle spark2 = new BoltParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 7, 0.3f, usedColor, new Vector2(1.8f, 0.8f), true, true, false, 0.7f); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Main.rand.NextBool(35)) + { + Particle spark2 = new BoltParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.9f), false, 23, Main.rand.NextFloat(0.2f, 0.3f), usedColor, new Vector2(1.8f, 0.8f), true, true, false, 0.3f); + GeneralParticleHandler.SpawnParticle(spark2); } } - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) + if (Projectile.numHits > 0) + homing = false; + if (time % 15 == 0) { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); + Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (effectVel * 10) * Main.rand.NextFloat(-0.4f, -0.7f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); + dust.noGravity = true; + dust.color = usedColor; + effectVel = Projectile.velocity.RotatedBy(0.2f * zagDirection * (hasZaged ? 1 : 0.5f)) * 0.08f; } - return new Color(255, 255, 255, 100); + if (time % 20 == 0) + { + hasZaged = true; + zagDirection *= -1; + } + + closestTarget = Projectile.Center.ClosestNPCAt(900); + if (closestTarget != null && homing && Projectile.ai[0] < 5) + { + Vector2 moveTotarget = (closestTarget.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < MathHelper.Clamp(12 * Utils.GetLerpValue(75, 300, Projectile.timeLeft, true), 4, 12)) + Projectile.velocity += moveTotarget * Utils.GetLerpValue(300, 200, Projectile.timeLeft, true) * 1f; + else + Projectile.velocity *= 0.85f; + colorValue = MathHelper.Lerp(50, 0, Utils.GetLerpValue(500, 0, Vector2.Distance(closestTarget.Center, Projectile.Center), true)); + } + if (!homing && Projectile.velocity.Length() < 12) + Projectile.velocity *= 1.01f; + + time++; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + if (target != closestTarget) + { + Projectile.numHits--; + Projectile.penetrate++; + } + else + colorValue = Main.rand.Next(0, 10); target.AddBuff(BuffID.Electrified, 90); } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } public override void OnKill(int timeLeft) { - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 32; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - int rando = Main.rand.Next(4, 8); - for (int i = 0; i < rando; i++) + for (int i = 0; i <= 2; i++) { - int dust = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, DustID.IceTorch, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 2f; - Main.dust[dust].noGravity = true; + Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (Projectile.velocity * 4).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(0.6f, 0.8f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid; } } }