diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 0a3822976f..31868841d0 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; @@ -13,8 +15,7 @@ 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() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -24,12 +25,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 110; + Item.damage = 85; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 12; - Item.reuseDelay = 12; - Item.useLimitPerAnimation = 9; + Item.useTime = 1; + Item.useAnimation = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1f; @@ -38,7 +37,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,63 +54,30 @@ 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) + 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 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) - { - rotation += 2; - } - else - { - rotation -= 2; - } - if (rotation >= 11) - { - limit = false; - } - else if (rotation <= -11) - { - limit = true; - } - return false; + 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 + 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 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 6665770842..4996c2f66a 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 = 5f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -45,33 +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; - if (player.altFunctionUse == 2) + int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); + int bulletAmt = 3; + Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; + for (int index = 0; index < bulletAmt; index++) { - 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; - } - } - 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), shotType, damage, knockback, player.whoAmI); } 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..e304c42a43 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,53 @@ 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) + 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) { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; + 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, 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); } - 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/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/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..30a3a8ef6f 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,14 @@ 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 Vector2 baseVel; + 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 +28,78 @@ 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; + 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; - float lightScale = 1f - Projectile.alpha / 255f; - Projectile.ai[2] = lightScale; - Lighting.AddLight(Projectile.Center, 0f, 0.3f * lightScale, 0.7f * lightScale); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - float beamLength = 60f; - float beamLengthGrowth = 1f; - 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 void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item62, Projectile.position); - int projectiles = 2; - if (Projectile.owner == Main.myPlayer) + if (baseColor == Color.White) { - 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); + baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + { + baseColor = Color.DarkOrchid; + } + 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; + 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); } } + public override void OnKill(int timeLeft) + { + if (!outOfTime) + { + 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, -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, (-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, (-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); + } + } + } + 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..fb72db7217 --- /dev/null +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -0,0 +1,143 @@ +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 +{ + 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 bool goToMouse = true; + bool direction; + public float homeSpeed; + 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() + { + 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 = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + baseColor = Color.DarkOrchid; + if (Projectile.ai[2] == 4) + baseColor = Color.MediumOrchid; + startVel = Projectile.velocity; + 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 && 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 (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 / 2; + goToMouse = false; + } + } + if (!goToMouse) + { + 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; + } + if (Infinity || Svant) + { + Projectile.tileCollide = false; + Projectile.penetrate = -1; + } + } + public override void OnKill(int timeLeft) + { + 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); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + + } + 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; + } + } +}