From 7f029fd0e2ecf691b1611a21e750829643b9fd39 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 22 May 2024 19:45:16 -0500 Subject: [PATCH] invalid range check for ranged characters attacking a building --- src/engine/gameManager/CombatManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 1778cf21..059d8ca0 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -165,8 +165,12 @@ public enum CombatManager { break; case Building: if(attackRange > 15){ - if(attacker.loc.distanceSquared(target.loc) < (attackRange * attackRange)) + float rangeSquared = attackRange * attackRange; + //float distanceSquared = attacker.loc.distanceSquared(target.loc); + if(distanceSquared < rangeSquared) { inRange = true; + break; + } }else { float locX = target.loc.x - target.getBounds().getHalfExtents().x; float locZ = target.loc.z - target.getBounds().getHalfExtents().y;