- Thread Author
- #1
Hey, this is a simple class i made to allow you to play emotes in old school.
To use it all you have to do is something like:
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!
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: