1 - Hive Mind circular hitbox.

This commit is contained in:
Andrew Marheine committed 2021-11-08 21:09:53 -06:00
1 parent e0fa44d2df
commit f26ea60600
1 file changed
+20 -1
+20 -1
View File
@@ -982,7 +982,26 @@ namespace CalamityMod.NPCs.HiveMind
public override bool? CanHitNPC(NPC target) => npc.alpha == 0; // Can only be hit while fully visible
public override bool CanHitPlayer(Player target, ref int cooldownSlot) => npc.alpha == 0 && npc.scale == 1f; // No damage while not fully visible or shrunk
// Can only hit the target if within certain distance
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
Rectangle targetHitbox = target.Hitbox;
float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft());
float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight());
float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft());
float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight());
float minDist = dist1;
if (dist2 < minDist)
minDist = dist2;
if (dist3 < minDist)
minDist = dist3;
if (dist4 < minDist)
minDist = dist4;
return minDist <= 60f && npc.alpha == 0 && npc.scale == 1f; // No damage while not fully visible or shrunk
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => npc.scale == 1f; // Only draw HP bar while at full size