Skip to content

Commit

Permalink
fix drone controller targeting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
direwolf420 committed Apr 25, 2022
1 parent 8cb8c86 commit 672521b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Base/AssAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public static int FindTarget(Entity ent, Vector2 relativeCenter, float range, bo
float between = Vector2.DistanceSquared(npc.Center, relativeCenter);
if ((between < range && Vector2.DistanceSquared(relativeCenter, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1)
{
if (ignoreTiles || Collision.CanHitLine(ent.position, ent.width, ent.height, npc.position, npc.width, npc.height))
if (ignoreTiles || Collision.CanHitLine(ent.position, ent.width, ent.height, npc.position, npc.width, npc.height) ||
Collision.CanHit(ent.position, ent.width, ent.height, npc.position, npc.width, npc.height))
{
distanceFromTarget = between;
targetCenter = npc.Center;
Expand Down
3 changes: 2 additions & 1 deletion Projectiles/Minions/Drones/BasicLaserDrone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ private int FindClosestTargetBelow(int range = 1000)
float between = Vector2.Distance(npc.Center, Projectile.Center);
if (((between < range &&
Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) &&
Projectile.Bottom.Y < npc.Top.Y + 40 && Collision.CanHitLine(Projectile.Center, 1, 1, npc.position, npc.width, npc.height))
Projectile.Bottom.Y < npc.Top.Y + 40 &&
(Collision.CanHitLine(Projectile.Center, 1, 1, npc.position, npc.width, npc.height) || Collision.CanHit(Projectile.Center, 1, 1, npc.position, npc.width, npc.height)))
{
distanceFromTarget = between;
targetCenter = npc.Center;
Expand Down
2 changes: 1 addition & 1 deletion Projectiles/Minions/Drones/HeavyLaserDrone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private int FindClosestHorizontalTarget()
float between = Vector2.Distance(npc.Center, player.Center);
if (((between < range &&
Vector2.Distance(player.Center, targetCenter) > between && between < distanceFromTarget) || targetIndex == -1) &&
Collision.CanHitLine(player.Center, 1, 1, npc.position, npc.width, npc.height))
(Collision.CanHitLine(player.Center, 1, 1, npc.position, npc.width, npc.height) || Collision.CanHit(Projectile.Center, 1, 1, npc.position, npc.width, npc.height)))
{
distanceFromTarget = between;
targetCenter = npc.Center;
Expand Down

0 comments on commit 672521b

Please sign in to comment.