diff --git a/src/main/java/io/blert/challenges/mokhaiotl/DelveDataTracker.java b/src/main/java/io/blert/challenges/mokhaiotl/DelveDataTracker.java index c082b8d..a23013e 100644 --- a/src/main/java/io/blert/challenges/mokhaiotl/DelveDataTracker.java +++ b/src/main/java/io/blert/challenges/mokhaiotl/DelveDataTracker.java @@ -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.*; @@ -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 SHOCKWAVE_GRAPHICS_IDs = ImmutableSet.of(3405, 3406, 3407); private static final int[] HITPOINTS_BY_DELVE = new int[] { @@ -86,10 +81,7 @@ private enum PhaseChange { private int unidentifiedAttackTick; private int lastRacecarTick; private final Map activeOrbs = new HashMap<>(); - private final Set activeRocksAndSplats = new HashSet<>(); - private final List rocksAndSplatsSpawnedThisTick = new ArrayList<>(); - private final List rocksAndSplatsDespawnedThisTick = new ArrayList<>(); - private final Set shockwaveLocationsThisTick = new HashSet<>(); + private boolean shockwaveThisTick; private final Queue healsThisTick = new LinkedList<>(); private final Queue larvaeLeakedThisTick = new LinkedList<>(); @@ -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 @@ -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, Integer, List> toWorldPoints = (objects, id) -> objects.stream() - .filter(o -> o.getId() == id) - .map(this::getWorldLocation) - .collect(Collectors.toList()); - List rocksSpawned = toWorldPoints.apply(rocksAndSplatsSpawnedThisTick, ROCK_GAME_OBJECT_ID); - List splatsSpawned = - toWorldPoints.apply(rocksAndSplatsSpawnedThisTick, ACID_BLOOD_GAME_OBJECT_ID); - List rocksDespawned = toWorldPoints.apply(rocksAndSplatsDespawnedThisTick, ROCK_GAME_OBJECT_ID); - List 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(); @@ -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; @@ -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; } } diff --git a/src/main/java/io/blert/events/EventType.java b/src/main/java/io/blert/events/EventType.java index 58de798..575e0ca 100644 --- a/src/main/java/io/blert/events/EventType.java +++ b/src/main/java/io/blert/events/EventType.java @@ -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), ; diff --git a/src/main/java/io/blert/events/mokhaiotl/MokhaiotlObjectsEvent.java b/src/main/java/io/blert/events/mokhaiotl/MokhaiotlObjectsEvent.java deleted file mode 100644 index 9485f79..0000000 --- a/src/main/java/io/blert/events/mokhaiotl/MokhaiotlObjectsEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2025 Alexei Frolov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the “Software”), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -package io.blert.events.mokhaiotl; - -import io.blert.core.Stage; -import io.blert.events.Event; -import io.blert.events.EventType; -import java.util.List; -import java.util.stream.Collectors; -import lombok.Getter; -import net.runelite.api.coords.WorldPoint; - -@Getter -public class MokhaiotlObjectsEvent extends Event { - private final List rocksSpawned; - private final List rocksDespawned; - private final List splatsSpawned; - private final List splatsDespawned; - - public MokhaiotlObjectsEvent( - Stage stage, - int tick, - List rocksSpawned, - List rocksDespawned, - List splatsSpawned, - List splatsDespawned) { - super(EventType.MOKHAIOTL_OBJECTS, stage, tick, null); - this.rocksSpawned = rocksSpawned; - this.rocksDespawned = rocksDespawned; - this.splatsSpawned = splatsSpawned; - this.splatsDespawned = splatsDespawned; - } - - @Override - protected String eventDataString() { - return String.format( - "rocks_spawned=%s, rocks_despawned=%s, splats_spawned=%s, splats_despawned=%s", - rocksSpawned.stream().map(WorldPoint::toString).collect(Collectors.joining(", ")), - rocksDespawned.stream().map(WorldPoint::toString).collect(Collectors.joining(", ")), - splatsSpawned.stream().map(WorldPoint::toString).collect(Collectors.joining(", ")), - splatsDespawned.stream().map(WorldPoint::toString).collect(Collectors.joining(", "))); - } -} diff --git a/src/main/java/io/blert/events/mokhaiotl/MokhaiotlShockwaveEvent.java b/src/main/java/io/blert/events/mokhaiotl/MokhaiotlShockwaveEvent.java deleted file mode 100644 index ce42bcd..0000000 --- a/src/main/java/io/blert/events/mokhaiotl/MokhaiotlShockwaveEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025 Alexei Frolov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the “Software”), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -package io.blert.events.mokhaiotl; - -import io.blert.core.Stage; -import io.blert.events.Event; -import io.blert.events.EventType; -import java.util.List; -import java.util.stream.Collectors; -import lombok.Getter; -import net.runelite.api.coords.WorldPoint; - -@Getter -public class MokhaiotlShockwaveEvent extends Event { - private final List shockwaveTiles; - - public MokhaiotlShockwaveEvent(Stage stage, int tick, List shockwaveTiles) { - super(EventType.MOKHAIOTL_SHOCKWAVE, stage, tick, null); - this.shockwaveTiles = shockwaveTiles; - } - - @Override - protected String eventDataString() { - return "shockwaveTiles=" - + shockwaveTiles.stream().map(WorldPoint::toString).collect(Collectors.joining(",")); - } -} diff --git a/src/main/java/io/blert/json/Event.java b/src/main/java/io/blert/json/Event.java index 0db693c..2c7eb81 100644 --- a/src/main/java/io/blert/json/Event.java +++ b/src/main/java/io/blert/json/Event.java @@ -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; @@ -239,22 +237,11 @@ public static class MokhaiotlOrb { public int endTick; } - public static class MokhaiotlObjects { - public List rocksSpawned; - public List rocksDespawned; - public List splatsSpawned; - public List splatsDespawned; - } - public static class MokhaiotlLarvaLeak { public long roomId; public int healAmount; } - public static class MokhaiotlShockwave { - public List tiles; - } - public static class ColosseumTotemHeal { public Npc source; public Npc target; diff --git a/src/main/java/io/blert/json/JsonEventTranslator.java b/src/main/java/io/blert/json/JsonEventTranslator.java index ed406f9..2be8160 100644 --- a/src/main/java/io/blert/json/JsonEventTranslator.java +++ b/src/main/java/io/blert/json/JsonEventTranslator.java @@ -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(); @@ -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();