From 25e1febe93f9f758d8e3cf07399e15dfd6ce912e Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sat, 28 Sep 2024 03:53:32 -0700 Subject: [PATCH] photo LC flares home on nearest npc instead of final in array --- Projectiles/Ranged/ExoLight.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index d1db382e64..2cf433a89a 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -82,10 +82,19 @@ namespace CalamityMod.Projectiles.Ranged Projectile.scale = MathHelper.Lerp(0.001f, 1f, Utils.GetLerpValue(0f, 25f, Time, true)); if (Projectile.localAI[0] == 0f) { + float currentDist = 25000f; foreach (NPC n in Main.ActiveNPCs) { if (n.CanBeChasedBy(Projectile.GetSource_FromThis(), false)) - NPCDestination = n.Center + n.velocity * 5f; + { + Vector2 potentialDest = n.Center + n.velocity * 5f; + float newDist = potentialDest.Distance(Projectile.Center); + if (newDist < currentDist) + { + currentDist = newDist; + NPCDestination = potentialDest; + } + } } InitialCenter = Projectile.Center; Projectile.localAI[0] = 1f;