From 06e35f04c086dbb014e297abf636541d6828c7c3 Mon Sep 17 00:00:00 2001 From: Xyk Date: Wed, 29 May 2024 00:41:04 -0700 Subject: [PATCH 1/5] Shredder And Infinity P1 --- Items/Weapons/Ranged/Infinity.cs | 79 ++++++--------- Items/Weapons/Ranged/Shredder.cs | 23 ++--- .../Mods.CalamityMod.Projectiles.Ranged.hjson | 1 + Projectiles/Ranged/ChargedBlast.cs | 73 ++++++++------ Projectiles/Ranged/ChargedBlast2.cs | 79 --------------- Projectiles/Ranged/ChargedBlastSplit.cs | 97 +++++++++++++++++++ 6 files changed, 178 insertions(+), 174 deletions(-) delete mode 100644 Projectiles/Ranged/ChargedBlast2.cs create mode 100644 Projectiles/Ranged/ChargedBlastSplit.cs diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 0a3822976f..4fb89f5188 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Materials; +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -15,6 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; internal int rotation = 0; internal bool limit = true; + public int SineCounter = 0; public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -24,11 +27,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 110; + Item.damage = 90; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 12; - Item.reuseDelay = 12; + Item.useTime = 1; + Item.useAnimation = 4; Item.useLimitPerAnimation = 9; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -38,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 12f; + Item.shootSpeed = 6f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -55,61 +57,34 @@ 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) { - if (player.altFunctionUse == 2) + position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; + float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 3.5f; + SineCounter++; + if (SineCounter % 4 == 0) { - //If you right click, shoots a helix of normal bullets - Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot2].timeLeft = 180; - //Code to constantly make the shooting go side to side to make the helix - if (limit) + if (player.altFunctionUse == 2) { - rotation += 2; + //If you right click, shoots a helix of normal bullets + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); } else { - rotation -= 2; + //If left click, do the same as above but spawn Charged Blasts instead + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1, 1f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 1f); } - if (rotation >= 11) - { - limit = false; - } - else if (rotation <= -11) - { - limit = true; - } - return false; } - else + else if (player.altFunctionUse != 2) { - //If left click, do the same as above but spawn Charged Blasts instead - Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot2].timeLeft = 180; - if (limit) - { - rotation += 2; - } - else - { - rotation -= 2; - } - if (rotation >= 11) - { - limit = false; - } - else if (rotation <= -11) - { - limit = true; - } - return false; + Particle spark2 = new LineParticle(position + Main.rand.NextVector2Circular(6, 6), (velocity * 4).RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(1.5f, 2f), new Color(229, 49, 39)); + GeneralParticleHandler.SpawnParticle(spark2); } + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 6665770842..eb54dab8c2 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using System; namespace CalamityMod.Items.Weapons.Ranged { @@ -20,11 +21,11 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 31; + Item.damage = 45; Item.DamageType = DamageClass.Ranged; Item.useTime = 4; - Item.useAnimation = 24; - Item.reuseDelay = 20; + Item.useAnimation = 32; + Item.reuseDelay = 35; Item.useLimitPerAnimation = 8; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.Bullet; - Item.shootSpeed = 9f; + Item.shootSpeed = 6f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -45,29 +46,21 @@ 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 bulletAmt = 4; + int bulletAmt = 3; if (player.altFunctionUse == 2) { - velocity *= 2f; Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - Vector2 cachedVelocity = velocity; for (int index = 0; index < bulletAmt; index++) { - velocity += new Vector2(Main.rand.Next(-30, 31) * 0.05f, Main.rand.Next(-30, 31) * 0.05f); - int shot = Projectile.NewProjectile(source, newPosition, velocity, type, damage, knockback, player.whoAmI); - Main.projectile[shot].timeLeft = 180; - velocity = cachedVelocity; + int shot = Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), type, damage, knockback, player.whoAmI); } } else { Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - Vector2 cachedVelocity = velocity; for (int index = 0; index < bulletAmt; index++) { - velocity += new Vector2(Main.rand.Next(-30, 31) * 0.05f, Main.rand.Next(-30, 31) * 0.05f); - Projectile.NewProjectile(source, newPosition, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - velocity = cachedVelocity; + Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); } } return false; diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index ebaa469e9d..0b711900a8 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -249,3 +249,4 @@ WildfireBloomFire.DisplayName: Wildfire Fire WildfireBloomFlare.DisplayName: Wildfire Flare WulfrumScrapBullet.DisplayName: High Speed Scrap NitroShot.DisplayName: Nitro Shot +ChargedBlastSplit.DisplayName: Charged Blast Split diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index caacfc330d..d57b2169da 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -1,4 +1,7 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -10,7 +13,13 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/LaserProj"; - + public Color baseColor = Color.White; + public bool outOfTime = false; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } public override void SetDefaults() { Projectile.width = 5; @@ -18,43 +27,51 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.MaxUpdates = 2; - Projectile.alpha = 255; + Projectile.extraUpdates = 6; Projectile.timeLeft = 360; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { - if (Projectile.alpha > 0) - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - - float lightScale = 1f - Projectile.alpha / 255f; - Projectile.ai[2] = lightScale; - Lighting.AddLight(Projectile.Center, 0f, 0.3f * lightScale, 0.7f * lightScale); - - float beamLength = 60f; - float beamLengthGrowth = 1f; - Projectile.localAI[0] += beamLengthGrowth; - if (Projectile.localAI[0] > beamLength) - Projectile.localAI[0] = beamLength; + if (baseColor == Color.White) + baseColor = (Projectile.ai[2] == 1 ? new Color(229, 49, 39) : Color.DodgerBlue); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (Projectile.timeLeft == 2) + outOfTime = true; } - - public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0) * Projectile.ai[2]; - - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); - public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item62, Projectile.position); - int projectiles = 2; - if (Projectile.owner == Main.myPlayer) + if (!outOfTime) { - for (int k = 0; k < projectiles; k++) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2CircularEdge(5f, 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.8f, Main.myPlayer); + SoundEngine.PlaySound(SoundID.Item62, Projectile.Center); + int projectiles = 2; + if (Projectile.owner == Main.myPlayer) + { + for (int k = 0; k < projectiles; k++) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -Projectile.velocity.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 0.7f), ModContent.ProjectileType(), (int)(Projectile.damage * (Projectile.ai[2] == 1 ? 0.3f : 0.5f)), Projectile.knockBack * 0.8f, Main.myPlayer, 0, 0, Projectile.ai[2] == 1 ? 1 : 0); + } + for (int k = 0; k < 3; k++) + { + Particle spark2 = new LineParticle(Projectile.Center, (-Projectile.velocity * 4).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(25, 32 + 1), Main.rand.NextFloat(1.5f, 2f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Projectile.ai[2] == 1) + { + Particle spark2 = new LineParticle(Projectile.Center, (-Projectile.velocity * 5).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(35, 48 + 1), Main.rand.NextFloat(2.3f, 3f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } } } + public override bool PreDraw(ref Color lightColor) + { + if (baseColor == Color.White) + return false; + Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLineBloom").Value; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], (baseColor * 0.7f) with { A = 0 }, 1, texture); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); } } diff --git a/Projectiles/Ranged/ChargedBlast2.cs b/Projectiles/Ranged/ChargedBlast2.cs deleted file mode 100644 index 89318cc187..0000000000 --- a/Projectiles/Ranged/ChargedBlast2.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ChargedBlast2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/LaserProj"; - - public override void SetDefaults() - { - Projectile.width = 5; - Projectile.height = 5; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 3; - Projectile.MaxUpdates = 2; - Projectile.alpha = 255; - Projectile.timeLeft = 180; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - if (Projectile.timeLeft < 60) - { - Projectile.alpha += 5; - if (Projectile.alpha >= 255) - Projectile.Kill(); - } - else - { - if (Projectile.alpha > 0) - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - } - - float lightScale = 1f - Projectile.alpha / 255f; - Projectile.ai[2] = lightScale; - Lighting.AddLight(Projectile.Center, 0f, 0.3f * lightScale, 0.7f * lightScale); - - float beamLength = 30f; - float beamLengthGrowth = 0.5f; - Projectile.localAI[0] += beamLengthGrowth; - if (Projectile.localAI[0] > beamLength) - Projectile.localAI[0] = beamLength; - } - - public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0) * Projectile.ai[2]; - - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); - - public override bool OnTileCollide(Vector2 oldVelocity) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); - } - else - { - if (Projectile.velocity.X != oldVelocity.X) - Projectile.velocity.X = -oldVelocity.X; - if (Projectile.velocity.Y != oldVelocity.Y) - Projectile.velocity.Y = -oldVelocity.Y; - } - - return false; - } - } -} diff --git a/Projectiles/Ranged/ChargedBlastSplit.cs b/Projectiles/Ranged/ChargedBlastSplit.cs new file mode 100644 index 0000000000..9e2da962aa --- /dev/null +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -0,0 +1,97 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ChargedBlastSplit : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/LaserProj"; + public Color baseColor = Color.White; + public int tileHits = 4; + public Vector2 startVel; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 5; + Projectile.height = 5; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 3; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 240; + Projectile.scale = 0.7f; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + + public override void AI() + { + bool InfinityShot = Projectile.ai[2] == 1; + if (baseColor == Color.White) + { + baseColor = (InfinityShot ? new Color(229, 49, 39) : Color.DodgerBlue); + startVel = Projectile.velocity; + if (InfinityShot) + Projectile.timeLeft = 340; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.timeLeft < 290 && InfinityShot) + { + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, -startVel.X, 0.02f); + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, -startVel.Y, 0.02f); + } + if (InfinityShot) + { + Projectile.tileCollide = false; + Projectile.penetrate = -1; + } + } + public override void OnKill(int timeLeft) + { + for (int k = 0; k < 3; k++) + { + Particle spark2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(8, 11 + 1), Main.rand.NextFloat(0.5f, 1f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + public override bool PreDraw(ref Color lightColor) + { + if (baseColor == Color.White) + return false; + Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLineBloom").Value; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], (baseColor * 0.7f) with { A = 0 }, 1, texture); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 10, targetHitbox); + + public override bool OnTileCollide(Vector2 oldVelocity) + { + tileHits--; + if (tileHits <= 0) + { + Projectile.Kill(); + } + else + { + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + } + + return false; + } + } +} From d9807be36223b2fa8c84b2b8fb67d1d45b826890 Mon Sep 17 00:00:00 2001 From: Xyk Date: Wed, 29 May 2024 13:03:29 -0700 Subject: [PATCH 2/5] Svant --- Items/Weapons/Ranged/Infinity.cs | 14 ++-- Items/Weapons/Ranged/Shredder.cs | 6 ++ Items/Weapons/Ranged/Svantechnical.cs | 98 +++++++++++++------------ Projectiles/Ranged/ChargedBlast.cs | 28 ++++++- Projectiles/Ranged/ChargedBlastSplit.cs | 57 ++++++++++++-- 5 files changed, 139 insertions(+), 64 deletions(-) diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 4fb89f5188..fb2c7136ee 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -15,8 +15,6 @@ namespace CalamityMod.Items.Weapons.Ranged public class Infinity : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - internal int rotation = 0; - internal bool limit = true; public int SineCounter = 0; public override void SetStaticDefaults() { @@ -27,11 +25,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 90; + Item.damage = 85; Item.DamageType = DamageClass.Ranged; Item.useTime = 1; Item.useAnimation = 4; - Item.useLimitPerAnimation = 9; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1f; @@ -75,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Ranged //If left click, do the same as above but spawn Charged Blasts instead Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1, 1f); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 1f); int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 1f); } } @@ -86,7 +83,12 @@ namespace CalamityMod.Items.Weapons.Ranged } return false; } - + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) > 80 && SineCounter % 4 == 0) + return true; + return false; + } public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index eb54dab8c2..06281c5e18 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -65,6 +65,12 @@ namespace CalamityMod.Items.Weapons.Ranged } return false; } + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) < 60) + return false; + return true; + } public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index efb03041fc..eced3fa849 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -1,5 +1,7 @@ using System; using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; @@ -13,16 +15,19 @@ namespace CalamityMod.Items.Weapons.Ranged public class Svantechnical : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public int SineCounter = 0; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } public override void SetDefaults() { Item.width = 60; Item.height = 26; - Item.damage = 150; + Item.damage = 200; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 24; - Item.reuseDelay = 10; - Item.useLimitPerAnimation = 12; + Item.useTime = 1; + Item.useAnimation = 3; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; @@ -33,70 +38,67 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; - Item.shootSpeed = 12f; + Item.shootSpeed = 6f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; + Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - - public override void HoldItem(Player player) => player.scope = true; - - public override bool CanConsumeAmmo(Item ammo, Player player) + public override bool AltFunctionUse(Player player) { - if (Main.rand.Next(0, 100) < 70) - return false; return true; } + public override void HoldItem(Player player) => player.scope = false; + 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 sSpeed = Item.shootSpeed; - 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) + position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; + float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 4f; + float sine2 = (float)Math.Sin(SineCounter * 0.275f / MathHelper.Pi) * 2f; + SineCounter++; + if (SineCounter % 4 == 0) { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; + if (player.altFunctionUse == 2) + { + //If you right click, shoots a helix of normal bullets + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + } + else + { + //If left click, do the same as above but spawn Charged Blasts instead + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 2f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 4f); + int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 3f); + } } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) + else if (player.altFunctionUse != 2) { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - } - else - { - mouseDistance = sSpeed / mouseDistance; - } - float randXOffset = mouseXDist; - float randYOffset = mouseYDist; - randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; - randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; - if (Collision.CanHitLine(player.Center, 0, 0, realPlayerPos + new Vector2(randXOffset, randYOffset) * 2f, 0, 0)) - { - realPlayerPos += new Vector2(randXOffset, randYOffset); - } - Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, randXOffset, randYOffset, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); - int bulletAmt = Main.rand.Next(2, 4); - for (int index = 0; index < bulletAmt; ++index) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Particle spark2 = new LineParticle(position + Main.rand.NextVector2Circular(6, 6), (velocity * 4).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(1.5f, 2f), Main.rand.NextBool() ? Color.MediumOrchid : Color.DarkViolet); + GeneralParticleHandler.SpawnParticle(spark2); } return false; } + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) > 90 && SineCounter % 4 == 0) + return true; + return false; + } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.SoulofMight, 10). - AddIngredient(ItemID.SoulofSight, 10). - AddIngredient(ItemID.SoulofFright, 10). + AddIngredient(). AddIngredient(5). AddTile(). Register(); diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index d57b2169da..e1aed457c9 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/LaserProj"; public Color baseColor = Color.White; public bool outOfTime = false; + public Vector2 baseVel; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; @@ -34,8 +35,27 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + bool Shredder = Projectile.ai[2] == 0; + bool Infinity = Projectile.ai[2] == 1; + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + if (baseColor == Color.White) - baseColor = (Projectile.ai[2] == 1 ? new Color(229, 49, 39) : Color.DodgerBlue); + { + baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + { + baseColor = Color.Violet; + } + if (Projectile.ai[2] == 4) + { + baseColor = Color.MediumOrchid; + } + baseVel = Projectile.velocity; + if (Svant) + Projectile.ArmorPenetration = 100; + if (Infinity) + Projectile.ArmorPenetration = 25; + } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Projectile.timeLeft == 2) outOfTime = true; @@ -49,16 +69,16 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.owner == Main.myPlayer) { for (int k = 0; k < projectiles; k++) - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -Projectile.velocity.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 0.7f), ModContent.ProjectileType(), (int)(Projectile.damage * (Projectile.ai[2] == 1 ? 0.3f : 0.5f)), Projectile.knockBack * 0.8f, Main.myPlayer, 0, 0, Projectile.ai[2] == 1 ? 1 : 0); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -baseVel.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 0.7f), ModContent.ProjectileType(), (int)(Projectile.damage * (Projectile.ai[2] > 0 ? 0.3f : 0.5f)), Projectile.knockBack * 0.8f, Main.myPlayer, 0, 0, Projectile.ai[2]); } for (int k = 0; k < 3; k++) { - Particle spark2 = new LineParticle(Projectile.Center, (-Projectile.velocity * 4).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(25, 32 + 1), Main.rand.NextFloat(1.5f, 2f), baseColor); + Particle spark2 = new LineParticle(Projectile.Center, (-baseVel * 4).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(25, 32 + 1), Main.rand.NextFloat(1.5f, 2f), baseColor); GeneralParticleHandler.SpawnParticle(spark2); } if (Projectile.ai[2] == 1) { - Particle spark2 = new LineParticle(Projectile.Center, (-Projectile.velocity * 5).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(35, 48 + 1), Main.rand.NextFloat(2.3f, 3f), baseColor); + Particle spark2 = new LineParticle(Projectile.Center, (-baseVel * 5).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(35, 48 + 1), Main.rand.NextFloat(2.3f, 3f), baseColor); GeneralParticleHandler.SpawnParticle(spark2); } } diff --git a/Projectiles/Ranged/ChargedBlastSplit.cs b/Projectiles/Ranged/ChargedBlastSplit.cs index 9e2da962aa..a5df485570 100644 --- a/Projectiles/Ranged/ChargedBlastSplit.cs +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -1,10 +1,12 @@ -using CalamityMod.Particles; +using System; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities.Terraria.Utilities; namespace CalamityMod.Projectiles.Ranged { @@ -15,6 +17,9 @@ namespace CalamityMod.Projectiles.Ranged public Color baseColor = Color.White; public int tileHits = 4; public Vector2 startVel; + public bool goToMouse = true; + bool direction; + public float homeSpeed; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; @@ -36,22 +41,58 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - bool InfinityShot = Projectile.ai[2] == 1; + Player player = Main.player[Projectile.owner]; + bool Shredder = Projectile.ai[2] == 0; + bool Infinity = Projectile.ai[2] == 1; + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + if (baseColor == Color.White) { - baseColor = (InfinityShot ? new Color(229, 49, 39) : Color.DodgerBlue); + baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + baseColor = Color.Violet; + if (Projectile.ai[2] == 4) + baseColor = Color.MediumOrchid; startVel = Projectile.velocity; - if (InfinityShot) + if (Infinity) + { Projectile.timeLeft = 340; + Projectile.ArmorPenetration = 25; + } + if (Svant) + { + Projectile.timeLeft = 640; + Projectile.ArmorPenetration = 100; + } + direction = Main.rand.NextBool(); + homeSpeed = Main.rand.NextFloat(5, 8); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.timeLeft < 290 && InfinityShot) + if (Projectile.timeLeft < 290 && Infinity) { Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, -startVel.X, 0.02f); Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, -startVel.Y, 0.02f); } - if (InfinityShot) + if (Projectile.timeLeft <= 500 && Svant && goToMouse && Projectile.timeLeft % Projectile.extraUpdates == 0) + { + Vector2 mouseSpot = (player.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX) * homeSpeed; + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, mouseSpot.X, 0.085f); + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, mouseSpot.Y, 0.085f); + if (Vector2.Distance(Projectile.Center, player.Calamity().mouseWorld) < 80) + { + Projectile.timeLeft = 300; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * homeSpeed; + goToMouse = false; + } + } + if (!goToMouse) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.375f / MathHelper.Pi) * 2.5f; + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * (direction ? 1 : -1); + Projectile.Center += offset; + } + if (Infinity || Svant) { Projectile.tileCollide = false; Projectile.penetrate = -1; @@ -64,6 +105,10 @@ namespace CalamityMod.Projectiles.Ranged Particle spark2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(8, 11 + 1), Main.rand.NextFloat(0.5f, 1f), baseColor); GeneralParticleHandler.SpawnParticle(spark2); } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + } public override bool PreDraw(ref Color lightColor) { From 435934f2a8833f8d09f63025fe1aaa603b5e035c Mon Sep 17 00:00:00 2001 From: Xyk Date: Wed, 29 May 2024 13:20:11 -0700 Subject: [PATCH 3/5] Small touch ups --- Items/Weapons/Ranged/Shredder.cs | 2 +- Projectiles/Ranged/ChargedBlast.cs | 10 +++++++++- Projectiles/Ranged/ChargedBlastSplit.cs | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 06281c5e18..b2dbd51af0 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.Bullet; - Item.shootSpeed = 6f; + Item.shootSpeed = 5f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index e1aed457c9..38cd9aad44 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -39,12 +39,15 @@ namespace CalamityMod.Projectiles.Ranged bool Infinity = Projectile.ai[2] == 1; bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (baseColor == Color.White) { baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); if (Projectile.ai[2] == 3) { - baseColor = Color.Violet; + baseColor = Color.DarkOrchid; } if (Projectile.ai[2] == 4) { @@ -59,6 +62,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Projectile.timeLeft == 2) outOfTime = true; + if ((Svant || Infinity) && Projectile.timeLeft % 2 == 0 && targetDist < 1400f) + { + Particle spark = new LineParticle(Projectile.Center - Projectile.velocity * 3, -Projectile.velocity * 0.05f, false, 5, 2f, baseColor * 0.65f); + GeneralParticleHandler.SpawnParticle(spark); + } } public override void OnKill(int timeLeft) { diff --git a/Projectiles/Ranged/ChargedBlastSplit.cs b/Projectiles/Ranged/ChargedBlastSplit.cs index a5df485570..fb72db7217 100644 --- a/Projectiles/Ranged/ChargedBlastSplit.cs +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged { baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); if (Projectile.ai[2] == 3) - baseColor = Color.Violet; + baseColor = Color.DarkOrchid; if (Projectile.ai[2] == 4) baseColor = Color.MediumOrchid; startVel = Projectile.velocity; @@ -82,13 +82,13 @@ namespace CalamityMod.Projectiles.Ranged if (Vector2.Distance(Projectile.Center, player.Calamity().mouseWorld) < 80) { Projectile.timeLeft = 300; - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * homeSpeed; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * homeSpeed / 2; goToMouse = false; } } if (!goToMouse) { - float sine = (float)Math.Sin(Projectile.timeLeft * 0.375f / MathHelper.Pi) * 2.5f; + float sine = (float)Math.Sin(Projectile.timeLeft * 0.175f / MathHelper.Pi) * 1.2f; Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * (direction ? 1 : -1); Projectile.Center += offset; } @@ -100,7 +100,8 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnKill(int timeLeft) { - for (int k = 0; k < 3; k++) + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + for (int k = 0; k < (Svant ? 2 : 3); k++) { Particle spark2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(8, 11 + 1), Main.rand.NextFloat(0.5f, 1f), baseColor); GeneralParticleHandler.SpawnParticle(spark2); From 25b5dd5af0a0a9469b5f713c55bb6eae7bda88c7 Mon Sep 17 00:00:00 2001 From: Xyk Date: Wed, 29 May 2024 15:21:29 -0700 Subject: [PATCH 4/5] Tooltips --- .../en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson | 7 ++++--- Projectiles/Ranged/ChargedBlast.cs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index f12bbcfdce..d15cb408ad 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -653,7 +653,7 @@ Infinity: { DisplayName: Infinity Tooltip: ''' - Fires a barrage of energy bolts that split and bounce + Fires a twin stream of energy bolts that split Press to fire a barrage of normal bullets 'They say infinity is neverending, yet you hold it in your hands' ''' @@ -1242,8 +1242,9 @@ Svantechnical: { DisplayName: Svantechnical Tooltip: ''' - Fires several barrages of bullets - Press to zoom out + Fires a trinity of energy bolts that split into beams that track your cursor + Press to fire a barrage of normal bullets + 'The age old balance of trading damage for frames' ''' } diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index 38cd9aad44..30a3a8ef6f 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Projectile.timeLeft == 2) outOfTime = true; - if ((Svant || Infinity) && Projectile.timeLeft % 2 == 0 && targetDist < 1400f) + if ((Svant || Infinity) && Projectile.timeLeft % 2 == 0 && targetDist < 1400f && Projectile.timeLeft < 340) { Particle spark = new LineParticle(Projectile.Center - Projectile.velocity * 3, -Projectile.velocity * 0.05f, false, 5, 2f, baseColor * 0.65f); GeneralParticleHandler.SpawnParticle(spark); From 86e69081dd154019eaf49688d76ab118aaa0e1a5 Mon Sep 17 00:00:00 2001 From: Xyk Date: Wed, 29 May 2024 22:07:28 -0700 Subject: [PATCH 5/5] Removed Redundant Code --- Items/Weapons/Ranged/Infinity.cs | 21 +++++---------------- Items/Weapons/Ranged/Shredder.cs | 18 ++++-------------- Items/Weapons/Ranged/Svantechnical.cs | 22 ++++------------------ 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index fb2c7136ee..31868841d0 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -54,27 +54,16 @@ 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 shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 3.5f; SineCounter++; if (SineCounter % 4 == 0) { - if (player.altFunctionUse == 2) - { - //If you right click, shoots a helix of normal bullets - Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); - Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - } - else - { - //If left click, do the same as above but spawn Charged Blasts instead - Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); - Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 1f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 1f); - } + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); } else if (player.altFunctionUse != 2) { diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index b2dbd51af0..4996c2f66a 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -46,22 +46,12 @@ 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 shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); int bulletAmt = 3; - if (player.altFunctionUse == 2) + Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; + for (int index = 0; index < bulletAmt; index++) { - Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - for (int index = 0; index < bulletAmt; index++) - { - int shot = Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), type, damage, knockback, player.whoAmI); - } - } - else - { - Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - for (int index = 0; index < bulletAmt; index++) - { - Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); - } + Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), shotType, damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index eced3fa849..e304c42a43 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -49,37 +49,23 @@ namespace CalamityMod.Items.Weapons.Ranged { return true; } - public override void HoldItem(Player player) => player.scope = false; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 4f; float sine2 = (float)Math.Sin(SineCounter * 0.275f / MathHelper.Pi) * 2f; SineCounter++; if (SineCounter % 4 == 0) { - if (player.altFunctionUse == 2) - { - //If you right click, shoots a helix of normal bullets Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - } - else - { - //If left click, do the same as above but spawn Charged Blasts instead - Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); - Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 2f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 4f); - int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0, 3f); - } + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 2f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 4f); + int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 3f); } else if (player.altFunctionUse != 2) {