private bool tryHitTarget(RangedAttackAbility rangedAttack, Vector3 position, Frame target, out Vector3 force, int steps) { float velocity = rangedAttack.weapon.range / 2.0f; float velocityStep = velocity / (float)steps; Vector3 direction = target.position - position; direction.y = 0.0f; float distance = direction.magnitude; direction.Normalize(); for (int i = 0; i < steps + 1; i++) { if (ProjectileUtils.canHitCoordinate(distance, 0.0f, velocity)) { float angle1 = ProjectileUtils.calculateAngle1ToHitCoordinate(distance, 0.0f, velocity); float angle2 = ProjectileUtils.calculateAngle2ToHitCoordinate(distance, 0.0f, velocity); if (ProjectileUtils.tryHitWithBallisticCast(target, position, velocity * direction, angle1, out force)) { return(true); } if (ProjectileUtils.tryHitWithBallisticCast(target, position, velocity * direction, angle2, out force)) { return(true); } if (!hasFallback) { fallbackPosition = position; fallBackVelocity = force; hasFallback = true; } } velocity += velocityStep; } force = Vector3.negativeInfinity; return(false); }