From 03295883888a72b96026b941d3e29816d237ad16 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Wed, 19 Jun 2019 22:02:06 +0100 Subject: [PATCH 01/12] fishing: add missing spots near farming guild --- .../net/runelite/client/plugins/fishing/FishingSpot.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java index 94f774ccc0..04dc3bacf8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java @@ -82,6 +82,9 @@ import static net.runelite.api.NpcID.FISHING_SPOT_7733; import static net.runelite.api.NpcID.FISHING_SPOT_7946; import static net.runelite.api.NpcID.FISHING_SPOT_7947; import static net.runelite.api.NpcID.FISHING_SPOT_8523; +import static net.runelite.api.NpcID.FISHING_SPOT_8525; +import static net.runelite.api.NpcID.FISHING_SPOT_8526; +import static net.runelite.api.NpcID.FISHING_SPOT_8527; import static net.runelite.api.NpcID.ROD_FISHING_SPOT; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1508; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1509; @@ -94,6 +97,7 @@ import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7463; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7464; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7468; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_7676; +import static net.runelite.api.NpcID.ROD_FISHING_SPOT_8524; @Getter enum FishingSpot @@ -115,7 +119,8 @@ enum FishingSpot FISHING_SPOT_1511, FISHING_SPOT_1520, FISHING_SPOT_3915, FISHING_SPOT_4476, FISHING_SPOT_4477, FISHING_SPOT_5233, FISHING_SPOT_5234, FISHING_SPOT_5821, FISHING_SPOT_7200, - FISHING_SPOT_7461, FISHING_SPOT_7466 + FISHING_SPOT_7461, FISHING_SPOT_7466, FISHING_SPOT_8525, + FISHING_SPOT_8526, FISHING_SPOT_8527 ), MONKFISH("Monkfish", ItemID.RAW_MONKFISH, FISHING_SPOT_4316 @@ -124,7 +129,7 @@ enum FishingSpot ROD_FISHING_SPOT, ROD_FISHING_SPOT_1508, ROD_FISHING_SPOT_1509, ROD_FISHING_SPOT_1513, ROD_FISHING_SPOT_1515, ROD_FISHING_SPOT_1526, ROD_FISHING_SPOT_1527, ROD_FISHING_SPOT_7463, ROD_FISHING_SPOT_7464, - ROD_FISHING_SPOT_7468 + ROD_FISHING_SPOT_7468, ROD_FISHING_SPOT_8524 ), BARB_FISH("Sturgeon, Salmon, Trout", ItemID.LEAPING_STURGEON, FISHING_SPOT_1542, FISHING_SPOT_7323 From 392c934393c4c9df2245eae19820d82a9c137b10 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Fri, 21 Jun 2019 17:24:20 -0700 Subject: [PATCH 02/12] EmoteClue: Add null checks for stashUnit Some clues may have item requirements, but no STASH unit, which would cause NPEs during rendering. This commit also marks stashUnit as nullable so this issue can hopefully be avoided in the future. --- .../plugins/cluescrolls/clues/EmoteClue.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/EmoteClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/EmoteClue.java index 6fa4f65e1d..7af6fac5d7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/EmoteClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/EmoteClue.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.util.Set; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.EquipmentInventorySlot; @@ -214,6 +215,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu } private final String text; + @Nullable private final STASHUnit stashUnit; private final WorldPoint location; private final Emote firstEmote; @@ -256,15 +258,19 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu if (itemRequirements.length > 0) { Client client = plugin.getClient(); - client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0); - int[] intStack = client.getIntStack(); - boolean stashUnitBuilt = intStack[0] == 1; - panelComponent.getChildren().add(LineComponent.builder() - .left("STASH Unit:") - .right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X) - .rightColor(stashUnitBuilt ? Color.GREEN : Color.RED) - .build()); + if (stashUnit != null) + { + client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0); + int[] intStack = client.getIntStack(); + boolean stashUnitBuilt = intStack[0] == 1; + + panelComponent.getChildren().add(LineComponent.builder() + .left("STASH Unit:") + .right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X) + .rightColor(stashUnitBuilt ? Color.GREEN : Color.RED) + .build()); + } panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build()); @@ -312,18 +318,21 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localPoint, plugin.getEmoteImage(), Color.ORANGE); } - final WorldPoint[] worldPoints = stashUnit.getWorldPoints(); - - for (final WorldPoint worldPoint : worldPoints) + if (stashUnit != null) { - final LocalPoint stashUnitLocalPoint = LocalPoint.fromWorld(plugin.getClient(), worldPoint); + final WorldPoint[] worldPoints = stashUnit.getWorldPoints(); - if (stashUnitLocalPoint != null) + for (final WorldPoint worldPoint : worldPoints) { - final Polygon poly = Perspective.getCanvasTilePoly(plugin.getClient(), stashUnitLocalPoint); - if (poly != null) + final LocalPoint stashUnitLocalPoint = LocalPoint.fromWorld(plugin.getClient(), worldPoint); + + if (stashUnitLocalPoint != null) { - OverlayUtil.renderPolygon(graphics, poly, Color.RED); + final Polygon poly = Perspective.getCanvasTilePoly(plugin.getClient(), stashUnitLocalPoint); + if (poly != null) + { + OverlayUtil.renderPolygon(graphics, poly, Color.RED); + } } } } From 438fbc9b0d46524b0f452885977cb25ce5e07c87 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Jun 2019 15:43:40 -0400 Subject: [PATCH 03/12] api: rename unknownSoundValues1 -> queuedSoundEffectLoops --- .../main/java/net/runelite/mixins/PlaySoundEffectMixin.java | 4 ++-- runescape-api/src/main/java/net/runelite/rs/api/RSClient.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java index b4a002b79d..79db5b70b9 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java @@ -47,14 +47,14 @@ public abstract class PlaySoundEffectMixin implements RSClient int position = ((x & 255) << 16) + ((y & 255) << 8) + (range & 255); int[] queuedSoundEffectIDs = getQueuedSoundEffectIDs(); - int[] unknownSoundValues1 = getUnknownSoundValues1(); + int[] queuedSoundEffectLoops = getQueuedSoundEffectLoops(); int[] queuedSoundEffectDelays = getQueuedSoundEffectDelays(); RSSoundEffect[] audioEffects = getAudioEffects(); int[] soundLocations = getSoundLocations(); int queuedSoundEffectCount = getQueuedSoundEffectCount(); queuedSoundEffectIDs[queuedSoundEffectCount] = id; - unknownSoundValues1[queuedSoundEffectCount] = 0; + queuedSoundEffectLoops[queuedSoundEffectCount] = 0; queuedSoundEffectDelays[queuedSoundEffectCount] = 0; audioEffects[queuedSoundEffectCount] = null; soundLocations[queuedSoundEffectCount] = position; diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index 7fff3d232d..e0a8c5f8d1 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -552,8 +552,8 @@ public interface RSClient extends RSGameEngine, Client @Import("soundLocations") int[] getSoundLocations(); - @Import("unknownSoundValues1") - int[] getUnknownSoundValues1(); + @Import("queuedSoundEffectLoops") + int[] getQueuedSoundEffectLoops(); @Import("queuedSoundEffectDelays") int[] getQueuedSoundEffectDelays(); From 45766fd65e86317dda2275b590135fed2ae03197 Mon Sep 17 00:00:00 2001 From: WooxSolo Date: Thu, 18 Oct 2018 21:35:30 +0200 Subject: [PATCH 04/12] Add sounds to devtools --- .../main/java/net/runelite/api/Client.java | 13 ++ .../api/events/AreaSoundEffectPlayed.java | 37 +++++ .../api/events/SoundEffectPlayed.java | 34 ++++ .../plugins/devtools/DevToolsPanel.java | 2 + .../plugins/devtools/DevToolsPlugin.java | 18 ++- .../plugins/devtools/SoundEffectOverlay.java | 145 ++++++++++++++++++ ...EffectMixin.java => SoundEffectMixin.java} | 64 +++++++- 7 files changed, 308 insertions(+), 5 deletions(-) create mode 100644 runelite-api/src/main/java/net/runelite/api/events/AreaSoundEffectPlayed.java create mode 100644 runelite-api/src/main/java/net/runelite/api/events/SoundEffectPlayed.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/devtools/SoundEffectOverlay.java rename runelite-mixins/src/main/java/net/runelite/mixins/{PlaySoundEffectMixin.java => SoundEffectMixin.java} (57%) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index a8ed2fba3a..1a36c3be9e 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -969,6 +969,19 @@ public interface Client extends GameEngine */ void playSoundEffect(int id, int x, int y, int range); + /** + * Play a sound effect from some point in the world. + * + * @param id the ID of the sound to play. Any int is allowed, but see + * {@link SoundEffectID} for some common ones + * @param x the ground coordinate on the x axis + * @param y the ground coordinate on the y axis + * @param range the number of tiles away that the sound can be heard + * from + * @param delay the amount of frames before the sound starts playing + */ + void playSoundEffect(int id, int x, int y, int range, int delay); + /** * Gets the clients graphic buffer provider. * diff --git a/runelite-api/src/main/java/net/runelite/api/events/AreaSoundEffectPlayed.java b/runelite-api/src/main/java/net/runelite/api/events/AreaSoundEffectPlayed.java new file mode 100644 index 0000000000..488bff8264 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/AreaSoundEffectPlayed.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, WooxSolo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Data; + +@Data +public class AreaSoundEffectPlayed +{ + private int soundId; + private int sceneX; + private int sceneY; + private int range; + private int delay; +} diff --git a/runelite-api/src/main/java/net/runelite/api/events/SoundEffectPlayed.java b/runelite-api/src/main/java/net/runelite/api/events/SoundEffectPlayed.java new file mode 100644 index 0000000000..127a9a2646 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/SoundEffectPlayed.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, WooxSolo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Data; + +@Data +public class SoundEffectPlayed +{ + private int soundId; + private int delay; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java index 6798d4056b..c33753d4a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java @@ -119,6 +119,8 @@ class DevToolsPanel extends PluginPanel } }); + container.add(plugin.getSoundEffects()); + return container; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java index 3998651fe5..d1cd2a2005 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java @@ -100,6 +100,9 @@ public class DevToolsPlugin extends Plugin @Inject private WorldMapRegionOverlay mapRegionOverlay; + @Inject + private SoundEffectOverlay soundEffectOverlay; + @Inject private EventBus eventBus; @@ -119,13 +122,14 @@ public class DevToolsPlugin extends Plugin private DevToolsButton validMovement; private DevToolsButton lineOfSight; private DevToolsButton cameraPosition; - private DevToolsButton worldMapLocation ; + private DevToolsButton worldMapLocation; private DevToolsButton tileLocation; private DevToolsButton interacting; private DevToolsButton examine; private DevToolsButton detachedCamera; private DevToolsButton widgetInspector; private DevToolsButton varInspector; + private DevToolsButton soundEffects; private NavigationButton navButton; @Provides @@ -166,6 +170,7 @@ public class DevToolsPlugin extends Plugin detachedCamera = new DevToolsButton("Detached Camera"); widgetInspector = new DevToolsButton("Widget Inspector"); varInspector = new DevToolsButton("Var Inspector"); + soundEffects = new DevToolsButton("Sound Effects"); overlayManager.add(overlay); overlayManager.add(locationOverlay); @@ -173,6 +178,7 @@ public class DevToolsPlugin extends Plugin overlayManager.add(cameraOverlay); overlayManager.add(worldMapLocationOverlay); overlayManager.add(mapRegionOverlay); + overlayManager.add(soundEffectOverlay); final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class); @@ -186,17 +192,21 @@ public class DevToolsPlugin extends Plugin .build(); clientToolbar.addNavigation(navButton); + + eventBus.register(soundEffectOverlay); } @Override protected void shutDown() throws Exception { + eventBus.unregister(soundEffectOverlay); overlayManager.remove(overlay); overlayManager.remove(locationOverlay); overlayManager.remove(sceneOverlay); overlayManager.remove(cameraOverlay); overlayManager.remove(worldMapLocationOverlay); overlayManager.remove(mapRegionOverlay); + overlayManager.remove(soundEffectOverlay); clientToolbar.removeNavigation(navButton); } @@ -336,6 +346,12 @@ public class DevToolsPlugin extends Plugin player.getPlayerComposition().setHash(); break; } + case "sound": + { + int id = Integer.parseInt(args[0]); + client.playSoundEffect(id); + break; + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SoundEffectOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SoundEffectOverlay.java new file mode 100644 index 0000000000..fbe2254066 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SoundEffectOverlay.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2018, WooxSolo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.devtools; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.Player; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.events.AreaSoundEffectPlayed; +import net.runelite.api.events.SoundEffectPlayed; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; + +class SoundEffectOverlay extends Overlay +{ + private final static int MAX_LINES = 16; + private final static Color COLOR_SOUND_EFFECT = Color.WHITE; + private final static Color COLOR_AREA_SOUND_EFFECT = Color.YELLOW; + private final static Color COLOR_SILENT_SOUND_EFFECT = Color.GRAY; + + private final Client client; + private final DevToolsPlugin plugin; + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + SoundEffectOverlay(Client client, DevToolsPlugin plugin) + { + this.client = client; + this.plugin = plugin; + panelComponent.setPreferredSize(new Dimension(200, 0)); + panelComponent.getChildren().add(LineComponent.builder() + .left("Sound Effects") + .leftColor(Color.CYAN) + .build()); + setPosition(OverlayPosition.TOP_LEFT); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!plugin.getSoundEffects().isActive()) + { + return null; + } + + return panelComponent.render(graphics); + } + + @Subscribe + public void onSoundEffectPlayed(SoundEffectPlayed event) + { + if (!plugin.getSoundEffects().isActive()) + { + return; + } + + String text = + "Id: " + event.getSoundId() + + " - D: " + event.getDelay(); + + panelComponent.getChildren().add(LineComponent.builder() + .left(text) + .leftColor(COLOR_SOUND_EFFECT) + .build()); + + checkMaxLines(); + } + + @Subscribe + public void onAreaSoundEffectPlayed(AreaSoundEffectPlayed event) + { + if (!plugin.getSoundEffects().isActive()) + { + return; + } + + Color textColor = COLOR_AREA_SOUND_EFFECT; + + // Check if the player is within range to hear the sound + Player localPlayer = client.getLocalPlayer(); + if (localPlayer != null) + { + LocalPoint lp = localPlayer.getLocalLocation(); + if (lp != null) + { + int sceneX = lp.getSceneX(); + int sceneY = lp.getSceneY(); + int distance = Math.abs(sceneX - event.getSceneX()) + Math.abs(sceneY - event.getSceneY()); + if (distance > event.getRange()) + { + textColor = COLOR_SILENT_SOUND_EFFECT; + } + } + } + + String text = + "Id: " + event.getSoundId() + + " - L: " + event.getSceneX() + "," + event.getSceneY() + + " - R: " + event.getRange() + + " - D: " + event.getDelay(); + + panelComponent.getChildren().add(LineComponent.builder() + .left(text) + .leftColor(textColor) + .build()); + + checkMaxLines(); + } + + private void checkMaxLines() + { + while (panelComponent.getChildren().size() > MAX_LINES) + { + panelComponent.getChildren().remove(1); + } + } +} diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java similarity index 57% rename from runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java rename to runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java index 79db5b70b9..8effc5a812 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/PlaySoundEffectMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java @@ -24,25 +24,41 @@ */ package net.runelite.mixins; +import net.runelite.api.events.AreaSoundEffectPlayed; +import net.runelite.api.events.SoundEffectPlayed; +import net.runelite.api.mixins.FieldHook; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; +import net.runelite.api.mixins.Shadow; import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSSoundEffect; @Mixin(RSClient.class) -public abstract class PlaySoundEffectMixin implements RSClient +public abstract class SoundEffectMixin implements RSClient { + @Shadow("clientInstance") + private static RSClient client; + + @Inject + private static int lastSoundEffectCount; @Inject @Override public void playSoundEffect(int id) { - playSoundEffect(id, 0, 0, 0); + playSoundEffect(id, 0, 0, 0, 0); } @Inject @Override public void playSoundEffect(int id, int x, int y, int range) + { + playSoundEffect(id, x, y, range, 0); + } + + @Inject + @Override + public void playSoundEffect(int id, int x, int y, int range, int delay) { int position = ((x & 255) << 16) + ((y & 255) << 8) + (range & 255); @@ -54,11 +70,51 @@ public abstract class PlaySoundEffectMixin implements RSClient int queuedSoundEffectCount = getQueuedSoundEffectCount(); queuedSoundEffectIDs[queuedSoundEffectCount] = id; - queuedSoundEffectLoops[queuedSoundEffectCount] = 0; - queuedSoundEffectDelays[queuedSoundEffectCount] = 0; + queuedSoundEffectLoops[queuedSoundEffectCount] = 1; + queuedSoundEffectDelays[queuedSoundEffectCount] = delay; audioEffects[queuedSoundEffectCount] = null; soundLocations[queuedSoundEffectCount] = position; setQueuedSoundEffectCount(queuedSoundEffectCount + 1); } + + @FieldHook("queuedSoundEffectCount") + @Inject + public static void queuedSoundEffectCountChanged(int idx) + { + int soundCount = client.getQueuedSoundEffectCount(); + if (soundCount == lastSoundEffectCount + 1) + { + int soundIndex = soundCount - 1; + int packedLocation = client.getSoundLocations()[soundIndex]; + + if (packedLocation == 0) + { + // Regular sound effect + + SoundEffectPlayed event = new SoundEffectPlayed(); + event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]); + event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]); + client.getCallbacks().post(event); + } + else + { + // Area sound effect + + int x = (packedLocation >> 16) & 0xFF; + int y = (packedLocation >> 8) & 0xFF; + int range = (packedLocation) & 0xFF; + + AreaSoundEffectPlayed event = new AreaSoundEffectPlayed(); + event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]); + event.setSceneX(x); + event.setSceneY(y); + event.setRange(range); + event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]); + client.getCallbacks().post(event); + } + } + + lastSoundEffectCount = soundCount; + } } From 257bf18742d7a0bf878166e01b0b4eb9d428131c Mon Sep 17 00:00:00 2001 From: trimbe Date: Mon, 11 Feb 2019 20:56:24 -0500 Subject: [PATCH 05/12] api: add method to play sound effects while volume is muted --- .../main/java/net/runelite/api/Client.java | 9 +++++ .../net/runelite/api/SoundEffectVolume.java | 37 +++++++++++++++++++ .../net/runelite/mixins/SoundEffectMixin.java | 28 ++++++++++++++ .../net/runelite/rs/api/RSAudioTaskNode.java | 33 +++++++++++++++++ .../runelite/rs/api/RSAudioTaskNodeQueue.java | 33 +++++++++++++++++ .../java/net/runelite/rs/api/RSClient.java | 21 +++++++++++ .../net/runelite/rs/api/RSRawAudioNode.java | 33 +++++++++++++++++ .../java/net/runelite/rs/api/RSResampler.java | 29 +++++++++++++++ .../net/runelite/rs/api/RSSoundEffect.java | 4 ++ .../net/runelite/rs/api/RSTaskDataNode.java | 29 +++++++++++++++ 10 files changed, 256 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/SoundEffectVolume.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNode.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNodeQueue.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSRawAudioNode.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSResampler.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSTaskDataNode.java diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 1a36c3be9e..754a6c0b74 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -982,6 +982,15 @@ public interface Client extends GameEngine */ void playSoundEffect(int id, int x, int y, int range, int delay); + /** + * Plays a sound effect, even if the player's sound effect volume is muted. + * + * @param id the ID of the sound effect - {@link SoundEffectID} + * @param volume the volume to play the sound effect at, see {@link SoundEffectVolume} for values used + * in the settings interface. if the sound effect volume is not muted, uses the set volume + */ + void playSoundEffect(int id, int volume); + /** * Gets the clients graphic buffer provider. * diff --git a/runelite-api/src/main/java/net/runelite/api/SoundEffectVolume.java b/runelite-api/src/main/java/net/runelite/api/SoundEffectVolume.java new file mode 100644 index 0000000000..dee7d7c9c1 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/SoundEffectVolume.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api; + +/** + * Volume values for each of the stops on the volume interface + */ +public final class SoundEffectVolume +{ + public static final int MUTED = 0; + public static final int LOW = 32; + public static final int MEDIUM_LOW = 64; + public static final int MEDIUM_HIGH = 96; + public static final int HIGH = 127; +} diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java index 8effc5a812..c9a3f77ba4 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/SoundEffectMixin.java @@ -24,14 +24,18 @@ */ package net.runelite.mixins; +import net.runelite.api.SoundEffectVolume; import net.runelite.api.events.AreaSoundEffectPlayed; import net.runelite.api.events.SoundEffectPlayed; import net.runelite.api.mixins.FieldHook; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Shadow; +import net.runelite.rs.api.RSAudioTaskNode; import net.runelite.rs.api.RSClient; +import net.runelite.rs.api.RSRawAudioNode; import net.runelite.rs.api.RSSoundEffect; +import net.runelite.rs.api.RSTaskDataNode; @Mixin(RSClient.class) public abstract class SoundEffectMixin implements RSClient @@ -78,6 +82,30 @@ public abstract class SoundEffectMixin implements RSClient setQueuedSoundEffectCount(queuedSoundEffectCount + 1); } + @Inject + @Override + public void playSoundEffect(int id, int volume) + { + RSSoundEffect soundEffect = getTrack(getIndexCache4(), id, 0); + if (soundEffect == null) + { + return; + } + + // If the current volume is not muted, use it instead + final int soundEffectVolume = getSoundEffectVolume(); + if (soundEffectVolume != SoundEffectVolume.MUTED) + { + volume = soundEffectVolume; + } + + RSRawAudioNode rawAudioNode = soundEffect.toRawAudioNode().applyResampler(getSoundEffectResampler()); + RSAudioTaskNode audioTaskNode = createSoundEffectAudioTaskNode(rawAudioNode, 100, volume); + audioTaskNode.setNumLoops(1); + + getSoundEffectAudioQueue().queueAudioTaskNode((RSTaskDataNode) audioTaskNode); + } + @FieldHook("queuedSoundEffectCount") @Inject public static void queuedSoundEffectCountChanged(int idx) diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNode.java b/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNode.java new file mode 100644 index 0000000000..9a90fc7883 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.mapping.Import; + +public interface RSAudioTaskNode +{ + @Import("setNumLoops") + void setNumLoops(int numLoops); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNodeQueue.java b/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNodeQueue.java new file mode 100644 index 0000000000..2a50e79471 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSAudioTaskNodeQueue.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.mapping.Import; + +public interface RSAudioTaskNodeQueue +{ + @Import("queueAudioTaskNode") + void queueAudioTaskNode(RSTaskDataNode taskDataNode); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index e0a8c5f8d1..c78a360dfc 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -564,6 +564,9 @@ public interface RSClient extends RSGameEngine, Client @Import("queuedSoundEffectCount") void setQueuedSoundEffectCount(int queuedSoundEffectCount); + @Import("queueSoundEffect") + void queueSoundEffect(int id, int numLoops, int delay); + @Import("rasterProvider") @Override RSBufferProvider getBufferProvider(); @@ -986,4 +989,22 @@ public interface RSClient extends RSGameEngine, Client @Import("healthBarSpriteCache") RSNodeCache getHealthBarSpriteCache(); + + @Import("getTrack") + RSSoundEffect getTrack(RSIndexData indexData, int id, int var0); + + @Import("createSoundEffectAudioTaskNode") + RSAudioTaskNode createSoundEffectAudioTaskNode(RSRawAudioNode audioNode, int var0, int volume); + + @Import("soundEffectAudioQueue") + RSAudioTaskNodeQueue getSoundEffectAudioQueue(); + + @Import("indexCache4") + RSIndexData getIndexCache4(); + + @Import("soundEffectResampler") + RSResampler getSoundEffectResampler(); + + @Import("soundEffectVolume") + int getSoundEffectVolume(); } diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSRawAudioNode.java b/runescape-api/src/main/java/net/runelite/rs/api/RSRawAudioNode.java new file mode 100644 index 0000000000..5c51c394da --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSRawAudioNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.mapping.Import; + +public interface RSRawAudioNode +{ + @Import("applyResampler") + RSRawAudioNode applyResampler(RSResampler resampler); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSResampler.java b/runescape-api/src/main/java/net/runelite/rs/api/RSResampler.java new file mode 100644 index 0000000000..6b75c34f09 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSResampler.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +public interface RSResampler +{ +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSSoundEffect.java b/runescape-api/src/main/java/net/runelite/rs/api/RSSoundEffect.java index 4ced2f19d5..c1f6002bf8 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSSoundEffect.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSSoundEffect.java @@ -24,6 +24,10 @@ */ package net.runelite.rs.api; +import net.runelite.mapping.Import; + public interface RSSoundEffect { + @Import("toRawAudioNode") + RSRawAudioNode toRawAudioNode(); } diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSTaskDataNode.java b/runescape-api/src/main/java/net/runelite/rs/api/RSTaskDataNode.java new file mode 100644 index 0000000000..bcc61f9684 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSTaskDataNode.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018, trimbe + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +public interface RSTaskDataNode +{ +} From 53504cc765b374ef862f22165c63775d73c38b69 Mon Sep 17 00:00:00 2001 From: trimbe Date: Mon, 11 Feb 2019 20:57:57 -0500 Subject: [PATCH 06/12] metronome: play sounds while volume is muted --- .../runelite/client/plugins/metronome/MetronomePlugin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java index 9a0b709aab..7d7416c7f0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.metronome; import com.google.inject.Provides; import javax.inject.Inject; +import net.runelite.api.SoundEffectVolume; import net.runelite.api.Client; import net.runelite.api.SoundEffectID; import net.runelite.api.events.GameTick; @@ -70,11 +71,11 @@ public class MetronomePlugin extends Plugin { if (config.enableTock() && shouldTock) { - client.playSoundEffect(SoundEffectID.GE_DECREMENT_PLOP); + client.playSoundEffect(SoundEffectID.GE_DECREMENT_PLOP, SoundEffectVolume.MEDIUM_HIGH); } else { - client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP); + client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP, SoundEffectVolume.MEDIUM_HIGH); } shouldTock = !shouldTock; } From 66ce5b85dcd1c5ba2eb81a9965ca56628c30c4e4 Mon Sep 17 00:00:00 2001 From: xdesr <49791189+xdesr@users.noreply.github.com> Date: Tue, 25 Jun 2019 12:14:10 +0100 Subject: [PATCH 07/12] Fix typos in Falo the Bard clues (comma, favourite) (#9185) --- .../client/plugins/cluescrolls/clues/FaloTheBardClue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java index 7025f2c8f4..1770e06423 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/FaloTheBardClue.java @@ -79,7 +79,7 @@ public class FaloTheBardClue extends ClueScroll implements TextClueScroll, NpcCl { private static final List CLUES = ImmutableList.of( new FaloTheBardClue("A blood red weapon, a strong curved sword, found on the island of primate lords.", item(DRAGON_SCIMITAR)), - new FaloTheBardClue("A book that preaches of some great figure, lending strength, might, and vigour.", any("Any god book (must be complete)", item(HOLY_BOOK), item(BOOK_OF_BALANCE), item(UNHOLY_BOOK), item(BOOK_OF_LAW), item(BOOK_OF_WAR), item(BOOK_OF_DARKNESS))), + new FaloTheBardClue("A book that preaches of some great figure, lending strength, might and vigour.", any("Any god book (must be complete)", item(HOLY_BOOK), item(BOOK_OF_BALANCE), item(UNHOLY_BOOK), item(BOOK_OF_LAW), item(BOOK_OF_WAR), item(BOOK_OF_DARKNESS))), new FaloTheBardClue("A bow of elven craft was made, it shimmers bright, but will soon fade.", any("Crystal Bow", range(NEW_CRYSTAL_BOW, CRYSTAL_BOW_110), range(NEW_CRYSTAL_BOW_I, CRYSTAL_BOW_110_I))), new FaloTheBardClue("A fiery axe of great inferno, when you use it, you'll wonder where the logs go.", item(INFERNAL_AXE)), new FaloTheBardClue("A mark used to increase one's grace, found atop a seer's place.", item(MARK_OF_GRACE)), @@ -88,7 +88,7 @@ public class FaloTheBardClue extends ClueScroll implements TextClueScroll, NpcCl // The wiki doesn't specify whether the trimmed dragon defender will work so I've assumed that it doesn't new FaloTheBardClue("A sword held in the other hand, red its colour, Cyclops strength you must withstand.", item(DRAGON_DEFENDER)), new FaloTheBardClue("A token used to kill mythical beasts, in hopes of a blade or just for an xp feast.", item(WARRIOR_GUILD_TOKEN)), - new FaloTheBardClue("Green is my favorite, mature ale I do love, this takes your herblore above.", item(GREENMANS_ALEM)), + new FaloTheBardClue("Green is my favourite, mature ale I do love, this takes your herblore above.", item(GREENMANS_ALEM)), new FaloTheBardClue("It can hold down a boat or crush a goat, this object, you see, is quite heavy.", item(BARRELCHEST_ANCHOR)), new FaloTheBardClue("It comes from the ground, underneath the snowy plain. Trolls aplenty, with what looks like a mane.", item(BASALT)), new FaloTheBardClue("No attack to wield, only strength is required, made of obsidian, but with no room for a shield.", item(TZHAARKETOM)), From 4abbf76dc711c1d3a4d2642e9462bb7111aa216b Mon Sep 17 00:00:00 2001 From: itscalvinwang Date: Tue, 25 Jun 2019 04:23:27 -0700 Subject: [PATCH 08/12] Add support for burning stews to Cooking plugin (#9196) (#9202) --- .../net/runelite/client/plugins/cooking/CookingPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java index f48897c94d..7d49a81681 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java @@ -172,7 +172,8 @@ public class CookingPlugin extends Plugin session.increaseCookAmount(); } - else if (message.startsWith("You accidentally burn")) + else if (message.startsWith("You accidentally burn") + || message.startsWith("You accidentally spoil")) { if (session == null) { From 4b0f8526ecb223ffbf2b512de3cec81ee60d7e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evaldas=20Lavrinovi=C4=8Dius?= Date: Tue, 25 Jun 2019 14:24:32 +0300 Subject: [PATCH 09/12] Fix location of Kourend Agility obstacle on world map (#9203) Fixes #9176 --- .../src/main/java/net/runelite/client/game/AgilityShortcut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java index 4a0312485c..dcee1e6acd 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java +++ b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java @@ -121,7 +121,7 @@ public enum AgilityShortcut TROLLHEIM_MEDIUM_CLIFF_SCRAMBLE_NORTH(43, "Rocks", new WorldPoint(2886, 3684, 0), ROCKS_3803, ROCKS_3804, ROCKS_16522), TROLLHEIM_MEDIUM_CLIFF_SCRAMBLE_SOUTH(43, "Rocks", new WorldPoint(2876, 3666, 0), ROCKS_3803, ROCKS_3804, ROCKS_16522), TROLLHEIM_ADVANCED_CLIFF_SCRAMBLE(44, "Rocks", new WorldPoint(2907, 3686, 0), ROCKS_16523, ROCKS_3748), - KOUREND_RIVER_STEPPING_STONES(45, "Stepping Stones", new WorldPoint(1721, 3509, 0), STEPPING_STONE_29728), + KOUREND_RIVER_STEPPING_STONES(45, "Stepping Stones", new WorldPoint(1720, 3551, 0), STEPPING_STONE_29728), TIRANNWN_LOG_BALANCE(45, "Log Balance", null, LOG_BALANCE_3933, LOG_BALANCE_3931, LOG_BALANCE_3930, LOG_BALANCE_3929, LOG_BALANCE_3932), COSMIC_ALTAR_MEDIUM_WALKWAY(46, "Narrow Walkway", new WorldPoint(2399, 4403, 0), JUTTING_WALL_17002), DEEP_WILDERNESS_DUNGEON_CREVICE_NORTH(46, "Narrow Crevice", new WorldPoint(3047, 10335, 0), CREVICE_19043), From 61ea6cf217215b6ccdd2fa2d72b49b0721942ace Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Jun 2019 13:20:38 -0400 Subject: [PATCH 10/12] config manager: treat null and empty string equally in setDefaultConfiguration The config manager treats null and empty string as equal and will unset config values which are set to the empty string with the config client. This fixes the config manager applying default config values which are the empty string when the current value is null, causing it to send an unnecessary unset request --- .../main/java/net/runelite/client/config/ConfigManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 87f63d3826..8ff9434069 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -523,7 +523,10 @@ public class ConfigManager String current = getConfiguration(group.value(), item.keyName()); String valueString = objectToString(defaultValue); - if (Objects.equals(current, valueString)) + // null and the empty string are treated identically in sendConfig and treated as an unset + // If a config value defaults to "" and the current value is null, it will cause an extra + // unset to be sent, so treat them as equal + if (Objects.equals(current, valueString) || (Strings.isNullOrEmpty(current) && Strings.isNullOrEmpty(valueString))) { continue; // already set to the default value } From a3e9b790dd92d8fe7eb12d35de6db250f1f78328 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 Jun 2019 20:39:15 -0400 Subject: [PATCH 11/12] client: fix behavior of walking where there are no tiles This only happens with a plugin force setting checkClick. This would cause the client to possibly incorrectly send a walk packet next tick if viewportWalking was set, since nothing ever clears it. --- .../main/java/net/runelite/api/Client.java | 17 ------------- .../plugins/party/PartyPingOverlay.java | 13 ---------- .../tileindicators/TileIndicatorsOverlay.java | 13 ---------- .../net/runelite/mixins/RSClientMixin.java | 8 ------- .../net/runelite/mixins/RSSceneMixin.java | 24 +++++++++++++++++++ .../java/net/runelite/rs/api/RSClient.java | 4 +++- 6 files changed, 27 insertions(+), 52 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 754a6c0b74..14f3ff5cb8 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -409,23 +409,6 @@ public interface Client extends GameEngine */ int getMouseCurrentButton(); - /** - * Schedules checking of current region tile for next frame, so ${@link Client#getSelectedSceneTile()} ()} will - * return actual value. - * - * @param checkClick when true next frame selected region tile will be updated - */ - void setCheckClick(boolean checkClick); - - /** - * Sets current mouse hover position. This value is automatically updated only when right-clicking in game. - * Setting this value together with ${@link Client#setCheckClick(boolean)} will update ${@link Client#getSelectedSceneTile()} ()} - * for next frame. - * - * @param position current mouse hover position - */ - void setMouseCanvasHoverPosition(Point position); - /** * Gets the currently selected tile (ie. last right clicked tile). * diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java index e6cc7dcf83..9134c1f8d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java @@ -32,7 +32,6 @@ import java.util.Iterator; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.Perspective; -import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.client.plugins.party.data.PartyTilePingData; import net.runelite.client.ui.overlay.Overlay; @@ -60,18 +59,6 @@ class PartyPingOverlay extends Overlay return null; } - // Update selected scene tile - if (!client.isMenuOpen()) - { - Point p = client.getMouseCanvasPosition(); - p = new Point( - p.getX() - client.getViewportXOffset(), - p.getY() - client.getViewportYOffset()); - - client.setCheckClick(true); - client.setMouseCanvasHoverPosition(p); - } - synchronized (plugin.getPendingTilePings()) { final Iterator iterator = plugin.getPendingTilePings().iterator(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java index a9e983656d..00e89241c3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java @@ -31,7 +31,6 @@ import java.awt.Polygon; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.Perspective; -import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; @@ -59,18 +58,6 @@ public class TileIndicatorsOverlay extends Overlay { if (config.highlightHoveredTile()) { - // Update selected scene tile - if (!client.isMenuOpen()) - { - Point p = client.getMouseCanvasPosition(); - p = new Point( - p.getX() - client.getViewportXOffset(), - p.getY() - client.getViewportYOffset()); - - client.setCheckClick(true); - client.setMouseCanvasHoverPosition(p); - } - // If we have tile "selected" render it if (client.getSelectedSceneTile() != null) { diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 2c9050ff2b..7932b31482 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -290,14 +290,6 @@ public abstract class RSClientMixin implements RSClient return AccountType.NORMAL; } - @Inject - @Override - public void setMouseCanvasHoverPosition(final Point position) - { - setMouseCanvasHoverPositionX(position.getX()); - setMouseCanvasHoverPositionY(position.getY()); - } - @Inject @Override public Tile getSelectedSceneTile() diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSSceneMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSSceneMixin.java index d865bf4f88..7bbb154848 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSSceneMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSSceneMixin.java @@ -84,6 +84,16 @@ public abstract class RSSceneMixin implements RSScene } final boolean isGpu = client.isGpu(); + final boolean checkClick = client.isCheckClick(); + if (!client.isMenuOpen()) + { + // Force check click to update the selected tile + client.setCheckClick(true); + final int mouseX = client.getMouseX(); + final int mouseY = client.getMouseY(); + client.setMouseCanvasHoverPositionX(mouseX - client.getViewportXOffset()); + client.setMouseCanvasHoverPositionY(mouseY - client.getViewportYOffset()); + } if (!isGpu) { @@ -292,6 +302,10 @@ public abstract class RSSceneMixin implements RSScene client.setEntitiesAtMouseCount(0); } client.setCheckClick(false); + if (!checkClick) + { + client.setViewportWalking(false); + } client.getCallbacks().drawScene(); return; } @@ -363,6 +377,10 @@ public abstract class RSSceneMixin implements RSScene client.setEntitiesAtMouseCount(0); } client.setCheckClick(false); + if (!checkClick) + { + client.setViewportWalking(false); + } client.getCallbacks().drawScene(); return; } @@ -376,6 +394,12 @@ public abstract class RSSceneMixin implements RSScene client.setEntitiesAtMouseCount(0); } client.setCheckClick(false); + if (!checkClick) + { + // If checkClick was false, then the selected tile wouldn't have existed next tick, + // so clear viewport walking in order to prevent it triggering a walk + client.setViewportWalking(false); + } client.getCallbacks().drawScene(); } diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index c78a360dfc..a620f4d539 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -140,7 +140,6 @@ public interface RSClient extends RSGameEngine, Client int getRSGameState(); @Import("checkClick") - @Override void setCheckClick(boolean checkClick); @Import("mouseX2") @@ -1007,4 +1006,7 @@ public interface RSClient extends RSGameEngine, Client @Import("soundEffectVolume") int getSoundEffectVolume(); + + @Import("viewportWalking") + void setViewportWalking(boolean viewportWalking); } From cb53857f044ddbfa98b2a003a717b7faf68e0485 Mon Sep 17 00:00:00 2001 From: Hermetism <42885564+Hermetism@users.noreply.github.com> Date: Wed, 26 Jun 2019 01:15:23 +1200 Subject: [PATCH 12/12] npchighlight: Do not render 'null' names (#9093) Fix names showing as null in the NPC highlight plugin Fixes #9084 --- .../runelite/client/plugins/npchighlight/NpcSceneOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java index 9e87b3f278..ae252aef93 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java @@ -173,7 +173,7 @@ public class NpcSceneOverlay extends Overlay break; } - if (config.drawNames()) + if (config.drawNames() && actor.getName() != null) { String npcName = Text.removeTags(actor.getName()); Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40);