Skip to content

Commit

Permalink
Minor FRU improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Dec 24, 2024
1 parent 474e188 commit f8439ea
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,11 @@ private static Predicate<HasDuration> initDurBetween(int secondsMin, int seconds
.extendedDescription("The long fire/stack pop calls happen about 25 seconds in.");
private final ModifiableCallout<BuffApplied> relLongStackPop = ModifiableCallout.<BuffApplied>durationBasedCall("Relativity: Long Stack Popping", "Stack").autoIcon();

private final ModifiableCallout<?> relMedFireBaitLookOut = new ModifiableCallout<>("Relativity: Medium Fire Final Baits", "Bait Light, Look Outside").statusIcon(0x998)
private final ModifiableCallout<?> relMedFireBaitLookOut = new ModifiableCallout<>("Relativity: Medium Fire Final Baits", "Bait Light then Look Outside")
.extendedDescription("Final Traffic Light Bait, with Medium Fire");
private final ModifiableCallout<?> relFinalCenterLookOut = new ModifiableCallout<>("Relativity: Final Mechanics", "Look Outside").statusIcon(0x998)
private final ModifiableCallout<BuffApplied> relMedFireBaitMoveInLookOut = ModifiableCallout.<BuffApplied>durationBasedCall("Relativity: Medium Fire Final Mechanic", "Move In, Look Outside").statusIcon(0x998)
.extendedDescription("Final Traffic Light Bait, with Medium Fire, after Baiting Light");
private final ModifiableCallout<BuffApplied> relFinalCenterLookOut = ModifiableCallout.<BuffApplied>durationBasedCall("Relativity: Final Mechanics", "Look Outside").statusIcon(0x998)
.extendedDescription("Final Traffic Light Bait, not Medium Fire");

@AutoFeed
Expand Down Expand Up @@ -938,9 +940,15 @@ private static Predicate<HasDuration> initDurBetween(int secondsMin, int seconds

s.waitMs(5_000); // T=31

var rewindBuff = s.findOrWaitForBuff(buffs, ba -> ba.buffIdMatches(0x994));

medFireC.findAny(isPlayer).ifPresentOrElse(
e -> s.updateCall(relMedFireBaitLookOut),
() -> s.updateCall(relFinalCenterLookOut)
e -> {
s.updateCall(relMedFireBaitLookOut);
s.waitEvent(AbilityUsedEvent.class, aue -> aue.abilityIdMatches(0x9D2B));
s.updateCall(relMedFireBaitMoveInLookOut, rewindBuff);
},
() -> s.updateCall(relFinalCenterLookOut, rewindBuff)
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected List<CalloutInitialValues> getExpectedCalls() {
call(473149, "Stack", "Stack (4.6)"),
call(478175, "Stand Middle", "Stand Middle"),
call(483195, "Move Out", "Move Out (4.5)"),
call(488217, "Look Outside", "Look Outside"),
call(488217, "Look Outside", "Look Outside (8.5)"),
call(500670, "Stack", "Stack (2.7)"),
call(507080, "Raidwide", "Raidwide (4.7)"),
call(515215, "Tankbuster on Chachajire Titijire", "Tankbuster on Chachajire Titijire (4.7)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gg.xp.xivsupport.events.actlines.events.HasStatusEffect;
import gg.xp.xivsupport.gui.tables.renderers.IconTextRenderer;
import gg.xp.xivsupport.gui.tables.renderers.RenderUtils;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -82,19 +83,23 @@ public ModifiableCallout(String descriptionAndText) {
* @param expiry A condition for expiring the callout (removes it from the on-screen display)
*/
public ModifiableCallout(String description, String tts, String text, Predicate<? super X> expiry) {
this(description, tts, text, (call, event) -> expiry.test(event));
}

private ModifiableCallout(String description, String tts, String text, CombinedExpiryCondition<X> expiry) {
this.description = description;
this.defaultTtsText = tts;
this.defaultVisualText = text;
this.expiry = x -> expiry.test(x.getEvent());
this.expiry = expiry.combined();
}

// // last argument is dumb but works
// public ModifiableCallout(String description, String tts, String text, Predicate<RawModifiedCallout<X>> expiry, int ignoredUnused) {
// this.description = description;
// this.defaultTtsText = tts;
// this.defaultVisualText = text;
// this.expiry = expiry;
// }
private interface CombinedExpiryCondition<X> {
boolean isExpired(RawModifiedCallout<X> callout, X event);

default Predicate<RawModifiedCallout<X>> combined() {
return c -> isExpired(c, c.getEvent());
}
}

/**
* A callout with the same TTS and on-screen text, and a custom expiry time.
Expand Down Expand Up @@ -131,7 +136,7 @@ public static <X> Predicate<X> expiresIn(Duration dur) {
return be.getEffectiveTimeSince().compareTo(dur) > 0;
}
else {
log.warn("Hit expiresIn false branch - this should never happen!");
log.error("Hit expiresIn false branch - this should never happen!");
return defaultExpiryAt.isBefore(Instant.now());
}
};
Expand Down Expand Up @@ -341,19 +346,14 @@ public RawModifiedCallout<X> getModified(Map<String, Object> rawArguments) {
* that the buff will.
*
* @param desc The description.
* @param text The base text. For the visual text, the duration will be appended in parenthesis.
* @param text The base text. For the visual text, the duration will be appended in parentheses.
* e.g. "Water on You" will become "Water on You" (123.4) will be appended, and the timer will count
* down.
* @return the ModifiableCallout
*/
public static <Y extends HasDuration> ModifiableCallout<Y> durationBasedCall(String desc, String text) {
Predicate<Y> expiry = hd -> {
if (hd == null) {
log.error("durationBasedCall: event was null! No time basis! Expiring callout prematurely.");
return true;
}
return hd.getEstimatedTimeSinceExpiry().compareTo(defaultLingerTime) > 0;
};
// TODO: this warns once per call per program execution, rather than once per call invocation
CombinedExpiryCondition<Y> expiry = combinedExpiry(defaultLingerTime);
return new ModifiableCallout<>(desc, text, text + " ({event.estimatedRemainingDuration})", expiry);
}

Expand All @@ -363,15 +363,23 @@ public static <Y extends HasDuration> ModifiableCallout<Y> durationBasedCall(Str

public static <Y extends HasDuration> ModifiableCallout<Y> durationBasedCallWithOffset(String desc, String text, Duration offset) {
Duration combinedLingerTime = defaultLingerTime.plus(offset);
Predicate<Y> expiry = hd -> {
CombinedExpiryCondition<Y> expiry = combinedExpiry(combinedLingerTime);
long millis = offset.toMillis();
return new ModifiableCallout<>(desc, text, text + " ({event.remainingDurationPlus(java.time.Duration.ofMillis(" + millis + "))})", expiry);
}

private static <Y extends HasDuration> CombinedExpiryCondition<Y> combinedExpiry(Duration combinedLingerTime) {
var alreadyWarned = new MutableBoolean();
return (call, hd) -> {
if (hd == null) {
log.error("durationBasedCall: event was null! No time basis! Expiring callout prematurely.");
return true;
if (alreadyWarned.isFalse()) {
log.error("durationBasedCall: event was null! No time basis! Falling back to fixed duration.");
alreadyWarned.setTrue();
}
return call.getEffectiveTimeSince().compareTo(defaultLingerTime) > 0;
}
return hd.getEstimatedTimeSinceExpiry().compareTo(combinedLingerTime) > 0;
};
long millis = offset.toMillis();
return new ModifiableCallout<>(desc, text, text + " ({event.remainingDurationPlus(java.time.Duration.ofMillis(" + millis + "))})", expiry);
}


Expand Down

0 comments on commit f8439ea

Please sign in to comment.