diff --git a/Projectiles/Ranged/TerraArrowMain.cs b/Projectiles/Ranged/TerraArrowMain.cs index af9e439e3f..1e93a8e051 100644 --- a/Projectiles/Ranged/TerraArrowMain.cs +++ b/Projectiles/Ranged/TerraArrowMain.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Ranged } value15.Normalize(); value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Ranged/TerraArrowSplit.cs b/Projectiles/Ranged/TerraArrowSplit.cs index 6b821fb134..5a75dadf2a 100644 --- a/Projectiles/Ranged/TerraArrowSplit.cs +++ b/Projectiles/Ranged/TerraArrowSplit.cs @@ -7,6 +7,7 @@ namespace CalamityMod.Projectiles.Ranged { public class TerraArrowSplit : ModProjectile { + private float speed = 0f; public override void SetStaticDefaults() { DisplayName.SetDefault("Arrow"); @@ -28,7 +29,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.alpha -= 5; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 20f, 20f); } diff --git a/Projectiles/Ranged/TerraBulletMain.cs b/Projectiles/Ranged/TerraBulletMain.cs index bd0366cb1a..28bb65c8e0 100644 --- a/Projectiles/Ranged/TerraBulletMain.cs +++ b/Projectiles/Ranged/TerraBulletMain.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Ranged } value15.Normalize(); value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.Item118, projectile.position); diff --git a/Projectiles/Ranged/TerraBulletSplit.cs b/Projectiles/Ranged/TerraBulletSplit.cs index 3f021bf8f2..b2f59896bc 100644 --- a/Projectiles/Ranged/TerraBulletSplit.cs +++ b/Projectiles/Ranged/TerraBulletSplit.cs @@ -9,6 +9,7 @@ namespace CalamityMod.Projectiles.Ranged { public class TerraBulletSplit : ModProjectile { + private float speed = 0f; public override void SetStaticDefaults() { DisplayName.SetDefault("Bullet"); @@ -57,81 +58,10 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num137].position.Y = y2; Main.dust[num137].velocity *= 0f; Main.dust[num137].noGravity = true; - float num138 = (float)Math.Sqrt((double)(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y)); - float num139 = projectile.localAI[0]; - if (num139 == 0f) - { - projectile.localAI[0] = num138; - num139 = num138; - } - float num140 = projectile.position.X; - float num141 = projectile.position.Y; - float num142 = 400f; - bool flag4 = false; - int num143 = 0; - if (projectile.ai[1] == 0f) - { - for (int num144 = 0; num144 < 200; num144++) - { - if (Main.npc[num144].CanBeChasedBy(projectile, false) && (projectile.ai[1] == 0f || projectile.ai[1] == (float)(num144 + 1))) - { - float num145 = Main.npc[num144].position.X + (float)(Main.npc[num144].width / 2); - float num146 = Main.npc[num144].position.Y + (float)(Main.npc[num144].height / 2); - float num147 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num145) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num146); - if (num147 < num142 && Collision.CanHit(new Vector2(projectile.position.X + (float)(projectile.width / 2), projectile.position.Y + (float)(projectile.height / 2)), 1, 1, Main.npc[num144].position, Main.npc[num144].width, Main.npc[num144].height)) - { - num142 = num147; - num140 = num145; - num141 = num146; - flag4 = true; - num143 = num144; - } - } - } - if (flag4) - { - projectile.ai[1] = (float)(num143 + 1); - } - flag4 = false; - } - if (projectile.ai[1] > 0f) - { - int num148 = (int)(projectile.ai[1] - 1f); - if (Main.npc[num148].active && Main.npc[num148].CanBeChasedBy(projectile, true) && !Main.npc[num148].dontTakeDamage) - { - float num149 = Main.npc[num148].position.X + (float)(Main.npc[num148].width / 2); - float num150 = Main.npc[num148].position.Y + (float)(Main.npc[num148].height / 2); - float num151 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num149) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num150); - if (num151 < 1000f) - { - flag4 = true; - num140 = Main.npc[num148].position.X + (float)(Main.npc[num148].width / 2); - num141 = Main.npc[num148].position.Y + (float)(Main.npc[num148].height / 2); - } - } - else - { - projectile.ai[1] = 0f; - } - } - if (!projectile.friendly) - { - flag4 = false; - } - if (flag4) - { - float num152 = num139; - Vector2 vector13 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num153 = num140 - vector13.X; - float num154 = num141 - vector13.Y; - float num155 = (float)Math.Sqrt((double)(num153 * num153 + num154 * num154)); - num155 = num152 / num155; - num153 *= num155; - num154 *= num155; - int num156 = 12; - projectile.velocity.X = (projectile.velocity.X * (float)(num156 - 1) + num153) / (float)num156; - projectile.velocity.Y = (projectile.velocity.Y * (float)(num156 - 1) + num154) / (float)num156; - } - } + + if (speed == 0f) + speed = projectile.velocity.Length(); + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, speed, 12f); + } } }