Vector pursueEntity(AIEntity entityToCatch) { Vector targetPos = entityToCatch.getPosition() - this.owner.getPosition(); double relativeHead = owner.getHeadingDirection().dotProduct(entityToCatch.getHeadingDirection()); if(targetPos.dotProduct(owner.getHeadingDirection()) > 0 && relativeHead < -0.9) { return this.seek(entityToCatch.getPosition()); } double lookAhead = Math.sqrt(vecToTarg.lengthSquared()) / (owner.getMaxSpeed() + Math.sqrt(entityToCatch.currentSpeedSquared())); return this.seek(entityToCatch.getPosition() + (entityToCatch.getVelocity() * lookAhead)); }
Vector evadeEntity(AIEntity entityToEvade) { Vector toTarget = entityToEvade.getPosition() - owner.getPosition(); double range = 1000; if(toTarget.lengthSquared() > range)return Vector(0,0); double lookAhead = Math.sqrt(vecToTarg.lengthSquared()) / (owner.getMaxSpeed() + Math.sqrt(entityToEvade.currentSpeedSquared())); return this.flee(entityToEvade.getPosition + (entityToEvade.getVelocity()*lookAhead)); }