diff --git a/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/EasyTriggers.java b/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/EasyTriggers.java index 429319b172c4..32d84c5a01dd 100644 --- a/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/EasyTriggers.java +++ b/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/EasyTriggers.java @@ -43,6 +43,7 @@ import gg.xp.xivsupport.events.misc.NpcYellEvent; import gg.xp.xivsupport.events.misc.pulls.PullEndedEvent; import gg.xp.xivsupport.events.misc.pulls.PullStartedEvent; +import gg.xp.xivsupport.events.misc.pulls.PullTracker; import gg.xp.xivsupport.events.state.XivState; import gg.xp.xivsupport.events.state.combatstate.CountdownCanceledEvent; import gg.xp.xivsupport.events.state.combatstate.CountdownStartedEvent; @@ -77,6 +78,7 @@ import gg.xp.xivsupport.events.triggers.easytriggers.conditions.NpcYellIdFilter; import gg.xp.xivsupport.events.triggers.easytriggers.conditions.OrFilter; import gg.xp.xivsupport.events.triggers.easytriggers.conditions.PlayerHasStatusFilter; +import gg.xp.xivsupport.events.triggers.easytriggers.conditions.PullDurationFilter; import gg.xp.xivsupport.events.triggers.easytriggers.conditions.RefireFilter; import gg.xp.xivsupport.events.triggers.easytriggers.conditions.SourceEntityNpcIdFilter; import gg.xp.xivsupport.events.triggers.easytriggers.conditions.SourceEntityTypeFilter; @@ -459,8 +461,9 @@ private Component generic(Object object, Object trigger) { new ConditionDescription<>(HitSeverityFilter.class, HasEffects.class, "Hit Severity (Crit/Direct Hit)", HitSeverityFilter::new, this::generic), new ConditionDescription<>(TargetabilityChangeFilter.class, TargetabilityUpdate.class, "Combatant becomes (un)targetable", TargetabilityChangeFilter::new, this::generic), new ConditionDescription<>(NpcYellIdFilter.class, NpcYellEvent.class, "NPC Yell ID", NpcYellIdFilter::new, this::generic), - new ConditionDescription<>(GroovyEventFilter.class, Event.class, "Make your own filter code with Groovy", () -> new GroovyEventFilter(inject(GroovyManager.class)), (a, b) -> new GroovyFilterEditor<>(a, b)), - new ConditionDescription<>(ZoneIdFilter.class, Object.class, "Restrict the Zone ID in which this trigger may run", () -> new ZoneIdFilter(inject(XivState.class)), this::generic) + new ConditionDescription<>(GroovyEventFilter.class, Event.class, "Make your own filter code with Groovy", () -> new GroovyEventFilter(inject(GroovyManager.class)), GroovyFilterEditor::new), + new ConditionDescription<>(ZoneIdFilter.class, Object.class, "Restrict the Zone ID in which this trigger may run", () -> new ZoneIdFilter(inject(XivState.class)), this::generic), + new ConditionDescription<>(PullDurationFilter.class, Object.class, "Restrict based on pull/combat duration", () -> new PullDurationFilter(inject(PullTracker.class)), this::generic) )); // XXX - DO NOT CHANGE NAMES OF THESE CLASSES OR PACKAGE PATH - FQCN IS PART OF DESERIALIZATION!!! diff --git a/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/conditions/PullDurationFilter.java b/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/conditions/PullDurationFilter.java new file mode 100644 index 000000000000..3dde75d3c5b6 --- /dev/null +++ b/easytriggers/src/main/java/gg/xp/xivsupport/events/triggers/easytriggers/conditions/PullDurationFilter.java @@ -0,0 +1,65 @@ +package gg.xp.xivsupport.events.triggers.easytriggers.conditions; + +import com.fasterxml.jackson.annotation.JacksonInject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.OptBoolean; +import gg.xp.xivsupport.events.misc.pulls.Pull; +import gg.xp.xivsupport.events.misc.pulls.PullTracker; +import gg.xp.xivsupport.events.triggers.easytriggers.model.SimpleCondition; +import org.jetbrains.annotations.Nullable; + +import java.time.Duration; + +public class PullDurationFilter implements SimpleCondition { + + private final PullTracker pt; + @Description("Min Duration") + public double minDuration = 10.5; + @Description("Max Duration") + public double maxDuration = 30.8; + @Description("Only Consider Time In-Combat") + public boolean useCombatDuration = true; + + public PullDurationFilter(@JacksonInject(useInput = OptBoolean.FALSE) PullTracker pt) { + this.pt = pt; + } + + + @JsonIgnore + private double getCurrentDuration() { + Pull currentPull = pt.getCurrentPull(); + if (currentPull == null) { + return 0; + } + if (useCombatDuration) { + Duration cd = currentPull.getCombatDuration(); + if (cd == null) { + return 0; + } + return durationToDouble(cd); + } + else { + return durationToDouble(currentPull.getDuration()); + } + } + + private static double durationToDouble(Duration duration) { + return duration.toSeconds() + duration.toMillisPart() * 0.001; + } + + @Override + public boolean test(Object event) { + double cd = getCurrentDuration(); + return minDuration <= cd && cd <= maxDuration; + } + + @Override + public @Nullable String fixedLabel() { + return "Pull Duration"; + } + + @Override + public String dynamicLabel() { + return "Pull Duration Between %.1fs and %.1fs".formatted(minDuration, maxDuration); + } +} diff --git a/xivsupport/src/main/resources/te_changelog.html b/xivsupport/src/main/resources/te_changelog.html index 7a0f8b96eb75..a25024ce4285 100644 --- a/xivsupport/src/main/resources/te_changelog.html +++ b/xivsupport/src/main/resources/te_changelog.html @@ -1,5 +1,9 @@ +

December 13, 2024

+

December 10, 2024