From e8772b8fa29a43bef33fa861d8f511f8736414c8 Mon Sep 17 00:00:00 2001 From: NycroV <83246959+NycroV@users.noreply.github.com> Date: Sun, 26 Jun 2022 01:47:43 -0400 Subject: [PATCH] Fixed the interaction between Luxor's Gift and the titanium railgun --- Items/CalamityGlobalItem.cs | 17 ++++++++++++----- Projectiles/Ranged/TitaniumRailgunScope.cs | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index d36e4b3fb2..ecf9165244 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -281,12 +281,19 @@ namespace CalamityMod.Items } else if (item.CountsAsClass()) { - double rangedDamage = newDamage * 0.15; - if (rangedDamage >= 1D) + // This projectile is channeled and has no cooldown unless the gun fires + // The damage of the projectile is also always the max damage of the weapon, and the shot damage is calculated based off of that + // You can see how this may cause issues + // The projectile is fired inside of the scope's code instead + if (type != ModContent.ProjectileType()) { - int projectile = Projectile.NewProjectile(source, position, velocity * 1.5f, ModContent.ProjectileType(), (int)rangedDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceClassless = true; + double rangedDamage = newDamage * 0.15; + if (rangedDamage >= 1D) + { + int projectile = Projectile.NewProjectile(source, position, velocity * 1.5f, ModContent.ProjectileType(), (int)rangedDamage, 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceClassless = true; + } } } else if (item.CountsAsClass()) diff --git a/Projectiles/Ranged/TitaniumRailgunScope.cs b/Projectiles/Ranged/TitaniumRailgunScope.cs index 0ec44dfce6..5319b838e9 100644 --- a/Projectiles/Ranged/TitaniumRailgunScope.cs +++ b/Projectiles/Ranged/TitaniumRailgunScope.cs @@ -113,7 +113,8 @@ namespace CalamityMod.Projectiles.Ranged Owner.Calamity().GeneralScreenShakePower = 4f * ChargePercent; // Spawn the laser - Projectile.NewProjectile(new EntitySource_ItemUse_WithAmmo(Owner, Owner.HeldItem, -1), Owner.MountedCenter + direction * WeaponLength, direction, ModContent.ProjectileType(), (int)(Projectile.damage * ChargePercent), Projectile.knockBack * ChargePercent, Projectile.owner, ai1: ChargePercent); + int shotDamage = (int)(Projectile.damage * ChargePercent); + Projectile.NewProjectile(new EntitySource_ItemUse_WithAmmo(Owner, Owner.HeldItem, -1), Owner.MountedCenter + direction * WeaponLength, direction, ModContent.ProjectileType(), shotDamage, Projectile.knockBack * ChargePercent, Projectile.owner, ai1: ChargePercent); // Calculate the target end recoil and initial recoil based off of charge level // Initial recoil is manually set to give a smoother recoil animation @@ -129,6 +130,19 @@ namespace CalamityMod.Projectiles.Ranged // Play a sound with volume scaling with charge percent SoundEngine.PlaySound(SoundID.Item62 with { Volume = SoundID.Item62.Volume * ChargePercent }, Owner.MountedCenter); + // Summon Luxor's gift manually, as channeling tends to be.... unbalanced, to say the least, if you don't + if (Owner.Calamity().luxorsGift) + { + double rangedDamage = shotDamage * 0.15; + if (rangedDamage >= 1D) + { + float speed = 24f * ChargePercent; + int projectile = Projectile.NewProjectile(new EntitySource_ItemUse_WithAmmo(Owner, Owner.HeldItem, -1), Projectile.Center, direction * speed, ModContent.ProjectileType(), (int)rangedDamage, 0f, Projectile.owner); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceClassless = true; + } + } + // Set the initial recoil, mark the projectile as fired, and set the target recoil Owner.itemRotation = initialRecoil; Charge = -1;