Skip to content

Commit

Permalink
More FRU p2, some p1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Nov 27, 2024
1 parent a5a94a8 commit 149129a
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import gg.xp.xivsupport.events.actlines.events.HasAbility;
import gg.xp.xivsupport.events.actlines.events.HasSourceEntity;
import gg.xp.xivsupport.events.actlines.events.HasTargetEntity;
import gg.xp.xivsupport.events.actlines.events.HeadMarkerEvent;
import gg.xp.xivsupport.events.actlines.events.TetherEvent;
import gg.xp.xivsupport.events.state.XivState;
import gg.xp.xivsupport.events.state.combatstate.ActiveCastRepository;
Expand All @@ -32,6 +33,9 @@
import gg.xp.xivsupport.persistence.PersistenceProvider;
import gg.xp.xivsupport.persistence.settings.JobSortOverrideSetting;
import gg.xp.xivsupport.persistence.settings.JobSortSetting;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serial;
import java.time.Duration;
Expand All @@ -43,6 +47,9 @@

@CalloutRepo(name = "FRU Triggers", duty = KnownDuty.FRU)
public class FRU extends AutoChildEventHandler implements FilteredEventHandler {

private static final Logger log = LoggerFactory.getLogger(FRU.class);

private final JobSortSetting defaultPrio;
private final JobSortOverrideSetting p1tethersPrio;
private final JobSortOverrideSetting p1towersPrio;
Expand Down Expand Up @@ -142,7 +149,7 @@ public boolean enabled(EventContext context) {
} while (safe.size() != 2);
s.setParam("safe", safe);
// Get the actual cast so that we have something to display
var cast = s.waitEvent(AbilityCastStart.class, acs -> acs.abilityIdMatches(0x9CDE));
var cast = s.findOrWaitForCast(casts, acs -> acs.abilityIdMatches(0x9CDE), false);
s.updateCall(isFire ? utopianSkyStackSafeSpot : utopianSkySpreadSafeSpot, cast);
});

Expand Down Expand Up @@ -376,6 +383,9 @@ private static ModifiableCallout<FruP1TetherEvent> makeTetherDefault(String desc
else {
s.updateCall(isKB ? towersKB : towers, e1);
}
// For identifying towers for an eventual prio:
// 9CC7 - single
// 9CBF - quad
}
);

