diff --git a/Items/Weapons/Ranged/SurgeDriver.cs b/Items/Weapons/Ranged/SurgeDriver.cs index b5f285e84d..6ce1f01aa4 100644 --- a/Items/Weapons/Ranged/SurgeDriver.cs +++ b/Items/Weapons/Ranged/SurgeDriver.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1200; + item.damage = 800; item.ranged = true; item.width = 164; item.height = 58; @@ -34,25 +34,38 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = AmmoID.Bullet; } - public override Vector2? HoldoutOffset() => Vector2.UnitX * -50f; + public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f); public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { if (player.altFunctionUse == 2) + { + item.noUseGraphic = false; + item.reuseDelay = 0; item.UseSound = SoundID.Item14; + item.channel = false; + } else + { + item.noUseGraphic = true; + item.reuseDelay = 28; item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"); + item.channel = true; + return player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + } return base.CanUseItem(player); } + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 1f; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 shootVelocity = new Vector2(speedX, speedY); Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Vector2 gunTip = position + shootDirection * item.scale * 132f; + Vector2 gunTip = position + shootDirection * item.scale * 126f; + gunTip.Y -= 6f; // Large bullet/rocket releasing. if (player.altFunctionUse == 2) @@ -65,13 +78,9 @@ namespace CalamityMod.Items.Weapons.Ranged } } - // Snipe blast. + // Snipe blast. Done via a held projectile. else - { - shootVelocity *= 0.64f; - damage = (int)(damage * 6.66); - Projectile.NewProjectile(gunTip, shootVelocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - } + Projectile.NewProjectile(gunTip, shootVelocity, ModContent.ProjectileType(), 0, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Ranged/SurgeDriver.png b/Items/Weapons/Ranged/SurgeDriver.png index f06915a6ac..12d9fe4928 100644 Binary files a/Items/Weapons/Ranged/SurgeDriver.png and b/Items/Weapons/Ranged/SurgeDriver.png differ diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.cs b/Projectiles/Ranged/PrismaticEnergyBlast.cs index 7613feb707..073240ffd1 100644 --- a/Projectiles/Ranged/PrismaticEnergyBlast.cs +++ b/Projectiles/Ranged/PrismaticEnergyBlast.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = projectile.height = 24; + projectile.width = projectile.height = 14; projectile.friendly = true; projectile.ranged = true; projectile.tileCollide = false; diff --git a/Projectiles/Ranged/SurgeDriverHoldout.cs b/Projectiles/Ranged/SurgeDriverHoldout.cs new file mode 100644 index 0000000000..0031b41ef4 --- /dev/null +++ b/Projectiles/Ranged/SurgeDriverHoldout.cs @@ -0,0 +1,100 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SurgeDriverHoldout : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + public ref float ShootCountdown => ref projectile.ai[0]; + public override void SetStaticDefaults() => DisplayName.SetDefault("Storm Driver"); + + public override void SetDefaults() + { + projectile.width = 192; + projectile.height = 52; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + if (!OwnerCanShoot) + projectile.Kill(); + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + armPosition += projectile.velocity.SafeNormalize(Owner.direction * Vector2.UnitX) * 32f; + armPosition.Y -= 12f; + + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + + ShootCountdown--; + if (ShootCountdown <= 0f) + { + if (Main.myPlayer == projectile.owner) + { + ShootProjectiles(armPosition); + ShootCountdown = 28f; + projectile.netUpdate = true; + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center); + } + } + + public void ShootProjectiles(Vector2 armPosition) + { + if (Main.myPlayer != projectile.owner) + return; + + Item heldItem = Owner.ActiveItem(); + int projectileType = ModContent.ProjectileType(); + float shootSpeed = heldItem.shootSpeed * projectile.scale * 0.64f; + int damage = (int)(Owner.GetWeaponDamage(heldItem) * 6.66); + float knockback = heldItem.knockBack; + + bool uselessFuckYou = OwnerCanShoot; + Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref damage, ref knockback, false); + projectileType = ModContent.ProjectileType(); + + knockback = Owner.GetWeaponKnockback(heldItem, knockback); + Vector2 shootDirection = (Main.MouseWorld - projectile.Center).SafeNormalize(-Vector2.UnitY); + Vector2 shootVelocity = shootDirection * shootSpeed; + + // Sync if the shoot direction changes. + if (shootDirection.X != projectile.velocity.X || shootDirection.Y != projectile.velocity.Y) + projectile.netUpdate = true; + + Vector2 gunTip = armPosition + shootDirection * heldItem.scale * 130f; + Projectile.NewProjectile(gunTip, shootVelocity, projectileType, damage, knockback, projectile.owner, 0f, 0f); + + projectile.velocity = shootDirection; + } + + public void UpdateProjectileHeldVariables(Vector2 armPosition) + { + projectile.position = armPosition - projectile.Size * 0.5f; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + } + + public void ManipulatePlayerVariables() + { + Owner.ChangeDir(projectile.direction); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + } + } +} diff --git a/Projectiles/Ranged/SurgeDriverHoldout.png b/Projectiles/Ranged/SurgeDriverHoldout.png new file mode 100644 index 0000000000..1d943243d5 Binary files /dev/null and b/Projectiles/Ranged/SurgeDriverHoldout.png differ diff --git a/Projectiles/Rogue/TheAtomSplitterProjectile.cs b/Projectiles/Rogue/TheAtomSplitterProjectile.cs index 61c475bdf3..abc384ed25 100644 --- a/Projectiles/Rogue/TheAtomSplitterProjectile.cs +++ b/Projectiles/Rogue/TheAtomSplitterProjectile.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Rogue public ref float HitTargetIndex => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/PrismJavelin"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/TheAtomSplitter"; public override void SetStaticDefaults() => DisplayName.SetDefault("Atom Splitter");