Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resource Old School Emote Player

Joined
Mar 14, 2015
Messages
24
Hey, this is a simple class i made to allow you to play emotes in old school.

Code:
import com.runemate.game.api.hybrid.input.Mouse;
import com.runemate.game.api.hybrid.local.hud.InteractableRectangle;
import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
import com.runemate.game.api.hybrid.util.Filter;
import com.runemate.game.api.hybrid.util.calculations.Random;

import java.util.List;

public class Emotes {

    public enum Emote {
        YES,
        NO,
        BOW,
        ANGRY,
        THINK,
        WAVE,
        SHRUG,
        CHEER,
        BECKON,
        LAUGH,
        JUMP_FOR_JOY,
        YAWN,
        DANCE,
        JIG,
        SPIN,
        HEADBANG,
        CRY,
        BLOW_KISS,
        PANIC,
        RASPBERRY,
        CLAP,
        SALUTE,
        GOBLIN_BOW,
        GOBLIN_SALUTE,
        GLASS_BOX,
        CLIMB_ROPE,
        LEAN,
        GLASS_WALL,
        IDEA,
        STAMP,
        FLAP,
        SLAP_HEAD,
        ZOMBIE_WALK,
        ZOMBIE_DANCE,
        SCARED,
        RABBIT_HOP,
        ZOMBIE_HAND,
        SKILL_CAPE;

        public String getAction() {
            return name().toLowerCase().replace('_', ' ');
        }
    }

    public static class EmoteFilter extends Filter<InterfaceComponent> {

        private Emote emote;

        public EmoteFilter(Emote emote) {
            this.emote = emote;
        }

        @Override
        public boolean accepts(InterfaceComponent interfaceComponent) {
            for(String action : interfaceComponent.getActions()) {
                if(action.equalsIgnoreCase(emote.getAction())) {
                    return true;
                }
            }
            return false;
        }
    }

    public static boolean isEmotesTabOpen() {
        InterfaceComponent tab = getEmotesTabComponent();

        if(tab == null) {
            return false;
        }

        return tab.getTextureId() >= 0;
    }

    public static void openEmotesTab() {
        InterfaceComponent tab = getEmotesTabComponent();

        if(tab == null) {
            return;
        }

        tab.interact("Emotes");
    }

    public static InterfaceComponent getEmotesTabComponent() {
        return Interfaces.newQuery().actions("Emotes").visible().results().first();
    }

    public static InterfaceComponent getEmotesInventoryComponent() {
        return Interfaces.getAt(216, 1);
    }

    public static InterfaceComponent getEmoteComponent(Emote emote) {
        InterfaceComponent emotesInv = getEmotesInventoryComponent();

        if(emotesInv == null || !emotesInv.isValid()) {
            return null;
        }

        List<InterfaceComponent> emotes = emotesInv.getComponents(new EmoteFilter(emote));

        if(emotes.size() <= 0) {
            return null;
        }

        InterfaceComponent emoteComponent = emotes.get(0);

        return emoteComponent;
    }

    public static float getEmoteScroll(Emote emote) {
        return getEmoteScroll(getEmoteComponent(emote));
    }

    public static float getEmoteScroll(InterfaceComponent emoteComponent) {
        if(emoteComponent == null) {
            return -1f;
        }

        InterfaceComponent inventory = getEmotesInventoryComponent();

        if(inventory == null) {
            return -1f;
        }

        int minY = Integer.MAX_VALUE;
        int maxY = Integer.MIN_VALUE;

        for(InterfaceComponent comp : inventory.getComponents()) {
            InteractableRectangle bounds = comp.getBounds();

            if(bounds.y < minY) {
                minY = bounds.y;
            }

            if(bounds.y > maxY) {
                maxY = bounds.y;
            }
        }

        int y = emoteComponent.getBounds().y - minY;

        return (float) y / (float) (maxY - minY);
    }

public static boolean isEmoteVisible(Emote emote) {
    return isEmoteVisisble(getEmoteComponent(emote));
}