Expand All @@ -395,17 +405,67 @@ private static ModifiableCallout<FruP1TetherEvent> makeTetherDefault(String desc
@NpcCastCallout(0x9D05)
private final ModifiableCallout<AbilityCastStart> diamondDust = ModifiableCallout.durationBasedCall("Diamond Dust", "Raidwide");

private final ModifiableCallout<AbilityCastStart> ddAxeWithMarker = ModifiableCallout.durationBasedCall("DD: Axe Kick with Marker", "Out with Marker, {firstIces} Safe");
private final ModifiableCallout<AbilityCastStart> ddAxeNoMarker = ModifiableCallout.durationBasedCall("DD: Axe Kick, no Marker", "Out, Bait, {firstIces} Safe");
private final ModifiableCallout<AbilityCastStart> ddScytheWithMarker = ModifiableCallout.durationBasedCall("DD: Scythe Kick with Marker", "In with Marker, {firstIces} Safe");
private final ModifiableCallout<AbilityCastStart> ddScytheNoMarker = ModifiableCallout.durationBasedCall("DD: Scythe Kick, no Marker", "In, Bait, {firstIces} Safe");
private final ModifiableCallout<?> ddDropPuddle = new ModifiableCallout<>("DD: Drop Puddle", "Drop Puddle");
private final ModifiableCallout<?> ddAvoidPuddle = new ModifiableCallout<>("DD: Avoid Puddles", "Avoid Puddles");
private final ModifiableCallout<?> ddKB = new ModifiableCallout<>("DD: KB", "Knockback to {firstIces}");
private final ModifiableCallout<?> ddKBimmune = new ModifiableCallout<>("DD: KB Immune", "Knockback Immunity");
private final ModifiableCallout<?> ddStacks = new ModifiableCallout<>("DD: Stacks", "Multiple Stacks, Keep Moving");
private final ModifiableCallout<?> ddGaze = new ModifiableCallout<>("DD: Gaze", "Look Away from {gazeFrom}");

@AutoFeed
private final SequentialTrigger<BaseEvent> axeScythe = SqtTemplates.sq(60_000,
AbilityCastStart.class, acs -> acs.abilityIdMatches(0x9D0A, 0x9D0B),
(e1, s) -> {
// Axe kick = out
boolean isAxeKick = e1.abilityIdMatches(0x9D0A);
// It's the next four HMs, so it should be fine to just look for four
List<HeadMarkerEvent> headmarkers = s.waitEventsQuickSuccession(4, HeadMarkerEvent.class, hme -> true);
s.waitThenRefreshCombatants(100);
@Nullable HeadMarkerEvent playerMarker = headmarkers.stream()
.filter(hme -> hme.getTarget().isThePlayer())
.findFirst()
.orElse(null);
// Find first pair of Icycle Impact
List<ArenaSector> firstIces = casts.getActiveCastsById(0x9D06).stream()
.map(CastTracker::getCast)
.map(AbilityCastStart::getSource)
.map(npc -> arenaPos.forCombatant(state.getLatestCombatantData(npc)))
.sorted(ArenaSector.northCcwSort)
.toList();
if (firstIces.size() != 2) {
log.error("firstIces size {}, expected 2! Data: {}", firstIces.size(), firstIces);
}
s.setParam("firstIces", firstIces);

boolean playerHasMarker = playerMarker != null;
if (isAxeKick) {
// out
s.updateCall(playerHasMarker ? ddAxeWithMarker : ddAxeNoMarker, e1);
}
else {
// in
s.updateCall(playerHasMarker ? ddScytheWithMarker : ddScytheNoMarker, e1);
}
s.waitCastFinished(casts, e1);
// Add a slight delay since things don't go off instantly
s.waitMs(300);
// Drop or avoid puddle
s.updateCall(playerHasMarker ? ddDropPuddle : ddAvoidPuddle);
var icycleCast = s.waitEvent(AbilityCastStart.class, acs -> acs.abilityIdMatches(0x9D06));
s.updateCall((playerHasMarker && isAxeKick) ? ddKBimmune : ddKB);
s.waitCastFinished(casts, icycleCast);
s.updateCall(ddStacks);
s.waitMs(4_000);
XivCombatant gazeNpc = state.npcById(17823);
if (gazeNpc != null) {
ArenaSector gazeFrom = arenaPos.forCombatant(gazeNpc);
s.setParam("gazeFrom", gazeFrom);
}
s.updateCall(ddGaze);
});

@NpcCastCallout(0x9D01)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
}
});
c.setMinWidth(50);
c.setMaxWidth(100);
c.setMaxWidth(110);
});

public static final CustomColumn<XivCombatant> combatantRawTypeColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,12 @@ public boolean isIntercard() {
return ordinal <= 7 && ordinal % 2 == 1;
}

/**
* Sort starting north and going CCW
*/
public static final Comparator<ArenaSector> northCcwSort = Comparator.comparing(sector -> {
// Ordinal is north==0, NE==1, etc, i.e. the opposite of what we want
// By doing this, we flip the order (north = 8, NE = 7, NW = 1), and then %8 to get north back to 0
return (8 - sector.ordinal()) % 8;
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gg.xp.xivsupport.models;

import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.List;

public class ArenaSectorTest {

@Test
void testNorthCcwSort() {
List<ArenaSector> actual = ArenaSector.all.stream().sorted(ArenaSector.northCcwSort).toList();
List<ArenaSector> expected = List.of(
ArenaSector.NORTH,
ArenaSector.NORTHWEST,
ArenaSector.WEST,
ArenaSector.SOUTHWEST,
ArenaSector.SOUTH,
ArenaSector.SOUTHEAST,
ArenaSector.EAST,
ArenaSector.NORTHEAST
);
Assert.assertEquals(actual, expected);
}

}

0 comments on commit 149129a

Please sign in to comment.