From 40a2b2b4942ae48cd63b7b3b99e8e57d2126c49c Mon Sep 17 00:00:00 2001 From: Infinitay Date: Thu, 18 Dec 2025 21:25:08 -0500 Subject: [PATCH 1/3] feat(maze): Add support for starting inside event - Added proper support for handling initial runs when (re)starting the plugin when already inside the maze random event --- .../randomevents/maze/MazeHelper.java | 63 +++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/src/main/java/randomeventhelper/randomevents/maze/MazeHelper.java b/src/main/java/randomeventhelper/randomevents/maze/MazeHelper.java index 5136f2d..eafb533 100644 --- a/src/main/java/randomeventhelper/randomevents/maze/MazeHelper.java +++ b/src/main/java/randomeventhelper/randomevents/maze/MazeHelper.java @@ -9,10 +9,13 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; +import net.runelite.api.GameObject; +import net.runelite.api.Tile; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectSpawned; +import net.runelite.api.events.GameTick; import net.runelite.api.gameval.ObjectID; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.EventBus; @@ -20,6 +23,7 @@ import net.runelite.client.events.PluginMessage; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginManager; +import randomeventhelper.RandomEventHelperPlugin; @Slf4j @Singleton @@ -41,7 +45,8 @@ public class MazeHelper private static final String PLUGIN_MESSAGE_SHORTEST_PATH_PATH_KEY = "path"; private static final String PLUGIN_MESSAGE_SHORTEST_PATH_CLEAR_KEY = "clear"; - private boolean isInsideMaze; + private boolean isFirstRun; + private GameObject mazeExitObject; // Only purpose this serves is to avoid unnecessary onGameTick public void startUp() { @@ -72,7 +77,8 @@ public void startUp() return; } this.eventBus.register(this); - this.isInsideMaze = false; + this.isFirstRun = true; + this.mazeExitObject = null; } public void shutDown() @@ -83,13 +89,14 @@ public void shutDown() { if (!pluginManager.isPluginEnabled(shortestPathPlugin.get())) { - if (this.isInsideMaze) + if (this.isFirstRun) { this.sendShortestPathClear(); } } } - this.isInsideMaze = false; + this.isFirstRun = true; + this.mazeExitObject = null; } @Subscribe @@ -102,7 +109,8 @@ public void onGameObjectSpawned(GameObjectSpawned gameObjectSpawned) LocalPoint shrineLocalPoint = gameObjectSpawned.getGameObject().getLocalLocation(); WorldPoint instancedShrineWorldPoint = WorldPoint.fromLocalInstance(this.client, shrineLocalPoint); log.debug("Detected maze exit object spawn, setting shortest path to it"); - this.isInsideMaze = true; + this.isFirstRun = false; + this.mazeExitObject = gameObjectSpawned.getGameObject(); this.sendShortestPathDestination(instancedShrineWorldPoint); } } @@ -114,11 +122,49 @@ public void onGameObjectDespawned(GameObjectDespawned gameObjectDespawned) if (gameObjectDespawned.getGameObject().getId() == ObjectID.MACRO_MAZE_COMPLETE) { log.debug("Detected maze exit object despawn, clearing shortest path"); - this.isInsideMaze = true; + this.isFirstRun = false; + this.mazeExitObject = null; this.sendShortestPathClear(); } } + @Subscribe + public void onGameTick(GameTick gameTick) + { + if (this.isFirstRun && this.isInMazeLocalInstance() && this.mazeExitObject == null) + { + log.debug("Cold start detected in maze instance, searching for maze exit object"); + this.isFirstRun = false; + + Tile[][][] sceneTiles = this.client.getTopLevelWorldView().getScene().getTiles(); // [Plane][x][y] + Tile[][] tilesInZ = sceneTiles[this.client.getTopLevelWorldView().getPlane()]; // Tiles at [z] + for (Tile[] tilesInZX : tilesInZ) // Tiles at [z][x] + { + for (Tile tile : tilesInZX) // Tiles at [z][x][y] + { + if (tile != null && tile.getGameObjects() != null) + { + for (GameObject gameObject : tile.getGameObjects()) + { + // There seemed to be some case where the game object was null + if (gameObject == null) + { + continue; + } + GameObjectSpawned gameObjectSpawnedEvent = new GameObjectSpawned(); + gameObjectSpawnedEvent.setGameObject(gameObject); + this.onGameObjectSpawned(gameObjectSpawnedEvent); + if (this.mazeExitObject != null) + { + return; + } + } + } + } + } + } + } + private boolean sendShortestPathDestination(WorldPoint destinationWorldPoint) { if (destinationWorldPoint == null) @@ -162,4 +208,9 @@ private void sendShortestPathClear() { this.eventBus.post(new PluginMessage(PLUGIN_MESSAGE_SHORTEST_PATH_NAMESPACE, PLUGIN_MESSAGE_SHORTEST_PATH_CLEAR_KEY)); } + + private boolean isInMazeLocalInstance() + { + return RandomEventHelperPlugin.getRegionIDFromCurrentLocalPointInstanced(client) == 11591; + } } From ceba8f66b5b8403b966d77aaae3958bf831878fe Mon Sep 17 00:00:00 2001 From: Infinitay Date: Thu, 18 Dec 2025 21:36:04 -0500 Subject: [PATCH 2/3] fix(maze): Fix handling varbit changed events for other events - Now ignoring VarbitChanged events for Drill demon and Pirate Chest when fired from within the maze random event - Added a maze instance check to the Drill Demon random event for VarbitChanged - Added a maze instance check to the Pirate Chest random revent for VarbitChanged --- .../randomevents/drilldemon/DrillDemonHelper.java | 11 +++++++++++ .../randomevents/pirate/PirateHelper.java | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/randomeventhelper/randomevents/drilldemon/DrillDemonHelper.java b/src/main/java/randomeventhelper/randomevents/drilldemon/DrillDemonHelper.java index 9dafac9..ca4f0c3 100644 --- a/src/main/java/randomeventhelper/randomevents/drilldemon/DrillDemonHelper.java +++ b/src/main/java/randomeventhelper/randomevents/drilldemon/DrillDemonHelper.java @@ -110,6 +110,12 @@ public void onNpcDespawned(NpcDespawned npcDespawned) @Subscribe public void onVarbitChanged(VarbitChanged varbitChanged) { + // For some reason, when the player is within the maze random event, the varbits for the drill demon event fire/are modified + if (this.isInMazeLocalInstance()) + { + return; + } + switch (varbitChanged.getVarbitId()) { case VarbitID.MACRO_DRILLDEMON_POST_1: @@ -206,4 +212,9 @@ private boolean isInDrillDemonLocalInstance() { return RandomEventHelperPlugin.getRegionIDFromCurrentLocalPointInstanced(client) == 12619; } + + private boolean isInMazeLocalInstance() + { + return RandomEventHelperPlugin.getRegionIDFromCurrentLocalPointInstanced(client) == 11591; + } } diff --git a/src/main/java/randomeventhelper/randomevents/pirate/PirateHelper.java b/src/main/java/randomeventhelper/randomevents/pirate/PirateHelper.java index f01753f..dbffc01 100644 --- a/src/main/java/randomeventhelper/randomevents/pirate/PirateHelper.java +++ b/src/main/java/randomeventhelper/randomevents/pirate/PirateHelper.java @@ -18,6 +18,7 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.Text; +import randomeventhelper.RandomEventHelperPlugin; @Slf4j @Singleton @@ -69,6 +70,12 @@ public void shutDown() @Subscribe public void onVarbitChanged(VarbitChanged varbitChanged) { + // For some reason, when the player is within the maze random event, the varbits for the pirate chest event fire/are modified + if (this.isInMazeLocalInstance()) + { + return; + } + switch (varbitChanged.getVarbitId()) { case VarbitID.PIRATE_COMBILOCK_LEFT: @@ -204,4 +211,9 @@ private void populateWidgetsMap() this.widgetMap.put(ChestLockSlot.RIGHT.getSubtractWidgetID(), rightSubtractWidget); } } + + private boolean isInMazeLocalInstance() + { + return RandomEventHelperPlugin.getRegionIDFromCurrentLocalPointInstanced(client) == 11591; + } } From bbd652fbc3b19e51bcc4b96bd757b1bdfb6d5002 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Thu, 18 Dec 2025 21:54:36 -0500 Subject: [PATCH 3/3] chore: Update plugin to v2.6.2 - Added proper support for handling initial runs when (re)starting the plugin when already inside the Maze random event - Fixed unnecessary VarbitChanged event handling when fired from within the Maze random event --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e2a8982..eab4ba7 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ test { } group = 'randomeventhelper' -version = '2.6.1' +version = '2.6.2' tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8'