From cf13d678b9ab74a1e217b3651c4aa50c8f65fa1e Mon Sep 17 00:00:00 2001 From: XP Date: Fri, 19 Jul 2024 20:35:30 -0700 Subject: [PATCH 1/2] Ignore snapshot location if a cast location is better --- .../events/actlines/events/AbilityCastCancel.java | 15 ++++++++++++++- .../events/actlines/events/AbilityUsedEvent.java | 13 ++++++++++++- .../events/actlines/events/HasCastPrecursor.java | 11 +++++++++++ .../events/SnapshotLocationDataEvent.java | 6 ++++++ .../events/actlines/parsers/Line264Parser.java | 9 ++++++++- .../combatstate/ActiveCastRepositoryImpl.java | 4 +++- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/HasCastPrecursor.java diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityCastCancel.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityCastCancel.java index e5b6151f41b2..f7cfdaaac099 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityCastCancel.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityCastCancel.java @@ -3,19 +3,22 @@ import gg.xp.reevent.events.BaseEvent; import gg.xp.xivsupport.models.XivAbility; import gg.xp.xivsupport.models.XivCombatant; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.Serial; /** * Represents an ability cast being cancelled/interrupted/etc */ -public class AbilityCastCancel extends BaseEvent implements HasSourceEntity, HasAbility { +public class AbilityCastCancel extends BaseEvent implements HasSourceEntity, HasAbility, HasCastPrecursor { @Serial private static final long serialVersionUID = -5704173639583049362L; private final XivCombatant source; private final XivAbility ability; private final String reason; + private @Nullable AbilityCastStart precursor; public AbilityCastCancel(XivCombatant source, XivAbility ability, String reason) { this.source = source; @@ -36,4 +39,14 @@ public XivAbility getAbility() { public String getReason() { return reason; } + + @Override + public @Nullable AbilityCastStart getPrecursor() { + return precursor; + } + + @Override + public void setPrecursor(@NotNull AbilityCastStart precursor) { + this.precursor = precursor; + } } diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityUsedEvent.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityUsedEvent.java index 3674eca805ed..a433f5b8f684 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityUsedEvent.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/AbilityUsedEvent.java @@ -15,7 +15,7 @@ /** * Represents an ability snapshotting */ -public class AbilityUsedEvent extends BaseEvent implements HasSourceEntity, HasTargetEntity, HasAbility, HasEffects, HasTargetIndex { +public class AbilityUsedEvent extends BaseEvent implements HasSourceEntity, HasTargetEntity, HasAbility, HasEffects, HasTargetIndex, HasCastPrecursor { @Serial private static final long serialVersionUID = -4539070760062288496L; @@ -28,6 +28,7 @@ public class AbilityUsedEvent extends BaseEvent implements HasSourceEntity, HasT private final long numberOfTargets; private @Nullable Duration animationLock; private @Nullable DescribesCastLocation locationInfo; + private @Nullable AbilityCastStart precursor; public AbilityUsedEvent(XivAbility ability, XivCombatant caster, XivCombatant target, List effects, long sequenceId, long targetIndex, long numberOfTargets) { this.ability = ability; @@ -91,6 +92,16 @@ public void setLocationInfo(@NotNull DescribesCastLocation loc this.locationInfo = locationInfo; } + @Override + public @Nullable AbilityCastStart getPrecursor() { + return precursor; + } + + @Override + public void setPrecursor(@NotNull AbilityCastStart precursor) { + this.precursor = precursor; + } + /** * Get the animation lock. *

diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/HasCastPrecursor.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/HasCastPrecursor.java new file mode 100644 index 000000000000..a6a95e8ba629 --- /dev/null +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/HasCastPrecursor.java @@ -0,0 +1,11 @@ +package gg.xp.xivsupport.events.actlines.events; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface HasCastPrecursor { + @Nullable + AbilityCastStart getPrecursor(); + + void setPrecursor(@NotNull AbilityCastStart precursor); +} diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/SnapshotLocationDataEvent.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/SnapshotLocationDataEvent.java index 8d4b880bc253..4221da95dad4 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/SnapshotLocationDataEvent.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/events/SnapshotLocationDataEvent.java @@ -18,6 +18,12 @@ public class SnapshotLocationDataEvent extends BaseEvent implements DescribesCas private final Position pos; private final Double heading; + public SnapshotLocationDataEvent(AbilityUsedEvent event, DescribesCastLocation other) { + this.event = event; + this.pos = other.getPos(); + this.heading = other.getHeadingOnly(); + } + public SnapshotLocationDataEvent(AbilityUsedEvent event, Position pos) { this.event = event; this.pos = pos; diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java index ab5ec2acecb8..3ffbdf831659 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java @@ -2,8 +2,10 @@ import gg.xp.reevent.events.Event; import gg.xp.reevent.scan.HandleEvents; +import gg.xp.xivsupport.events.actlines.events.AbilityCastStart; import gg.xp.xivsupport.events.actlines.events.AbilityUsedEvent; import gg.xp.xivsupport.events.actlines.events.AnimationLockEvent; +import gg.xp.xivsupport.events.actlines.events.DescribesCastLocation; import gg.xp.xivsupport.events.actlines.events.SnapshotLocationDataEvent; import gg.xp.xivsupport.events.misc.OverwritingRingBuffer; import gg.xp.xivsupport.models.Position; @@ -56,7 +58,12 @@ protected Event convert(FieldMapper fields, int lineNumber, ZonedDateTim double z = fields.getDouble(Fields.z); double h = fields.getDouble(Fields.rotation); if (x == 0.0 && y == 0.0 && z == 0.0) { - if (h == 0.0) { + AbilityCastStart precursor = last.getPrecursor(); + DescribesCastLocation castLocation; + if (precursor != null && (castLocation = precursor.getLocationInfo()) != null) { + slde = new SnapshotLocationDataEvent(last, castLocation); + } + else if (h == 0.0) { slde = null; } else { diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/state/combatstate/ActiveCastRepositoryImpl.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/state/combatstate/ActiveCastRepositoryImpl.java index 37c1712ea687..93dc818e857b 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/state/combatstate/ActiveCastRepositoryImpl.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/state/combatstate/ActiveCastRepositoryImpl.java @@ -7,6 +7,7 @@ import gg.xp.xivsupport.events.actlines.events.AbilityCastStart; import gg.xp.xivsupport.events.actlines.events.AbilityUsedEvent; import gg.xp.xivsupport.events.actlines.events.HasAbility; +import gg.xp.xivsupport.events.actlines.events.HasCastPrecursor; import gg.xp.xivsupport.events.actlines.events.HasSourceEntity; import gg.xp.xivsupport.events.misc.pulls.PullStartedEvent; import gg.xp.xivsupport.models.XivCombatant; @@ -65,7 +66,7 @@ public void pullStartedEvent(EventContext ctx, PullStartedEvent event) { } } - private void doEnd(X event) { + private void doEnd(X event) { CastTracker tracker; synchronized (lock) { tracker = cbtCasts.get(event.getSource()); @@ -74,6 +75,7 @@ private void doEnd(X event) { return; } if (tracker.getCast().getAbility().equals(event.getAbility())) { + event.setPrecursor(tracker.getCast()); tracker.setEnd(event); } From d2bc965800456edc015d0d9fb1a426ec91f55a8f Mon Sep 17 00:00:00 2001 From: XP Date: Fri, 19 Jul 2024 20:42:51 -0700 Subject: [PATCH 2/2] Only change the logic if the original cast had a position --- .../gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java index 3ffbdf831659..721a1ddcb731 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/events/actlines/parsers/Line264Parser.java @@ -60,7 +60,7 @@ protected Event convert(FieldMapper fields, int lineNumber, ZonedDateTim if (x == 0.0 && y == 0.0 && z == 0.0) { AbilityCastStart precursor = last.getPrecursor(); DescribesCastLocation castLocation; - if (precursor != null && (castLocation = precursor.getLocationInfo()) != null) { + if (precursor != null && (castLocation = precursor.getLocationInfo()) != null && castLocation.getPos() != null) { slde = new SnapshotLocationDataEvent(last, castLocation); } else if (h == 0.0) {