    public static boolean isEmoteVisisble(InterfaceComponent emoteComponent) {
        if(emoteComponent == null) {
            return false;
        }

        InterfaceComponent inventory = getEmotesInventoryComponent();

        if(inventory == null) {
            return false;
        }

        InteractableRectangle inv = inventory.getBounds();
        InteractableRectangle emote = emoteComponent.getBounds();

        return emote.y >= inv.y - 5 && emote.y + emote.height <= inv.y + inv.height + 5;
    }

    public static float getScroll() {
        InterfaceComponent scrollBox = Interfaces.getAt(216, 2, 0);
        InterfaceComponent scrollBar = Interfaces.getAt(216, 2, 1);

        int maxScroll = scrollBox.getHeight() - scrollBar.getHeight();
        int scroll = scrollBar.getBounds().y - scrollBox.getBounds().y;

        return (float) scroll / (float) maxScroll;
    }

    public static void scrollTo(Emote emote) {
        scrollTo(getEmoteScroll(emote));
    }

    public static void scrollTo(InterfaceComponent emotesComponent) {
        scrollTo(getEmoteScroll(emotesComponent));
    }

    public static void scrollTo(float scroll) {
        InterfaceComponent scrollBox = Interfaces.getAt(216, 2, 0);
        InterfaceComponent scrollBar = Interfaces.getAt(216, 2, 1);

        int maxScroll = scrollBox.getHeight() - scrollBar.getHeight();

        int fromY = scrollBar.getBounds().y - scrollBox.getBounds().y;
        int toY = (int) (scroll * maxScroll);

        int difY = toY - fromY;
        difY = Random.nextInt(difY - 5, difY + 5);

        int difX = Random.nextInt(-5, 5);

        Mouse.move(scrollBar);

        Mouse.press(Mouse.Button.LEFT);

        int x = Mouse.getPosition().x + difX - 5;
        int y = Mouse.getPosition().y + difY - 5;
        int width = 11;
        int height = 11;

        InteractableRectangle rect = new InteractableRectangle(x, y, width, height);

        Mouse.move(rect);

        Mouse.release(Mouse.Button.LEFT);
    }

    public static void runEmote(Emote emote) {
        if(!isEmotesTabOpen()) {
            openEmotesTab();

            if(!isEmotesTabOpen()) {
                return;
            }
        }

        if(!isEmoteVisible(emote)) {
            scrollTo(emote);

            if(!isEmoteVisible(emote)) {
                return;
            }
        }

        InterfaceComponent component = getEmoteComponent(emote);

        if(component != null) {
            component.click();
        }
    }

}


To use it all you have to do is something like:

Code:
if(Players.getLocal().getAnimationId() <= -1) {
    Emotes.runEmote(Emotes.Emote.BLOW_KISS);
}


This will run the blow kiss animation if your not already running an animation.
Note: the animation doesn't have to be an emote, any animation will cause you to not run the emote

You do not have to worry about opening the emotes tab or scrolling to the emote, this will do it for you :).

Enjoy!
 
Last edited:
Joined
Mar 14, 2015
Messages
24
@Cloud consider API addition.

Made a smallified version for you:

Code:
import com.runemate.game.api.hybrid.input.Mouse;
import com.runemate.game.api.hybrid.local.hud.InteractableRectangle;
import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
import com.runemate.game.api.hybrid.util.Filter;
import com.runemate.game.api.hybrid.util.calculations.Random;

public class Emotes {

    public enum Emote {
        YES, NO, BOW, ANGRY,
        THINK, WAVE, SHRUG, CHEER,
        BECKON, LAUGH, JUMP_FOR_JOY, YAWN,
        DANCE, JIG, SPIN, HEADBANG,
        CRY, BLOW_KISS, PANIC, RASPBERRY,
        CLAP, SALUTE, GOBLIN_BOW, GOBLIN_SALUTE,
        GLASS_BOX, CLIMB_ROPE, LEAN, GLASS_WALL,
        IDEA, STAMP, FLAP, SLAP_HEAD,
        ZOMBIE_WALK, ZOMBIE_DANCE, SCARED, RABBIT_HOP,
        ZOMBIE_HAND, SKILL_CAPE
    }

