Skip to content

Commit

Permalink
Animation lock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Nov 16, 2024
1 parent 27610d6 commit 13c75e8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ public class AbilityUsedEvent extends BaseEvent implements HasSourceEntity, HasT
private final long sequenceId;
private final long targetIndex;
private final long numberOfTargets;
private @Nullable Duration animationLock;
private final @Nullable Duration animationLock;
private @Nullable DescribesCastLocation<AbilityUsedEvent> locationInfo;
private @Nullable AbilityCastStart precursor;

public AbilityUsedEvent(XivAbility ability, XivCombatant caster, XivCombatant target, List<AbilityEffect> effects, long sequenceId, long targetIndex, long numberOfTargets) {
this(ability, caster, target, effects, sequenceId, targetIndex, numberOfTargets, null);
}

public AbilityUsedEvent(XivAbility ability, XivCombatant caster, XivCombatant target, List<AbilityEffect> effects, long sequenceId, long targetIndex, long numberOfTargets, @Nullable Duration animationLock) {
this.ability = ability;
this.caster = caster;
this.target = target;
this.effects = effects;
this.sequenceId = sequenceId;
this.targetIndex = targetIndex;
this.numberOfTargets = numberOfTargets;
this.animationLock = animationLock;
}

@Override
Expand Down Expand Up @@ -104,22 +109,13 @@ public void setPrecursor(@NotNull AbilityCastStart precursor) {

/**
* Get the animation lock.
* <p>
* Note that this is expected to be populated *after* this event is emitted, as this data
* is not known at the time of the original event. In addition, it may never be present,
* such as if you are importing a non-OP log, or an fflogs import.
*
* @see AnimationLockEvent
* @return The animation lock, if one has been set.
* @return The animation lock, if one has been set. Null if using an old ACT version that does not support this.
*/
public @Nullable Duration getAnimationLock() {
return animationLock;
}

public void setAnimationLock(@Nullable Duration animationLock) {
this.animationLock = animationLock;
}

@Override
public String toString() {
return "AbilityUsedEvent{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.Serial;
import java.time.Duration;

@Deprecated // No longer needed
@SystemEvent
public class AnimationLockEvent extends BaseEvent implements HasDuration, HasAbility, HasSourceEntity, HasTargetEntity {
@Serial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import gg.xp.reevent.events.Event;
import gg.xp.xivsupport.events.actlines.events.AbilityUsedEvent;
import gg.xp.xivsupport.models.XivCombatant;
import org.apache.commons.lang3.time.DurationUtils;

import java.time.Duration;

enum NetworkAbilityFields {
casterId, casterName, abilityId, abilityName, targetId, targetName,
Expand All @@ -17,8 +20,13 @@ enum NetworkAbilityFields {
targetCurHp, targetMaxHp, targetCurMp, targetMaxMp, targetUnknown1, targetUnknown2, targetX, targetY, targetZ, targetHeading,
casterCurHp, casterMaxHp, casterCurMp, casterMaxMp, casterUnknown1, casterUnknown2, casterX, casterY, casterZ, casterHeading,
sequenceId,
targetIndex,
numberOfTargets;
targetIndex, numberOfTargets,
casterOwnerId, casterOwnerName,
effectDisplayType,
actionId,
actionAnimationId,
animationLock,
castAngleRaw;
// New fields (not currently used are):
/*
source.owner.id
Expand All @@ -44,14 +52,24 @@ public static Event convert(FieldMapper<NetworkAbilityFields> fields) {
// Workaround in case someone is using an old ACT version or importing an old log
targets = targetIndex;
}
return new AbilityUsedEvent(
Duration animLock;
try {
double animLockRaw = fields.getDouble(animationLock);
animLock = Duration.ofMillis((long) (animLockRaw * 1000.0));
}
catch (Throwable e) {
animLock = null;
}
AbilityUsedEvent out = new AbilityUsedEvent(
fields.getAbility(abilityId, abilityName),
caster,
target,
fields.getAbilityEffects(targetName.ordinal() + 3, 8),
sequenceId == null ? -1 : sequenceId,
targetIndex,
targets
targets,
animLock
);
return out;
}
}
4 changes: 4 additions & 0 deletions xivsupport/src/main/resources/te_changelog.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<html lang="en">
<body style="margin: 5px 20px 5px 20px">
<h2>November 15, 2024</h2>
<ul>
<li>Properly support animation lock field.</li>
</ul>
<h2>November 12, 2024</h2>
<ul>
<li>Game data updates for 7.1.</li>
Expand Down

0 comments on commit 13c75e8

Please sign in to comment.