23 if (!interval.intervalElapsed())
return;
25 if (
fleet.getAI() instanceof ModularFleetAIAPI) {
26 ModularFleetAIAPI ai = (ModularFleetAIAPI)
fleet.getAI();
27 if (ai.getTacticalModule().isMaintainingContact()) {
32 MemoryAPI mem =
fleet.getMemoryWithoutUpdate();
33 if (
ability.isActiveOrInProgress()) {
34 mem.set(FleetAIFlags.HAS_SPEED_PENALTY,
true, 0.2f);
35 mem.set(FleetAIFlags.USED_INTERDICTION_PULSE,
true, 0.5f);
39 if (!
ability.isUsable())
return;
41 CampaignFleetAPI pursueTarget = mem.getFleet(FleetAIFlags.PURSUIT_TARGET);
42 CampaignFleetAPI fleeingFrom = mem.getFleet(FleetAIFlags.NEAREST_FLEEING_FROM);
45 float activationTime =
ability.getSpec().getActivationDays() *
Global.
getSector().getClock().getSecondsPerDay();
46 if (fleeingFrom !=
null) {
49 float dist = Misc.getDistance(
fleet.getLocation(), fleeingFrom.getLocation());
50 if (dist > range + 200)
return;
52 VisibilityLevel level = fleeingFrom.getVisibilityLevelTo(
fleet);
53 if (level == VisibilityLevel.NONE)
return;
55 if (
fleet.getAI() !=
null) {
56 if (!
fleet.getAI().isHostileTo(fleeingFrom))
return;
60 float speed = Math.max(1f, fleeingFrom.getVelocity().length());
61 float time = dist / speed;
63 boolean usingHasBenefit =
false;
67 if (interdictDur > 0 && fleeingFrom.getVelocity().length() >
fleet.getVelocity().length()) {
68 for (AbilityPlugin
ability : fleeingFrom.getAbilities().values()) {
69 if (!
ability.getSpec().hasTag(Abilities.TAG_BURN +
"+"))
continue;
70 if (
ability.isActiveOrInProgress()) {
71 usingHasBenefit =
true;
76 AbilityPlugin eb =
fleet.getAbility(Abilities.EMERGENCY_BURN);
77 if (eb !=
null && eb.getCooldownLeft() < activationTime + 1f) usingHasBenefit =
true;
80 if (time > activationTime + 2f && time < activationTime + 7f && usingHasBenefit) {
87 if (pursueTarget !=
null) {
89 float dist = Misc.getDistance(
fleet.getLocation(), pursueTarget.getLocation());
90 if (dist > range + 200)
return;
92 VisibilityLevel level = pursueTarget.getVisibilityLevelTo(
fleet);
93 if (level == VisibilityLevel.NONE)
return;
95 if (
fleet.getAI() !=
null) {
96 if (!
fleet.getAI().isHostileTo(pursueTarget))
return;
101 float speed = Math.max(1f, pursueTarget.getVelocity().length());
102 float closingSpeed = Misc.getClosingSpeed(
fleet.getLocation(), pursueTarget.getLocation(),
103 fleet.getVelocity(), pursueTarget.getVelocity());
104 speed = Math.max(1f, (speed - closingSpeed) / 2f);
105 float time = Math.max(200, (range - dist)) / speed;
106 float timeToReach = dist /
fleet.getVelocity().length();
108 boolean usingHasBenefit =
false;
111 if (interdictDur > 0 && pursueTarget.getVelocity().length() >
fleet.getVelocity().length()) {
112 for (AbilityPlugin
ability : pursueTarget.getAbilities().values()) {
113 if (!
ability.getSpec().hasTag(Abilities.TAG_BURN +
"+"))
continue;
114 if (
ability.isActiveOrInProgress()) {
115 usingHasBenefit =
true;
124 AbilityPlugin tj = pursueTarget.getAbility(Abilities.TRANSVERSE_JUMP);
125 if (tj !=
null && tj.isActiveOrInProgress() && timeToReach > activationTime &&
127 usingHasBenefit =
true;
130 AbilityPlugin sb = pursueTarget.getAbility(Abilities.SUSTAINED_BURN);
131 if (sb !=
null && sb.isActiveOrInProgress() &&
132 sb.getProgressFraction() > 0.25f &&
133 sb.getProgressFraction() <= 0.5f) {
134 usingHasBenefit =
true;
137 if (usingHasBenefit && time > activationTime + 0.5f) {