    public static class EmoteFilter extends Filter<InterfaceComponent> {

        private Emote emote;

        public EmoteFilter(Emote emote) {
            this.emote = emote;
        }

        @Override
        public boolean accepts(InterfaceComponent interfaceComponent) {
            return interfaceComponent.getActions().stream().anyMatch(action -> action.equalsIgnoreCase(emote.name().replace('_', ' ')));
        }
    }

    public static boolean isEmotesTabOpen() {
        InterfaceComponent tab = getEmotesTabComponent();
        return tab != null && tab.getTextureId() >= 0;
    }

    public static boolean openEmotesTab() {
        InterfaceComponent tab = getEmotesTabComponent();
        return tab != null && tab.isValid() && ((tab.getTextureId() < 0 && tab.interact("Emotes")) || tab.getTextureId() >= 0);
    }

    public static InterfaceComponent getEmotesTabComponent() {
        return Interfaces.newQuery().actions("Emotes").visible().results().first();
    }

    public static InterfaceComponent getEmotesInventoryComponent() {
        return Interfaces.getAt(216, 1);
    }

    public static InterfaceComponent getEmoteComponent(Emote emote) {
        InterfaceComponent emotesInv, emotes;
        return ((emotesInv = getEmotesInventoryComponent()) == null || !emotesInv.isValid() ? null : emotesInv.getComponents(new EmoteFilter(emote)).stream().findFirst().get());
    }

    public static float getEmoteScroll(Emote emote) {
        return getEmoteScroll(getEmoteComponent(emote));
    }

    public static float getEmoteScroll(InterfaceComponent emoteComponent) {
        InterfaceComponent inventory = getEmotesInventoryComponent();
        int minY = (inventory == null || !inventory.isValid() ? -1 : inventory.getComponents().stream().mapToInt(comp -> comp.getBounds().y).min().getAsInt());
        int maxY = (inventory == null || !inventory.isValid() ? -1 : inventory.getComponents().stream().mapToInt(comp -> comp.getBounds().y).max().getAsInt());
        return (inventory == null || !inventory.isValid() || emoteComponent == null || !emoteComponent.isValid() ? -1f : (float) (emoteComponent.getBounds().y - minY) / (float) (maxY - minY));
    }

    public static boolean isEmoteVisible(Emote emote) {
        InterfaceComponent invent = getEmotesInventoryComponent(), emoteComp = getEmoteComponent(emote);
        InteractableRectangle inv, emo;
        return isEmotesTabOpen() && emoteComp != null && emoteComp.isValid() && invent != null && invent.isValid() && (emo = emoteComp.getBounds()).y >= (inv = invent.getBounds()).y && emo.y + emo.height <= inv.y + inv.height;
    }

    public static float getScroll() {
        InterfaceComponent scrollBox = Interfaces.getAt(216, 2, 0), scrollBar = Interfaces.getAt(216, 2, 1);
        return (float) (scrollBar.getBounds().y - scrollBox.getBounds().y) / (float) (scrollBox.getHeight() - scrollBar.getHeight());
    }

    public static boolean scrollTo(Emote emote) {
        return isEmoteVisible(emote) || (scrollTo(getEmoteScroll(emote)) && isEmoteVisible(emote));
    }

    public static boolean scrollTo(float scroll) {
        InterfaceComponent scrollBox = Interfaces.getAt(216, 2, 0), scrollBar = Interfaces.getAt(216, 2, 1);
        int difY = ((int) (scroll * (scrollBox.getHeight() - scrollBar.getHeight()))) - (scrollBar.getBounds().y - scrollBox.getBounds().y) + Random.nextInt(-5, 5);

        Mouse.move(scrollBar);
        Mouse.press(Mouse.Button.LEFT);
        Mouse.move(new InteractableRectangle(Mouse.getPosition().x + Random.nextInt(-5, 5), Mouse.getPosition().y + difY, 11, 11));
        Mouse.release(Mouse.Button.LEFT);

        return true;
    }

