Skip to content

Commit 95d57f0

Browse files
authored
Update CannonLead.java
1 parent f149aa2 commit 95d57f0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/java/com/happysg/radar/compat/cbc/CannonLead.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ public static LeadSolution solveLeadPerTickWithAcceleration(
317317
return new LeadSolution(aimPoint, chosenPitchDeg, chosenYawRad, flightTicks);
318318
}
319319

320+
private static int computeMaxSimTicks(double targetHorizontalDist, double muzzleSpeedPerTick) {
321+
322+
final double MAX_SIM_DISTANCE_BLOCKS = 4096.0;
323+
final int HARD_MAX_TICKS = 8000;
324+
325+
double speed = Math.max(1.0e-6, muzzleSpeedPerTick);
326+
327+
int ticksToTarget = (int) Math.ceil(targetHorizontalDist / speed);
328+
int ticksToBudget = (int) Math.ceil(MAX_SIM_DISTANCE_BLOCKS / speed);
329+
int ticks = Math.max(ticksToTarget + 40, ticksToBudget);
330+
331+
if (ticks < 60) ticks = 60;
332+
if (ticks > HARD_MAX_TICKS) ticks = HARD_MAX_TICKS;
333+
334+
return ticks;
335+
}
336+
320337

321338
public static void logLeadByBlocks(Vec3 targetPosNow, Vec3 aimPoint, Vec3 targetVelPerTick) {
322339
if (targetPosNow == null || aimPoint == null) return;

0 commit comments

Comments
 (0)