Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 5 additions & 90 deletions src/main/java/io/blert/challenges/mokhaiotl/DelveDataTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
import io.blert.util.Location;
import io.blert.util.Tick;
import java.util.*;
import java.util.function.BiFunction;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.*;
Expand All @@ -53,9 +51,6 @@ public class DelveDataTracker extends DataTracker {
private static final int MOKHAIOTL_RANGED_BALL_PROJECTILE_ID = 3384;
private static final int MOKHAIOTL_MAGE_BALL_PROJECTILE_ID = 3385;

private static final int ACID_BLOOD_GAME_OBJECT_ID = 57283;
private static final int ROCK_GAME_OBJECT_ID = 57286;

private static final Set<Number> SHOCKWAVE_GRAPHICS_IDs = ImmutableSet.of(3405, 3406, 3407);

private static final int[] HITPOINTS_BY_DELVE = new int[] {
Expand Down Expand Up @@ -86,10 +81,7 @@ private enum PhaseChange {
private int unidentifiedAttackTick;
private int lastRacecarTick;
private final Map<Projectile, Orb> activeOrbs = new HashMap<>();
private final Set<GameObject> activeRocksAndSplats = new HashSet<>();
private final List<GameObject> rocksAndSplatsSpawnedThisTick = new ArrayList<>();
private final List<GameObject> rocksAndSplatsDespawnedThisTick = new ArrayList<>();
private final Set<WorldPoint> shockwaveLocationsThisTick = new HashSet<>();
private boolean shockwaveThisTick;
private final Queue<Hitsplat> healsThisTick = new LinkedList<>();
private final Queue<TrackedNpc> larvaeLeakedThisTick = new LinkedList<>();

Expand Down Expand Up @@ -119,33 +111,6 @@ public DelveDataTracker(
protected void start() {
super.start();
log.info("Starting delve {}", delve);

// The client doesn't receive `GameObjectSpawned` events for acid already present
// when entering the delve, so we have to manually grab our initial set.
Tile[][][] tiles = client.getTopLevelWorldView().getScene().getTiles();
if (tiles.length == 0 || tiles[0].length == 0) {
log.warn("No tiles available during delve start, cannot initialize splats");
return;
}

try {
for (Tile[] tileRow : tiles[0]) {
for (Tile tile : tileRow) {
if (tile == null || tile.getGameObjects() == null) {
continue;
}
for (GameObject gameObject : tile.getGameObjects()) {
if (gameObject != null && gameObject.getId() == ACID_BLOOD_GAME_OBJECT_ID) {
activeRocksAndSplats.add(gameObject);
rocksAndSplatsSpawnedThisTick.add(gameObject);
}
}
}
}
log.debug("Found {} splats on delve start", activeRocksAndSplats.size());
} catch (Exception e) {
log.warn("Error while initializing splats on delve start", e);
}
}

@Override
Expand All @@ -161,21 +126,6 @@ protected void onTick() {
mokhaiotl.setHitpoints(new Hitpoints(hitpointsBeforeShield, HITPOINTS_BY_DELVE[Math.min(delve, 8)]));
}

if (!rocksAndSplatsSpawnedThisTick.isEmpty() || !rocksAndSplatsDespawnedThisTick.isEmpty()) {
BiFunction<List<GameObject>, Integer, List<WorldPoint>> toWorldPoints = (objects, id) -> objects.stream()
.filter(o -> o.getId() == id)
.map(this::getWorldLocation)
.collect(Collectors.toList());
List<WorldPoint> rocksSpawned = toWorldPoints.apply(rocksAndSplatsSpawnedThisTick, ROCK_GAME_OBJECT_ID);
List<WorldPoint> splatsSpawned =
toWorldPoints.apply(rocksAndSplatsSpawnedThisTick, ACID_BLOOD_GAME_OBJECT_ID);
List<WorldPoint> rocksDespawned = toWorldPoints.apply(rocksAndSplatsDespawnedThisTick, ROCK_GAME_OBJECT_ID);
List<WorldPoint> splatsDespawned =
toWorldPoints.apply(rocksAndSplatsDespawnedThisTick, ACID_BLOOD_GAME_OBJECT_ID);
dispatchEvent(new MokhaiotlObjectsEvent(
getStage(), tick, rocksSpawned, rocksDespawned, splatsSpawned, splatsDespawned));
}

while (!healsThisTick.isEmpty()) {
Hitsplat hitsplat = healsThisTick.remove();
TrackedNpc larva = larvaeLeakedThisTick.poll();
Expand All @@ -186,17 +136,14 @@ protected void onTick() {
dispatchEvent(new MokhaiotlLarvaLeakEvent(getStage(), tick, larva.getRoomId(), hitsplat.getAmount()));
}

if (!shockwaveLocationsThisTick.isEmpty()) {
if (shockwaveThisTick) {
boolean isSlam = mokhaiotl.getNpc().getId() == MokhaiotlNpc.MOKHAIOTL_BURROWED.getId()
|| lastRacecarTick >= tick - 12;
NpcAttack attack = isSlam ? NpcAttack.MOKHAIOTL_SLAM : NpcAttack.MOKHAIOTL_SHOCKWAVE;
dispatchEvent(new NpcAttackEvent(getStage(), tick, getWorldLocation(mokhaiotl), attack, mokhaiotl));
dispatchEvent(new MokhaiotlShockwaveEvent(getStage(), tick, new ArrayList<>(shockwaveLocationsThisTick)));
}

rocksAndSplatsSpawnedThisTick.clear();
rocksAndSplatsDespawnedThisTick.clear();
shockwaveLocationsThisTick.clear();
shockwaveThisTick = false;
healsThisTick.clear();
larvaeLeakedThisTick.clear();
phaseChange = PhaseChange.NONE;
Expand Down Expand Up @@ -384,42 +331,10 @@ protected void onProjectile(ProjectileMoved event) {
}
}

@Override
protected void onGameObjectSpawn(GameObjectSpawned event) {
GameObject object = event.getGameObject();
switch (object.getId()) {
case ACID_BLOOD_GAME_OBJECT_ID:
case ROCK_GAME_OBJECT_ID:
if (activeRocksAndSplats.add(object)) {
rocksAndSplatsSpawnedThisTick.add(object);
}
break;
default:
break;
}
}

@Override
protected void onGameObjectDespawn(GameObjectDespawned event) {
GameObject object = event.getGameObject();
switch (object.getId()) {
case ACID_BLOOD_GAME_OBJECT_ID:
case ROCK_GAME_OBJECT_ID:
if (activeRocksAndSplats.remove(object)) {
rocksAndSplatsDespawnedThisTick.add(object);
}
break;
default:
break;
}
}

@Override
protected void onGraphicsObjectCreation(GraphicsObjectCreated event) {
GraphicsObject object = event.getGraphicsObject();
if (SHOCKWAVE_GRAPHICS_IDs.contains(object.getId())) {
WorldPoint wp = WorldPoint.fromLocal(client, object.getLocation());
shockwaveLocationsThisTick.add(Location.getWorldLocation(client, wp));
if (SHOCKWAVE_GRAPHICS_IDs.contains(event.getGraphicsObject().getId())) {
shockwaveThisTick = true;
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/blert/events/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public enum EventType {

MOKHAIOTL_ATTACK_STYLE(250),
MOKHAIOTL_ORB(251),
MOKHAIOTL_OBJECTS(252),
MOKHAIOTL_LARVA_LEAK(253),
MOKHAIOTL_SHOCKWAVE(254),

INFERNO_WAVE_START(300),
;
Expand Down
64 changes: 0 additions & 64 deletions src/main/java/io/blert/events/mokhaiotl/MokhaiotlObjectsEvent.java

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/io/blert/json/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ public class Event {
// Mokhaiotl event-specific fields
public AttackStyle mokhaiotlAttackStyle;
public MokhaiotlOrb mokhaiotlOrb;
public MokhaiotlObjects mokhaiotlObjects;
public MokhaiotlLarvaLeak mokhaiotlLarvaLeak;
public MokhaiotlShockwave mokhaiotlShockwave;

// Inferno event-specific fields
public InfernoWaveStart infernoWaveStart;
Expand Down Expand Up @@ -239,22 +237,11 @@ public static class MokhaiotlOrb {
public int endTick;
}

public static class MokhaiotlObjects {
public List<Coords> rocksSpawned;
public List<Coords> rocksDespawned;
public List<Coords> splatsSpawned;
public List<Coords> splatsDespawned;
}

public static class MokhaiotlLarvaLeak {
public long roomId;
public int healAmount;
}

public static class MokhaiotlShockwave {
public List<Coords> tiles;
}

public static class ColosseumTotemHeal {
public Npc source;
public Npc target;
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/io/blert/json/JsonEventTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,6 @@ public static Event toJson(io.blert.events.Event event, @Nullable String challen
break;
}

case MOKHAIOTL_OBJECTS: {
MokhaiotlObjectsEvent mokhaiotlObjectsEvent = (MokhaiotlObjectsEvent) event;
json.mokhaiotlObjects = new Event.MokhaiotlObjects();
json.mokhaiotlObjects.rocksSpawned = toCoordsList(mokhaiotlObjectsEvent.getRocksSpawned());
json.mokhaiotlObjects.splatsDespawned = toCoordsList(mokhaiotlObjectsEvent.getSplatsDespawned());
json.mokhaiotlObjects.rocksDespawned = toCoordsList(mokhaiotlObjectsEvent.getRocksDespawned());
json.mokhaiotlObjects.splatsSpawned = toCoordsList(mokhaiotlObjectsEvent.getSplatsSpawned());
break;
}

case MOKHAIOTL_LARVA_LEAK: {
MokhaiotlLarvaLeakEvent mokhaiotlLarvaLeakEvent = (MokhaiotlLarvaLeakEvent) event;
json.mokhaiotlLarvaLeak = new Event.MokhaiotlLarvaLeak();
Expand All @@ -498,13 +488,6 @@ public static Event toJson(io.blert.events.Event event, @Nullable String challen
break;
}

case MOKHAIOTL_SHOCKWAVE: {
MokhaiotlShockwaveEvent mokhaiotlShockwaveEvent = (MokhaiotlShockwaveEvent) event;
json.mokhaiotlShockwave = new Event.MokhaiotlShockwave();
json.mokhaiotlShockwave.tiles = toCoordsList(mokhaiotlShockwaveEvent.getShockwaveTiles());
break;
}

case INFERNO_WAVE_START: {
InfernoWaveStartEvent infernoWaveStartEvent = (InfernoWaveStartEvent) event;
json.infernoWaveStart = new Event.InfernoWaveStart();
Expand Down
Loading