From ea1f677b7cd405c424f2e5216aea29fade4d85b8 Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Wed, 12 Feb 2020 23:00:08 -0600 Subject: [PATCH] Some homing melee projectiles reworked. --- Projectiles/Melee/AccretionDiskMeleeProj.cs | 53 ++++++++++++--------- Projectiles/Melee/BlazingPhantomBlade.cs | 48 +++++++++++-------- Projectiles/Melee/Blood.cs | 48 +++++++++++-------- Projectiles/Melee/Blood2.cs | 48 +++++++++++-------- Projectiles/Melee/Brimlash2.cs | 48 +++++++++++-------- Projectiles/Melee/CosmicOrb.cs | 52 +++++++++++--------- Projectiles/Melee/DepthOrb2.cs | 48 +++++++++++-------- Projectiles/Melee/ElementBall.cs | 48 +++++++++++-------- Projectiles/Melee/ElementalExcaliburBeam.cs | 47 ++++++++++-------- Projectiles/Melee/EssenceFlame2.cs | 48 +++++++++++-------- Projectiles/Melee/EssenceScythe.cs | 48 +++++++++++-------- Projectiles/Melee/Flarefrost.cs | 48 +++++++++++-------- Projectiles/Melee/Galaxia.cs | 48 +++++++++++-------- Projectiles/Melee/Galaxia2.cs | 48 +++++++++++-------- Projectiles/Melee/GhastlySoulLarge.cs | 48 +++++++++++-------- Projectiles/Melee/GhastlySoulMedium.cs | 48 +++++++++++-------- Projectiles/Melee/GhastlySoulSmall.cs | 48 +++++++++++-------- Projectiles/Melee/HyperBlade.cs | 48 +++++++++++-------- Projectiles/Melee/JudgementBlah.cs | 48 +++++++++++-------- Projectiles/Melee/JudgementProj.cs | 48 +++++++++++-------- Projectiles/Melee/Leech.cs | 48 +++++++++++-------- Projectiles/Melee/NightStabber.cs | 48 +++++++++++-------- Projectiles/Melee/OmegaBiomeOrb.cs | 23 +++++---- Projectiles/Melee/PlagueSeeker.cs | 48 +++++++++++-------- Projectiles/Melee/PlasmaBall.cs | 48 +++++++++++-------- Projectiles/Melee/RainBolt.cs | 48 +++++++++++-------- Projectiles/Melee/Razorwind.cs | 50 ++++++++++--------- Projectiles/Melee/RoyalKnifeMelee.cs | 48 +++++++++++-------- Projectiles/Melee/SandFire.cs | 48 +++++++++++-------- Projectiles/Melee/TerraBall.cs | 45 +++++++++-------- Projectiles/Melee/TerratomereProjectile.cs | 47 ++++++++++-------- Projectiles/Melee/TinyFlare.cs | 48 +++++++++++-------- Projectiles/Melee/UltimusCleaverDust.cs | 48 +++++++++++-------- Projectiles/Melee/Whiterain.cs | 48 +++++++++++-------- Projectiles/Melee/WhiterainBlah.cs | 48 +++++++++++-------- Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs | 51 +++++++++++--------- Projectiles/Melee/Yoyos/CnidarianYoyo.cs | 51 +++++++++++--------- Projectiles/Melee/Yoyos/GodsGambitYoyo.cs | 51 +++++++++++--------- Projectiles/Melee/Yoyos/OblivionYoyo.cs | 51 +++++++++++--------- Projectiles/Melee/Yoyos/PandemicYoyo.cs | 51 +++++++++++--------- Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs | 53 +++++++++++---------- Projectiles/Melee/Yoyos/VerdantYoyo.cs | 53 ++++++++++++--------- Projectiles/Melee/Yoyos/YinYoyo.cs | 51 +++++++++++--------- 43 files changed, 1160 insertions(+), 913 deletions(-) diff --git a/Projectiles/Melee/AccretionDiskMeleeProj.cs b/Projectiles/Melee/AccretionDiskMeleeProj.cs index b42ff2fdac..4dd802f2a7 100644 --- a/Projectiles/Melee/AccretionDiskMeleeProj.cs +++ b/Projectiles/Melee/AccretionDiskMeleeProj.cs @@ -44,30 +44,37 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num250].velocity *= 0f; } } + Lighting.AddLight(projectile.Center, 0.15f, 1f, 0.25f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + (float)(Main.npc[num430].width / 2); - float num432 = Main.npc[num430].position.Y + (float)(Main.npc[num430].height / 2); - float num433 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num431) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/BlazingPhantomBlade.cs b/Projectiles/Melee/BlazingPhantomBlade.cs index da46216b29..854293ec84 100644 --- a/Projectiles/Melee/BlazingPhantomBlade.cs +++ b/Projectiles/Melee/BlazingPhantomBlade.cs @@ -34,27 +34,33 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 460f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 500f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 8f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index 0f49f5bf50..986b32fa6e 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -33,27 +33,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 6f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index ab61e361b3..75f8e0856a 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -33,27 +33,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 300f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 300f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 6f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Brimlash2.cs b/Projectiles/Melee/Brimlash2.cs index 7acd005674..2a41d963c7 100644 --- a/Projectiles/Melee/Brimlash2.cs +++ b/Projectiles/Melee/Brimlash2.cs @@ -33,27 +33,33 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 15f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/CosmicOrb.cs b/Projectiles/Melee/CosmicOrb.cs index 0aabe57df2..a52ca59700 100644 --- a/Projectiles/Melee/CosmicOrb.cs +++ b/Projectiles/Melee/CosmicOrb.cs @@ -49,29 +49,35 @@ namespace CalamityMod.Projectiles.Melee return; } } - int[] array = new int[20]; - int num428 = 0; - float num429 = 500f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + (float)(Main.npc[num430].width / 2); - float num432 = Main.npc[num430].position.Y + (float)(Main.npc[num430].height / 2); - float num433 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num431) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + + int[] array = new int[20]; + int num428 = 0; + float distance = 500f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/DepthOrb2.cs b/Projectiles/Melee/DepthOrb2.cs index 57f683afd7..8832378600 100644 --- a/Projectiles/Melee/DepthOrb2.cs +++ b/Projectiles/Melee/DepthOrb2.cs @@ -34,27 +34,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 18f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/ElementBall.cs b/Projectiles/Melee/ElementBall.cs index 80a914c163..b839e06643 100644 --- a/Projectiles/Melee/ElementBall.cs +++ b/Projectiles/Melee/ElementBall.cs @@ -30,27 +30,33 @@ namespace CalamityMod.Projectiles.Melee int num250 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); Main.dust[num250].noGravity = true; Main.dust[num250].velocity *= 0f; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 25f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/ElementalExcaliburBeam.cs b/Projectiles/Melee/ElementalExcaliburBeam.cs index c7c5f5845f..d787c62a1d 100644 --- a/Projectiles/Melee/ElementalExcaliburBeam.cs +++ b/Projectiles/Melee/ElementalExcaliburBeam.cs @@ -157,27 +157,32 @@ namespace CalamityMod.Projectiles.Melee case 4: // Green, home in on enemies color = new Color(0, 255, 0, alpha); - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 12f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/EssenceFlame2.cs b/Projectiles/Melee/EssenceFlame2.cs index 20a1c21b9d..bbbb02fe88 100644 --- a/Projectiles/Melee/EssenceFlame2.cs +++ b/Projectiles/Melee/EssenceFlame2.cs @@ -38,27 +38,33 @@ namespace CalamityMod.Projectiles.Melee { projectile.frame = 0; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 10f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/EssenceScythe.cs b/Projectiles/Melee/EssenceScythe.cs index eea65cb06c..52b4ce4fe2 100644 --- a/Projectiles/Melee/EssenceScythe.cs +++ b/Projectiles/Melee/EssenceScythe.cs @@ -39,27 +39,33 @@ namespace CalamityMod.Projectiles.Melee { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < Main.npc.Length; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 18f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Flarefrost.cs b/Projectiles/Melee/Flarefrost.cs index a42ec9756b..7a025c5b27 100644 --- a/Projectiles/Melee/Flarefrost.cs +++ b/Projectiles/Melee/Flarefrost.cs @@ -50,27 +50,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 14f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Galaxia.cs b/Projectiles/Melee/Galaxia.cs index 14d62e3cd3..c9b7ee00e8 100644 --- a/Projectiles/Melee/Galaxia.cs +++ b/Projectiles/Melee/Galaxia.cs @@ -81,27 +81,33 @@ namespace CalamityMod.Projectiles.Melee Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 1600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 1600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 35f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Galaxia2.cs b/Projectiles/Melee/Galaxia2.cs index 77dc7ae64c..4a763b7e3f 100644 --- a/Projectiles/Melee/Galaxia2.cs +++ b/Projectiles/Melee/Galaxia2.cs @@ -80,27 +80,33 @@ namespace CalamityMod.Projectiles.Melee Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 1600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 1600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 35f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/GhastlySoulLarge.cs b/Projectiles/Melee/GhastlySoulLarge.cs index 892bf87a35..c9c29d111c 100644 --- a/Projectiles/Melee/GhastlySoulLarge.cs +++ b/Projectiles/Melee/GhastlySoulLarge.cs @@ -65,27 +65,33 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; return; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 14f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/GhastlySoulMedium.cs b/Projectiles/Melee/GhastlySoulMedium.cs index 000dea66c0..0099d93b31 100644 --- a/Projectiles/Melee/GhastlySoulMedium.cs +++ b/Projectiles/Melee/GhastlySoulMedium.cs @@ -65,27 +65,33 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; return; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 16f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/GhastlySoulSmall.cs b/Projectiles/Melee/GhastlySoulSmall.cs index 923b51fcd3..8da499d1a0 100644 --- a/Projectiles/Melee/GhastlySoulSmall.cs +++ b/Projectiles/Melee/GhastlySoulSmall.cs @@ -64,27 +64,33 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; return; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 18f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/HyperBlade.cs b/Projectiles/Melee/HyperBlade.cs index 53dfc473fb..586276017d 100644 --- a/Projectiles/Melee/HyperBlade.cs +++ b/Projectiles/Melee/HyperBlade.cs @@ -36,27 +36,33 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, 0f, 0.5f, 0f); - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 25f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/JudgementBlah.cs b/Projectiles/Melee/JudgementBlah.cs index 7c98624ea6..816560da98 100644 --- a/Projectiles/Melee/JudgementBlah.cs +++ b/Projectiles/Melee/JudgementBlah.cs @@ -86,27 +86,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 10f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index fa9cbc4e6f..8dc9412f84 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -57,27 +57,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 9f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Leech.cs b/Projectiles/Melee/Leech.cs index 1c5bed626e..e57826c611 100644 --- a/Projectiles/Melee/Leech.cs +++ b/Projectiles/Melee/Leech.cs @@ -33,27 +33,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 6f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/NightStabber.cs b/Projectiles/Melee/NightStabber.cs index cbb95f8b6c..8fa870f035 100644 --- a/Projectiles/Melee/NightStabber.cs +++ b/Projectiles/Melee/NightStabber.cs @@ -34,27 +34,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 7f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/OmegaBiomeOrb.cs b/Projectiles/Melee/OmegaBiomeOrb.cs index 3996347b44..cf65030097 100644 --- a/Projectiles/Melee/OmegaBiomeOrb.cs +++ b/Projectiles/Melee/OmegaBiomeOrb.cs @@ -137,24 +137,29 @@ namespace CalamityMod.Projectiles.Melee float num472 = projectile.Center.X; float num473 = projectile.Center.Y; - float num474 = 400f; + float distance = 400f; bool flag17 = false; for (int num475 = 0; num475 < 200; num475++) { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) + if (Main.npc[num475].CanBeChasedBy(projectile, false)) { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) { - num474 = num478; - num472 = num476; - num473 = num477; + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; flag17 = true; } } } + if (flag17) { float num483 = 15f; diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index 53a206186f..c942c135e2 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -34,27 +34,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 18f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/PlasmaBall.cs b/Projectiles/Melee/PlasmaBall.cs index fc34d9b3a9..e2fb9aaad4 100644 --- a/Projectiles/Melee/PlasmaBall.cs +++ b/Projectiles/Melee/PlasmaBall.cs @@ -48,27 +48,33 @@ namespace CalamityMod.Projectiles.Melee int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, 0f, 0f, 100, default, 0.8f); Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 12f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index 738cf2698a..9e5c2ea91c 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -33,27 +33,33 @@ namespace CalamityMod.Projectiles.Melee int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 14f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Razorwind.cs b/Projectiles/Melee/Razorwind.cs index a48d3a27f7..071408afb1 100644 --- a/Projectiles/Melee/Razorwind.cs +++ b/Projectiles/Melee/Razorwind.cs @@ -49,29 +49,35 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 150f * 3f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 450f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) - { - float num483 = 5f * 3f; + float num483 = 15f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num484 = num472 - vector35.X; float num485 = num473 - vector35.Y; diff --git a/Projectiles/Melee/RoyalKnifeMelee.cs b/Projectiles/Melee/RoyalKnifeMelee.cs index 73cd47c79e..34f71a8f7e 100644 --- a/Projectiles/Melee/RoyalKnifeMelee.cs +++ b/Projectiles/Melee/RoyalKnifeMelee.cs @@ -44,27 +44,33 @@ namespace CalamityMod.Projectiles.Melee { projectile.rotation += 0.5f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 800f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 800f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 35f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/SandFire.cs b/Projectiles/Melee/SandFire.cs index 8603c36230..2c1eb79470 100644 --- a/Projectiles/Melee/SandFire.cs +++ b/Projectiles/Melee/SandFire.cs @@ -36,27 +36,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 20f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/TerraBall.cs b/Projectiles/Melee/TerraBall.cs index fcb42096c2..3707e88464 100644 --- a/Projectiles/Melee/TerraBall.cs +++ b/Projectiles/Melee/TerraBall.cs @@ -50,26 +50,31 @@ namespace CalamityMod.Projectiles.Melee projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 12f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/TerratomereProjectile.cs b/Projectiles/Melee/TerratomereProjectile.cs index 9ad8444b75..2e9ed68a4c 100644 --- a/Projectiles/Melee/TerratomereProjectile.cs +++ b/Projectiles/Melee/TerratomereProjectile.cs @@ -28,27 +28,32 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 20f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/TinyFlare.cs b/Projectiles/Melee/TinyFlare.cs index ec0eec2830..3d3793ae0f 100644 --- a/Projectiles/Melee/TinyFlare.cs +++ b/Projectiles/Melee/TinyFlare.cs @@ -34,27 +34,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 400f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 400f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 10f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 06be44f4b5..a0b530272e 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -83,27 +83,33 @@ namespace CalamityMod.Projectiles.Melee { projectile.velocity.Y = 16f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 150f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 150f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 12f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Whiterain.cs b/Projectiles/Melee/Whiterain.cs index 37a653fb6b..1a7d9b44e3 100644 --- a/Projectiles/Melee/Whiterain.cs +++ b/Projectiles/Melee/Whiterain.cs @@ -39,27 +39,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 600f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 12f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/WhiterainBlah.cs b/Projectiles/Melee/WhiterainBlah.cs index a959f85939..6081f621db 100644 --- a/Projectiles/Melee/WhiterainBlah.cs +++ b/Projectiles/Melee/WhiterainBlah.cs @@ -39,27 +39,33 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 1000f; - bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) + + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float distance = 1000f; + bool flag17 = false; + for (int num475 = 0; num475 < 200; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num475].width / 2) + (float)(Main.npc[num475].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num475].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(Main.npc[num475].Center, projectile.Center); + num472 = Main.npc[num475].Center.X; + num473 = Main.npc[num475].Center.Y; + flag17 = true; + } + } + } + + if (flag17) { float num483 = 18f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); diff --git a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs index 8d18cd7ffc..3366e4c9df 100644 --- a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs +++ b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs @@ -34,29 +34,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs index 05bfcdb62a..f625c34047 100644 --- a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs +++ b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs @@ -31,29 +31,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs index a83ad987a3..f361a763ca 100644 --- a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs +++ b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs @@ -30,29 +30,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 450f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 450f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/OblivionYoyo.cs b/Projectiles/Melee/Yoyos/OblivionYoyo.cs index dfb702921c..e7aaf74169 100644 --- a/Projectiles/Melee/Yoyos/OblivionYoyo.cs +++ b/Projectiles/Melee/Yoyos/OblivionYoyo.cs @@ -33,29 +33,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/PandemicYoyo.cs b/Projectiles/Melee/Yoyos/PandemicYoyo.cs index 9f1ff3adce..33cfc07f99 100644 --- a/Projectiles/Melee/Yoyos/PandemicYoyo.cs +++ b/Projectiles/Melee/Yoyos/PandemicYoyo.cs @@ -31,29 +31,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs index 9243254c22..c1a16a3540 100644 --- a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs +++ b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs @@ -30,31 +30,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - if (Main.rand.NextBool(5)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 73, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/VerdantYoyo.cs b/Projectiles/Melee/Yoyos/VerdantYoyo.cs index c9202c6025..a36c657957 100644 --- a/Projectiles/Melee/Yoyos/VerdantYoyo.cs +++ b/Projectiles/Melee/Yoyos/VerdantYoyo.cs @@ -38,31 +38,38 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { projectile.velocity.X *= 1.01f; projectile.velocity.Y *= 1.01f; + if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 75, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Melee/Yoyos/YinYoyo.cs b/Projectiles/Melee/Yoyos/YinYoyo.cs index 2fc86d0959..b88cbe527a 100644 --- a/Projectiles/Melee/Yoyos/YinYoyo.cs +++ b/Projectiles/Melee/Yoyos/YinYoyo.cs @@ -30,29 +30,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2; - float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2; - float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434];