mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-07 00:38:21 +00:00
Re-arranged code
This commit is contained in:
@@ -22,76 +22,74 @@ import java.io.File;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@ServerManifest(author = "Everel & Paradox", name = "Server name here", type = Type.INJECTION, version = 2.1)
|
@ServerManifest(author = "Everel & Paradox", name = "Server name here", type = Type.INJECTION, version = 2.1)
|
||||||
public class Loader extends ServerProvider {
|
public class Loader extends ServerProvider {
|
||||||
private Applet applet;
|
private Applet applet;
|
||||||
private HookFile hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getExtendenHookFile(), HookFile.TYPE_XML);
|
private HookFile hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getExtendenHookFile(), HookFile.TYPE_XML);
|
||||||
|
|
||||||
@Override
|
public static Client getClient() {
|
||||||
public Applet fetchApplet() {
|
return (Client) Context.getInstance().getClient();
|
||||||
try {
|
}
|
||||||
final Context context = Context.getInstance();
|
|
||||||
final ASMClassLoader classLoader = context.getASMClassLoader();
|
@Override
|
||||||
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
|
public Applet fetchApplet() {
|
||||||
Object instance = clientClass.newInstance();
|
try {
|
||||||
applet = (Applet) instance;
|
final Context context = Context.getInstance();
|
||||||
return applet;
|
final ASMClassLoader classLoader = context.getASMClassLoader();
|
||||||
} catch (Exception e) {
|
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
|
||||||
e.printStackTrace();
|
Object instance = clientClass.newInstance();
|
||||||
return null;
|
applet = (Applet) instance;
|
||||||
}
|
return applet;
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getJar() {
|
public URL getJar() {
|
||||||
ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo();
|
ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo();
|
||||||
|
|
||||||
File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar");
|
File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar");
|
||||||
if(!target.exists()) {
|
if (!target.exists()) {
|
||||||
WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get());
|
WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return WebUtil.toURL(target);
|
return WebUtil.toURL(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Client getClient() {
|
@Override
|
||||||
return (Client) Context.getInstance().getClient();
|
public void addMenuItems(JMenuBar bar) {
|
||||||
}
|
new BotMenu(bar);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void addMenuItems(JMenuBar bar) {
|
@Override
|
||||||
new BotMenu(bar);
|
public void injectHooks() {
|
||||||
}
|
AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/");
|
||||||
|
|
||||||
@Override
|
|
||||||
public void injectHooks() {
|
|
||||||
AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/");
|
|
||||||
try {
|
try {
|
||||||
super.injectHooks();
|
super.injectHooks();
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML);
|
this.hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML);
|
||||||
super.injectHooks();
|
super.injectHooks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initScript(Script script) {
|
public void initScript(Script script) {
|
||||||
ScriptEngine.getInstance().setScript(script);
|
ScriptEngine.getInstance().setScript(script);
|
||||||
ScriptEngine.getInstance().init();
|
ScriptEngine.getInstance().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HookFile getHookFile() {
|
public HookFile getHookFile() {
|
||||||
return this.hookFile;
|
return this.hookFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadScript(Script script) {
|
public void unloadScript(Script script) {
|
||||||
ScriptEngine.getInstance().unload();
|
ScriptEngine.getInstance().unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Character {
|
public interface Character {
|
||||||
|
|
||||||
public int getX();
|
public int getX();
|
||||||
|
|
||||||
public int getY();
|
public int getY();
|
||||||
|
|
||||||
public int getAnimation();
|
public int getAnimation();
|
||||||
|
|
||||||
public int getLoopCycleStatus();
|
public int getLoopCycleStatus();
|
||||||
|
|
||||||
public int getCurrentHealth();
|
public int getCurrentHealth();
|
||||||
|
|
||||||
public int getMaxHealth();
|
public int getMaxHealth();
|
||||||
|
|
||||||
public int getInteractingEntity();
|
public int getInteractingEntity();
|
||||||
|
|
||||||
public boolean isLoggedIn();
|
public boolean isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Client {
|
public interface Client {
|
||||||
|
|
||||||
public Scene getScene();
|
|
||||||
|
|
||||||
public Player getMyPlayer();
|
|
||||||
|
|
||||||
public Interface[] getInterfaceCache();
|
|
||||||
|
|
||||||
public Npc[] getNpcs();
|
|
||||||
|
|
||||||
public Player[] getPlayers();
|
|
||||||
|
|
||||||
public int getOpenInterfaceId();
|
|
||||||
|
|
||||||
public int getBaseX();
|
|
||||||
|
|
||||||
public int getBaseY();
|
|
||||||
|
|
||||||
public void setInterface(int id);
|
|
||||||
|
|
||||||
public int[] getCurrentExp();
|
public Scene getScene();
|
||||||
|
|
||||||
public Deque[][][] getGroundItems();
|
public Player getMyPlayer();
|
||||||
|
|
||||||
public int getLoopCycle();
|
public Interface[] getInterfaceCache();
|
||||||
|
|
||||||
public int getBackDialogId();
|
public Npc[] getNpcs();
|
||||||
|
|
||||||
public int getPlane();
|
public Player[] getPlayers();
|
||||||
|
|
||||||
public int[] getMenuActionId();
|
public int getOpenInterfaceId();
|
||||||
|
|
||||||
public int[] getMenuAction1();
|
public int getBaseX();
|
||||||
|
|
||||||
public int[] getMenuAction2();
|
public int getBaseY();
|
||||||
|
|
||||||
public int[] getMenuAction3();
|
public void setInterface(int id);
|
||||||
|
|
||||||
public int[] getMenuAction4();
|
public int[] getCurrentExp();
|
||||||
|
|
||||||
public CollisionMap[] getCollisionMap();
|
public Deque[][][] getGroundItems();
|
||||||
|
|
||||||
// args switched
|
public int getLoopCycle();
|
||||||
public boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation);
|
|
||||||
|
public int getBackDialogId();
|
||||||
public void doAction(int i);
|
|
||||||
|
public int getPlane();
|
||||||
|
|
||||||
|
public int[] getMenuActionId();
|
||||||
|
|
||||||
|
public int[] getMenuAction1();
|
||||||
|
|
||||||
|
public int[] getMenuAction2();
|
||||||
|
|
||||||
|
public int[] getMenuAction3();
|
||||||
|
|
||||||
|
public int[] getMenuAction4();
|
||||||
|
|
||||||
|
public CollisionMap[] getCollisionMap();
|
||||||
|
|
||||||
|
// args switched
|
||||||
|
public boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation);
|
||||||
|
|
||||||
|
public void doAction(int i);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.rev317.min.accessors;
|
|||||||
|
|
||||||
|
|
||||||
public interface CollisionMap {
|
public interface CollisionMap {
|
||||||
|
|
||||||
public int[][] getFlags();
|
public int[][] getFlags();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Deque {
|
public interface Deque {
|
||||||
|
|
||||||
public Node getHead();
|
public Node getHead();
|
||||||
|
|
||||||
public Node getCurrent();
|
public Node getCurrent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package org.rev317.min.accessors;
|
|||||||
|
|
||||||
public interface Ground {
|
public interface Ground {
|
||||||
|
|
||||||
public SceneObjectTile getWallObject();
|
public SceneObjectTile getWallObject();
|
||||||
|
|
||||||
public SceneObjectTile getWallDecoration();
|
public SceneObjectTile getWallDecoration();
|
||||||
|
|
||||||
public SceneObjectTile getGroundDecoration();
|
public SceneObjectTile getGroundDecoration();
|
||||||
|
|
||||||
public SceneObjectTile getGroundItem();
|
public SceneObjectTile getGroundItem();
|
||||||
|
|
||||||
public SceneObjectTile[] getInteractiveObjects();
|
public SceneObjectTile[] getInteractiveObjects();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Interface {
|
public interface Interface {
|
||||||
|
|
||||||
public int[] getItems();
|
|
||||||
|
|
||||||
public int[] getStackSizes();
|
public int[] getItems();
|
||||||
|
|
||||||
|
public int[] getStackSizes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Item {
|
public interface Item {
|
||||||
|
|
||||||
public int getId();
|
public int getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Node {
|
public interface Node {
|
||||||
|
|
||||||
public Node getNext();
|
public Node getNext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Npc extends Character {
|
public interface Npc extends Character {
|
||||||
|
|
||||||
public NpcDef getDef();
|
public NpcDef getDef();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface NpcDef {
|
public interface NpcDef {
|
||||||
|
|
||||||
public int getId();
|
public int getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface Scene {
|
public interface Scene {
|
||||||
|
|
||||||
public Ground[][][] getGroundArray();
|
public Ground[][][] getGroundArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.rev317.min.accessors;
|
package org.rev317.min.accessors;
|
||||||
|
|
||||||
public interface SceneObjectTile {
|
public interface SceneObjectTile {
|
||||||
|
|
||||||
public int getHash();
|
public int getHash();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,44 +1,42 @@
|
|||||||
package org.rev317.min.api.events;
|
package org.rev317.min.api.events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matt, Everel
|
* @author Matt, Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class GameActionEvent {
|
public final class GameActionEvent {
|
||||||
private int index, cmd1, cmd2, cmd3, cmd4, action;
|
private int index, cmd1, cmd2, cmd3, cmd4, action;
|
||||||
|
|
||||||
public GameActionEvent(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
|
public GameActionEvent(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.cmd1 = cmd1;
|
this.cmd1 = cmd1;
|
||||||
this.cmd2 = cmd2;
|
this.cmd2 = cmd2;
|
||||||
this.cmd3 = cmd3;
|
this.cmd3 = cmd3;
|
||||||
this.cmd4 = cmd4;
|
this.cmd4 = cmd4;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCmd1() {
|
public int getCmd1() {
|
||||||
return cmd1;
|
return cmd1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCmd2() {
|
public int getCmd2() {
|
||||||
return cmd2;
|
return cmd2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCmd3() {
|
public int getCmd3() {
|
||||||
return cmd3;
|
return cmd3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCmd4() {
|
|
||||||
return cmd4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAction() {
|
public int getCmd4() {
|
||||||
return action;
|
return cmd4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getAction() {
|
||||||
return index;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,33 @@
|
|||||||
package org.rev317.min.api.events;
|
package org.rev317.min.api.events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel, Matt
|
* @author Everel, Matt
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class MessageEvent {
|
public final class MessageEvent {
|
||||||
private int type;
|
public static final int TYPE_GENERIC = 0;
|
||||||
private String name;
|
public static final int TYPE_PLAYER = 2;
|
||||||
private String message;
|
public static final int TYPE_TRADE = 4;
|
||||||
|
public static final int TYPE_DUEL = 8;
|
||||||
|
private int type;
|
||||||
|
private String name;
|
||||||
|
private String message;
|
||||||
|
|
||||||
public static final int TYPE_GENERIC = 0;
|
public MessageEvent(final int type, String name, String msg) {
|
||||||
public static final int TYPE_PLAYER = 2;
|
this.type = type;
|
||||||
public static final int TYPE_TRADE = 4;
|
this.name = name;
|
||||||
public static final int TYPE_DUEL = 8;
|
this.message = msg;
|
||||||
|
}
|
||||||
|
|
||||||
public MessageEvent(final int type, String name, String msg) {
|
public final String getMessage() {
|
||||||
this.type = type;
|
return message;
|
||||||
this.name = name;
|
}
|
||||||
this.message = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getMessage() {
|
public final int getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getType() {
|
public final String getSender() {
|
||||||
return type;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getSender() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,7 @@ package org.rev317.min.api.events.listeners;
|
|||||||
import org.rev317.min.api.events.GameActionEvent;
|
import org.rev317.min.api.events.GameActionEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matt
|
* @author Matt
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface GameActionListener {
|
public interface GameActionListener {
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import org.rev317.min.api.events.MessageEvent;
|
|||||||
|
|
||||||
|
|
||||||
public interface MessageListener {
|
public interface MessageListener {
|
||||||
|
|
||||||
public void messageReceived(MessageEvent event);
|
public void messageReceived(MessageEvent event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,22 +3,22 @@ package org.rev317.min.api.interfaces;
|
|||||||
import org.rev317.min.api.wrappers.Tile;
|
import org.rev317.min.api.wrappers.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface Locatable {
|
public interface Locatable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets location of this locatable instance
|
* Gets location of this locatable instance
|
||||||
* @return location
|
*
|
||||||
*/
|
* @return location
|
||||||
public Tile getLocation();
|
*/
|
||||||
|
public Tile getLocation();
|
||||||
/**
|
|
||||||
* Gets distance to this locatable instance
|
/**
|
||||||
* @return distance from player to locatable
|
* Gets distance to this locatable instance
|
||||||
*/
|
*
|
||||||
public int distanceTo();
|
* @return distance from player to locatable
|
||||||
|
*/
|
||||||
|
public int distanceTo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package org.rev317.min.api.interfaces;
|
package org.rev317.min.api.interfaces;
|
||||||
|
|
||||||
public interface TileFlags {
|
public interface TileFlags {
|
||||||
|
|
||||||
public int WALL_NORTHWEST = 0x1;
|
public int WALL_NORTHWEST = 0x1;
|
||||||
public int WALL_NORTH = 0x2;
|
public int WALL_NORTH = 0x2;
|
||||||
public int WALL_NORTHEAST = 0x4;
|
public int WALL_NORTHEAST = 0x4;
|
||||||
public int WALL_EAST = 0x8;
|
public int WALL_EAST = 0x8;
|
||||||
public int WALL_SOUTHEAST = 0x10;
|
public int WALL_SOUTHEAST = 0x10;
|
||||||
public int WALL_SOUTH = 0x20;
|
public int WALL_SOUTH = 0x20;
|
||||||
public int WALL_SOUTHWEST = 0x40;
|
public int WALL_SOUTHWEST = 0x40;
|
||||||
public int WALL_WEST = 0x80;
|
public int WALL_WEST = 0x80;
|
||||||
public int OBJECT_TILE = 0x100;
|
public int OBJECT_TILE = 0x100;
|
||||||
public int UNKNOWN = 0x80000;
|
public int UNKNOWN = 0x80000;
|
||||||
public int BLOCKED_TILE = 0x200000;
|
public int BLOCKED_TILE = 0x200000;
|
||||||
public int UNLOADED_TILE = 0x1000000;
|
public int UNLOADED_TILE = 0x1000000;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
import org.parabot.environment.input.Keyboard;
|
import org.parabot.environment.input.Keyboard;
|
||||||
@@ -11,288 +8,287 @@ import org.rev317.min.api.wrappers.Item;
|
|||||||
import org.rev317.min.api.wrappers.Npc;
|
import org.rev317.min.api.wrappers.Npc;
|
||||||
import org.rev317.min.api.wrappers.SceneObject;
|
import org.rev317.min.api.wrappers.SceneObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @author Matt123337
|
* @author Matt123337
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Bank {
|
public class Bank {
|
||||||
public static int BANK_INTERFACE = 5292;
|
public static final int[] BANKERS = new int[]{44, 45, 494, 495, 498, 499,
|
||||||
public static int ITEM_INTERFACE = 5382;
|
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
|
||||||
public static int BUTTON_DEPOSIT_ALL = 5386;
|
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
|
||||||
public static int INV_PARENT_ID = 5064;
|
9710, 14367};
|
||||||
public static int BANK_OPEN_INDEX = 1;
|
public static final int[] BANKS = new int[]{782, 2213, 2995, 5276, 6084,
|
||||||
|
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
|
||||||
static {
|
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
|
||||||
HashMap<String, String> p = Context.getInstance().getServerProviderInfo().getProperties();
|
4483, 12308, 20607, 21301, 27663, 42192};
|
||||||
if(p.containsKey("bankInterface"))
|
public static int BANK_INTERFACE = 5292;
|
||||||
BANK_INTERFACE = Integer.parseInt(p.get("bankInterface"));
|
public static int ITEM_INTERFACE = 5382;
|
||||||
if(p.containsKey("bankItemInterface"))
|
public static int BUTTON_DEPOSIT_ALL = 5386;
|
||||||
ITEM_INTERFACE = Integer.parseInt(p.get("bankItemInterface"));
|
public static int INV_PARENT_ID = 5064;
|
||||||
if(p.containsKey("bankDepositAll"))
|
public static int BANK_OPEN_INDEX = 1;
|
||||||
BUTTON_DEPOSIT_ALL = Integer.parseInt(p.get("bankDepositAll"));
|
static {
|
||||||
if(p.containsKey("bankInvParent"))
|
HashMap<String, String> p = Context.getInstance().getServerProviderInfo().getProperties();
|
||||||
INV_PARENT_ID = Integer.parseInt(p.get("bankInvParent"));
|
if (p.containsKey("bankInterface"))
|
||||||
if(p.containsKey("bankOpenIndex"))
|
BANK_INTERFACE = Integer.parseInt(p.get("bankInterface"));
|
||||||
BANK_OPEN_INDEX = Integer.parseInt(p.get("bankOpenIndex"));
|
if (p.containsKey("bankItemInterface"))
|
||||||
}
|
ITEM_INTERFACE = Integer.parseInt(p.get("bankItemInterface"));
|
||||||
|
if (p.containsKey("bankDepositAll"))
|
||||||
|
BUTTON_DEPOSIT_ALL = Integer.parseInt(p.get("bankDepositAll"));
|
||||||
|
if (p.containsKey("bankInvParent"))
|
||||||
|
INV_PARENT_ID = Integer.parseInt(p.get("bankInvParent"));
|
||||||
|
if (p.containsKey("bankOpenIndex"))
|
||||||
|
BANK_OPEN_INDEX = Integer.parseInt(p.get("bankOpenIndex"));
|
||||||
|
}
|
||||||
|
|
||||||
public static final int[] BANKERS = new int[] { 44, 45, 494, 495, 498, 499,
|
/**
|
||||||
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
|
* Gets nearest banker
|
||||||
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
|
*
|
||||||
9710, 14367 };
|
* @return nearest banker
|
||||||
public static final int[] BANKS = new int[] { 782, 2213, 2995, 5276, 6084,
|
*/
|
||||||
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
|
public static Npc getBanker() {
|
||||||
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
|
return Npcs.getClosest(BANKERS);
|
||||||
4483, 12308, 20607, 21301, 27663, 42192 };
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nearest banker
|
* Gets nearest bank booths
|
||||||
*
|
*
|
||||||
* @return nearest banker
|
* @return bank booths
|
||||||
*/
|
*/
|
||||||
public static Npc getBanker() {
|
public static SceneObject[] getNearestBanks() {
|
||||||
return Npcs.getClosest(BANKERS);
|
return SceneObjects.getNearest(BANKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nearest bank booths
|
* Gets nearest bank booths
|
||||||
*
|
*
|
||||||
* @return bank booths
|
* @return bank booth
|
||||||
*/
|
*/
|
||||||
public static SceneObject[] getNearestBanks() {
|
public static SceneObject getBank() {
|
||||||
return SceneObjects.getNearest(BANKS);
|
SceneObject[] banks = getNearestBanks();
|
||||||
}
|
if (banks != null && banks[0] != null) {
|
||||||
|
return banks[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nearest bank booths
|
* Opens bank using banker or bank booth
|
||||||
*
|
*
|
||||||
* @return bank booth
|
* @return <b>true</b> if successfully interacted
|
||||||
*/
|
*/
|
||||||
public static SceneObject getBank() {
|
public static boolean open() {
|
||||||
SceneObject[] banks = getNearestBanks();
|
|
||||||
if (banks != null && banks[0] != null) {
|
|
||||||
return banks[0];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (isOpen()) {
|
||||||
* Opens bank using banker or bank booth
|
return false;
|
||||||
*
|
}
|
||||||
* @return <b>true</b> if successfully interacted
|
SceneObject bank = getBank();
|
||||||
*/
|
Npc banker = getBanker();
|
||||||
public static boolean open() {
|
|
||||||
|
|
||||||
if (isOpen()) {
|
if (bank != null) {
|
||||||
return false;
|
bank.interact(BANK_OPEN_INDEX);
|
||||||
}
|
return true;
|
||||||
SceneObject bank = getBank();
|
} else if (banker != null) {
|
||||||
Npc banker = getBanker();
|
banker.interact(BANK_OPEN_INDEX);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (bank != null) {
|
return false;
|
||||||
bank.interact(BANK_OPEN_INDEX);
|
}
|
||||||
return true;
|
|
||||||
} else if (banker != null) {
|
|
||||||
banker.interact(BANK_OPEN_INDEX);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
/**
|
||||||
}
|
* Deposits all items
|
||||||
|
*/
|
||||||
/**
|
public static void depositAll() {
|
||||||
* Deposits all items
|
Menu.clickButton(BUTTON_DEPOSIT_ALL);
|
||||||
*/
|
}
|
||||||
public static void depositAll() {
|
|
||||||
Menu.clickButton(BUTTON_DEPOSIT_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Withdraws items at bank based on given parameters
|
* Withdraws items at bank based on given parameters
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param amount
|
* @param amount
|
||||||
*/
|
*/
|
||||||
public static void withdraw(int id, int amount, int sleep) {
|
public static void withdraw(int id, int amount, int sleep) {
|
||||||
|
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item b = getItem(id);
|
Item b = getItem(id);
|
||||||
|
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount == 1) {
|
if (amount == 1) {
|
||||||
b.transform(0, ITEM_INTERFACE);
|
b.transform(0, ITEM_INTERFACE);
|
||||||
} else if (amount == 5) {
|
} else if (amount == 5) {
|
||||||
b.transform(1, ITEM_INTERFACE);
|
b.transform(1, ITEM_INTERFACE);
|
||||||
} else if (amount == 10) {
|
} else if (amount == 10) {
|
||||||
b.transform(2, ITEM_INTERFACE);
|
b.transform(2, ITEM_INTERFACE);
|
||||||
} else if (amount == 0) {
|
} else if (amount == 0) {
|
||||||
b.transform(3, ITEM_INTERFACE);
|
b.transform(3, ITEM_INTERFACE);
|
||||||
} else {
|
} else {
|
||||||
b.transform(4, ITEM_INTERFACE);
|
b.transform(4, ITEM_INTERFACE);
|
||||||
Time.sleep(1500 + sleep);
|
Time.sleep(1500 + sleep);
|
||||||
Keyboard.getInstance().sendKeys("" + amount);
|
Keyboard.getInstance().sendKeys("" + amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets bank item with given id
|
* Gets bank item with given id
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return bank item
|
*
|
||||||
*/
|
* @return bank item
|
||||||
public static Item getItem(int id) {
|
*/
|
||||||
|
public static Item getItem(int id) {
|
||||||
|
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Item i : Bank.getBankItems()) {
|
for (Item i : Bank.getBankItems()) {
|
||||||
if (i.getId() == id) {
|
if (i.getId() == id) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the amount of items with given id in bank
|
* Counts the amount of items with given id in bank
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return count
|
*
|
||||||
*/
|
* @return count
|
||||||
public static int getCount(int id) {
|
*/
|
||||||
if (!isOpen()) {
|
public static int getCount(int id) {
|
||||||
return 0;
|
if (!isOpen()) {
|
||||||
}
|
return 0;
|
||||||
return getItem(id).getStackSize();
|
}
|
||||||
}
|
return getItem(id).getStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the bank
|
* Opens the bank
|
||||||
*
|
*
|
||||||
* @param bank
|
* @param bank booth
|
||||||
* booth
|
*/
|
||||||
*/
|
public static void open(SceneObject bank) {
|
||||||
public static void open(SceneObject bank) {
|
|
||||||
|
|
||||||
if (isOpen()) {
|
if (isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bank.getLocation().distanceTo() > 8) {
|
if (bank.getLocation().distanceTo() > 8) {
|
||||||
bank.getLocation().walkTo();
|
bank.getLocation().walkTo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bank.interact(BANK_OPEN_INDEX);
|
bank.interact(BANK_OPEN_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the bank interface
|
* Closes the bank interface
|
||||||
*/
|
*/
|
||||||
public static void close() {
|
public static void close() {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//[index: 1, action1: -1, action2: -1, action3: 5384, id: 200]
|
//[index: 1, action1: -1, action2: -1, action3: 5384, id: 200]
|
||||||
Menu.sendAction(200, -1, -1, 5384);
|
Menu.sendAction(200, -1, -1, 5384);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deposits all items except the given ids
|
* Deposits all items except the given ids
|
||||||
*
|
*
|
||||||
* @param exceptions
|
* @param exceptions the item indexes that will be ignored.
|
||||||
* the item indexes that will be ignored.
|
*/
|
||||||
*/
|
public static void depositAllExcept(int... exceptions) {
|
||||||
public static void depositAllExcept(int... exceptions) {
|
if (Bank.isOpen()) {
|
||||||
if (Bank.isOpen()) {
|
final ArrayList<Integer> ignored = new ArrayList<Integer>();
|
||||||
final ArrayList<Integer> ignored = new ArrayList<Integer>();
|
for (int i : exceptions) {
|
||||||
for (int i : exceptions) {
|
ignored.add(i);
|
||||||
ignored.add(i);
|
}
|
||||||
}
|
for (Item i : Inventory.getItems()) {
|
||||||
for (Item i : Inventory.getItems()) {
|
if (!ignored.contains(i.getId())) {
|
||||||
if (!ignored.contains(i.getId())) {
|
while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) {
|
||||||
while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) {
|
i.transform(3, INV_PARENT_ID);
|
||||||
i.transform(3, INV_PARENT_ID);
|
ignored.add(i.getId());
|
||||||
ignored.add(i.getId());
|
Time.sleep(50);
|
||||||
Time.sleep(50);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all bank item ids in bank
|
* Gets all bank item ids in bank
|
||||||
*
|
*
|
||||||
* @return bank items
|
* @return bank items
|
||||||
*/
|
*/
|
||||||
public static int[] getBankItemIDs() {
|
public static int[] getBankItemIDs() {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Loader.getClient().getInterfaceCache()[5382].getItems();
|
return Loader.getClient().getInterfaceCache()[5382].getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all stack sizes in bank
|
* Gets all stack sizes in bank
|
||||||
*
|
*
|
||||||
* @return stack sizes
|
* @return stack sizes
|
||||||
*/
|
*/
|
||||||
public static int[] getBankStacks() {
|
public static int[] getBankStacks() {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Loader.getClient().getInterfaceCache()[5382].getStackSizes();
|
return Loader.getClient().getInterfaceCache()[5382].getStackSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all bank items in bank
|
* Gets all bank items in bank
|
||||||
*
|
*
|
||||||
* @return bank items
|
* @return bank items
|
||||||
*/
|
*/
|
||||||
public static Item[] getBankItems() {
|
public static Item[] getBankItems() {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList<Item> items = new ArrayList<Item>();
|
ArrayList<Item> items = new ArrayList<Item>();
|
||||||
int[] ids = getBankItemIDs();
|
int[] ids = getBankItemIDs();
|
||||||
int[] stacks = getBankStacks();
|
int[] stacks = getBankStacks();
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
if (ids[i] > 0) {
|
if (ids[i] > 0) {
|
||||||
items.add(new Item(ids[i], stacks[i], i));
|
items.add(new Item(ids[i], stacks[i], i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (Item[]) items.toArray(new Item[items.size()]);
|
return (Item[]) items.toArray(new Item[items.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts total amount of items in bank
|
* Counts total amount of items in bank
|
||||||
*
|
*
|
||||||
* @return total amount of items
|
* @return total amount of items
|
||||||
*/
|
*/
|
||||||
public static int getBankCount() {
|
public static int getBankCount() {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return getBankItemIDs().length;
|
return getBankItemIDs().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if bank is open
|
* Determines if bank is open
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if bank is open
|
* @return <b>true</b> if bank is open
|
||||||
*/
|
*/
|
||||||
public static boolean isOpen() {
|
public static boolean isOpen() {
|
||||||
return Loader.getClient().getOpenInterfaceId() == BANK_INTERFACE;
|
return Loader.getClient().getOpenInterfaceId() == BANK_INTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,151 +3,154 @@ package org.rev317.min.api.methods;
|
|||||||
import org.rev317.min.api.wrappers.Tile;
|
import org.rev317.min.api.wrappers.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Calculations {
|
public class Calculations {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates distance between local player and given tile
|
* Calculates distance between local player and given tile
|
||||||
*
|
*
|
||||||
* @param tile
|
* @param tile
|
||||||
* @return distance between local player and given tile
|
*
|
||||||
*/
|
* @return distance between local player and given tile
|
||||||
public static final double distanceTo(Tile tile) {
|
*/
|
||||||
return distanceBetween(tile, Players.getMyPlayer().getLocation());
|
public static final double distanceTo(Tile tile) {
|
||||||
}
|
return distanceBetween(tile, Players.getMyPlayer().getLocation());
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Calculates distance between two given tiles
|
/**
|
||||||
* @param a
|
* Calculates distance between two given tiles
|
||||||
* @param b
|
*
|
||||||
* @return distance between a and b
|
* @param a
|
||||||
*/
|
* @param b
|
||||||
public static final double distanceBetween(Tile a, Tile b) {
|
*
|
||||||
int x = b.getX() - a.getX();
|
* @return distance between a and b
|
||||||
int y = b.getY() - a.getY();
|
*/
|
||||||
return Math.sqrt((x * x) + (y * y));
|
public static final double distanceBetween(Tile a, Tile b) {
|
||||||
}
|
int x = b.getX() - a.getX();
|
||||||
|
int y = b.getY() - a.getY();
|
||||||
|
return Math.sqrt((x * x) + (y * y));
|
||||||
/**
|
}
|
||||||
* @param startX the startX (0 < startX < 104)
|
|
||||||
* @param startY the startY (0 < startY < 104)
|
|
||||||
* @param destX the destX (0 < destX < 104)
|
/**
|
||||||
* @param destY the destY (0 < destY < 104)
|
* @param startX the startX (0 < startX < 104)
|
||||||
* @param findAdjacent if it's an object, it will find path which touches it.
|
* @param startY the startY (0 < startY < 104)
|
||||||
* @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was found.
|
* @param destX the destX (0 < destX < 104)
|
||||||
*/
|
* @param destY the destY (0 < destY < 104)
|
||||||
public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) {
|
* @param findAdjacent if it's an object, it will find path which touches it.
|
||||||
try {
|
*
|
||||||
final int[][] prev = new int[104][104];
|
* @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was
|
||||||
final int[][] dist = new int[104][104];
|
* found.
|
||||||
final int[] path_x = new int[4000];
|
*/
|
||||||
final int[] path_y = new int[4000];
|
public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) {
|
||||||
for (int xx = 0; xx < 104; xx++) {
|
try {
|
||||||
for (int yy = 0; yy < 104; yy++) {
|
final int[][] prev = new int[104][104];
|
||||||
prev[xx][yy] = 0;
|
final int[][] dist = new int[104][104];
|
||||||
dist[xx][yy] = 99999999;
|
final int[] path_x = new int[4000];
|
||||||
}
|
final int[] path_y = new int[4000];
|
||||||
}
|
for (int xx = 0; xx < 104; xx++) {
|
||||||
int curr_x = startX;
|
for (int yy = 0; yy < 104; yy++) {
|
||||||
int curr_y = startY;
|
prev[xx][yy] = 0;
|
||||||
prev[startX][startY] = 99;
|
dist[xx][yy] = 99999999;
|
||||||
dist[startX][startY] = 0;
|
}
|
||||||
int path_ptr = 0;
|
}
|
||||||
int step_ptr = 0;
|
int curr_x = startX;
|
||||||
path_x[path_ptr] = startX;
|
int curr_y = startY;
|
||||||
path_y[path_ptr++] = startY;
|
prev[startX][startY] = 99;
|
||||||
final int blocks[][] = Game.getCollisionFlags();
|
dist[startX][startY] = 0;
|
||||||
final int pathLength = path_x.length;
|
int path_ptr = 0;
|
||||||
boolean foundPath = false;
|
int step_ptr = 0;
|
||||||
while (step_ptr != path_ptr) {
|
path_x[path_ptr] = startX;
|
||||||
curr_x = path_x[step_ptr];
|
path_y[path_ptr++] = startY;
|
||||||
curr_y = path_y[step_ptr];
|
final int blocks[][] = Game.getCollisionFlags();
|
||||||
if (Math.abs(curr_x - destX) + Math.abs(curr_y - destY) == (findAdjacent ? 1 : 0)) {
|
final int pathLength = path_x.length;
|
||||||
foundPath = true;
|
boolean foundPath = false;
|
||||||
break;
|
while (step_ptr != path_ptr) {
|
||||||
}
|
curr_x = path_x[step_ptr];
|
||||||
step_ptr = (step_ptr + 1) % pathLength;
|
curr_y = path_y[step_ptr];
|
||||||
final int cost = dist[curr_x][curr_y] + 1;
|
if (Math.abs(curr_x - destX) + Math.abs(curr_y - destY) == (findAdjacent ? 1 : 0)) {
|
||||||
// south
|
foundPath = true;
|
||||||
if (curr_y > 0 && prev[curr_x][curr_y - 1] == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) {
|
break;
|
||||||
path_x[path_ptr] = curr_x;
|
}
|
||||||
path_y[path_ptr] = curr_y - 1;
|
step_ptr = (step_ptr + 1) % pathLength;
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
final int cost = dist[curr_x][curr_y] + 1;
|
||||||
prev[curr_x][curr_y - 1] = 1;
|
// south
|
||||||
dist[curr_x][curr_y - 1] = cost;
|
if (curr_y > 0 && prev[curr_x][curr_y - 1] == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x;
|
||||||
// west
|
path_y[path_ptr] = curr_y - 1;
|
||||||
if (curr_x > 0 && prev[curr_x - 1][curr_y] == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0) {
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
path_x[path_ptr] = curr_x - 1;
|
prev[curr_x][curr_y - 1] = 1;
|
||||||
path_y[path_ptr] = curr_y;
|
dist[curr_x][curr_y - 1] = cost;
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
}
|
||||||
prev[curr_x - 1][curr_y] = 2;
|
// west
|
||||||
dist[curr_x - 1][curr_y] = cost;
|
if (curr_x > 0 && prev[curr_x - 1][curr_y] == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x - 1;
|
||||||
// north
|
path_y[path_ptr] = curr_y;
|
||||||
if (curr_y < 104 - 1 && prev[curr_x][curr_y + 1] == 0 && (blocks[curr_x][curr_y + 1] &
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
0x1280120) == 0) {
|
prev[curr_x - 1][curr_y] = 2;
|
||||||
path_x[path_ptr] = curr_x;
|
dist[curr_x - 1][curr_y] = cost;
|
||||||
path_y[path_ptr] = curr_y + 1;
|
}
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
// north
|
||||||
prev[curr_x][curr_y + 1] = 4;
|
if (curr_y < 104 - 1 && prev[curr_x][curr_y + 1] == 0 && (blocks[curr_x][curr_y + 1] &
|
||||||
dist[curr_x][curr_y + 1] = cost;
|
0x1280120) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x;
|
||||||
// east
|
path_y[path_ptr] = curr_y + 1;
|
||||||
if (curr_x < 104 - 1 && prev[curr_x + 1][curr_y] == 0 && (blocks[curr_x + 1][curr_y] &
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
0x1280180) == 0) {
|
prev[curr_x][curr_y + 1] = 4;
|
||||||
path_x[path_ptr] = curr_x + 1;
|
dist[curr_x][curr_y + 1] = cost;
|
||||||
path_y[path_ptr] = curr_y;
|
}
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
// east
|
||||||
prev[curr_x + 1][curr_y] = 8;
|
if (curr_x < 104 - 1 && prev[curr_x + 1][curr_y] == 0 && (blocks[curr_x + 1][curr_y] &
|
||||||
dist[curr_x + 1][curr_y] = cost;
|
0x1280180) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x + 1;
|
||||||
// south west
|
path_y[path_ptr] = curr_y;
|
||||||
if (curr_x > 0 && curr_y > 0 && prev[curr_x - 1][curr_y - 1] == 0 && (blocks[curr_x - 1][curr_y - 1] &
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
0x128010E) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0 && (blocks[curr_x
|
prev[curr_x + 1][curr_y] = 8;
|
||||||
][curr_y - 1] & 0x1280102) == 0) {
|
dist[curr_x + 1][curr_y] = cost;
|
||||||
path_x[path_ptr] = curr_x - 1;
|
}
|
||||||
path_y[path_ptr] = curr_y - 1;
|
// south west
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
if (curr_x > 0 && curr_y > 0 && prev[curr_x - 1][curr_y - 1] == 0 && (blocks[curr_x - 1][curr_y - 1] &
|
||||||
prev[curr_x - 1][curr_y - 1] = 3;
|
0x128010E) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0 && (blocks[curr_x
|
||||||
dist[curr_x - 1][curr_y - 1] = cost;
|
][curr_y - 1] & 0x1280102) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x - 1;
|
||||||
// north west
|
path_y[path_ptr] = curr_y - 1;
|
||||||
if (curr_x > 0 && curr_y < 104 - 1 && prev[curr_x - 1][curr_y + 1] == 0 && (blocks[curr_x - 1][curr_y + 1] & 0x1280138) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) ==
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) {
|
prev[curr_x - 1][curr_y - 1] = 3;
|
||||||
path_x[path_ptr] = curr_x - 1;
|
dist[curr_x - 1][curr_y - 1] = cost;
|
||||||
path_y[path_ptr] = curr_y + 1;
|
}
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
// north west
|
||||||
prev[curr_x - 1][curr_y + 1] = 6;
|
if (curr_x > 0 && curr_y < 104 - 1 && prev[curr_x - 1][curr_y + 1] == 0 && (blocks[curr_x - 1][curr_y + 1] & 0x1280138) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) ==
|
||||||
dist[curr_x - 1][curr_y + 1] = cost;
|
0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x - 1;
|
||||||
// south east
|
path_y[path_ptr] = curr_y + 1;
|
||||||
if (curr_x < 104 - 1 && curr_y > 0 && prev[curr_x + 1][curr_y - 1] == 0 && (blocks[curr_x +
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
1][curr_y - 1] & 0x1280183) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) {
|
prev[curr_x - 1][curr_y + 1] = 6;
|
||||||
path_x[path_ptr] = curr_x + 1;
|
dist[curr_x - 1][curr_y + 1] = cost;
|
||||||
path_y[path_ptr] = curr_y - 1;
|
}
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
// south east
|
||||||
prev[curr_x + 1][curr_y - 1] = 9;
|
if (curr_x < 104 - 1 && curr_y > 0 && prev[curr_x + 1][curr_y - 1] == 0 && (blocks[curr_x +
|
||||||
dist[curr_x + 1][curr_y - 1] = cost;
|
1][curr_y - 1] & 0x1280183) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x + 1;
|
||||||
// north east
|
path_y[path_ptr] = curr_y - 1;
|
||||||
if (curr_x < 104 - 1 && curr_y < 104 - 1 && prev[curr_x + 1][curr_y + 1] == 0 && (blocks[curr_x
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
+ 1][curr_y + 1] & 0x12801E0) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) {
|
prev[curr_x + 1][curr_y - 1] = 9;
|
||||||
path_x[path_ptr] = curr_x + 1;
|
dist[curr_x + 1][curr_y - 1] = cost;
|
||||||
path_y[path_ptr] = curr_y + 1;
|
}
|
||||||
path_ptr = (path_ptr + 1) % pathLength;
|
// north east
|
||||||
prev[curr_x + 1][curr_y + 1] = 12;
|
if (curr_x < 104 - 1 && curr_y < 104 - 1 && prev[curr_x + 1][curr_y + 1] == 0 && (blocks[curr_x
|
||||||
dist[curr_x + 1][curr_y + 1] = cost;
|
+ 1][curr_y + 1] & 0x12801E0) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) {
|
||||||
}
|
path_x[path_ptr] = curr_x + 1;
|
||||||
}
|
path_y[path_ptr] = curr_y + 1;
|
||||||
return foundPath ? dist[curr_x][curr_y] : -1;
|
path_ptr = (path_ptr + 1) % pathLength;
|
||||||
} catch (Exception e) {
|
prev[curr_x + 1][curr_y + 1] = 12;
|
||||||
return -1;
|
dist[curr_x + 1][curr_y + 1] = cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return foundPath ? dist[curr_x][curr_y] : -1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,79 +3,85 @@ package org.rev317.min.api.methods;
|
|||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets BaseX
|
* Gets BaseX
|
||||||
* @return baseX
|
*
|
||||||
*/
|
* @return baseX
|
||||||
public static int getBaseX() {
|
*/
|
||||||
return Loader.getClient().getBaseX();
|
public static int getBaseX() {
|
||||||
}
|
return Loader.getClient().getBaseX();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets BaseY
|
/**
|
||||||
* @return baseY
|
* Gets BaseY
|
||||||
*/
|
*
|
||||||
public static int getBaseY() {
|
* @return baseY
|
||||||
return Loader.getClient().getBaseY();
|
*/
|
||||||
}
|
public static int getBaseY() {
|
||||||
|
return Loader.getClient().getBaseY();
|
||||||
/**
|
}
|
||||||
* Gets open interface id
|
|
||||||
* @return interface id
|
/**
|
||||||
*/
|
* Gets open interface id
|
||||||
public static int getOpenInterfaceId() {
|
*
|
||||||
return Loader.getClient().getOpenInterfaceId();
|
* @return interface id
|
||||||
}
|
*/
|
||||||
|
public static int getOpenInterfaceId() {
|
||||||
/**
|
return Loader.getClient().getOpenInterfaceId();
|
||||||
* Get open back dialog id
|
}
|
||||||
* @return back dialog id
|
|
||||||
*/
|
/**
|
||||||
public static int getOpenBackDialogId() {
|
* Get open back dialog id
|
||||||
return Loader.getClient().getBackDialogId();
|
*
|
||||||
}
|
* @return back dialog id
|
||||||
|
*/
|
||||||
/**
|
public static int getOpenBackDialogId() {
|
||||||
* Gets loop cycle
|
return Loader.getClient().getBackDialogId();
|
||||||
* @return loop cycle
|
}
|
||||||
*/
|
|
||||||
public static int getLoopCycle() {
|
/**
|
||||||
return Loader.getClient().getLoopCycle();
|
* Gets loop cycle
|
||||||
}
|
*
|
||||||
|
* @return loop cycle
|
||||||
/**
|
*/
|
||||||
* Get collision flags
|
public static int getLoopCycle() {
|
||||||
* @return collision flags
|
return Loader.getClient().getLoopCycle();
|
||||||
*/
|
}
|
||||||
public static int[][] getCollisionFlags() {
|
|
||||||
return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags();
|
/**
|
||||||
}
|
* Get collision flags
|
||||||
|
*
|
||||||
/**
|
* @return collision flags
|
||||||
* Gets current plane
|
*/
|
||||||
* @return current plane
|
public static int[][] getCollisionFlags() {
|
||||||
*/
|
return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags();
|
||||||
public static int getPlane() {
|
}
|
||||||
return Loader.getClient().getPlane();
|
|
||||||
}
|
/**
|
||||||
|
* Gets current plane
|
||||||
/**
|
*
|
||||||
* Determines whether this client has action 4 hooked
|
* @return current plane
|
||||||
* @return <code>true</code> if action 4 is hooked
|
*/
|
||||||
*/
|
public static int getPlane() {
|
||||||
public static boolean hasAction4() {
|
return Loader.getClient().getPlane();
|
||||||
try {
|
}
|
||||||
Loader.getClient().getMenuAction4();
|
|
||||||
return true;
|
/**
|
||||||
} catch(AbstractMethodError e) {
|
* Determines whether this client has action 4 hooked
|
||||||
return false;
|
*
|
||||||
}
|
* @return <code>true</code> if action 4 is hooked
|
||||||
}
|
*/
|
||||||
|
public static boolean hasAction4() {
|
||||||
|
try {
|
||||||
|
Loader.getClient().getMenuAction4();
|
||||||
|
return true;
|
||||||
|
} catch (AbstractMethodError e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.parabot.environment.api.utils.Filter;
|
import org.parabot.environment.api.utils.Filter;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
@@ -11,145 +7,146 @@ import org.rev317.min.accessors.Deque;
|
|||||||
import org.rev317.min.accessors.Node;
|
import org.rev317.min.accessors.Node;
|
||||||
import org.rev317.min.api.wrappers.GroundItem;
|
import org.rev317.min.api.wrappers.GroundItem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GroundItems {
|
public class GroundItems {
|
||||||
private static Client client;
|
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
|
||||||
|
|
||||||
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
|
@Override
|
||||||
|
public int compare(GroundItem n1, GroundItem n2) {
|
||||||
|
return n1.distanceTo() - n2.distanceTo();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
};
|
||||||
public int compare(GroundItem n1, GroundItem n2) {
|
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
|
||||||
return n1.distanceTo() - n2.distanceTo();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
@Override
|
||||||
|
public boolean accept(GroundItem item) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
|
};
|
||||||
|
private static Client client;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean accept(GroundItem item) {
|
* Gets all loaded ground items
|
||||||
return true;
|
*
|
||||||
}
|
* @return ground item array
|
||||||
|
*/
|
||||||
|
public final static GroundItem[] getGroundItems(
|
||||||
|
final Filter<GroundItem> filter) {
|
||||||
|
if (client == null) {
|
||||||
|
client = Loader.getClient();
|
||||||
|
}
|
||||||
|
final ArrayList<GroundItem> items = new ArrayList<GroundItem>();
|
||||||
|
for (int x = 0; x < 104; x++) {
|
||||||
|
for (int y = 0; y < 104; y++) {
|
||||||
|
final GroundItem[] groundItemsAtTile = getGroundItemsAt(x, y);
|
||||||
|
if (groundItemsAtTile != null) {
|
||||||
|
for (final GroundItem item : groundItemsAtTile) {
|
||||||
|
if (filter.accept(item)) {
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items.toArray(new GroundItem[items.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
/**
|
||||||
|
* Gets a ground item
|
||||||
|
*
|
||||||
|
* @param x - local region x
|
||||||
|
* @param y - local region y
|
||||||
|
*
|
||||||
|
* @return ground item array
|
||||||
|
*/
|
||||||
|
public static final GroundItem[] getGroundItemsAt(final int x, final int y) {
|
||||||
|
try {
|
||||||
|
if (client == null) {
|
||||||
|
client = Loader.getClient();
|
||||||
|
}
|
||||||
|
final Deque deque = client.getGroundItems()[Game.getPlane()][x][y];
|
||||||
|
if (deque == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ArrayList<GroundItem> list = null;
|
||||||
|
final Node holder = deque.getHead();
|
||||||
|
Node curNode = holder.getNext();
|
||||||
|
while (curNode != null && curNode != holder
|
||||||
|
&& curNode != deque.getHead()) {
|
||||||
|
if (list == null) {
|
||||||
|
list = new ArrayList<GroundItem>();
|
||||||
|
}
|
||||||
|
final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode;
|
||||||
|
list.add(new GroundItem(groundItem, x, y));
|
||||||
|
curNode = curNode.getNext();
|
||||||
|
}
|
||||||
|
return list.toArray(new GroundItem[list.size()]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all loaded ground items
|
* Gets all ground items in game
|
||||||
*
|
*
|
||||||
* @return ground item array
|
* @return ground items
|
||||||
*/
|
*/
|
||||||
public final static GroundItem[] getGroundItems(
|
public static final GroundItem[] getGroundItems() {
|
||||||
final Filter<GroundItem> filter) {
|
return getGroundItems(ALL_FILTER);
|
||||||
if (client == null) {
|
}
|
||||||
client = Loader.getClient();
|
|
||||||
}
|
|
||||||
final ArrayList<GroundItem> items = new ArrayList<GroundItem>();
|
|
||||||
for (int x = 0; x < 104; x++) {
|
|
||||||
for (int y = 0; y < 104; y++) {
|
|
||||||
final GroundItem[] groundItemsAtTile = getGroundItemsAt(x, y);
|
|
||||||
if (groundItemsAtTile != null) {
|
|
||||||
for (final GroundItem item : groundItemsAtTile) {
|
|
||||||
if (filter.accept(item)) {
|
|
||||||
items.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items.toArray(new GroundItem[items.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a ground item
|
* Returns array of GroundItems with the first index to be the nearest
|
||||||
*
|
*
|
||||||
* @param x
|
* @param filter
|
||||||
* - local region x
|
*
|
||||||
* @param y
|
* @return GroundItems
|
||||||
* - local region y
|
*/
|
||||||
* @return ground item array
|
public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
|
||||||
*/
|
final GroundItem[] objects = getGroundItems(filter);
|
||||||
public static final GroundItem[] getGroundItemsAt(final int x, final int y) {
|
Arrays.sort(objects, NEAREST_SORTER);
|
||||||
try {
|
return objects;
|
||||||
if (client == null) {
|
}
|
||||||
client = Loader.getClient();
|
|
||||||
}
|
|
||||||
final Deque deque = client.getGroundItems()[Game.getPlane()][x][y];
|
|
||||||
if (deque == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ArrayList<GroundItem> list = null;
|
|
||||||
final Node holder = deque.getHead();
|
|
||||||
Node curNode = holder.getNext();
|
|
||||||
while (curNode != null && curNode != holder
|
|
||||||
&& curNode != deque.getHead()) {
|
|
||||||
if (list == null) {
|
|
||||||
list = new ArrayList<GroundItem>();
|
|
||||||
}
|
|
||||||
final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode;
|
|
||||||
list.add(new GroundItem(groundItem, x, y));
|
|
||||||
curNode = curNode.getNext();
|
|
||||||
}
|
|
||||||
return list.toArray(new GroundItem[list.size()]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all ground items in game
|
* Returns array of GroundItems with the first index to be the nearest
|
||||||
*
|
*
|
||||||
* @return ground items
|
* @return GroundItems
|
||||||
*/
|
*/
|
||||||
public static final GroundItem[] getGroundItems() {
|
public static final GroundItem[] getNearest() {
|
||||||
return getGroundItems(ALL_FILTER);
|
return getNearest(ALL_FILTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns array of GroundItems with the first index to be the nearest
|
* Returns nearest ground items with given id
|
||||||
*
|
*
|
||||||
* @param filter
|
* @param ids
|
||||||
* @return GroundItems
|
*
|
||||||
*/
|
* @return GroundItems
|
||||||
public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
|
*/
|
||||||
final GroundItem[] objects = getGroundItems(filter);
|
public static final GroundItem[] getNearest(final int... ids) {
|
||||||
Arrays.sort(objects, NEAREST_SORTER);
|
return getNearest(new Filter<GroundItem>() {
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns array of GroundItems with the first index to be the nearest
|
public boolean accept(GroundItem object) {
|
||||||
*
|
for (final int id : ids) {
|
||||||
* @return GroundItems
|
if (id == object.getId()) {
|
||||||
*/
|
return true;
|
||||||
public static final GroundItem[] getNearest() {
|
}
|
||||||
return getNearest(ALL_FILTER);
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
});
|
||||||
* Returns nearest ground items with given id
|
}
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return GroundItems
|
|
||||||
*/
|
|
||||||
public static final GroundItem[] getNearest(final int... ids) {
|
|
||||||
return getNearest(new Filter<GroundItem>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(GroundItem object) {
|
|
||||||
for (final int id : ids) {
|
|
||||||
if (id == object.getId()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,186 +1,199 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.parabot.environment.api.utils.Filter;
|
import org.parabot.environment.api.utils.Filter;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Interface;
|
import org.rev317.min.accessors.Interface;
|
||||||
import org.rev317.min.api.wrappers.Item;
|
import org.rev317.min.api.wrappers.Item;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Inventory {
|
public class Inventory {
|
||||||
public static final int INVENTORY_INDEX = 3214;
|
public static final int INVENTORY_INDEX = 3214;
|
||||||
|
|
||||||
private static final Filter<Item> ALL_FILTER = new Filter<Item>() {
|
|
||||||
|
|
||||||
@Override
|
private static final Filter<Item> ALL_FILTER = new Filter<Item>() {
|
||||||
public boolean accept(Item i) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the inventory
|
|
||||||
*/
|
|
||||||
public static void clear() {
|
|
||||||
for(Item item : Inventory.getItems()) {
|
|
||||||
item.drop();
|
|
||||||
Time.sleep(60, 80);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets inventory interface
|
public boolean accept(Item i) {
|
||||||
* @return interface of inventory
|
return true;
|
||||||
*/
|
}
|
||||||
public static Interface getInterface() {
|
|
||||||
return Loader.getClient().getInterfaceCache()[INVENTORY_INDEX];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the amount of items in inventory, excludes the stack sizes
|
|
||||||
* @return amount of items
|
|
||||||
*/
|
|
||||||
public static final int getCount() {
|
|
||||||
return getCount(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the amount of items with given ids in inventory, excludes the stack sizes
|
|
||||||
* @param ids
|
|
||||||
* @return amount of items
|
|
||||||
*/
|
|
||||||
public static final int getCount(int... ids) {
|
|
||||||
return getCount(false, ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the amount of items in inventory
|
|
||||||
* @param includeStack - true for including stack sizes to the counting
|
|
||||||
* @return amount of items
|
|
||||||
*/
|
|
||||||
public static final int getCount(final boolean includeStack) {
|
|
||||||
final Interface inventory = getInterface();
|
|
||||||
if(inventory == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
final int[] items = inventory.getItems();
|
|
||||||
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
|
|
||||||
for(int i = 0; i < items.length; i++) {
|
|
||||||
if(items[i] > 0) {
|
|
||||||
count += includeStack ? stackSizes[i] : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the amount of items with given ids in inventory
|
|
||||||
* @param includeStack - true for including stack sizes to the counting
|
|
||||||
* @param ids
|
|
||||||
* @return amount of items
|
|
||||||
*/
|
|
||||||
public static final int getCount(final boolean includeStack, int... ids) {
|
|
||||||
final Interface inventory = getInterface();
|
|
||||||
if(inventory == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
final int[] items = inventory.getItems();
|
|
||||||
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
|
|
||||||
for(int i = 0; i < items.length; i++) {
|
|
||||||
final int itemId = items[i];
|
|
||||||
if(itemId > 0) {
|
|
||||||
for(final int id : ids) {
|
|
||||||
if(id == itemId) {
|
|
||||||
count += includeStack ? stackSizes[i] : 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets every item in inventory
|
|
||||||
* @return items
|
|
||||||
*/
|
|
||||||
public static final Item[] getItems() {
|
|
||||||
return getItems(ALL_FILTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all items with given ids
|
|
||||||
* @param ids
|
|
||||||
* @return items
|
|
||||||
*/
|
|
||||||
public static final Item[] getItems(final int... ids) {
|
|
||||||
return getItems(new Filter<Item>() {
|
|
||||||
|
|
||||||
@Override
|
};
|
||||||
public boolean accept(Item e) {
|
|
||||||
for(int id : ids) {
|
/**
|
||||||
if(e.getId() == id) {
|
* Clears the inventory
|
||||||
return true;
|
*/
|
||||||
}
|
public static void clear() {
|
||||||
}
|
for (Item item : Inventory.getItems()) {
|
||||||
return false;
|
item.drop();
|
||||||
}
|
Time.sleep(60, 80);
|
||||||
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Gets inventory interface
|
||||||
* Gets all items accepted by filter
|
*
|
||||||
* @param filter
|
* @return interface of inventory
|
||||||
* @return items
|
*/
|
||||||
*/
|
public static Interface getInterface() {
|
||||||
public static final Item[] getItems(final Filter<Item> filter) {
|
return Loader.getClient().getInterfaceCache()[INVENTORY_INDEX];
|
||||||
final Interface inventory = getInterface();
|
}
|
||||||
if(inventory == null) {
|
|
||||||
return null;
|
/**
|
||||||
}
|
* Gets the amount of items in inventory, excludes the stack sizes
|
||||||
final int[] items = inventory.getItems();
|
*
|
||||||
final int[] stackSizes = inventory.getStackSizes();
|
* @return amount of items
|
||||||
final ArrayList<Item> invItems = new ArrayList<Item>(28);
|
*/
|
||||||
for(int i = 0; i < items.length; i++) {
|
public static final int getCount() {
|
||||||
final int itemId = items[i];
|
return getCount(false);
|
||||||
if(itemId < 1) {
|
}
|
||||||
continue;
|
|
||||||
}
|
/**
|
||||||
final int stackSize = stackSizes[i];
|
* Gets the amount of items with given ids in inventory, excludes the stack sizes
|
||||||
final Item item = new Item(itemId, stackSize, i);
|
*
|
||||||
if(filter.accept(item)) {
|
* @param ids
|
||||||
invItems.add(item);
|
*
|
||||||
}
|
* @return amount of items
|
||||||
}
|
*/
|
||||||
return invItems.toArray(new Item[invItems.size()]);
|
public static final int getCount(int... ids) {
|
||||||
}
|
return getCount(false, ids);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Determines if inventory is full
|
/**
|
||||||
* @return <b>true</b> if inventory is full, otherwise <b>false</b>
|
* Gets the amount of items in inventory
|
||||||
*/
|
*
|
||||||
public static final boolean isFull() {
|
* @param includeStack - true for including stack sizes to the counting
|
||||||
return Inventory.getCount() == 28;
|
*
|
||||||
}
|
* @return amount of items
|
||||||
|
*/
|
||||||
/**
|
public static final int getCount(final boolean includeStack) {
|
||||||
* Determines if inventory is empty
|
final Interface inventory = getInterface();
|
||||||
* @return <b>true</b> if inventory is empty, otherwise <b>false</b>
|
if (inventory == null) {
|
||||||
*/
|
return -1;
|
||||||
public static final boolean isEmpty() {
|
}
|
||||||
return Inventory.getCount() == 0;
|
int count = 0;
|
||||||
}
|
final int[] items = inventory.getItems();
|
||||||
|
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
if (items[i] > 0) {
|
||||||
|
count += includeStack ? stackSizes[i] : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of items with given ids in inventory
|
||||||
|
*
|
||||||
|
* @param includeStack - true for including stack sizes to the counting
|
||||||
|
* @param ids
|
||||||
|
*
|
||||||
|
* @return amount of items
|
||||||
|
*/
|
||||||
|
public static final int getCount(final boolean includeStack, int... ids) {
|
||||||
|
final Interface inventory = getInterface();
|
||||||
|
if (inventory == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int count = 0;
|
||||||
|
final int[] items = inventory.getItems();
|
||||||
|
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
final int itemId = items[i];
|
||||||
|
if (itemId > 0) {
|
||||||
|
for (final int id : ids) {
|
||||||
|
if (id == itemId) {
|
||||||
|
count += includeStack ? stackSizes[i] : 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets every item in inventory
|
||||||
|
*
|
||||||
|
* @return items
|
||||||
|
*/
|
||||||
|
public static final Item[] getItems() {
|
||||||
|
return getItems(ALL_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all items with given ids
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
*
|
||||||
|
* @return items
|
||||||
|
*/
|
||||||
|
public static final Item[] getItems(final int... ids) {
|
||||||
|
return getItems(new Filter<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item e) {
|
||||||
|
for (int id : ids) {
|
||||||
|
if (e.getId() == id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all items accepted by filter
|
||||||
|
*
|
||||||
|
* @param filter
|
||||||
|
*
|
||||||
|
* @return items
|
||||||
|
*/
|
||||||
|
public static final Item[] getItems(final Filter<Item> filter) {
|
||||||
|
final Interface inventory = getInterface();
|
||||||
|
if (inventory == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final int[] items = inventory.getItems();
|
||||||
|
final int[] stackSizes = inventory.getStackSizes();
|
||||||
|
final ArrayList<Item> invItems = new ArrayList<Item>(28);
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
final int itemId = items[i];
|
||||||
|
if (itemId < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final int stackSize = stackSizes[i];
|
||||||
|
final Item item = new Item(itemId, stackSize, i);
|
||||||
|
if (filter.accept(item)) {
|
||||||
|
invItems.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return invItems.toArray(new Item[invItems.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if inventory is full
|
||||||
|
*
|
||||||
|
* @return <b>true</b> if inventory is full, otherwise <b>false</b>
|
||||||
|
*/
|
||||||
|
public static final boolean isFull() {
|
||||||
|
return Inventory.getCount() == 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if inventory is empty
|
||||||
|
*
|
||||||
|
* @return <b>true</b> if inventory is empty, otherwise <b>false</b>
|
||||||
|
*/
|
||||||
|
public static final boolean isEmpty() {
|
||||||
|
return Inventory.getCount() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
@@ -10,212 +8,218 @@ import org.rev317.min.api.wrappers.GroundItem;
|
|||||||
import org.rev317.min.api.wrappers.Item;
|
import org.rev317.min.api.wrappers.Item;
|
||||||
import org.rev317.min.api.wrappers.SceneObject;
|
import org.rev317.min.api.wrappers.SceneObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Menu {
|
public class Menu {
|
||||||
public static final int ACTION_CLICK_BUTTON = 646;
|
public static final int ACTION_CLICK_BUTTON = 646;
|
||||||
public static final int ACTION_DROP_ITEM = 847;
|
public static final int ACTION_DROP_ITEM = 847;
|
||||||
public static final int ACTION_TAKE_ITEM = 234;
|
public static final int ACTION_TAKE_ITEM = 234;
|
||||||
|
|
||||||
private static HashMap<String, String> constants;
|
private static HashMap<String, String> constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interacts with a sceneobject
|
* Interacts with a sceneobject
|
||||||
* @param object
|
*
|
||||||
* @param actionIndex
|
* @param object
|
||||||
*/
|
* @param actionIndex
|
||||||
public static void interact(SceneObject object, int actionIndex) {
|
*/
|
||||||
int actionId = 502;
|
public static void interact(SceneObject object, int actionIndex) {
|
||||||
switch (actionIndex) {
|
int actionId = 502;
|
||||||
case 0:
|
switch (actionIndex) {
|
||||||
actionId = 502;
|
case 0:
|
||||||
break;
|
actionId = 502;
|
||||||
case 1:
|
break;
|
||||||
actionId = 900;
|
case 1:
|
||||||
break;
|
actionId = 900;
|
||||||
case 2:
|
break;
|
||||||
actionId = 113;
|
case 2:
|
||||||
break;
|
actionId = 113;
|
||||||
case 3:
|
break;
|
||||||
actionId = 872;
|
case 3:
|
||||||
break;
|
actionId = 872;
|
||||||
case 4:
|
break;
|
||||||
actionId = 1062;
|
case 4:
|
||||||
break;
|
actionId = 1062;
|
||||||
}
|
break;
|
||||||
if(Game.hasAction4()) {
|
}
|
||||||
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
|
if (Game.hasAction4()) {
|
||||||
} else {
|
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
|
||||||
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
|
} else {
|
||||||
}
|
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interacts with a character
|
* Interacts with a character
|
||||||
* @param character
|
*
|
||||||
* @param actionIndex
|
* @param character
|
||||||
*/
|
* @param actionIndex
|
||||||
public static void interact(Character character, int actionIndex) {
|
*/
|
||||||
int actionId = 20;
|
public static void interact(Character character, int actionIndex) {
|
||||||
switch (actionIndex) {
|
int actionId = 20;
|
||||||
case 0:
|
switch (actionIndex) {
|
||||||
actionId = 20;
|
case 0:
|
||||||
break;
|
actionId = 20;
|
||||||
case 1:
|
break;
|
||||||
actionId = 412;
|
case 1:
|
||||||
break;
|
actionId = 412;
|
||||||
case 2:
|
break;
|
||||||
actionId = 225;
|
case 2:
|
||||||
break;
|
actionId = 225;
|
||||||
case 3:
|
break;
|
||||||
actionId = 965;
|
case 3:
|
||||||
break;
|
actionId = 965;
|
||||||
case 4:
|
break;
|
||||||
actionId = 478;
|
case 4:
|
||||||
break;
|
actionId = 478;
|
||||||
}
|
break;
|
||||||
sendAction(actionId, character.getIndex(), 0, 0);
|
}
|
||||||
}
|
sendAction(actionId, character.getIndex(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interacts with an item when it has the following menu
|
* Interacts with an item when it has the following menu Transform-1 Transform-5 Transform-10 etc..
|
||||||
* Transform-1
|
*
|
||||||
* Transform-5
|
* @param item
|
||||||
* Transform-10
|
* @param actionIndex
|
||||||
* etc..
|
* @param interfaceParentId
|
||||||
* @param item
|
*/
|
||||||
* @param actionIndex
|
public static void transformItem(Item item, int actionIndex,
|
||||||
* @param interfaceParentId
|
int interfaceParentId) {
|
||||||
*/
|
int actionId = 632;
|
||||||
public static void transformItem(Item item, int actionIndex,
|
switch (actionIndex) {
|
||||||
int interfaceParentId) {
|
case 0:
|
||||||
int actionId = 632;
|
actionId = 632;
|
||||||
switch (actionIndex) {
|
break;
|
||||||
case 0:
|
case 1:
|
||||||
actionId = 632;
|
actionId = 78;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 2:
|
||||||
actionId = 78;
|
actionId = 867;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 3:
|
||||||
actionId = 867;
|
actionId = 431;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 4:
|
||||||
actionId = 431;
|
actionId = 53;
|
||||||
break;
|
break;
|
||||||
case 4:
|
}
|
||||||
actionId = 53;
|
sendAction(actionId, (int) item.getId() - 1, item.getSlot(),
|
||||||
break;
|
interfaceParentId);
|
||||||
}
|
}
|
||||||
sendAction(actionId, (int) item.getId() - 1, item.getSlot(),
|
|
||||||
interfaceParentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes grounditem from the ground
|
|
||||||
* @param item
|
|
||||||
*/
|
|
||||||
public static void take(GroundItem item) {
|
|
||||||
sendAction(ACTION_TAKE_ITEM, item.getId(), item.getX(), item.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interacts with a ground item
|
* Takes grounditem from the ground
|
||||||
* @param item
|
*
|
||||||
* @param action
|
* @param item
|
||||||
*/
|
*/
|
||||||
public static void interact(GroundItem item, int action) {
|
public static void take(GroundItem item) {
|
||||||
int actionId = 652;
|
sendAction(ACTION_TAKE_ITEM, item.getId(), item.getX(), item.getY());
|
||||||
switch (action) {
|
}
|
||||||
case 0:
|
|
||||||
actionId = 652;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
actionId = 567;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
actionId = 234;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
actionId = 244;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
actionId = 213;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sendAction(actionId, item.getId(), item.getX(), item.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drops an item
|
* Interacts with a ground item
|
||||||
* @param item
|
*
|
||||||
*/
|
* @param item
|
||||||
public static void drop(Item item) {
|
* @param action
|
||||||
sendAction(ACTION_DROP_ITEM, (int) item.getId() - 1, item.getSlot(),
|
*/
|
||||||
Inventory.INVENTORY_INDEX);
|
public static void interact(GroundItem item, int action) {
|
||||||
}
|
int actionId = 652;
|
||||||
|
switch (action) {
|
||||||
|
case 0:
|
||||||
|
actionId = 652;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
actionId = 567;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
actionId = 234;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
actionId = 244;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
actionId = 213;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sendAction(actionId, item.getId(), item.getX(), item.getY());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicks a button
|
* Drops an item
|
||||||
* @param id
|
*
|
||||||
*/
|
* @param item
|
||||||
public static void clickButton(int id) {
|
*/
|
||||||
sendAction(ACTION_CLICK_BUTTON, 0, 0, id);
|
public static void drop(Item item) {
|
||||||
}
|
sendAction(ACTION_DROP_ITEM, (int) item.getId() - 1, item.getSlot(),
|
||||||
|
Inventory.INVENTORY_INDEX);
|
||||||
/**
|
}
|
||||||
* Sends an action to the client
|
|
||||||
* @param action
|
|
||||||
* @param cmd1
|
|
||||||
* @param cmd2
|
|
||||||
* @param cmd3
|
|
||||||
*/
|
|
||||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3) {
|
|
||||||
sendAction(action, cmd1, cmd2, cmd3, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends an action to the client
|
|
||||||
* @param action
|
|
||||||
* @param cmd1
|
|
||||||
* @param cmd2
|
|
||||||
* @param cmd3
|
|
||||||
* @param index
|
|
||||||
*/
|
|
||||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int index) {
|
|
||||||
sendAction(action, cmd1, cmd2, cmd3, 0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends an action to the client
|
|
||||||
* @param action
|
|
||||||
* @param cmd1
|
|
||||||
* @param cmd2
|
|
||||||
* @param cmd3
|
|
||||||
* @param cmd4
|
|
||||||
* @param index
|
|
||||||
*/
|
|
||||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
|
|
||||||
if (constants == null) {
|
|
||||||
constants = Context.getInstance().getHookParser().getConstants();
|
|
||||||
}
|
|
||||||
|
|
||||||
Client client = Loader.getClient();
|
/**
|
||||||
|
* Clicks a button
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public static void clickButton(int id) {
|
||||||
|
sendAction(ACTION_CLICK_BUTTON, 0, 0, id);
|
||||||
|
}
|
||||||
|
|
||||||
client.getMenuAction1()[index] = cmd1;
|
/**
|
||||||
client.getMenuAction2()[index] = cmd2;
|
* Sends an action to the client
|
||||||
client.getMenuAction3()[index] = cmd3;
|
*
|
||||||
if(Game.hasAction4()) {
|
* @param action
|
||||||
client.getMenuAction4()[index] = cmd4;
|
* @param cmd1
|
||||||
}
|
* @param cmd2
|
||||||
client.getMenuActionId()[index] = action;
|
* @param cmd3
|
||||||
|
*/
|
||||||
|
public static void sendAction(int action, int cmd1, int cmd2, int cmd3) {
|
||||||
|
sendAction(action, cmd1, cmd2, cmd3, 1);
|
||||||
|
}
|
||||||
|
|
||||||
client.doAction(index);
|
/**
|
||||||
}
|
* Sends an action to the client
|
||||||
|
*
|
||||||
|
* @param action
|
||||||
|
* @param cmd1
|
||||||
|
* @param cmd2
|
||||||
|
* @param cmd3
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int index) {
|
||||||
|
sendAction(action, cmd1, cmd2, cmd3, 0, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action to the client
|
||||||
|
*
|
||||||
|
* @param action
|
||||||
|
* @param cmd1
|
||||||
|
* @param cmd2
|
||||||
|
* @param cmd3
|
||||||
|
* @param cmd4
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) {
|
||||||
|
if (constants == null) {
|
||||||
|
constants = Context.getInstance().getHookParser().getConstants();
|
||||||
|
}
|
||||||
|
|
||||||
|
Client client = Loader.getClient();
|
||||||
|
|
||||||
|
client.getMenuAction1()[index] = cmd1;
|
||||||
|
client.getMenuAction2()[index] = cmd2;
|
||||||
|
client.getMenuAction3()[index] = cmd3;
|
||||||
|
if (Game.hasAction4()) {
|
||||||
|
client.getMenuAction4()[index] = cmd4;
|
||||||
|
}
|
||||||
|
client.getMenuActionId()[index] = action;
|
||||||
|
|
||||||
|
|
||||||
|
client.doAction(index);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,139 +1,144 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.parabot.environment.api.utils.Filter;
|
import org.parabot.environment.api.utils.Filter;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
import org.rev317.min.api.wrappers.Npc;
|
import org.rev317.min.api.wrappers.Npc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Npcs {
|
public class Npcs {
|
||||||
|
|
||||||
private static final Comparator<Npc> NEAREST_SORTER = new Comparator<Npc>() {
|
private static final Comparator<Npc> NEAREST_SORTER = new Comparator<Npc>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Npc n1, Npc n2) {
|
public int compare(Npc n1, Npc n2) {
|
||||||
return n1.distanceTo() - n2.distanceTo();
|
return n1.distanceTo() - n2.distanceTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Filter<Npc> ALL_FILTER = new Filter<Npc>() {
|
private static final Filter<Npc> ALL_FILTER = new Filter<Npc>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Npc n) {
|
public boolean accept(Npc n) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all Npcs except local Npc
|
* Gets all Npcs except local Npc
|
||||||
*
|
*
|
||||||
* @param filter
|
* @param filter
|
||||||
* @return all Npcs
|
*
|
||||||
*/
|
* @return all Npcs
|
||||||
public static final Npc[] getNpcs(final Filter<Npc> filter) {
|
*/
|
||||||
final Client client = Loader.getClient();
|
public static final Npc[] getNpcs(final Filter<Npc> filter) {
|
||||||
ArrayList<Npc> npcList = new ArrayList<Npc>();
|
final Client client = Loader.getClient();
|
||||||
final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs();
|
ArrayList<Npc> npcList = new ArrayList<Npc>();
|
||||||
for (int i = 0; i < accNpcs.length; i++) {
|
final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs();
|
||||||
if(accNpcs[i] == null) {
|
for (int i = 0; i < accNpcs.length; i++) {
|
||||||
continue;
|
if (accNpcs[i] == null) {
|
||||||
}
|
continue;
|
||||||
final Npc npc = new Npc(accNpcs[i], i);
|
}
|
||||||
if (filter.accept(npc)) {
|
final Npc npc = new Npc(accNpcs[i], i);
|
||||||
npcList.add(npc);
|
if (filter.accept(npc)) {
|
||||||
}
|
npcList.add(npc);
|
||||||
}
|
}
|
||||||
return npcList.toArray(new Npc[npcList.size()]);
|
}
|
||||||
}
|
return npcList.toArray(new Npc[npcList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all Npcs
|
* Gets all Npcs
|
||||||
*
|
*
|
||||||
* @return all Npcs
|
* @return all Npcs
|
||||||
*/
|
*/
|
||||||
public static final Npc[] getNpcs() {
|
public static final Npc[] getNpcs() {
|
||||||
return getNpcs(ALL_FILTER);
|
return getNpcs(ALL_FILTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the closest npc which matches the given filter
|
|
||||||
* @param filter
|
|
||||||
* @return closest npc
|
|
||||||
*/
|
|
||||||
public static final Npc getClosest(final Filter<Npc> filter) {
|
|
||||||
Npc[] npcs = getNearest(filter);
|
|
||||||
if(npcs == null || npcs.length == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return npcs[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the closest npc which matches the given ids
|
|
||||||
* @param ids
|
|
||||||
* @return closest npc
|
|
||||||
*/
|
|
||||||
public static final Npc getClosest(int... ids) {
|
|
||||||
Npc[] npcs = getNearest(ids);
|
|
||||||
if(npcs == null || npcs.length == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return npcs[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns array with the first index to be the nearest Npc
|
* Gets the closest npc which matches the given filter
|
||||||
*
|
*
|
||||||
* @param filter
|
* @param filter
|
||||||
* @return nearest Npcs
|
*
|
||||||
*/
|
* @return closest npc
|
||||||
public static final Npc[] getNearest(final Filter<Npc> filter) {
|
*/
|
||||||
final Npc[] npcs = getNpcs(filter);
|
public static final Npc getClosest(final Filter<Npc> filter) {
|
||||||
Arrays.sort(npcs, NEAREST_SORTER);
|
Npc[] npcs = getNearest(filter);
|
||||||
return npcs;
|
if (npcs == null || npcs.length == 0) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
return npcs[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nearest npcs which hold given id(s)
|
* Gets the closest npc which matches the given ids
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return array of npcs with the first index to be the nearest
|
*
|
||||||
*/
|
* @return closest npc
|
||||||
public static final Npc[] getNearest(final int... ids) {
|
*/
|
||||||
final Npc[] npcs = getNpcs(new Filter<Npc>() {
|
public static final Npc getClosest(int... ids) {
|
||||||
|
Npc[] npcs = getNearest(ids);
|
||||||
|
if (npcs == null || npcs.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return npcs[0];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean accept(Npc npc) {
|
* Returns array with the first index to be the nearest Npc
|
||||||
for (final int id : ids) {
|
*
|
||||||
if (id == npc.getDef().getId()) {
|
* @param filter
|
||||||
return true;
|
*
|
||||||
}
|
* @return nearest Npcs
|
||||||
}
|
*/
|
||||||
return false;
|
public static final Npc[] getNearest(final Filter<Npc> filter) {
|
||||||
}
|
final Npc[] npcs = getNpcs(filter);
|
||||||
|
Arrays.sort(npcs, NEAREST_SORTER);
|
||||||
|
return npcs;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
/**
|
||||||
Arrays.sort(npcs, NEAREST_SORTER);
|
* Gets nearest npcs which hold given id(s)
|
||||||
return npcs;
|
*
|
||||||
}
|
* @param ids
|
||||||
|
*
|
||||||
|
* @return array of npcs with the first index to be the nearest
|
||||||
|
*/
|
||||||
|
public static final Npc[] getNearest(final int... ids) {
|
||||||
|
final Npc[] npcs = getNpcs(new Filter<Npc>() {
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns array with the first index to be the nearest Npc
|
public boolean accept(Npc npc) {
|
||||||
*
|
for (final int id : ids) {
|
||||||
* @return nearest Npcs
|
if (id == npc.getDef().getId()) {
|
||||||
*/
|
return true;
|
||||||
public static final Npc[] getNearest() {
|
}
|
||||||
return getNearest(ALL_FILTER);
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
Arrays.sort(npcs, NEAREST_SORTER);
|
||||||
|
return npcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns array with the first index to be the nearest Npc
|
||||||
|
*
|
||||||
|
* @return nearest Npcs
|
||||||
|
*/
|
||||||
|
public static final Npc[] getNearest() {
|
||||||
|
return getNearest(ALL_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,93 +1,98 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.parabot.environment.api.utils.Filter;
|
import org.parabot.environment.api.utils.Filter;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
import org.rev317.min.api.wrappers.Player;
|
import org.rev317.min.api.wrappers.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Players {
|
public class Players {
|
||||||
|
|
||||||
private static final Comparator<Player> NEAREST_SORTER = new Comparator<Player>() {
|
|
||||||
|
|
||||||
@Override
|
private static final Comparator<Player> NEAREST_SORTER = new Comparator<Player>() {
|
||||||
public int compare(Player p1, Player p2) {
|
|
||||||
return p1.distanceTo() - p2.distanceTo();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Filter<Player> ALL_FILTER = new Filter<Player>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Player p) {
|
public int compare(Player p1, Player p2) {
|
||||||
return true;
|
return p1.distanceTo() - p2.distanceTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
private static final Filter<Player> ALL_FILTER = new Filter<Player>() {
|
||||||
* Gets all players except local player
|
|
||||||
* @param filter
|
@Override
|
||||||
* @return all players
|
public boolean accept(Player p) {
|
||||||
*/
|
return true;
|
||||||
public static final Player[] getPlayers(final Filter<Player> filter) {
|
}
|
||||||
final Client client = Loader.getClient();
|
|
||||||
ArrayList<Player> playerList = new ArrayList<Player>();
|
};
|
||||||
final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers();
|
|
||||||
for(int i = 0; i < accPlayers.length; i++) {
|
/**
|
||||||
if(accPlayers[i] == null) {
|
* Gets all players except local player
|
||||||
continue;
|
*
|
||||||
}
|
* @param filter
|
||||||
final Player player = new Player(accPlayers[i], i);
|
*
|
||||||
if(filter.accept(player)) {
|
* @return all players
|
||||||
playerList.add(player);
|
*/
|
||||||
}
|
public static final Player[] getPlayers(final Filter<Player> filter) {
|
||||||
}
|
final Client client = Loader.getClient();
|
||||||
return playerList.toArray(new Player[playerList.size()]);
|
ArrayList<Player> playerList = new ArrayList<Player>();
|
||||||
}
|
final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers();
|
||||||
|
for (int i = 0; i < accPlayers.length; i++) {
|
||||||
/**
|
if (accPlayers[i] == null) {
|
||||||
* Gets all players except local player
|
continue;
|
||||||
* @return all players
|
}
|
||||||
*/
|
final Player player = new Player(accPlayers[i], i);
|
||||||
public static final Player[] getPlayers() {
|
if (filter.accept(player)) {
|
||||||
return getPlayers(ALL_FILTER);
|
playerList.add(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
return playerList.toArray(new Player[playerList.size()]);
|
||||||
* Returns array with the first index to be the nearest player
|
}
|
||||||
* @param filter
|
|
||||||
* @return nearest players
|
/**
|
||||||
*/
|
* Gets all players except local player
|
||||||
public static final Player[] getNearest(final Filter<Player> filter) {
|
*
|
||||||
final Player[] players = getPlayers(filter);
|
* @return all players
|
||||||
Arrays.sort(players, NEAREST_SORTER);
|
*/
|
||||||
return players;
|
public static final Player[] getPlayers() {
|
||||||
}
|
return getPlayers(ALL_FILTER);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns array with the first index to be the nearest player
|
/**
|
||||||
* @return nearest players
|
* Returns array with the first index to be the nearest player
|
||||||
*/
|
*
|
||||||
public static final Player[] getNearest() {
|
* @param filter
|
||||||
return getNearest(ALL_FILTER);
|
*
|
||||||
}
|
* @return nearest players
|
||||||
|
*/
|
||||||
/**
|
public static final Player[] getNearest(final Filter<Player> filter) {
|
||||||
* Gets local player
|
final Player[] players = getPlayers(filter);
|
||||||
* @return local player
|
Arrays.sort(players, NEAREST_SORTER);
|
||||||
*/
|
return players;
|
||||||
public static Player getMyPlayer() {
|
}
|
||||||
return new Player(Loader.getClient().getMyPlayer(), -1);
|
|
||||||
}
|
/**
|
||||||
|
* Returns array with the first index to be the nearest player
|
||||||
|
*
|
||||||
|
* @return nearest players
|
||||||
|
*/
|
||||||
|
public static final Player[] getNearest() {
|
||||||
|
return getNearest(ALL_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets local player
|
||||||
|
*
|
||||||
|
* @return local player
|
||||||
|
*/
|
||||||
|
public static Player getMyPlayer() {
|
||||||
|
return new Player(Loader.getClient().getMyPlayer(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,114 +1,104 @@
|
|||||||
package org.rev317.min.api.methods;
|
package org.rev317.min.api.methods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import org.parabot.environment.api.utils.Filter;
|
import org.parabot.environment.api.utils.Filter;
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Ground;
|
import org.rev317.min.accessors.Ground;
|
||||||
import org.rev317.min.accessors.SceneObjectTile;
|
import org.rev317.min.accessors.SceneObjectTile;
|
||||||
import org.rev317.min.api.wrappers.SceneObject;
|
import org.rev317.min.api.wrappers.SceneObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SceneObjects {
|
public class SceneObjects {
|
||||||
|
|
||||||
private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() {
|
|
||||||
|
|
||||||
@Override
|
private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() {
|
||||||
public int compare(SceneObject n1,SceneObject n2) {
|
|
||||||
return n1.distanceTo() - n2.distanceTo();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
@Override
|
||||||
|
public int compare(SceneObject n1, SceneObject n2) {
|
||||||
private static final Filter<SceneObject> ALL_FILTER = new Filter<SceneObject>() {
|
return n1.distanceTo() - n2.distanceTo();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
};
|
||||||
public boolean accept(SceneObject object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall decorations, ground decorations'
|
|
||||||
* @return scene objects
|
|
||||||
*/
|
|
||||||
public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) {
|
|
||||||
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
|
||||||
for(int x = 0; x < 104; x++) {
|
|
||||||
for(int y = 0; y < 104; y++) {
|
|
||||||
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true);
|
|
||||||
if(sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
|
|
||||||
sceneObjects.add(sceneObjectAtTile);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the most important scene objects in game which can be interacted with
|
|
||||||
* @return scene objects
|
|
||||||
*/
|
|
||||||
public static final SceneObject[] getSceneObjects() {
|
|
||||||
return getSceneObjects(ALL_FILTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns array of sceneobjects with the first index to be the nearest
|
|
||||||
* @param filter
|
|
||||||
* @return sceneobjects
|
|
||||||
*/
|
|
||||||
public static final SceneObject[] getNearest(Filter<SceneObject> filter) {
|
|
||||||
final SceneObject[] objects = getSceneObjects(filter);
|
|
||||||
Arrays.sort(objects, NEAREST_SORTER);
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns array of sceneobjects with the first index to be the nearest
|
|
||||||
* @return sceneobjects
|
|
||||||
*/
|
|
||||||
public static final SceneObject[] getNearest() {
|
|
||||||
return getNearest(ALL_FILTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns nearest objects with given id
|
|
||||||
* @param ids
|
|
||||||
* @return sceneobjects
|
|
||||||
*/
|
|
||||||
public static final SceneObject[] getNearest(final int... ids) {
|
|
||||||
return getNearest(new Filter<SceneObject>() {
|
|
||||||
|
|
||||||
@Override
|
private static final Filter<SceneObject> ALL_FILTER = new Filter<SceneObject>() {
|
||||||
public boolean accept(SceneObject object) {
|
|
||||||
for(final int id : ids) {
|
|
||||||
if(id == object.getId()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SceneObject getClosest(final int... ids) {
|
@Override
|
||||||
SceneObject[] nearestObjects = getNearest(new Filter<SceneObject>() {
|
public boolean accept(SceneObject object) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall
|
||||||
|
* decorations, ground decorations'
|
||||||
|
*
|
||||||
|
* @return scene objects
|
||||||
|
*/
|
||||||
|
public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) {
|
||||||
|
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
for (int x = 0; x < 104; x++) {
|
||||||
|
for (int y = 0; y < 104; y++) {
|
||||||
|
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true);
|
||||||
|
if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
|
||||||
|
sceneObjects.add(sceneObjectAtTile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the most important scene objects in game which can be interacted with
|
||||||
|
*
|
||||||
|
* @return scene objects
|
||||||
|
*/
|
||||||
|
public static final SceneObject[] getSceneObjects() {
|
||||||
|
return getSceneObjects(ALL_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns array of sceneobjects with the first index to be the nearest
|
||||||
|
*
|
||||||
|
* @param filter
|
||||||
|
*
|
||||||
|
* @return sceneobjects
|
||||||
|
*/
|
||||||
|
public static final SceneObject[] getNearest(Filter<SceneObject> filter) {
|
||||||
|
final SceneObject[] objects = getSceneObjects(filter);
|
||||||
|
Arrays.sort(objects, NEAREST_SORTER);
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns array of sceneobjects with the first index to be the nearest
|
||||||
|
*
|
||||||
|
* @return sceneobjects
|
||||||
|
*/
|
||||||
|
public static final SceneObject[] getNearest() {
|
||||||
|
return getNearest(ALL_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns nearest objects with given id
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
*
|
||||||
|
* @return sceneobjects
|
||||||
|
*/
|
||||||
|
public static final SceneObject[] getNearest(final int... ids) {
|
||||||
|
return getNearest(new Filter<SceneObject>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(SceneObject object) {
|
public boolean accept(SceneObject object) {
|
||||||
for(final int id : ids) {
|
for (final int id : ids) {
|
||||||
if(id == object.getId()) {
|
if (id == object.getId()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,104 +106,123 @@ public class SceneObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
if(nearestObjects == null || nearestObjects.length == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return nearestObjects[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) {
|
|
||||||
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
|
||||||
if(sceneTile == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
|
|
||||||
if(interactiveObjects != null) {
|
|
||||||
for(final SceneObjectTile interactiveObject : interactiveObjects) {
|
|
||||||
// get top
|
|
||||||
if(interactiveObject != null) {
|
|
||||||
return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
|
|
||||||
if(sceneObjectTile != null) {
|
|
||||||
return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public static final SceneObject getClosest(final int... ids) {
|
||||||
* Gets every loaded scene object in game
|
SceneObject[] nearestObjects = getNearest(new Filter<SceneObject>() {
|
||||||
* @return every loaded scene object in game
|
|
||||||
*/
|
@Override
|
||||||
public static final SceneObject[] getAllSceneObjects() {
|
public boolean accept(SceneObject object) {
|
||||||
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
for (final int id : ids) {
|
||||||
for(int x = 0; x < 104; x++) {
|
if (id == object.getId()) {
|
||||||
for(int y = 0; y < 104; y++) {
|
return true;
|
||||||
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
|
}
|
||||||
if(sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
|
}
|
||||||
sceneObjects.addAll(sceneObjectsAtTile);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
});
|
||||||
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
if (nearestObjects == null || nearestObjects.length == 0) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
/**
|
return nearestObjects[0];
|
||||||
* Gets all sceneobjects at a tile
|
}
|
||||||
* @param x
|
|
||||||
* @param y
|
private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) {
|
||||||
* @param useCached
|
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
||||||
* @return array of sceneobjects, or null if there aren't any
|
if (sceneTile == null) {
|
||||||
*/
|
return null;
|
||||||
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
|
}
|
||||||
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
|
||||||
ArrayList<SceneObject> sceneObjects = null;
|
if (interactiveObjects != null) {
|
||||||
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
|
for (final SceneObjectTile interactiveObject : interactiveObjects) {
|
||||||
if(interactiveObjects != null) {
|
// get top
|
||||||
for(final SceneObjectTile interactiveObject : interactiveObjects) {
|
if (interactiveObject != null) {
|
||||||
if(interactiveObject != null) {
|
return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE);
|
||||||
if(sceneObjects == null) {
|
}
|
||||||
sceneObjects = new ArrayList<SceneObject>();
|
}
|
||||||
}
|
}
|
||||||
sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE));
|
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
|
||||||
}
|
if (sceneObjectTile != null) {
|
||||||
}
|
return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL);
|
||||||
}
|
}
|
||||||
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
|
return null;
|
||||||
if(sceneObjectTile != null) {
|
}
|
||||||
if(sceneObjects == null) {
|
|
||||||
sceneObjects = new ArrayList<SceneObject>();
|
/**
|
||||||
}
|
* Gets every loaded scene object in game
|
||||||
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL));
|
*
|
||||||
}
|
* @return every loaded scene object in game
|
||||||
|
*/
|
||||||
sceneObjectTile = sceneTile.getWallDecoration();
|
public static final SceneObject[] getAllSceneObjects() {
|
||||||
if(sceneObjectTile != null) {
|
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
||||||
if(sceneObjects == null) {
|
for (int x = 0; x < 104; x++) {
|
||||||
sceneObjects = new ArrayList<SceneObject>();
|
for (int y = 0; y < 104; y++) {
|
||||||
}
|
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
|
||||||
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION));
|
if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
|
||||||
}
|
sceneObjects.addAll(sceneObjectsAtTile);
|
||||||
|
}
|
||||||
sceneObjectTile = sceneTile.getGroundDecoration();
|
}
|
||||||
if(sceneObjectTile != null) {
|
}
|
||||||
if(sceneObjects == null) {
|
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
||||||
sceneObjects = new ArrayList<SceneObject>();
|
}
|
||||||
}
|
|
||||||
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION));
|
/**
|
||||||
}
|
* Gets all sceneobjects at a tile
|
||||||
|
*
|
||||||
sceneObjectTile = sceneTile.getGroundItem();
|
* @param x
|
||||||
if(sceneObjectTile != null) {
|
* @param y
|
||||||
if(sceneObjects == null) {
|
* @param useCached
|
||||||
sceneObjects = new ArrayList<SceneObject>();
|
*
|
||||||
}
|
* @return array of sceneobjects, or null if there aren't any
|
||||||
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDITEM));
|
*/
|
||||||
}
|
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
|
||||||
return sceneObjects;
|
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
||||||
}
|
ArrayList<SceneObject> sceneObjects = null;
|
||||||
|
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
|
||||||
|
if (interactiveObjects != null) {
|
||||||
|
for (final SceneObjectTile interactiveObject : interactiveObjects) {
|
||||||
|
if (interactiveObject != null) {
|
||||||
|
if (sceneObjects == null) {
|
||||||
|
sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
}
|
||||||
|
sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
|
||||||
|
if (sceneObjectTile != null) {
|
||||||
|
if (sceneObjects == null) {
|
||||||
|
sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
}
|
||||||
|
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
sceneObjectTile = sceneTile.getWallDecoration();
|
||||||
|
if (sceneObjectTile != null) {
|
||||||
|
if (sceneObjects == null) {
|
||||||
|
sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
}
|
||||||
|
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
sceneObjectTile = sceneTile.getGroundDecoration();
|
||||||
|
if (sceneObjectTile != null) {
|
||||||
|
if (sceneObjects == null) {
|
||||||
|
sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
}
|
||||||
|
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
sceneObjectTile = sceneTile.getGroundItem();
|
||||||
|
if (sceneObjectTile != null) {
|
||||||
|
if (sceneObjects == null) {
|
||||||
|
sceneObjects = new ArrayList<SceneObject>();
|
||||||
|
}
|
||||||
|
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDITEM));
|
||||||
|
}
|
||||||
|
return sceneObjects;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,190 +3,182 @@ package org.rev317.min.api.methods;
|
|||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Dane
|
* @author Dane
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum Skill {
|
public enum Skill {
|
||||||
|
|
||||||
ATTACK, DEFENSE, STRENGTH, HITPOINTS, CONSTITUTION, RANGE, PRAYER
|
ATTACK, DEFENSE, STRENGTH, HITPOINTS, CONSTITUTION, RANGE, PRAYER, MAGIC, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, HERBLORE, HERBLAW, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFTING, HUNTER, CONSTRUCTION, SUMMONING, DUNGEONEERING;
|
||||||
, MAGIC, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING
|
|
||||||
, CRAFTING, SMITHING, MINING, HERBLORE, HERBLAW
|
|
||||||
, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFTING
|
|
||||||
, HUNTER, CONSTRUCTION, SUMMONING, DUNGEONEERING;
|
|
||||||
|
|
||||||
private static final int[] EXPERIENCE = { 0, 0, 83, 174, 276, 388, 512,
|
private static final int[] EXPERIENCE = {0, 0, 83, 174, 276, 388, 512,
|
||||||
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
|
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
|
||||||
3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,
|
3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,
|
||||||
12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
|
12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
|
||||||
30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983,
|
30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983,
|
||||||
75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872,
|
75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872,
|
||||||
166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804,
|
166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804,
|
||||||
368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627,
|
368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627,
|
||||||
814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,
|
814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,
|
||||||
1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,
|
1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,
|
||||||
3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831,
|
3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831,
|
||||||
6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606,
|
6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606,
|
||||||
13034431, 14391160, 15889109, 17542976, 19368992, 21385073,
|
13034431, 14391160, 15889109, 17542976, 19368992, 21385073,
|
||||||
23611006, 26068632, 28782069, 31777943, 35085654, 38737661,
|
23611006, 26068632, 28782069, 31777943, 35085654, 38737661,
|
||||||
42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
|
42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
|
||||||
77474828, 85539082, 94442737, 104273167 };
|
77474828, 85539082, 94442737, 104273167};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Deprecated use Skill.ordinal() instead
|
* Returns the experience of the provided skill.
|
||||||
* Returns the skill's index.
|
*
|
||||||
*/
|
* @param index the skill index.
|
||||||
public int getIndex() {
|
*
|
||||||
return ordinal();
|
* @return the experience.
|
||||||
}
|
*/
|
||||||
|
public static final int getCurrentExperience(int index) {
|
||||||
|
return Loader.getClient().getCurrentExp()[index];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the skill.
|
* Returns the real level of the provided skill.
|
||||||
*/
|
*
|
||||||
public final String getName() {
|
* @param index the skill index.
|
||||||
return Character.toUpperCase(name().charAt(0))
|
*
|
||||||
+ name().toLowerCase().substring(1);
|
* @return the real skill level.
|
||||||
}
|
*/
|
||||||
|
public static final int getRealLevel(int index) {
|
||||||
|
return getLevelByExperience(getCurrentExperience(index));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current experience.
|
* Returns the current level of the provided skill. (Will return de-buffed/buffed levels)
|
||||||
*/
|
*
|
||||||
public final int getExperience() {
|
* @param index the skill index.
|
||||||
return Skill.getCurrentExperience(this.getIndex());
|
*
|
||||||
}
|
* @return the current skill level. Done by Bears
|
||||||
|
*/
|
||||||
|
public static final int getCurrentLevel(int index) {
|
||||||
|
//return Loader.getClient().getCurrentStats()[index];
|
||||||
|
return getRealLevel(index); //TODO fix this method, it invokes a method not in the client accessor.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real level.
|
* Returns the exact experience at the provided level.
|
||||||
*/
|
*
|
||||||
public final int getRealLevel() {
|
* @param level the level.
|
||||||
return Skill.getRealLevel(this.getIndex());
|
*
|
||||||
}
|
* @return the experience at the provided level.
|
||||||
|
*/
|
||||||
|
public static final int getExperienceByLevel(int level) {
|
||||||
|
if (level > 99 || level < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return EXPERIENCE[level];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the stat; it will return the buffed level.)
|
* Returns the exact level with the provided experience.
|
||||||
* Done by Bears
|
*
|
||||||
*/
|
* @param experience the experience.
|
||||||
public final int getLevel() {
|
*
|
||||||
return Skill.getCurrentLevel(this.getIndex());
|
* @return the level at the provided experience.
|
||||||
}
|
*/
|
||||||
|
public static final int getLevelByExperience(int experience) {
|
||||||
|
for (int i = EXPERIENCE.length - 1; i > 0; i--) {
|
||||||
|
if (experience > EXPERIENCE[i]) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the remaining experience until the next level.
|
* Returns the remaining experience for the provided skill to level up.
|
||||||
*/
|
*
|
||||||
public final int getRemaining() {
|
* @param index the skill index.
|
||||||
return Skill.getRemainingExperience(this.getIndex());
|
*
|
||||||
}
|
* @return the remaining experience.
|
||||||
|
*/
|
||||||
|
public static final int getRemainingExperience(int index) {
|
||||||
|
int level = getLevelByExperience(getCurrentExperience(index));
|
||||||
|
if (level >= 99 || level < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return EXPERIENCE[(level + 1)] - getCurrentExperience(index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the percentage until the next level.
|
* Returns the percentage to the next level for the provided skill.
|
||||||
*/
|
*
|
||||||
public final int getPercentage() {
|
* @param index the skill index.
|
||||||
return Skill.getPercentToNextLevel(this.getIndex());
|
*
|
||||||
}
|
* @return the remaining percentage.
|
||||||
|
*/
|
||||||
|
public static final int getPercentToNextLevel(int index) {
|
||||||
|
int currentLevel = getLevelByExperience(getCurrentExperience(index));
|
||||||
|
int nextLevel = currentLevel + 1;
|
||||||
|
if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1
|
||||||
|
|| nextLevel < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns '[Name, Level / RealLevel]'
|
* @Deprecated use Skill.ordinal() instead Returns the skill's index.
|
||||||
*/
|
*/
|
||||||
@Override
|
public int getIndex() {
|
||||||
public final String toString() {
|
return ordinal();
|
||||||
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
|
}
|
||||||
+ this.getRealLevel() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the experience of the provided skill.
|
* Returns the name of the skill.
|
||||||
*
|
*/
|
||||||
* @param index
|
public final String getName() {
|
||||||
* the skill index.
|
return Character.toUpperCase(name().charAt(0))
|
||||||
* @return the experience.
|
+ name().toLowerCase().substring(1);
|
||||||
*/
|
}
|
||||||
public static final int getCurrentExperience(int index) {
|
|
||||||
return Loader.getClient().getCurrentExp()[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real level of the provided skill.
|
* Returns the current experience.
|
||||||
*
|
*/
|
||||||
* @param index
|
public final int getExperience() {
|
||||||
* the skill index.
|
return Skill.getCurrentExperience(this.getIndex());
|
||||||
* @return the real skill level.
|
}
|
||||||
*/
|
|
||||||
public static final int getRealLevel(int index) {
|
|
||||||
return getLevelByExperience(getCurrentExperience(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current level of the provided skill. (Will return de-buffed/buffed levels)
|
|
||||||
*
|
|
||||||
* @param index
|
|
||||||
* the skill index.
|
|
||||||
* @return the current skill level.
|
|
||||||
* Done by Bears
|
|
||||||
*/
|
|
||||||
public static final int getCurrentLevel(int index) {
|
|
||||||
//return Loader.getClient().getCurrentStats()[index];
|
|
||||||
return getRealLevel(index); //TODO fix this method, it invokes a method not in the client accessor.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the exact experience at the provided level.
|
* Returns the real level.
|
||||||
*
|
*/
|
||||||
* @param level
|
public final int getRealLevel() {
|
||||||
* the level.
|
return Skill.getRealLevel(this.getIndex());
|
||||||
* @return the experience at the provided level.
|
}
|
||||||
*/
|
|
||||||
public static final int getExperienceByLevel(int level) {
|
|
||||||
if (level > 99 || level < 1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return EXPERIENCE[level];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the exact level with the provided experience.
|
* Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the
|
||||||
*
|
* stat; it will return the buffed level.) Done by Bears
|
||||||
* @param experience
|
*/
|
||||||
* the experience.
|
public final int getLevel() {
|
||||||
* @return the level at the provided experience.
|
return Skill.getCurrentLevel(this.getIndex());
|
||||||
*/
|
}
|
||||||
public static final int getLevelByExperience(int experience) {
|
|
||||||
for (int i = EXPERIENCE.length - 1; i > 0; i--) {
|
|
||||||
if (experience > EXPERIENCE[i]) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the remaining experience for the provided skill to level up.
|
* Returns the remaining experience until the next level.
|
||||||
*
|
*/
|
||||||
* @param index
|
public final int getRemaining() {
|
||||||
* the skill index.
|
return Skill.getRemainingExperience(this.getIndex());
|
||||||
* @return the remaining experience.
|
}
|
||||||
*/
|
|
||||||
public static final int getRemainingExperience(int index) {
|
|
||||||
int level = getLevelByExperience(getCurrentExperience(index));
|
|
||||||
if (level >= 99 || level < 1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return EXPERIENCE[(level + 1)] - getCurrentExperience(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the percentage to the next level for the provided skill.
|
* Returns the percentage until the next level.
|
||||||
*
|
*/
|
||||||
* @param index
|
public final int getPercentage() {
|
||||||
* the skill index.
|
return Skill.getPercentToNextLevel(this.getIndex());
|
||||||
* @return the remaining percentage.
|
}
|
||||||
*/
|
|
||||||
public static final int getPercentToNextLevel(int index) {
|
/**
|
||||||
int currentLevel = getLevelByExperience(getCurrentExperience(index));
|
* Returns '[Name, Level / RealLevel]'
|
||||||
int nextLevel = currentLevel + 1;
|
*/
|
||||||
if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1
|
@Override
|
||||||
|| nextLevel < 1) {
|
public final String toString() {
|
||||||
return 0;
|
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
|
||||||
}
|
+ this.getRealLevel() + "]";
|
||||||
return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel]));
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,50 +5,51 @@ import org.rev317.min.api.wrappers.Tile;
|
|||||||
import org.rev317.min.api.wrappers.TilePath;
|
import org.rev317.min.api.wrappers.TilePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Walking {
|
public class Walking {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walks from tile to tile
|
* Walks from tile to tile
|
||||||
* @param from
|
*
|
||||||
* @param to
|
* @param from
|
||||||
*/
|
* @param to
|
||||||
public static void walkTo(Tile from, Tile to) {
|
*/
|
||||||
Loader.getClient().walkTo(0, 0, 0, 0, from.getRegionY(), 0, 0, to.getRegionY(), from.getRegionX(), true, to.getRegionX());
|
public static void walkTo(Tile from, Tile to) {
|
||||||
}
|
Loader.getClient().walkTo(0, 0, 0, 0, from.getRegionY(), 0, 0, to.getRegionY(), from.getRegionX(), true, to.getRegionX());
|
||||||
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @param tilePath
|
* @param tilePath
|
||||||
* @return <b>true</b> if destination reached, otherwise <b>false</b>
|
*
|
||||||
*/
|
* @return <b>true</b> if destination reached, otherwise <b>false</b>
|
||||||
public static boolean walkDown(TilePath tilePath) {
|
*/
|
||||||
if(tilePath.hasReached()) {
|
public static boolean walkDown(TilePath tilePath) {
|
||||||
return true;
|
if (tilePath.hasReached()) {
|
||||||
}
|
return true;
|
||||||
tilePath.traverse();
|
}
|
||||||
return false;
|
tilePath.traverse();
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets nearest reachable tile on minimap to given tile
|
/**
|
||||||
* @param tile
|
* Gets nearest reachable tile on minimap to given tile
|
||||||
* @return nearest reachable tile on minimap
|
*
|
||||||
*/
|
* @param tile
|
||||||
public static Tile getNearestTileTo(Tile tile) {
|
*
|
||||||
Tile loc = Players.getMyPlayer().getLocation();
|
* @return nearest reachable tile on minimap
|
||||||
for (int i = 0; i < 1000; ++i) {
|
*/
|
||||||
if (tile.distanceTo() < 16 && tile.isWalkable()) {
|
public static Tile getNearestTileTo(Tile tile) {
|
||||||
return tile;
|
Tile loc = Players.getMyPlayer().getLocation();
|
||||||
}
|
for (int i = 0; i < 1000; ++i) {
|
||||||
tile = new Tile((loc.getX() + tile.getX()) / 2,
|
if (tile.distanceTo() < 16 && tile.isWalkable()) {
|
||||||
(loc.getY() + tile.getY()) / 2);
|
return tile;
|
||||||
}
|
}
|
||||||
return null;
|
tile = new Tile((loc.getX() + tile.getX()) / 2,
|
||||||
}
|
(loc.getY() + tile.getY()) / 2);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,187 +9,186 @@ import org.rev317.min.api.methods.Menu;
|
|||||||
import org.rev317.min.api.methods.Players;
|
import org.rev317.min.api.methods.Players;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Character implements Locatable {
|
public class Character implements Locatable {
|
||||||
|
|
||||||
private org.rev317.min.accessors.Character accessor;
|
private org.rev317.min.accessors.Character accessor;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
public Character(org.rev317.min.accessors.Character accessor, int index) {
|
public Character(org.rev317.min.accessors.Character accessor, int index) {
|
||||||
this.accessor = accessor;
|
this.accessor = accessor;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets local region x
|
* Gets local region x
|
||||||
*
|
*
|
||||||
* @return x
|
* @return x
|
||||||
*/
|
*/
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return accessor.getX() >> 7;
|
return accessor.getX() >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets local region y
|
* Gets local region y
|
||||||
*
|
*
|
||||||
* @return y
|
* @return y
|
||||||
*/
|
*/
|
||||||
public int getY() {
|
public int getY() {
|
||||||
return accessor.getY() >> 7;
|
return accessor.getY() >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the character array
|
* Index of the character array
|
||||||
*
|
*
|
||||||
* @return index
|
* @return index
|
||||||
*/
|
*/
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation of this character
|
* Animation of this character
|
||||||
*
|
*
|
||||||
* @return animation
|
* @return animation
|
||||||
*/
|
*/
|
||||||
public int getAnimation() {
|
public int getAnimation() {
|
||||||
return accessor.getAnimation();
|
return accessor.getAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of this character
|
* Location of this character
|
||||||
*
|
*
|
||||||
* @return location
|
* @return location
|
||||||
*/
|
*/
|
||||||
public Tile getLocation() {
|
public Tile getLocation() {
|
||||||
return new Tile(Game.getBaseX() + getX(), Game.getBaseY() + getY());
|
return new Tile(Game.getBaseX() + getX(), Game.getBaseY() + getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distance to this character
|
* Distance to this character
|
||||||
*
|
*
|
||||||
* @return distance
|
* @return distance
|
||||||
*/
|
*/
|
||||||
public int distanceTo() {
|
public int distanceTo() {
|
||||||
return (int) Calculations.distanceTo(getLocation());
|
return (int) Calculations.distanceTo(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interacts with this character
|
* Interacts with this character
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i
|
||||||
*/
|
*/
|
||||||
public void interact(int i) {
|
public void interact(int i) {
|
||||||
Menu.interact(this, i);
|
Menu.interact(this, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets current health
|
* Gets current health
|
||||||
*
|
*
|
||||||
* @return health
|
* @return health
|
||||||
*/
|
*/
|
||||||
public final int getHealth() {
|
public final int getHealth() {
|
||||||
return this.accessor.getCurrentHealth();
|
return this.accessor.getCurrentHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets maximum health of this character
|
* Gets maximum health of this character
|
||||||
*
|
*
|
||||||
* @return max health
|
* @return max health
|
||||||
*/
|
*/
|
||||||
public final int getMaxHealth() {
|
public final int getMaxHealth() {
|
||||||
return this.accessor.getMaxHealth();
|
return this.accessor.getMaxHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches loop cycle status
|
* Fetches loop cycle status
|
||||||
*
|
*
|
||||||
* @return loop cycle status
|
* @return loop cycle status
|
||||||
*/
|
*/
|
||||||
public final int getLoopCycleStatus() {
|
public final int getLoopCycleStatus() {
|
||||||
return this.accessor.getLoopCycleStatus();
|
return this.accessor.getLoopCycleStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if entity is in combat
|
* Determines if entity is in combat
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if entity is in combat
|
* @return <b>true</b> if entity is in combat
|
||||||
*/
|
*/
|
||||||
public boolean isInCombat() {
|
public boolean isInCombat() {
|
||||||
return accessor.getLoopCycleStatus() > Loader.getClient()
|
return accessor.getLoopCycleStatus() > Loader.getClient()
|
||||||
.getLoopCycle();
|
.getLoopCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character this character is interacting with
|
* Returns the character this character is interacting with
|
||||||
*
|
*
|
||||||
* @return interacting character
|
* @return interacting character
|
||||||
*/
|
*/
|
||||||
public final Character getInteractingCharacter() {
|
public final Character getInteractingCharacter() {
|
||||||
int index = this.accessor.getInteractingEntity();
|
int index = this.accessor.getInteractingEntity();
|
||||||
if (index != -1 && index < 32768) {
|
if (index != -1 && index < 32768) {
|
||||||
return new Npc(Loader.getClient().getNpcs()[index], index);
|
return new Npc(Loader.getClient().getNpcs()[index], index);
|
||||||
} else if (index >= 32768) {
|
} else if (index >= 32768) {
|
||||||
index -= 32768;
|
index -= 32768;
|
||||||
try {
|
try {
|
||||||
if (Loader.getClient().getPlayers()[index] == null) {
|
if (Loader.getClient().getPlayers()[index] == null) {
|
||||||
return Players.getMyPlayer();
|
return Players.getMyPlayer();
|
||||||
}
|
}
|
||||||
return new Player(Loader.getClient().getPlayers()[index], index);
|
return new Player(Loader.getClient().getPlayers()[index], index);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return Players.getMyPlayer();
|
return Players.getMyPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the entity is logged in
|
* Determines if the entity is logged in
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if entity is logged in
|
* @return <b>true</b> if entity is logged in
|
||||||
*/
|
*/
|
||||||
public boolean isLoggedIn(){
|
public boolean isLoggedIn() {
|
||||||
return accessor.isLoggedIn();
|
return accessor.isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the accessor class
|
|
||||||
* @return RefClass of accessor
|
|
||||||
*/
|
|
||||||
public RefClass getRefClass() {
|
|
||||||
return new RefClass(this.accessor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public int hashCode() {
|
* Gets the accessor class
|
||||||
final int prime = 31;
|
*
|
||||||
int result = 1;
|
* @return RefClass of accessor
|
||||||
result = prime * result
|
*/
|
||||||
+ ((accessor == null) ? 0 : accessor.hashCode());
|
public RefClass getRefClass() {
|
||||||
result = prime * result + index;
|
return new RefClass(this.accessor);
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public int hashCode() {
|
||||||
if (this == obj)
|
final int prime = 31;
|
||||||
return true;
|
int result = 1;
|
||||||
if (obj == null)
|
result = prime * result
|
||||||
return false;
|
+ ((accessor == null) ? 0 : accessor.hashCode());
|
||||||
if (getClass() != obj.getClass())
|
result = prime * result + index;
|
||||||
return false;
|
return result;
|
||||||
Character other = (Character) obj;
|
}
|
||||||
if (accessor == null) {
|
|
||||||
if (other.accessor != null)
|
@Override
|
||||||
return false;
|
public boolean equals(Object obj) {
|
||||||
} else if (!accessor.equals(other.accessor))
|
if (this == obj)
|
||||||
return false;
|
return true;
|
||||||
if (index != other.index)
|
if (obj == null)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
if (getClass() != obj.getClass())
|
||||||
}
|
return false;
|
||||||
|
Character other = (Character) obj;
|
||||||
|
if (accessor == null) {
|
||||||
|
if (other.accessor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!accessor.equals(other.accessor))
|
||||||
|
return false;
|
||||||
|
if (index != other.index)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,82 +7,87 @@ import org.rev317.min.api.methods.Game;
|
|||||||
import org.rev317.min.api.methods.Menu;
|
import org.rev317.min.api.methods.Menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GroundItem implements Locatable {
|
public class GroundItem implements Locatable {
|
||||||
private org.rev317.min.accessors.Item accessor;
|
private org.rev317.min.accessors.Item accessor;
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
||||||
public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) {
|
|
||||||
this.accessor = accessor;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets location of this ground item
|
|
||||||
* @return location
|
|
||||||
*/
|
|
||||||
public Tile getLocation() {
|
|
||||||
return new Tile(Game.getBaseX() + x, Game.getBaseY() + y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets region X
|
|
||||||
* @return x
|
|
||||||
*/
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets region Y
|
|
||||||
* @return y
|
|
||||||
*/
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interacts with this ground item
|
|
||||||
* @param actionIndex
|
|
||||||
*/
|
|
||||||
public void interact(int actionIndex) {
|
|
||||||
Menu.interact(this, actionIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes this item from the ground
|
|
||||||
*/
|
|
||||||
public void take() {
|
|
||||||
Menu.take(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) {
|
||||||
* Gets distance between you and this ground item
|
this.accessor = accessor;
|
||||||
* @return distance
|
this.x = x;
|
||||||
*/
|
this.y = y;
|
||||||
public int distanceTo() {
|
}
|
||||||
return (int) Calculations.distanceTo(getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's ID of this item
|
* Gets location of this ground item
|
||||||
* @return ID
|
*
|
||||||
*/
|
* @return location
|
||||||
public int getId() {
|
*/
|
||||||
return accessor.getId();
|
public Tile getLocation() {
|
||||||
}
|
return new Tile(Game.getBaseX() + x, Game.getBaseY() + y);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets the accessor class
|
/**
|
||||||
* @return RefClass of accessor
|
* Gets region X
|
||||||
*/
|
*
|
||||||
public RefClass getRefClass() {
|
* @return x
|
||||||
return new RefClass(this.accessor);
|
*/
|
||||||
}
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets region Y
|
||||||
|
*
|
||||||
|
* @return y
|
||||||
|
*/
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interacts with this ground item
|
||||||
|
*
|
||||||
|
* @param actionIndex
|
||||||
|
*/
|
||||||
|
public void interact(int actionIndex) {
|
||||||
|
Menu.interact(this, actionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes this item from the ground
|
||||||
|
*/
|
||||||
|
public void take() {
|
||||||
|
Menu.take(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets distance between you and this ground item
|
||||||
|
*
|
||||||
|
* @return distance
|
||||||
|
*/
|
||||||
|
public int distanceTo() {
|
||||||
|
return (int) Calculations.distanceTo(getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get's ID of this item
|
||||||
|
*
|
||||||
|
* @return ID
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return accessor.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the accessor class
|
||||||
|
*
|
||||||
|
* @return RefClass of accessor
|
||||||
|
*/
|
||||||
|
public RefClass getRefClass() {
|
||||||
|
return new RefClass(this.accessor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,61 +3,63 @@ package org.rev317.min.api.wrappers;
|
|||||||
import org.rev317.min.api.methods.Menu;
|
import org.rev317.min.api.methods.Menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Item {
|
public class Item {
|
||||||
private int id, stackSize;
|
private int id, stackSize;
|
||||||
private int slot;
|
private int slot;
|
||||||
|
|
||||||
public Item(int id, int stackSize, int slot) {
|
|
||||||
this.id = id;
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id of this item
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets quantity of this item
|
|
||||||
* @return stack size
|
|
||||||
*/
|
|
||||||
public int getStackSize() {
|
|
||||||
return stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Item slot
|
|
||||||
* @return slot
|
|
||||||
*/
|
|
||||||
public int getSlot() {
|
|
||||||
return slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drops this item
|
|
||||||
*/
|
|
||||||
public void drop() {
|
|
||||||
Menu.drop(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public Item(int id, int stackSize, int slot) {
|
||||||
* Interacts with this item
|
this.id = id;
|
||||||
* @param i
|
this.stackSize = stackSize;
|
||||||
*/
|
this.slot = slot;
|
||||||
public void interact(int i) {
|
}
|
||||||
// TODO
|
|
||||||
}
|
/**
|
||||||
|
* Get id of this item
|
||||||
public void transform(int actionIndex, int interfaceParentId) {
|
*
|
||||||
Menu.transformItem(this, actionIndex, interfaceParentId);
|
* @return id
|
||||||
}
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets quantity of this item
|
||||||
|
*
|
||||||
|
* @return stack size
|
||||||
|
*/
|
||||||
|
public int getStackSize() {
|
||||||
|
return stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item slot
|
||||||
|
*
|
||||||
|
* @return slot
|
||||||
|
*/
|
||||||
|
public int getSlot() {
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drops this item
|
||||||
|
*/
|
||||||
|
public void drop() {
|
||||||
|
Menu.drop(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interacts with this item
|
||||||
|
*
|
||||||
|
* @param i
|
||||||
|
*/
|
||||||
|
public void interact(int i) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transform(int actionIndex, int interfaceParentId) {
|
||||||
|
Menu.transformItem(this, actionIndex, interfaceParentId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,33 +3,33 @@ package org.rev317.min.api.wrappers;
|
|||||||
import org.parabot.core.reflect.RefClass;
|
import org.parabot.core.reflect.RefClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Npc extends Character {
|
public final class Npc extends Character {
|
||||||
private org.rev317.min.accessors.Npc accessor;
|
private org.rev317.min.accessors.Npc accessor;
|
||||||
|
|
||||||
public Npc(org.rev317.min.accessors.Npc accessor, int index) {
|
public Npc(org.rev317.min.accessors.Npc accessor, int index) {
|
||||||
super(accessor, index);
|
super(accessor, index);
|
||||||
this.accessor = accessor;
|
this.accessor = accessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the definition of this npc
|
* Gets the definition of this npc
|
||||||
* @return npc definitions
|
*
|
||||||
*/
|
* @return npc definitions
|
||||||
public final NpcDef getDef() {
|
*/
|
||||||
return new NpcDef(this.accessor.getDef());
|
public final NpcDef getDef() {
|
||||||
}
|
return new NpcDef(this.accessor.getDef());
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets the accessor class
|
/**
|
||||||
* @return RefClass of accessor
|
* Gets the accessor class
|
||||||
*/
|
*
|
||||||
public RefClass getRefClass() {
|
* @return RefClass of accessor
|
||||||
return new RefClass(this.accessor);
|
*/
|
||||||
}
|
public RefClass getRefClass() {
|
||||||
|
return new RefClass(this.accessor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,32 +3,32 @@ package org.rev317.min.api.wrappers;
|
|||||||
import org.parabot.core.reflect.RefClass;
|
import org.parabot.core.reflect.RefClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class NpcDef {
|
public class NpcDef {
|
||||||
private org.rev317.min.accessors.NpcDef accessor;
|
private org.rev317.min.accessors.NpcDef accessor;
|
||||||
|
|
||||||
public NpcDef(org.rev317.min.accessors.NpcDef accessor) {
|
public NpcDef(org.rev317.min.accessors.NpcDef accessor) {
|
||||||
this.accessor = accessor;
|
this.accessor = accessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets id of this item
|
* Gets id of this item
|
||||||
* @return id of this item
|
*
|
||||||
*/
|
* @return id of this item
|
||||||
public int getId() {
|
*/
|
||||||
return accessor.getId();
|
public int getId() {
|
||||||
}
|
return accessor.getId();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets the accessor class
|
/**
|
||||||
* @return RefClass of accessor
|
* Gets the accessor class
|
||||||
*/
|
*
|
||||||
public RefClass getRefClass() {
|
* @return RefClass of accessor
|
||||||
return new RefClass(this.accessor);
|
*/
|
||||||
}
|
public RefClass getRefClass() {
|
||||||
|
return new RefClass(this.accessor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package org.rev317.min.api.wrappers;
|
package org.rev317.min.api.wrappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Player extends Character {
|
public class Player extends Character {
|
||||||
|
|
||||||
public Player(org.rev317.min.accessors.Player accessor, int index) {
|
public Player(org.rev317.min.accessors.Player accessor, int index) {
|
||||||
super(accessor, index);
|
super(accessor, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,103 +8,107 @@ import org.rev317.min.api.methods.Game;
|
|||||||
import org.rev317.min.api.methods.Menu;
|
import org.rev317.min.api.methods.Menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SceneObject implements Locatable {
|
public class SceneObject implements Locatable {
|
||||||
public static final int TYPE_WALL = 0; // object1
|
public static final int TYPE_WALL = 0; // object1
|
||||||
public static final int TYPE_WALLDECORATION = 1; // object2
|
public static final int TYPE_WALLDECORATION = 1; // object2
|
||||||
public static final int TYPE_GROUNDDECORATION = 2; // object3
|
public static final int TYPE_GROUNDDECORATION = 2; // object3
|
||||||
public static final int TYPE_GROUNDITEM = 3; // object4
|
public static final int TYPE_GROUNDITEM = 3; // object4
|
||||||
public static final int TYPE_INTERACTIVE = 4; // object5
|
public static final int TYPE_INTERACTIVE = 4; // object5
|
||||||
|
|
||||||
public SceneObjectTile accessor;
|
public SceneObjectTile accessor;
|
||||||
private int type;
|
private int type;
|
||||||
|
|
||||||
public SceneObject(SceneObjectTile accessor, int type) {
|
public SceneObject(SceneObjectTile accessor, int type) {
|
||||||
this.accessor = accessor;
|
this.accessor = accessor;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this object's hash
|
* Gets this object's hash
|
||||||
*
|
*
|
||||||
* @return hash
|
* @return hash
|
||||||
*/
|
*/
|
||||||
public final int getHash() {
|
public final int getHash() {
|
||||||
return accessor.getHash();
|
return accessor.getHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets location of this tile
|
* Gets location of this tile
|
||||||
* @return location
|
*
|
||||||
*/
|
* @return location
|
||||||
public final Tile getLocation() {
|
*/
|
||||||
return new Tile(Game.getBaseX() + getLocalRegionX(), Game.getBaseY() + getLocalRegionY());
|
public final Tile getLocation() {
|
||||||
}
|
return new Tile(Game.getBaseX() + getLocalRegionX(), Game.getBaseY() + getLocalRegionY());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets region X
|
* Gets region X
|
||||||
* @return region X
|
*
|
||||||
*/
|
* @return region X
|
||||||
public final int getLocalRegionX() {
|
*/
|
||||||
return accessor.getHash() & 0x7f;
|
public final int getLocalRegionX() {
|
||||||
}
|
return accessor.getHash() & 0x7f;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets region Y
|
* Gets region Y
|
||||||
* @return region Y
|
*
|
||||||
*/
|
* @return region Y
|
||||||
public final int getLocalRegionY() {
|
*/
|
||||||
return accessor.getHash() >> 7 & 0x7f;
|
public final int getLocalRegionY() {
|
||||||
}
|
return accessor.getHash() >> 7 & 0x7f;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this object's id
|
* Gets this object's id
|
||||||
*
|
*
|
||||||
* @return object id
|
* @return object id
|
||||||
*/
|
*/
|
||||||
public final int getId() {
|
public final int getId() {
|
||||||
return accessor.getHash() >> 14 & 0x7FFF;
|
return accessor.getHash() >> 14 & 0x7FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this object's type
|
* Gets this object's type
|
||||||
*
|
*
|
||||||
* @return type of object
|
* @return type of object
|
||||||
*/
|
*/
|
||||||
public final int getType() {
|
public final int getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates distance to this object
|
* Calculates distance to this object
|
||||||
* @return distance
|
*
|
||||||
*/
|
* @return distance
|
||||||
public final int distanceTo() {
|
*/
|
||||||
return (int) Calculations.distanceTo(getLocation());
|
public final int distanceTo() {
|
||||||
}
|
return (int) Calculations.distanceTo(getLocation());
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Interacts with this object
|
/**
|
||||||
* @param actionIndex
|
* Interacts with this object
|
||||||
*/
|
*
|
||||||
public void interact(int actionIndex) {
|
* @param actionIndex
|
||||||
Menu.interact(this, actionIndex);
|
*/
|
||||||
}
|
public void interact(int actionIndex) {
|
||||||
|
Menu.interact(this, actionIndex);
|
||||||
/**
|
}
|
||||||
* Gets the accessor class
|
|
||||||
* @return RefClass of accessor
|
/**
|
||||||
*/
|
* Gets the accessor class
|
||||||
public RefClass getRefClass() {
|
*
|
||||||
return new RefClass(this.accessor);
|
* @return RefClass of accessor
|
||||||
}
|
*/
|
||||||
|
public RefClass getRefClass() {
|
||||||
@Override
|
return new RefClass(this.accessor);
|
||||||
public String toString() {
|
}
|
||||||
return String.format("[ID: %d, X: %d, Y: %d]", getId(), getLocalRegionX(), getLocalRegionY());
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("[ID: %d, X: %d, Y: %d]", getId(), getLocalRegionX(), getLocalRegionY());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,164 +8,169 @@ import org.rev317.min.api.methods.Players;
|
|||||||
import org.rev317.min.api.methods.Walking;
|
import org.rev317.min.api.methods.Walking;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Class which holds a world location
|
* Class which holds a world location
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Tile implements TileFlags, Locatable {
|
public final class Tile implements TileFlags, Locatable {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
|
|
||||||
public Tile(int x, int y) {
|
public Tile(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, int z) {
|
public Tile(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets x
|
* Gets x
|
||||||
*
|
*
|
||||||
* @return x
|
* @return x
|
||||||
*/
|
*/
|
||||||
public final int getX() {
|
public final int getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets y
|
* Gets y
|
||||||
*
|
*
|
||||||
* @return y
|
* @return y
|
||||||
*/
|
*/
|
||||||
public final int getY() {
|
public final int getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets region x
|
* Gets region x
|
||||||
* @return region x
|
*
|
||||||
*/
|
* @return region x
|
||||||
public final int getRegionX() {
|
*/
|
||||||
return x - Game.getBaseX();
|
public final int getRegionX() {
|
||||||
}
|
return x - Game.getBaseX();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets region y
|
|
||||||
* @return region y
|
|
||||||
*/
|
|
||||||
public final int getRegionY() {
|
|
||||||
return y - Game.getBaseY();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets z/plane
|
|
||||||
*
|
|
||||||
* @return plane
|
|
||||||
*/
|
|
||||||
public final int getPlane() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Gets region y
|
||||||
* {@inheritDoc}
|
*
|
||||||
*/
|
* @return region y
|
||||||
@Override
|
*/
|
||||||
public final int distanceTo() {
|
public final int getRegionY() {
|
||||||
return (int) Calculations.distanceTo(this);
|
return y - Game.getBaseY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this tile is on minimap
|
* Gets z/plane
|
||||||
*
|
*
|
||||||
* @return whether this tile is on minimap
|
* @return plane
|
||||||
*/
|
*/
|
||||||
public final boolean isOnMinimap() {
|
public final int getPlane() {
|
||||||
return distanceTo() < 16;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Tile: [" + getX() + ", " + getY() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean equals(Object obj) {
|
* {@inheritDoc}
|
||||||
if (obj == null || obj.getClass() != this.getClass()) {
|
*/
|
||||||
return false;
|
@Override
|
||||||
}
|
public final int distanceTo() {
|
||||||
if (obj == this) {
|
return (int) Calculations.distanceTo(this);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
final Tile t = (Tile) obj;
|
/**
|
||||||
return t.getX() == this.getX() && t.getY() == this.getY()
|
* Determines if this tile is on minimap
|
||||||
&& t.getPlane() == this.getPlane();
|
*
|
||||||
}
|
* @return whether this tile is on minimap
|
||||||
|
*/
|
||||||
|
public final boolean isOnMinimap() {
|
||||||
|
return distanceTo() < 16;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public String toString() {
|
||||||
int hash = 7;
|
return "Tile: [" + getX() + ", " + getY() + "]";
|
||||||
hash = 31 * hash + this.x;
|
}
|
||||||
hash = 31 * hash + this.y;
|
|
||||||
hash = 31 * hash + this.z;
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Walks to this tile
|
public boolean equals(Object obj) {
|
||||||
*/
|
if (obj == null || obj.getClass() != this.getClass()) {
|
||||||
public void walkTo() {
|
return false;
|
||||||
Walking.walkTo(Players.getMyPlayer().getLocation(), this);
|
}
|
||||||
}
|
if (obj == this) {
|
||||||
|
return true;
|
||||||
/**
|
}
|
||||||
* Determines if this tile is walkable
|
|
||||||
* @return <code>true</code> if this tile is walkable, otherwise <code>false</code>
|
|
||||||
*/
|
|
||||||
public boolean isWalkable() {
|
|
||||||
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if this tile is reachable
|
|
||||||
* @param isObject whether this tile is an object tile
|
|
||||||
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
|
||||||
*/
|
|
||||||
public boolean isReachable(boolean isObject) {
|
|
||||||
Tile current = Players.getMyPlayer().getLocation();
|
|
||||||
return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if this tile is reachable
|
|
||||||
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
|
||||||
*/
|
|
||||||
public boolean isReachable() {
|
|
||||||
return isReachable(isObjectTile());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if this tile is an object tile
|
|
||||||
* @return <code>true</code> if this tile is an object tile, otherwise <code>false</code>
|
|
||||||
*/
|
|
||||||
public boolean isObjectTile() {
|
|
||||||
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
final Tile t = (Tile) obj;
|
||||||
* {@inheritDoc}
|
return t.getX() == this.getX() && t.getY() == this.getY()
|
||||||
*/
|
&& t.getPlane() == this.getPlane();
|
||||||
@Override
|
}
|
||||||
public Tile getLocation() {
|
|
||||||
return this;
|
@Override
|
||||||
}
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 31 * hash + this.x;
|
||||||
|
hash = 31 * hash + this.y;
|
||||||
|
hash = 31 * hash + this.z;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Walks to this tile
|
||||||
|
*/
|
||||||
|
public void walkTo() {
|
||||||
|
Walking.walkTo(Players.getMyPlayer().getLocation(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is walkable
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this tile is walkable, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean isWalkable() {
|
||||||
|
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is reachable
|
||||||
|
*
|
||||||
|
* @param isObject whether this tile is an object tile
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean isReachable(boolean isObject) {
|
||||||
|
Tile current = Players.getMyPlayer().getLocation();
|
||||||
|
return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is reachable
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean isReachable() {
|
||||||
|
return isReachable(isObjectTile());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this tile is an object tile
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this tile is an object tile, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean isObjectTile() {
|
||||||
|
return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Tile getLocation() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +1,80 @@
|
|||||||
package org.rev317.min.api.wrappers;
|
package org.rev317.min.api.wrappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TilePath {
|
public class TilePath {
|
||||||
|
|
||||||
private Tile[] tiles;
|
private Tile[] tiles;
|
||||||
|
|
||||||
public TilePath(Tile[] tiles) {
|
public TilePath(Tile[] tiles) {
|
||||||
this.tiles = tiles;
|
this.tiles = tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this path's tiles
|
* Gets this path's tiles
|
||||||
*
|
*
|
||||||
* @return path tiles
|
* @return path tiles
|
||||||
*/
|
*/
|
||||||
public final Tile[] getTiles() {
|
public final Tile[] getTiles() {
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets next tile to walk to
|
* Gets next tile to walk to
|
||||||
*
|
*
|
||||||
* @return tile
|
* @return tile
|
||||||
*/
|
*/
|
||||||
public final Tile getNextTile() {
|
public final Tile getNextTile() {
|
||||||
Tile next = null;
|
Tile next = null;
|
||||||
for (int x = 0; x < tiles.length; x++) {
|
for (int x = 0; x < tiles.length; x++) {
|
||||||
if (tiles[x].isOnMinimap()) {
|
if (tiles[x].isOnMinimap()) {
|
||||||
next = tiles[x];
|
next = tiles[x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this path can be walked down
|
* Determines if this path can be walked down
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if path is valid
|
* @return <b>true</b> if path is valid
|
||||||
*/
|
*/
|
||||||
public final boolean isValid() {
|
public final boolean isValid() {
|
||||||
return getNextTile() != null;
|
return getNextTile() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if player has reached end of path
|
* Determines if player has reached end of path
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if player has reached end of path
|
* @return <b>true</b> if player has reached end of path
|
||||||
*/
|
*/
|
||||||
public final boolean hasReached() {
|
public final boolean hasReached() {
|
||||||
return tiles[tiles.length - 1].distanceTo() < 5;
|
return tiles[tiles.length - 1].distanceTo() < 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walks down the path
|
* Walks down the path
|
||||||
*/
|
*/
|
||||||
public final void traverse() {
|
public final void traverse() {
|
||||||
final Tile next = getNextTile();
|
final Tile next = getNextTile();
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
next.walkTo();
|
next.walkTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverses the current path
|
* Reverses the current path
|
||||||
*
|
*
|
||||||
* @return The reversed path
|
* @return The reversed path
|
||||||
*/
|
*/
|
||||||
public final TilePath reverse() {
|
public final TilePath reverse() {
|
||||||
Tile[] newTiles = new Tile[tiles.length];
|
Tile[] newTiles = new Tile[tiles.length];
|
||||||
for (int i = 0; i < tiles.length; i++)
|
for (int i = 0; i < tiles.length; i++)
|
||||||
newTiles[i] = tiles[tiles.length - i - 1];
|
newTiles[i] = tiles[tiles.length - i - 1];
|
||||||
return new TilePath(newTiles);
|
return new TilePath(newTiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,37 +2,35 @@ package org.rev317.min.callback;
|
|||||||
|
|
||||||
import org.rev317.min.Loader;
|
import org.rev317.min.Loader;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
import org.rev317.min.debug.DActions;
|
|
||||||
import org.rev317.min.api.events.GameActionEvent;
|
import org.rev317.min.api.events.GameActionEvent;
|
||||||
import org.rev317.min.api.methods.Game;
|
import org.rev317.min.api.methods.Game;
|
||||||
|
import org.rev317.min.debug.DActions;
|
||||||
import org.rev317.min.script.ScriptEngine;
|
import org.rev317.min.script.ScriptEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @author Matt123337
|
* @author Matt123337
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MenuAction {
|
public class MenuAction {
|
||||||
|
|
||||||
public static void intercept(int index) {
|
public static void intercept(int index) {
|
||||||
Client client = Loader.getClient();
|
Client client = Loader.getClient();
|
||||||
int action1 = client.getMenuAction1()[index];
|
int action1 = client.getMenuAction1()[index];
|
||||||
int action2 = client.getMenuAction2()[index];
|
int action2 = client.getMenuAction2()[index];
|
||||||
int action3 = client.getMenuAction3()[index];
|
int action3 = client.getMenuAction3()[index];
|
||||||
int action4 = 0;
|
int action4 = 0;
|
||||||
int actionId = client.getMenuActionId()[index];
|
int actionId = client.getMenuActionId()[index];
|
||||||
if (DActions.debugActions()) {
|
if (DActions.debugActions()) {
|
||||||
if(Game.hasAction4()) {
|
if (Game.hasAction4()) {
|
||||||
action4 = client.getMenuAction4()[index];
|
action4 = client.getMenuAction4()[index];
|
||||||
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId));
|
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId));
|
||||||
} else {
|
} else {
|
||||||
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId));
|
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final GameActionEvent actionEvent = new GameActionEvent(actionId, action1, action2, action3, action4, index);
|
final GameActionEvent actionEvent = new GameActionEvent(actionId, action1, action2, action3, action4, index);
|
||||||
ScriptEngine.getInstance().dispatch(actionEvent);
|
ScriptEngine.getInstance().dispatch(actionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package org.rev317.min.callback;
|
package org.rev317.min.callback;
|
||||||
|
|
||||||
import org.rev317.min.api.events.MessageEvent;
|
import org.rev317.min.api.events.MessageEvent;
|
||||||
|
|
||||||
import org.rev317.min.script.ScriptEngine;
|
import org.rev317.min.script.ScriptEngine;
|
||||||
|
|
||||||
|
|
||||||
public class MessageCallback {
|
public class MessageCallback {
|
||||||
|
|
||||||
public static final void messageListenerHook(int type, String name, String message) {
|
public static final void messageListenerHook(int type, String name, String message) {
|
||||||
final MessageEvent messageEvent = new MessageEvent(type, name, message);
|
final MessageEvent messageEvent = new MessageEvent(type, name, message);
|
||||||
ScriptEngine.getInstance().dispatch(messageEvent);
|
ScriptEngine.getInstance().dispatch(messageEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DActions extends AbstractDebugger {
|
public class DActions extends AbstractDebugger {
|
||||||
private static boolean enabled;
|
private static boolean enabled;
|
||||||
|
|
||||||
@Override
|
public static boolean debugActions() {
|
||||||
public void paint(Graphics g) {
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public void paint(Graphics g) {
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public boolean isEnabled() {
|
||||||
enabled = !enabled;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean debugActions() {
|
@Override
|
||||||
return enabled;
|
public void toggle() {
|
||||||
}
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.Players;
|
import org.rev317.min.api.methods.Players;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DAnimation extends AbstractDebugger {
|
public class DAnimation extends AbstractDebugger {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
Context.getInstance().getPaintDebugger().addLine("Animation: " + Players.getMyPlayer().getAnimation());
|
Context.getInstance().getPaintDebugger().addLine("Animation: " + Players.getMyPlayer().getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
enabled = !enabled;
|
enabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.Bank;
|
import org.rev317.min.api.methods.Bank;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DBank extends AbstractDebugger {
|
public class DBank extends AbstractDebugger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
if (!Bank.isOpen())
|
if (!Bank.isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = Bank.getBankItems().length - 1; i >= 0; i--) {
|
for (int i = Bank.getBankItems().length - 1; i >= 0; i--) {
|
||||||
System.out.println("ID: " + Bank.getBankItems()[i].getId()
|
System.out.println("ID: " + Bank.getBankItems()[i].getId()
|
||||||
+ " Stack: " + Bank.getBankItems()[i].getStackSize()
|
+ " Stack: " + Bank.getBankItems()[i].getStackSize()
|
||||||
+ " Slot: " + Bank.getBankItems()[i].getSlot());
|
+ " Slot: " + Bank.getBankItems()[i].getSlot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
@@ -9,31 +7,33 @@ import org.rev317.min.api.methods.Game;
|
|||||||
import org.rev317.min.api.methods.Players;
|
import org.rev317.min.api.methods.Players;
|
||||||
import org.rev317.min.api.wrappers.Tile;
|
import org.rev317.min.api.wrappers.Tile;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DCollisionFlags extends AbstractDebugger {
|
public class DCollisionFlags extends AbstractDebugger {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
Tile location = Players.getMyPlayer().getLocation();
|
Tile location = Players.getMyPlayer().getLocation();
|
||||||
Tile north = new Tile(location.getX(), location.getY() + 1);
|
Tile north = new Tile(location.getX(), location.getY() + 1);
|
||||||
Tile south = new Tile(location.getX(), location.getY() - 1);
|
Tile south = new Tile(location.getX(), location.getY() - 1);
|
||||||
Tile west = new Tile(location.getX() - 1, location.getY());
|
Tile west = new Tile(location.getX() - 1, location.getY());
|
||||||
Tile east = new Tile(location.getX() + 1, location.getY());
|
Tile east = new Tile(location.getX() + 1, location.getY());
|
||||||
int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()];
|
int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()];
|
||||||
p.addLine("Collision flag: 0x" + String.format("%X", flag));
|
p.addLine("Collision flag: 0x" + String.format("%X", flag));
|
||||||
p.addLine("Reachable: [ cur: " + location.isReachable() + ", north: " + north.isReachable() + ", south: " + south.isReachable() + ", east: " + east.isReachable() + ", west: " + west.isReachable() + " ]");
|
p.addLine("Reachable: [ cur: " + location.isReachable() + ", north: " + north.isReachable() + ", south: " + south.isReachable() + ", east: " + east.isReachable() + ", west: " + west.isReachable() + " ]");
|
||||||
p.addLine("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]");
|
p.addLine("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
enabled = !enabled;
|
enabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.GroundItems;
|
import org.rev317.min.api.methods.GroundItems;
|
||||||
import org.rev317.min.api.wrappers.GroundItem;
|
import org.rev317.min.api.wrappers.GroundItem;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DGroundItems extends AbstractDebugger {
|
public class DGroundItems extends AbstractDebugger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean isEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public boolean isEnabled() {
|
||||||
GroundItem[] items = GroundItems.getNearest();
|
return false;
|
||||||
if(items == null || items.length == 0) {
|
}
|
||||||
return;
|
|
||||||
}
|
@Override
|
||||||
for(GroundItem item : items) {
|
public void toggle() {
|
||||||
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
|
GroundItem[] items = GroundItems.getNearest();
|
||||||
}
|
if (items == null || items.length == 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
for (GroundItem item : items) {
|
||||||
|
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
import org.rev317.min.api.methods.Game;
|
import org.rev317.min.api.methods.Game;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DInterfaces extends AbstractDebugger {
|
public class DInterfaces extends AbstractDebugger {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
p.addLine("Open interface: " + Game.getOpenInterfaceId());
|
p.addLine("Open interface: " + Game.getOpenInterfaceId());
|
||||||
p.addLine("Open back dialog: " + Game.getOpenBackDialogId());
|
p.addLine("Open back dialog: " + Game.getOpenBackDialogId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
enabled = !enabled;
|
enabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.Inventory;
|
import org.rev317.min.api.methods.Inventory;
|
||||||
import org.rev317.min.api.wrappers.Item;
|
import org.rev317.min.api.wrappers.Item;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DInventory extends AbstractDebugger {
|
public class DInventory extends AbstractDebugger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean isEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public boolean isEnabled() {
|
||||||
for(Item i : Inventory.getItems()) {
|
return false;
|
||||||
System.out.println("ID: " + i.getId() + " Stack: " + i.getStackSize() + " Slot: " + i.getSlot());
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
for (Item i : Inventory.getItems()) {
|
||||||
|
System.out.println("ID: " + i.getId() + " Stack: " + i.getStackSize() + " Slot: " + i.getSlot());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
import org.rev317.min.api.methods.Game;
|
import org.rev317.min.api.methods.Game;
|
||||||
import org.rev317.min.api.methods.Players;
|
import org.rev317.min.api.methods.Players;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DMap extends AbstractDebugger {
|
public class DMap extends AbstractDebugger {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
PaintDebugger p = Context.getInstance().getPaintDebugger();
|
||||||
p.addLine("Location: " + Players.getMyPlayer().getLocation());
|
p.addLine("Location: " + Players.getMyPlayer().getLocation());
|
||||||
p.addLine("Plane: " + Game.getPlane());
|
p.addLine("Plane: " + Game.getPlane());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
enabled = !enabled;
|
enabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.parabot.environment.input.Mouse;
|
import org.parabot.environment.input.Mouse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DMouse extends AbstractDebugger {
|
public class DMouse extends AbstractDebugger {
|
||||||
|
|
||||||
private boolean enabled;
|
|
||||||
|
|
||||||
@Override
|
private boolean enabled;
|
||||||
public void paint(Graphics g) {
|
|
||||||
Context.getInstance().getPaintDebugger().addLine("Mouse: " + Mouse.getInstance().getPoint().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public void paint(Graphics g) {
|
||||||
return enabled;
|
Context.getInstance().getPaintDebugger().addLine("Mouse: " + Mouse.getInstance().getPoint().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public boolean isEnabled() {
|
||||||
enabled = !enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggle() {
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.Npcs;
|
import org.rev317.min.api.methods.Npcs;
|
||||||
import org.rev317.min.api.wrappers.Npc;
|
import org.rev317.min.api.wrappers.Npc;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DNpcs extends AbstractDebugger {
|
public class DNpcs extends AbstractDebugger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean isEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public boolean isEnabled() {
|
||||||
for(Npc n : Npcs.getNearest()) {
|
return false;
|
||||||
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
}
|
public void toggle() {
|
||||||
|
for (Npc n : Npcs.getNearest()) {
|
||||||
|
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
package org.rev317.min.debug;
|
package org.rev317.min.debug;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import org.parabot.core.paint.AbstractDebugger;
|
import org.parabot.core.paint.AbstractDebugger;
|
||||||
import org.rev317.min.api.methods.SceneObjects;
|
import org.rev317.min.api.methods.SceneObjects;
|
||||||
import org.rev317.min.api.wrappers.SceneObject;
|
import org.rev317.min.api.wrappers.SceneObject;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class DSceneObjects extends AbstractDebugger {
|
public class DSceneObjects extends AbstractDebugger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
SceneObject[] objects = SceneObjects.getNearest();
|
SceneObject[] objects = SceneObjects.getNearest();
|
||||||
if(objects == null || objects.length == 0)
|
if (objects == null || objects.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = objects.length - 1; i >= 0; i--) {
|
for (int i = objects.length - 1; i >= 0; i--) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
" ID: " + objects[i].getId() +
|
" ID: " + objects[i].getId() +
|
||||||
" UID: " + objects[i].getHash() +
|
" UID: " + objects[i].getHash() +
|
||||||
" Location: "+ objects[i].getLocation() +
|
" Location: " + objects[i].getLocation() +
|
||||||
" Distance: "+ objects[i].distanceTo());
|
" Distance: " + objects[i].distanceTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,183 +1,181 @@
|
|||||||
package org.rev317.min.script;
|
package org.rev317.min.script;
|
||||||
|
|
||||||
import java.awt.AWTEvent;
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.environment.api.interfaces.Paintable;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
|
import org.rev317.min.api.events.GameActionEvent;
|
||||||
|
import org.rev317.min.api.events.MessageEvent;
|
||||||
|
import org.rev317.min.api.events.listeners.GameActionListener;
|
||||||
|
import org.rev317.min.api.events.listeners.MessageListener;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.environment.api.interfaces.Paintable;
|
|
||||||
import org.parabot.environment.scripts.Script;
|
|
||||||
import org.rev317.min.api.events.MessageEvent;
|
|
||||||
import org.rev317.min.api.events.listeners.MessageListener;
|
|
||||||
import org.rev317.min.api.events.GameActionEvent;
|
|
||||||
import org.rev317.min.api.events.listeners.GameActionListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @author matt123337
|
* @author matt123337
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ScriptEngine {
|
public class ScriptEngine {
|
||||||
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
|
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
|
||||||
private ArrayList<MouseListener> mouseListeners;
|
private ArrayList<MouseListener> mouseListeners;
|
||||||
private ArrayList<MouseMotionListener> mouseMotionListeners;
|
private ArrayList<MouseMotionListener> mouseMotionListeners;
|
||||||
private ArrayList<MessageListener> messageListeners;
|
private ArrayList<MessageListener> messageListeners;
|
||||||
private ArrayList<GameActionListener> actionListeners;
|
private ArrayList<GameActionListener> actionListeners;
|
||||||
|
|
||||||
private Script script = null;
|
private Script script = null;
|
||||||
|
|
||||||
private ScriptEngine() {
|
private ScriptEngine() {
|
||||||
this.mouseListeners = new ArrayList<MouseListener>();
|
this.mouseListeners = new ArrayList<MouseListener>();
|
||||||
this.mouseMotionListeners = new ArrayList<MouseMotionListener>();
|
this.mouseMotionListeners = new ArrayList<MouseMotionListener>();
|
||||||
this.messageListeners = new ArrayList<MessageListener>();
|
this.messageListeners = new ArrayList<MessageListener>();
|
||||||
this.actionListeners = new ArrayList<GameActionListener>();
|
this.actionListeners = new ArrayList<GameActionListener>();
|
||||||
instances.put(Context.getInstance(), this);
|
instances.put(Context.getInstance(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScriptEngine getInstance() {
|
public static ScriptEngine getInstance() {
|
||||||
final ScriptEngine engine = instances.get(Context.getInstance());
|
final ScriptEngine engine = instances.get(Context.getInstance());
|
||||||
if(engine != null) {
|
if (engine != null) {
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
return new ScriptEngine();
|
return new ScriptEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addActionListener(GameActionListener a){
|
public void addActionListener(GameActionListener a) {
|
||||||
actionListeners.add(a);
|
actionListeners.add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeActionListener(GameActionListener a){
|
public void removeActionListener(GameActionListener a) {
|
||||||
actionListeners.remove(a);
|
actionListeners.remove(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearActionListeners(){
|
public void clearActionListeners() {
|
||||||
actionListeners.clear();
|
actionListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMouseListener(MouseListener mouseListener) {
|
public void addMouseListener(MouseListener mouseListener) {
|
||||||
mouseListeners.add(mouseListener);
|
mouseListeners.add(mouseListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMouseListener(MouseListener mouseListener) {
|
public void removeMouseListener(MouseListener mouseListener) {
|
||||||
mouseListeners.remove(mouseListener);
|
mouseListeners.remove(mouseListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMouseListeners() {
|
public void clearMouseListeners() {
|
||||||
mouseListeners.clear();
|
mouseListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
public void addMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
||||||
mouseMotionListeners.add(mouseMotionListener);
|
mouseMotionListeners.add(mouseMotionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
public void removeMouseMotionListener(MouseMotionListener mouseMotionListener) {
|
||||||
mouseMotionListeners.remove(mouseMotionListener);
|
mouseMotionListeners.remove(mouseMotionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMouseMotionListeners() {
|
public void clearMouseMotionListeners() {
|
||||||
mouseMotionListeners.clear();
|
mouseMotionListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMessageListener(MessageListener messageListener) {
|
public void addMessageListener(MessageListener messageListener) {
|
||||||
messageListeners.add(messageListener);
|
messageListeners.add(messageListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMessageListener(MessageListener messageListener) {
|
public void removeMessageListener(MessageListener messageListener) {
|
||||||
messageListeners.remove(messageListener);
|
messageListeners.remove(messageListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMessageListeners() {
|
public void clearMessageListeners() {
|
||||||
messageListeners.clear();
|
messageListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScript(final Script script) {
|
public void setScript(final Script script) {
|
||||||
this.script = script;
|
this.script = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unload() {
|
public void unload() {
|
||||||
clearMouseListeners();
|
clearMouseListeners();
|
||||||
clearMouseMotionListeners();
|
clearMouseMotionListeners();
|
||||||
clearMessageListeners();
|
clearMessageListeners();
|
||||||
if(script instanceof Paintable) {
|
if (script instanceof Paintable) {
|
||||||
Context.getInstance().removePaintable((Paintable)script);
|
Context.getInstance().removePaintable((Paintable) script);
|
||||||
}
|
}
|
||||||
this.script = null;
|
this.script = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
if(script == null) {
|
if (script == null) {
|
||||||
throw new RuntimeException("Script is null");
|
throw new RuntimeException("Script is null");
|
||||||
}
|
}
|
||||||
if(script instanceof MouseListener) {
|
if (script instanceof MouseListener) {
|
||||||
addMouseListener((MouseListener)script);
|
addMouseListener((MouseListener) script);
|
||||||
}
|
}
|
||||||
if(script instanceof MouseMotionListener) {
|
if (script instanceof MouseMotionListener) {
|
||||||
addMouseMotionListener((MouseMotionListener)script);
|
addMouseMotionListener((MouseMotionListener) script);
|
||||||
}
|
}
|
||||||
if(script instanceof MessageListener) {
|
if (script instanceof MessageListener) {
|
||||||
addMessageListener((MessageListener)script);
|
addMessageListener((MessageListener) script);
|
||||||
}
|
}
|
||||||
if(script instanceof Paintable) {
|
if (script instanceof Paintable) {
|
||||||
Context.getInstance().addPaintable((Paintable)script);
|
Context.getInstance().addPaintable((Paintable) script);
|
||||||
}
|
}
|
||||||
if(script instanceof GameActionListener){
|
if (script instanceof GameActionListener) {
|
||||||
addActionListener((GameActionListener) script);
|
addActionListener((GameActionListener) script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatch(AWTEvent event) {
|
public void dispatch(AWTEvent event) {
|
||||||
if(this.script == null) {
|
if (this.script == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!(event instanceof MouseEvent)) {
|
if (!(event instanceof MouseEvent)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final MouseEvent e = (MouseEvent) event;
|
final MouseEvent e = (MouseEvent) event;
|
||||||
for(final MouseListener m : mouseListeners) {
|
for (final MouseListener m : mouseListeners) {
|
||||||
switch(e.getID()) {
|
switch (e.getID()) {
|
||||||
case MouseEvent.MOUSE_CLICKED:
|
case MouseEvent.MOUSE_CLICKED:
|
||||||
m.mouseClicked(e);
|
m.mouseClicked(e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_ENTERED:
|
case MouseEvent.MOUSE_ENTERED:
|
||||||
m.mouseEntered(e);
|
m.mouseEntered(e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_EXITED:
|
case MouseEvent.MOUSE_EXITED:
|
||||||
m.mouseExited(e);
|
m.mouseExited(e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_PRESSED:
|
case MouseEvent.MOUSE_PRESSED:
|
||||||
m.mousePressed(e);
|
m.mousePressed(e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_RELEASED:
|
case MouseEvent.MOUSE_RELEASED:
|
||||||
m.mouseReleased(e);
|
m.mouseReleased(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(final MouseMotionListener m : mouseMotionListeners) {
|
for (final MouseMotionListener m : mouseMotionListeners) {
|
||||||
switch(e.getID()) {
|
switch (e.getID()) {
|
||||||
case MouseEvent.MOUSE_MOVED:
|
case MouseEvent.MOUSE_MOVED:
|
||||||
m.mouseMoved(e);
|
m.mouseMoved(e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_DRAGGED:
|
case MouseEvent.MOUSE_DRAGGED:
|
||||||
m.mouseDragged(e);
|
m.mouseDragged(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatch(MessageEvent event) {
|
public void dispatch(MessageEvent event) {
|
||||||
for(final MessageListener messageListener : messageListeners) {
|
for (final MessageListener messageListener : messageListeners) {
|
||||||
messageListener.messageReceived(event);
|
messageListener.messageReceived(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatch(GameActionEvent event) {
|
public void dispatch(GameActionEvent event) {
|
||||||
for(final GameActionListener a : actionListeners) {
|
for (final GameActionListener a : actionListeners) {
|
||||||
a.onGameAction(event);
|
a.onGameAction(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,73 +1,69 @@
|
|||||||
package org.rev317.min.ui;
|
package org.rev317.min.ui;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
import org.rev317.min.debug.*;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JCheckBoxMenuItem;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
|
|
||||||
import org.rev317.min.debug.*;
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
|
||||||
|
|
||||||
|
|
||||||
public class BotMenu implements ActionListener {
|
public class BotMenu implements ActionListener {
|
||||||
|
|
||||||
public BotMenu(JMenuBar bar) {
|
public BotMenu(JMenuBar bar) {
|
||||||
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
||||||
|
|
||||||
JMenu debug = new JMenu("Debug");
|
JMenu debug = new JMenu("Debug");
|
||||||
|
|
||||||
JMenuItem inventory = newItem("Inventory");
|
JMenuItem inventory = newItem("Inventory");
|
||||||
JMenuItem bank = newItem("Bank");
|
JMenuItem bank = newItem("Bank");
|
||||||
JMenuItem map = newItem("Map");
|
JMenuItem map = newItem("Map");
|
||||||
JMenuItem animation = newItem("Animation");
|
JMenuItem animation = newItem("Animation");
|
||||||
JMenuItem objects = newItem("Objects");
|
JMenuItem objects = newItem("Objects");
|
||||||
JMenuItem npcs = newItem("Npcs");
|
JMenuItem npcs = newItem("Npcs");
|
||||||
JMenuItem items = newItem("GroundItems");
|
JMenuItem items = newItem("GroundItems");
|
||||||
JMenuItem interfaces = newItem("Interfaces");
|
JMenuItem interfaces = newItem("Interfaces");
|
||||||
JMenuItem flags = newItem("Collision flags");
|
JMenuItem flags = newItem("Collision flags");
|
||||||
JMenuItem actions = newItem("Actions");
|
JMenuItem actions = newItem("Actions");
|
||||||
JMenuItem mouse = newItem("Mouse");
|
JMenuItem mouse = newItem("Mouse");
|
||||||
|
|
||||||
debugger.addDebugger("Actions", new DActions());
|
debugger.addDebugger("Actions", new DActions());
|
||||||
debugger.addDebugger("Animation", new DAnimation());
|
debugger.addDebugger("Animation", new DAnimation());
|
||||||
debugger.addDebugger("Inventory", new DInventory());
|
debugger.addDebugger("Inventory", new DInventory());
|
||||||
debugger.addDebugger("Bank", new DBank());
|
debugger.addDebugger("Bank", new DBank());
|
||||||
debugger.addDebugger("Map", new DMap());
|
debugger.addDebugger("Map", new DMap());
|
||||||
debugger.addDebugger("Objects", new DSceneObjects());
|
debugger.addDebugger("Objects", new DSceneObjects());
|
||||||
debugger.addDebugger("Npcs", new DNpcs());
|
debugger.addDebugger("Npcs", new DNpcs());
|
||||||
debugger.addDebugger("GroundItems", new DGroundItems());
|
debugger.addDebugger("GroundItems", new DGroundItems());
|
||||||
debugger.addDebugger("Interfaces", new DInterfaces());
|
debugger.addDebugger("Interfaces", new DInterfaces());
|
||||||
debugger.addDebugger("Collision flags", new DCollisionFlags());
|
debugger.addDebugger("Collision flags", new DCollisionFlags());
|
||||||
debugger.addDebugger("Mouse", new DMouse());
|
debugger.addDebugger("Mouse", new DMouse());
|
||||||
|
|
||||||
debug.add(actions);
|
debug.add(actions);
|
||||||
debug.add(map);
|
debug.add(map);
|
||||||
debug.add(animation);
|
debug.add(animation);
|
||||||
debug.add(objects);
|
debug.add(objects);
|
||||||
debug.add(npcs);
|
debug.add(npcs);
|
||||||
debug.add(items);
|
debug.add(items);
|
||||||
debug.add(interfaces);
|
debug.add(interfaces);
|
||||||
debug.add(flags);
|
debug.add(flags);
|
||||||
debug.add(inventory);
|
debug.add(inventory);
|
||||||
debug.add(bank);
|
debug.add(bank);
|
||||||
debug.add(mouse);
|
debug.add(mouse);
|
||||||
|
|
||||||
bar.add(debug);
|
bar.add(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JMenuItem newItem(String name) {
|
private JMenuItem newItem(String name) {
|
||||||
JMenuItem item = new JCheckBoxMenuItem(name);
|
JMenuItem item = new JCheckBoxMenuItem(name);
|
||||||
item.addActionListener(this);
|
item.addActionListener(this);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Context.getInstance().getPaintDebugger().toggle(e.getActionCommand());
|
Context.getInstance().getPaintDebugger().toggle(e.getActionCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user