diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index 14f578fa0d..f580d96470 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -75,35 +75,20 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - float xPos = Main.rand.NextBool(2) ? projectile.position.X + 800 : projectile.position.X - 800; - Vector2 vector2 = new Vector2(xPos, projectile.position.Y + Main.rand.Next(-800, 801)); - float num80 = xPos; - float speedX = (float)target.position.X - vector2.X; - float speedY = (float)target.position.Y - vector2.Y; - float dir = 10 / num80; - speedX *= dir * 150; - speedY *= dir * 150; - if (speedX > 15f) - { - speedX = 15f; - } - if (speedX < -15f) - { - speedX = -15f; - } - if (speedY > 15f) - { - speedY = 15f; - } - if (speedY < -15f) - { - speedY = -15f; - } + float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); + float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); + Vector2 spawnPosition = new Vector2(xPos, yPos); + Vector2 velocity = target.Center - spawnPosition; + float dir = 10 / spawnPosition.X; + velocity.X *= dir * 150; + velocity.Y *= dir * 150; + velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); + velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); if (projectile.owner == Main.myPlayer) { int splitDamage = (int)(projectile.damage * 0.6f); float splitKB = 1f; - Projectile.NewProjectile(vector2, new Vector2(speedX, speedY), ModContent.ProjectileType(), splitDamage, splitKB, projectile.owner); + Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), splitDamage, splitKB, projectile.owner); } }