Merge pull request #403 from SomeoneWithAnInternetConnection/ticktock

Add metronome plugin, and sound-effect playing API
This commit is contained in:
Adam
2018-01-22 12:19:19 -05:00
committed by GitHub
7 changed files with 330 additions and 0 deletions

View File

@@ -177,6 +177,25 @@ public interface Client extends GameEngine
List<Projectile> getProjectiles();
/**
* Play a sound effect at the player's current location.
* This is how UI, and player-generated (e.g. mining, woodcutting) sound effects are normally played
*
* @param id the ID of the sound to play. Any int is allowed, but see {@link SoundEffectID} for some common ones
*/
void playSoundEffect(int id);
/**
* 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
*/
void playSoundEffect(int id, int x, int y, int range);
BufferProvider getBufferProvider();
int getMouseIdleTicks();

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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;
public final class SoundEffectID
{
public final static int UI_BOOP = 2266;
public final static int GE_INCREMENT_PLOP = 3929;
public final static int GE_DECREMENT_PLOP = 3930;
public final static int GE_ADD_OFFER_DINGALING = 3925;
public final static int GE_COLLECT_BLOOP = 3928;
public final static int GE_COIN_TINKLE = 3924;
public final static int CLOSE_DOOR = 60;
public final static int OPEN_DOOR = 62;
public final static int ITEM_DROP = 2739;
public final static int ITEM_PICKUP = 2582;
public final static int PICK_PLANT_BLOOP = 2581;
public final static int BURY_BONES = 2738;
public final static int TINDER_STRIKE = 2597;
public final static int FIRE_WOOSH = 2596;
public final static int TREE_FALLING = 2734;
public final static int TREE_CHOP = 2735;
public final static int MINING_TINK = 3220;
public final static int COOK_WOOSH = 2577;
public final static int MAGIC_SPLASH_BOING = 227;
public final static int SMITH_ANVIL_TINK = 3790;
public final static int SMITH_ANVIL_TONK = 3791;
/**
* Used for random event NPCs spawning, and the imp teleport
*/
public final static int NPC_TELEPORT_WOOSH = 1930;
public final static int TELEPORT_VWOOP = 200;
public final static int ZERO_DAMAGE_SPLAT = 511;
public final static int TAKE_DAMAGE_SPLAT = 510;
public final static int ATTACK_HIT = 2498;
public final static int PRAYER_ACTIVATE_VROOM = 2690;
public final static int PRAYER_DEACTIVE_VWOOP = 2663;
public final static int PRAYER_DEPLETE_TWINKLE = 2672;
public final static int TOWN_CRIER_BELL_DING = 3813;
public final static int TOWN_CRIER_BELL_DONG = 3817;
public final static int TOWN_CRIER_SHOUT_SQUEAK = 3816;
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.metronome;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import net.runelite.api.Client;
import net.runelite.api.SoundEffectID;
import net.runelite.api.events.GameTick;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
@PluginDescriptor(
name = "Metronome plugin"
)
public class MetronomePlugin extends Plugin
{
private static final Logger logger = LoggerFactory.getLogger(MetronomePlugin.class);
@Inject
Client client;
@Inject
MetronomePluginConfiguration config;
private boolean tock = false;
@Subscribe
void onTick(GameTick tick)
{
if (!config.enabled())
{
return;
}
if (tock)
{
client.playSoundEffect(SoundEffectID.GE_DECREMENT_PLOP);
}
else // tick
{
client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP);
}
tock = !tock;
}
@Provides
MetronomePluginConfiguration provideConfig(ConfigManager configManager)
{
return configManager.getConfig(MetronomePluginConfiguration.class);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.metronome;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "metronomeplugin",
name = "Metronome plugin",
description = "Configuration for the metronome plugin"
)
public interface MetronomePluginConfiguration extends Config
{
@ConfigItem(
keyName = "enabled",
name = "Enable metronome",
description = "Toggles tick metronome"
)
default boolean enabled()
{
return false;
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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.mixins;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSSoundEffect;
@Mixin(RSClient.class)
public abstract class PlaySoundEffectMixin implements RSClient
{
@Inject
@Override
public void playSoundEffect(int id)
{
playSoundEffect(id, 0, 0, 0);
}
@Inject
@Override
public void playSoundEffect(int id, int x, int y, int range)
{
int position = ((x & 255) << 16) + ((y & 255) << 8) + (range & 255);
int[] queuedSoundEffectIDs = getQueuedSoundEffectIDs();
int[] unknownSoundValues1 = getUnknownSoundValues1();
int[] unknownSoundValues2 = getUnknownSoundValues2();
RSSoundEffect[] audioEffects = getAudioEffects();
int[] soundLocations = getSoundLocations();
int queuedSoundEffectCount = getQueuedSoundEffectCount();
queuedSoundEffectIDs[queuedSoundEffectCount] = id;
unknownSoundValues1[queuedSoundEffectCount] = 0;
unknownSoundValues2[queuedSoundEffectCount] = 0;
audioEffects[queuedSoundEffectCount] = null;
soundLocations[queuedSoundEffectCount] = position;
setQueuedSoundEffectCount(queuedSoundEffectCount + 1);
}
}

View File

@@ -352,6 +352,27 @@ public interface RSClient extends RSGameEngine, Client
@Override
boolean isIgnored(String name);
@Import("audioEffects")
RSSoundEffect[] getAudioEffects();
@Import("queuedSoundEffectIDs")
int[] getQueuedSoundEffectIDs();
@Import("soundLocations")
int[] getSoundLocations();
@Import("unknownSoundValues1")
int[] getUnknownSoundValues1();
@Import("unknownSoundValues2")
int[] getUnknownSoundValues2();
@Import("queuedSoundEffectCount")
int getQueuedSoundEffectCount();
@Import("queuedSoundEffectCount")
void setQueuedSoundEffectCount(int queuedSoundEffectCount);
@Import("rasterProvider")
@Override
BufferProvider getBufferProvider();

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018, SomeoneWithAnInternetConnection
* 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 RSSoundEffect
{
}