Browse Source

invalid range check for ranged characters attacking a building

combat-2
FatBoy-DOTC 6 months ago
parent
commit
cc7188b404
  1. 22
      src/engine/gameManager/CombatManager.java

22
src/engine/gameManager/CombatManager.java

@ -12,6 +12,7 @@ import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.AttackJob; import engine.jobs.AttackJob;
import engine.jobs.DeferredPowerJob; import engine.jobs.DeferredPowerJob;
import engine.math.Vector3f;
import engine.mbEnums; import engine.mbEnums;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.TargetedActionMsg; import engine.net.client.msg.TargetedActionMsg;
@ -163,14 +164,19 @@ public enum CombatManager {
inRange = true; inRange = true;
break; break;
case Building: case Building:
float locX = target.loc.x - target.getBounds().getHalfExtents().x; if(attackRange > 15){
float locZ = target.loc.z - target.getBounds().getHalfExtents().y; if(attacker.loc.distanceSquared(target.loc) < (attackRange * attackRange))
float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; inRange = true;
float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2; }else {
Rectangle2D.Float rect = new Rectangle2D.Float(locX, locZ, sizeX, sizeZ); float locX = target.loc.x - target.getBounds().getHalfExtents().x;
if (rect.contains(new Point2D.Float(attacker.loc.x, attacker.loc.z))) float locZ = target.loc.z - target.getBounds().getHalfExtents().y;
inRange = true; float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2;
break; float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2;
Rectangle2D.Float rect = new Rectangle2D.Float(locX, locZ, sizeX, sizeZ);
if (rect.contains(new Point2D.Float(attacker.loc.x, attacker.loc.z)))
inRange = true;
break;
}
} }
//get delay for the auto attack job //get delay for the auto attack job

Loading…
Cancel
Save