    public static boolean runEmote(Emote emote) {
        InterfaceComponent component = getEmoteComponent(emote);
        return (openEmotesTab() && scrollTo(emote) && component != null && component.click());
    }

}
 
Re-written using the ScrollBar util i made (https://www.runemate.com/community/threads/old-school-scroll-bar-util.1955/):

Code:
package me.sothatsit.dancingformoney.util;

import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
import com.runemate.game.api.hybrid.util.Filter;

public class Emotes {

    public enum Emote {
        YES, NO, BOW, ANGRY,
        THINK, WAVE, SHRUG, CHEER,
        BECKON, LAUGH, JUMP_FOR_JOY, YAWN,
        DANCE, JIG, SPIN, HEADBANG,
        CRY, BLOW_KISS, PANIC, RASPBERRY,
        CLAP, SALUTE, GOBLIN_BOW, GOBLIN_SALUTE,
        GLASS_BOX, CLIMB_ROPE, LEAN, GLASS_WALL,
        IDEA, STAMP, FLAP, SLAP_HEAD,
        ZOMBIE_WALK, ZOMBIE_DANCE, SCARED, RABBIT_HOP,
        ZOMBIE_HAND, SKILL_CAPE
    }

    public static class EmoteFilter extends Filter<InterfaceComponent> {

        private Emote emote;

        public EmoteFilter(Emote emote) {
            this.emote = emote;
        }

        @Override
        public boolean accepts(InterfaceComponent interfaceComponent) {
            return interfaceComponent.getActions().stream().anyMatch(action -> action.equalsIgnoreCase(emote.name().replace('_', ' ')));
        }
    }

    public static boolean isEmotesTabOpen() {
        InterfaceComponent tab = getEmotesTabComponent();
        return tab != null && tab.getTextureId() >= 0;
    }

    public static boolean openEmotesTab() {
        InterfaceComponent tab = getEmotesTabComponent();
        return tab != null && tab.isValid() && ((tab.getTextureId() < 0 && tab.interact("Emotes")) || tab.getTextureId() >= 0);
    }

    public static InterfaceComponent getEmotesTabComponent() {
        return Interfaces.newQuery().actions("Emotes").visible().results().first();
    }

    public static InterfaceComponent getEmoteComponent(Emote emote) {
        InterfaceComponent emotesInv, emotes;
        return ((emotesInv = Interfaces.getAt(216, 1)) == null || !emotesInv.isValid() ? null : emotesInv.getComponents(new EmoteFilter(emote)).stream().findFirst().get());
    }

    public static float getEmoteScroll(Emote emote) {
        return getEmoteScroll(getEmoteComponent(emote));
    }

    public static float getEmoteScroll(InterfaceComponent emoteComponent) {
        return ScrollBar.getEmotesScrollBar().getScroll(emoteComponent);
    }

    public static boolean isEmoteVisible(Emote emote) {
        InterfaceComponent emoteComp = getEmoteComponent(emote);
        return ScrollBar.getEmotesScrollBar().isVisible(emoteComp);
    }

    public static float getScroll() {
        return ScrollBar.getEmotesScrollBar().getCurrentScroll();
    }

    public static boolean scrollTo(Emote emote) {
        return isEmoteVisible(emote) || (scrollTo(getEmoteScroll(emote)) && isEmoteVisible(emote));
    }

    public static boolean scrollTo(float scroll) {
        return ScrollBar.getEmotesScrollBar().scrollTo(scroll);
    }

    public static boolean runEmote(Emote emote) {
        InterfaceComponent component = getEmoteComponent(emote);
        return (openEmotesTab() && scrollTo(emote) && component != null && component.click());
    }

}
 
Top