Skip to content

Commit

Permalink
Merge pull request #573 from xpdota/codcar-triggers
Browse files Browse the repository at this point in the history
Codcar triggers, various improvements
  • Loading branch information
xpdota authored Dec 28, 2024
2 parents 98e2109 + f584282 commit 4cdedec
Show file tree
Hide file tree
Showing 28 changed files with 754 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@
import gg.xp.reevent.scan.FeedHelperAdapter;
import gg.xp.reevent.scan.ScanMe;
import gg.xp.xivsupport.callouts.ModifiableCallout;
import gg.xp.xivsupport.callouts.RawModifiedCallout;
import gg.xp.xivsupport.events.actlines.events.BuffApplied;
import gg.xp.xivsupport.events.state.combatstate.CastTracker;
import gg.xp.xivsupport.events.state.combatstate.StatusEffectCurrentStatus;
import gg.xp.xivsupport.events.state.combatstate.StatusEffectRepository;

import java.util.Optional;

@ScanMe
public class PlayerStatusAdapter implements FeedHelperAdapter<PlayerStatusCallout, BuffApplied, ModifiableCallout<BuffApplied>> {

private final StatusEffectRepository buffs;

public PlayerStatusAdapter(StatusEffectRepository buffs) {
this.buffs = buffs;
}

@Override
public Class<BuffApplied> eventType() {
return BuffApplied.class;
Expand All @@ -19,6 +31,7 @@ public Class<BuffApplied> eventType() {
@Override
public TypedEventHandler<BuffApplied> makeHandler(FeedHandlerChildInfo<PlayerStatusCallout, ModifiableCallout<BuffApplied>> info) {
long[] castIds = info.getAnnotation().value();
PlayerStatusCallout ann = info.getAnnotation();
return new TypedEventHandler<>() {
@Override
public Class<? extends BuffApplied> getType() {
Expand All @@ -28,7 +41,14 @@ public Class<? extends BuffApplied> getType() {
@Override
public void handle(EventContext context, BuffApplied event) {
if (event.getTarget().isThePlayer() && event.buffIdMatches(castIds)) {
context.accept(info.getHandlerFieldValue().getModified(event));
RawModifiedCallout<BuffApplied> modified = info.getHandlerFieldValue().getModified(event);
if (ann.cancellable()) {
modified.addExpiryCondition(() -> {
StatusEffectCurrentStatus cs = buffs.statusOf(event);
return cs != StatusEffectCurrentStatus.ACTIVE;
});
}
context.accept(modified);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
* @return Which status IDs to trigger on
*/
long[] value();

/**
* @return Whether the callout should be removed if the buff is removed. A buff being replaced/refreshed
* counts as being removed.
*/
boolean cancellable() default false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public JailSolver(PersistenceProvider persistence, XivState state) {

@Override
public boolean enabled(EventContext context) {
// return true;
return overrideZoneLock.get() || context.getStateInfo().get(XivState.class).zoneIs(0x309L);
return overrideZoneLock.get() || state.dutyIs(KnownDuty.UWU);
}

@HandleEvents
Expand Down Expand Up @@ -145,8 +144,7 @@ public void jailedPlayerDied(EventContext context, EntityKilledEvent event) {
@HandleEvents
public void handleJailCast(EventContext context, AbilityUsedEvent event) {
// Check ability ID - we only care about these two
long id = event.getAbility().getId();
if (id != 0x2B6B && id != 0x2B6C) {
if (!event.abilityIdMatches(0x2B6B, 0x2B6C)) {
return;
}
XivCombatant target = event.getTarget();
Expand Down
Loading

0 comments on commit 4cdedec

Please sign in to comment.