mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-05 16:49:42 +00:00
Changed package
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.parabot.environment.api.utils.Filter;
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.parabot.environment.input.Keyboard;
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.api.wrappers.Item;
|
||||
import org.rev317.min.api.wrappers.Npc;
|
||||
import org.rev317.min.api.wrappers.SceneObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Bank {
|
||||
public static final int BANK_INTERFACE = 5292;
|
||||
public static final int ITEM_INTERFACE = 5382;
|
||||
public static final int BUTTON_DEPOSIT_ALL = 5386;
|
||||
public static final int INV_PARENT_ID = 5064;
|
||||
|
||||
public static final int[] BANKERS = new int[] { 44, 45, 494, 495, 498, 499,
|
||||
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
|
||||
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
|
||||
9710, 14367 };
|
||||
public static final int[] BANKS = new int[] { 782, 2213, 2995, 5276, 6084,
|
||||
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
|
||||
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
|
||||
4483, 12308, 20607, 21301, 27663, 42192 };
|
||||
|
||||
/**
|
||||
* Gets nearest banker
|
||||
*
|
||||
* @return nearest banker
|
||||
*/
|
||||
public static Npc getBanker() {
|
||||
return Npcs.getNearest(new Filter<Npc>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(Npc f) {
|
||||
for (int id : BANKERS) {
|
||||
if (id == f.getDef().getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
})[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets nearest bank booths
|
||||
*
|
||||
* @return bank booths
|
||||
*/
|
||||
public static SceneObject[] getNearestBanks() {
|
||||
return SceneObjects.getNearest(BANKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets nearest bank booths
|
||||
*
|
||||
* @return bank booth
|
||||
*/
|
||||
public static SceneObject getBank() {
|
||||
SceneObject[] banks = getNearestBanks();
|
||||
if (banks != null && banks[0] != null) {
|
||||
return banks[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens bank using banker or bank booth
|
||||
*
|
||||
* @return <b>true</b> if successfully interacted
|
||||
*/
|
||||
public static boolean open() {
|
||||
|
||||
if (isOpen()) {
|
||||
return false;
|
||||
}
|
||||
SceneObject bank = getBank();
|
||||
Npc banker = getBanker();
|
||||
|
||||
if (bank != null) {
|
||||
bank.interact(1);
|
||||
return true;
|
||||
} else if (banker != null) {
|
||||
banker.interact(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits all items
|
||||
*/
|
||||
public static void depositAll() {
|
||||
Menu.clickButton(BUTTON_DEPOSIT_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraws items at bank based on given parameters
|
||||
*
|
||||
* @param id
|
||||
* @param amount
|
||||
*/
|
||||
public static void withdraw(int id, int amount, int sleep) {
|
||||
|
||||
if (!isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item b = getItem(id);
|
||||
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount == 1) {
|
||||
b.transform(0, INV_PARENT_ID);
|
||||
} else if (amount == 5) {
|
||||
b.transform(1, INV_PARENT_ID);
|
||||
} else if (amount == 10) {
|
||||
b.transform(2, INV_PARENT_ID);
|
||||
} else if (amount == 0) {
|
||||
b.transform(3, INV_PARENT_ID);
|
||||
} else {
|
||||
b.transform(4, INV_PARENT_ID);
|
||||
Time.sleep(1500 + sleep);
|
||||
Keyboard.getInstance().sendKeys("" + amount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bank item with given id
|
||||
*
|
||||
* @param id
|
||||
* @return bank item
|
||||
*/
|
||||
public static Item getItem(int id) {
|
||||
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Item i : Bank.getBankItems()) {
|
||||
if (i.getId() == id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the amount of items with given id in bank
|
||||
*
|
||||
* @param id
|
||||
* @return count
|
||||
*/
|
||||
public static int getCount(int id) {
|
||||
if (!isOpen()) {
|
||||
return 0;
|
||||
}
|
||||
return getItem(id).getStackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the bank
|
||||
*
|
||||
* @param bank
|
||||
* booth
|
||||
*/
|
||||
public static void open(SceneObject bank) {
|
||||
|
||||
if (isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bank.getLocation().distanceTo() > 8) {
|
||||
bank.getLocation().walkTo();
|
||||
return;
|
||||
}
|
||||
bank.interact(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes the bank interface
|
||||
*/
|
||||
public static void close() {
|
||||
if (!isOpen()) {
|
||||
return;
|
||||
}
|
||||
//[index: 1, action1: -1, action2: -1, action3: 5384, id: 200]
|
||||
Menu.sendAction(200, -1, -1, 5384);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits all items except the given ids
|
||||
*
|
||||
* @param exceptions
|
||||
* the item indexes that will be ignored.
|
||||
*/
|
||||
public static void depositAllExcept(int... exceptions) {
|
||||
if (Bank.isOpen()) {
|
||||
final ArrayList<Integer> ignored = new ArrayList<Integer>();
|
||||
for (int i : exceptions) {
|
||||
ignored.add(i);
|
||||
}
|
||||
for (Item i : Inventory.getItems()) {
|
||||
if (!ignored.contains(i.getId())) {
|
||||
while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) {
|
||||
i.transform(3, INV_PARENT_ID);
|
||||
ignored.add(i.getId());
|
||||
Time.sleep(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all bank item ids in bank
|
||||
*
|
||||
* @return bank items
|
||||
*/
|
||||
public static int[] getBankItemIDs() {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
return Loader.getClient().getInterfaceCache()[5382].getItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all stack sizes in bank
|
||||
*
|
||||
* @return stack sizes
|
||||
*/
|
||||
public static int[] getBankStacks() {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
return Loader.getClient().getInterfaceCache()[5382].getStackSizes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all bank items in bank
|
||||
*
|
||||
* @return bank items
|
||||
*/
|
||||
public static Item[] getBankItems() {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<Item> items = new ArrayList<Item>();
|
||||
int[] ids = getBankItemIDs();
|
||||
int[] stacks = getBankStacks();
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (ids[i] > 0) {
|
||||
items.add(new Item(ids[i], stacks[i], i));
|
||||
}
|
||||
}
|
||||
return (Item[]) items.toArray(new Item[items.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts total amount of items in bank
|
||||
*
|
||||
* @return total amount of items
|
||||
*/
|
||||
public static int getBankCount() {
|
||||
if (!isOpen()) {
|
||||
return 0;
|
||||
}
|
||||
return getBankItemIDs().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if bank is open
|
||||
*
|
||||
* @return <b>true</b> if bank is open
|
||||
*/
|
||||
public static boolean isOpen() {
|
||||
return Loader.getClient().getOpenInterfaceId() == BANK_INTERFACE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import org.rev317.min.api.wrappers.Tile;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Calculations {
|
||||
|
||||
/**
|
||||
* Calculates distance between local player and given tile
|
||||
*
|
||||
* @param tile
|
||||
* @return distance between local player and given tile
|
||||
*/
|
||||
public static final double distanceTo(Tile tile) {
|
||||
return distanceBetween(tile, Players.getMyPlayer().getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates distance between two given tiles
|
||||
* @param a
|
||||
* @param b
|
||||
* @return distance between a and b
|
||||
*/
|
||||
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 findAdjacent if it's an object, it will find path which touches it.
|
||||
* @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was found.
|
||||
*/
|
||||
public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) {
|
||||
try {
|
||||
final int[][] prev = new int[104][104];
|
||||
final int[][] dist = new int[104][104];
|
||||
final int[] path_x = new int[4000];
|
||||
final int[] path_y = new int[4000];
|
||||
for (int xx = 0; xx < 104; xx++) {
|
||||
for (int yy = 0; yy < 104; yy++) {
|
||||
prev[xx][yy] = 0;
|
||||
dist[xx][yy] = 99999999;
|
||||
}
|
||||
}
|
||||
int curr_x = startX;
|
||||
int curr_y = startY;
|
||||
prev[startX][startY] = 99;
|
||||
dist[startX][startY] = 0;
|
||||
int path_ptr = 0;
|
||||
int step_ptr = 0;
|
||||
path_x[path_ptr] = startX;
|
||||
path_y[path_ptr++] = startY;
|
||||
final int blocks[][] = Game.getCollisionFlags();
|
||||
final int pathLength = path_x.length;
|
||||
boolean foundPath = false;
|
||||
while (step_ptr != path_ptr) {
|
||||
curr_x = path_x[step_ptr];
|
||||
curr_y = path_y[step_ptr];
|
||||
if (Math.abs(curr_x - destX) + Math.abs(curr_y - destY) == (findAdjacent ? 1 : 0)) {
|
||||
foundPath = true;
|
||||
break;
|
||||
}
|
||||
step_ptr = (step_ptr + 1) % pathLength;
|
||||
final int cost = dist[curr_x][curr_y] + 1;
|
||||
// south
|
||||
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;
|
||||
path_y[path_ptr] = curr_y - 1;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x][curr_y - 1] = 1;
|
||||
dist[curr_x][curr_y - 1] = cost;
|
||||
}
|
||||
// west
|
||||
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;
|
||||
path_y[path_ptr] = curr_y;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x - 1][curr_y] = 2;
|
||||
dist[curr_x - 1][curr_y] = cost;
|
||||
}
|
||||
// north
|
||||
if (curr_y < 104 - 1 && prev[curr_x][curr_y + 1] == 0 && (blocks[curr_x][curr_y + 1] &
|
||||
0x1280120) == 0) {
|
||||
path_x[path_ptr] = curr_x;
|
||||
path_y[path_ptr] = curr_y + 1;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x][curr_y + 1] = 4;
|
||||
dist[curr_x][curr_y + 1] = cost;
|
||||
}
|
||||
// east
|
||||
if (curr_x < 104 - 1 && prev[curr_x + 1][curr_y] == 0 && (blocks[curr_x + 1][curr_y] &
|
||||
0x1280180) == 0) {
|
||||
path_x[path_ptr] = curr_x + 1;
|
||||
path_y[path_ptr] = curr_y;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x + 1][curr_y] = 8;
|
||||
dist[curr_x + 1][curr_y] = cost;
|
||||
}
|
||||
// south west
|
||||
if (curr_x > 0 && curr_y > 0 && prev[curr_x - 1][curr_y - 1] == 0 && (blocks[curr_x - 1][curr_y - 1] &
|
||||
0x128010E) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0 && (blocks[curr_x
|
||||
][curr_y - 1] & 0x1280102) == 0) {
|
||||
path_x[path_ptr] = curr_x - 1;
|
||||
path_y[path_ptr] = curr_y - 1;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x - 1][curr_y - 1] = 3;
|
||||
dist[curr_x - 1][curr_y - 1] = cost;
|
||||
}
|
||||
// north west
|
||||
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) ==
|
||||
0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) {
|
||||
path_x[path_ptr] = curr_x - 1;
|
||||
path_y[path_ptr] = curr_y + 1;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x - 1][curr_y + 1] = 6;
|
||||
dist[curr_x - 1][curr_y + 1] = cost;
|
||||
}
|
||||
// south east
|
||||
if (curr_x < 104 - 1 && curr_y > 0 && prev[curr_x + 1][curr_y - 1] == 0 && (blocks[curr_x +
|
||||
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;
|
||||
path_y[path_ptr] = curr_y - 1;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x + 1][curr_y - 1] = 9;
|
||||
dist[curr_x + 1][curr_y - 1] = cost;
|
||||
}
|
||||
// north east
|
||||
if (curr_x < 104 - 1 && curr_y < 104 - 1 && prev[curr_x + 1][curr_y + 1] == 0 && (blocks[curr_x
|
||||
+ 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;
|
||||
path_ptr = (path_ptr + 1) % pathLength;
|
||||
prev[curr_x + 1][curr_y + 1] = 12;
|
||||
dist[curr_x + 1][curr_y + 1] = cost;
|
||||
}
|
||||
}
|
||||
return foundPath ? dist[curr_x][curr_y] : -1;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import org.rev317.min.Loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Game {
|
||||
|
||||
/**
|
||||
* Gets BaseX
|
||||
* @return baseX
|
||||
*/
|
||||
public static int getBaseX() {
|
||||
return Loader.getClient().getBaseX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets BaseY
|
||||
* @return baseY
|
||||
*/
|
||||
public static int getBaseY() {
|
||||
return Loader.getClient().getBaseY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets open interface id
|
||||
* @return interface id
|
||||
*/
|
||||
public static int getOpenInterfaceId() {
|
||||
return Loader.getClient().getOpenInterfaceId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get open back dialog id
|
||||
* @return back dialog id
|
||||
*/
|
||||
public static int getOpenBackDialogId() {
|
||||
return Loader.getClient().getBackDialogId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets loop cycle
|
||||
* @return loop cycle
|
||||
*/
|
||||
public static int getLoopCycle() {
|
||||
return Loader.getClient().getLoopCycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision flags
|
||||
* @return collision flags
|
||||
*/
|
||||
public static int[][] getCollisionFlags() {
|
||||
return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets current plane
|
||||
* @return current plane
|
||||
*/
|
||||
public static int getPlane() {
|
||||
return Loader.getClient().getPlane();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
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.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.accessors.Deque;
|
||||
import org.rev317.min.accessors.Node;
|
||||
import org.rev317.min.api.wrappers.GroundItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class GroundItems {
|
||||
private static Client client;
|
||||
|
||||
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
|
||||
|
||||
@Override
|
||||
public int compare(GroundItem n1, GroundItem n2) {
|
||||
return n1.distanceTo() - n2.distanceTo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(GroundItem item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets all loaded ground items
|
||||
*
|
||||
* @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 ground items in game
|
||||
*
|
||||
* @return ground items
|
||||
*/
|
||||
public static final GroundItem[] getGroundItems() {
|
||||
return getGroundItems(ALL_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of GroundItems with the first index to be the nearest
|
||||
*
|
||||
* @param filter
|
||||
* @return GroundItems
|
||||
*/
|
||||
public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
|
||||
final GroundItem[] objects = getGroundItems(filter);
|
||||
Arrays.sort(objects, NEAREST_SORTER);
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of GroundItems with the first index to be the nearest
|
||||
*
|
||||
* @return GroundItems
|
||||
*/
|
||||
public static final GroundItem[] getNearest() {
|
||||
return getNearest(ALL_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.parabot.environment.api.utils.Filter;
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Interface;
|
||||
import org.rev317.min.api.wrappers.Item;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Inventory {
|
||||
public static final int INVENTORY_INDEX = 3214;
|
||||
|
||||
private static final Filter<Item> ALL_FILTER = new Filter<Item>() {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets inventory interface
|
||||
* @return interface of inventory
|
||||
*/
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.api.wrappers.Character;
|
||||
import org.rev317.min.api.wrappers.GroundItem;
|
||||
import org.rev317.min.api.wrappers.Item;
|
||||
import org.rev317.min.api.wrappers.SceneObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Menu {
|
||||
public static final int ACTION_CLICK_BUTTON = 646;
|
||||
public static final int ACTION_DROP_ITEM = 847;
|
||||
public static final int ACTION_TAKE_ITEM = 234;
|
||||
|
||||
private static HashMap<String, String> constants;
|
||||
|
||||
/**
|
||||
* Interacts with a sceneobject
|
||||
* @param object
|
||||
* @param actionIndex
|
||||
*/
|
||||
public static void interact(SceneObject object, int actionIndex) {
|
||||
int actionId = 502;
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
actionId = 502;
|
||||
break;
|
||||
case 1:
|
||||
actionId = 900;
|
||||
break;
|
||||
case 2:
|
||||
actionId = 113;
|
||||
break;
|
||||
case 3:
|
||||
actionId = 872;
|
||||
break;
|
||||
case 4:
|
||||
actionId = 1062;
|
||||
break;
|
||||
}
|
||||
sendAction(actionId, object.getId(), object.getLocalRegionX(), object.getLocalRegionY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Interacts with a character
|
||||
* @param character
|
||||
* @param actionIndex
|
||||
*/
|
||||
public static void interact(Character character, int actionIndex) {
|
||||
int actionId = 20;
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
actionId = 20;
|
||||
break;
|
||||
case 1:
|
||||
actionId = 412;
|
||||
break;
|
||||
case 2:
|
||||
actionId = 225;
|
||||
break;
|
||||
case 3:
|
||||
actionId = 965;
|
||||
break;
|
||||
case 4:
|
||||
actionId = 478;
|
||||
break;
|
||||
}
|
||||
sendAction(actionId, character.getIndex(), 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interacts with an item when it has the following menu
|
||||
* Transform-1
|
||||
* Transform-5
|
||||
* Transform-10
|
||||
* etc..
|
||||
* @param item
|
||||
* @param actionIndex
|
||||
* @param interfaceParentId
|
||||
*/
|
||||
public static void transformItem(Item item, int actionIndex,
|
||||
int interfaceParentId) {
|
||||
int actionId = 632;
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
actionId = 632;
|
||||
break;
|
||||
case 1:
|
||||
actionId = 78;
|
||||
break;
|
||||
case 2:
|
||||
actionId = 867;
|
||||
break;
|
||||
case 3:
|
||||
actionId = 431;
|
||||
break;
|
||||
case 4:
|
||||
actionId = 53;
|
||||
break;
|
||||
}
|
||||
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
|
||||
* @param item
|
||||
* @param action
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops an item
|
||||
* @param item
|
||||
*/
|
||||
public static void drop(Item item) {
|
||||
sendAction(ACTION_DROP_ITEM, (int) item.getId() - 1, item.getSlot(),
|
||||
Inventory.INVENTORY_INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks a button
|
||||
* @param id
|
||||
*/
|
||||
public static void clickButton(int id) {
|
||||
sendAction(ACTION_CLICK_BUTTON, 0, 0, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an action to the client
|
||||
* @param action
|
||||
* @param cmd1
|
||||
* @param cmd2
|
||||
* @param cmd3
|
||||
* @param cmd4
|
||||
*/
|
||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4) {
|
||||
if (constants == null) {
|
||||
constants = Context.getInstance().getHookParser().getConstants();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
Client client = Loader.getClient();
|
||||
|
||||
client.getMenuAction1()[index] = cmd1;
|
||||
client.getMenuAction2()[index] = cmd2;
|
||||
client.getMenuAction3()[index] = cmd3;
|
||||
client.getMenuActionId()[index] = action;
|
||||
|
||||
|
||||
client.doAction(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
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.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.api.wrappers.Npc;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Npcs {
|
||||
|
||||
private static final Comparator<Npc> NEAREST_SORTER = new Comparator<Npc>() {
|
||||
|
||||
@Override
|
||||
public int compare(Npc n1, Npc n2) {
|
||||
return n1.distanceTo() - n2.distanceTo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final Filter<Npc> ALL_FILTER = new Filter<Npc>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(Npc n) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets all Npcs except local Npc
|
||||
*
|
||||
* @param filter
|
||||
* @return all Npcs
|
||||
*/
|
||||
public static final Npc[] getNpcs(final Filter<Npc> filter) {
|
||||
final Client client = Loader.getClient();
|
||||
ArrayList<Npc> npcList = new ArrayList<Npc>();
|
||||
final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs();
|
||||
for (int i = 0; i < accNpcs.length; i++) {
|
||||
if(accNpcs[i] == null) {
|
||||
continue;
|
||||
}
|
||||
final Npc npc = new Npc(accNpcs[i], i);
|
||||
if (filter.accept(npc)) {
|
||||
npcList.add(npc);
|
||||
}
|
||||
}
|
||||
return npcList.toArray(new Npc[npcList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all Npcs
|
||||
*
|
||||
* @return all Npcs
|
||||
*/
|
||||
public static final Npc[] getNpcs() {
|
||||
return getNpcs(ALL_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array with the first index to be the nearest Npc
|
||||
*
|
||||
* @param filter
|
||||
* @return nearest Npcs
|
||||
*/
|
||||
public static final Npc[] getNearest(final Filter<Npc> filter) {
|
||||
final Npc[] npcs = getNpcs(filter);
|
||||
Arrays.sort(npcs, NEAREST_SORTER);
|
||||
return npcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets nearest npcs which hold given id(s)
|
||||
*
|
||||
* @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
|
||||
public boolean accept(Npc npc) {
|
||||
for (final int id : ids) {
|
||||
if (id == npc.getDef().getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
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.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.api.wrappers.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Players {
|
||||
|
||||
private static final Comparator<Player> NEAREST_SORTER = new Comparator<Player>() {
|
||||
|
||||
@Override
|
||||
public int compare(Player p1, Player p2) {
|
||||
return p1.distanceTo() - p2.distanceTo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final Filter<Player> ALL_FILTER = new Filter<Player>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(Player p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets all players except local player
|
||||
* @param filter
|
||||
* @return all players
|
||||
*/
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
final Player player = new Player(accPlayers[i], i);
|
||||
if(filter.accept(player)) {
|
||||
playerList.add(player);
|
||||
}
|
||||
}
|
||||
return playerList.toArray(new Player[playerList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all players except local player
|
||||
* @return all players
|
||||
*/
|
||||
public static final Player[] getPlayers() {
|
||||
return getPlayers(ALL_FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array with the first index to be the nearest player
|
||||
* @param filter
|
||||
* @return nearest players
|
||||
*/
|
||||
public static final Player[] getNearest(final Filter<Player> filter) {
|
||||
final Player[] players = getPlayers(filter);
|
||||
Arrays.sort(players, NEAREST_SORTER);
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Ground;
|
||||
import org.rev317.min.accessors.SceneObjectTile;
|
||||
import org.rev317.min.api.wrappers.SceneObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class SceneObjects {
|
||||
|
||||
private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() {
|
||||
|
||||
@Override
|
||||
public int compare(SceneObject n1,SceneObject n2) {
|
||||
return n1.distanceTo() - n2.distanceTo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final Filter<SceneObject> ALL_FILTER = new Filter<SceneObject>() {
|
||||
|
||||
@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
|
||||
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) {
|
||||
SceneObject[] nearestObjects = getNearest(new Filter<SceneObject>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(SceneObject object) {
|
||||
for(final int id : ids) {
|
||||
if(id == object.getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets every loaded scene object in game
|
||||
* @return every loaded scene object in game
|
||||
*/
|
||||
public static final SceneObject[] getAllSceneObjects() {
|
||||
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
||||
for(int x = 0; x < 104; x++) {
|
||||
for(int y = 0; y < 104; y++) {
|
||||
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
|
||||
if(sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
|
||||
sceneObjects.addAll(sceneObjectsAtTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all sceneobjects at a tile
|
||||
* @param x
|
||||
* @param y
|
||||
* @param useCached
|
||||
* @return array of sceneobjects, or null if there aren't any
|
||||
*/
|
||||
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import org.rev317.min.Loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dane
|
||||
*
|
||||
*/
|
||||
public enum Skill {
|
||||
|
||||
ATTACK(0), DEFENSE(1), STRENGTH(2), HITPOINTS(3), CONSTITUTION(3), RANGE(4), PRAYER(
|
||||
5), MAGIC(6), COOKING(7), WOODCUTTING(8), FLETCHING(9), FISHING(10), FIREMAKING(
|
||||
11), CRAFTING(12), SMITHING(13), MINING(14), HERBLORE(15), HERBLAW(
|
||||
15), AGILITY(16), THIEVING(17), SLAYER(18), FARMING(19), RUNECRAFTING(
|
||||
20), HUNTER(21), CONSTRUCTION(22), SUMMONING(23), DUNGEONEERING(24);
|
||||
|
||||
private static final int[] EXPERIENCE = { 0, 0, 83, 174, 276, 388, 512,
|
||||
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
|
||||
3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,
|
||||
12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
|
||||
30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983,
|
||||
75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872,
|
||||
166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804,
|
||||
368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627,
|
||||
814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,
|
||||
1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,
|
||||
3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831,
|
||||
6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606,
|
||||
13034431, 14391160, 15889109, 17542976, 19368992, 21385073,
|
||||
23611006, 26068632, 28782069, 31777943, 35085654, 38737661,
|
||||
42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
|
||||
77474828, 85539082, 94442737, 104273167 };
|
||||
|
||||
private int index;
|
||||
|
||||
private Skill(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the skill's index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the skill.
|
||||
*/
|
||||
public final String getName() {
|
||||
return Character.toUpperCase(name().charAt(0))
|
||||
+ name().toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current experience.
|
||||
*/
|
||||
public final int getExperience() {
|
||||
return Skill.getCurrentExperience(this.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real level.
|
||||
*/
|
||||
public final int getRealLevel() {
|
||||
return Skill.getRealLevel(this.getIndex());
|
||||
}
|
||||
|
||||
public final int getLevel() {
|
||||
return Skill.getRealLevel(this.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remaining experience until the next level.
|
||||
*/
|
||||
public final int getRemaining() {
|
||||
return Skill.getRemainingExperience(this.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage until the next level.
|
||||
*/
|
||||
public final int getPercentage() {
|
||||
return Skill.getPercentToNextLevel(this.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns '[Name, Level / RealLevel]'
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
|
||||
+ this.getRealLevel() + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the experience of the provided skill.
|
||||
*
|
||||
* @param index
|
||||
* the skill index.
|
||||
* @return the experience.
|
||||
*/
|
||||
public static final int getCurrentExperience(int index) {
|
||||
return Loader.getClient().getCurrentExp()[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real level of the provided skill.
|
||||
*
|
||||
* @param index
|
||||
* the skill index.
|
||||
* @return the real skill level.
|
||||
*/
|
||||
public static final int getRealLevel(int index) {
|
||||
return getLevelByExperience(getCurrentExperience(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exact experience at the provided level.
|
||||
*
|
||||
* @param level
|
||||
* the level.
|
||||
* @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.
|
||||
*
|
||||
* @param experience
|
||||
* the experience.
|
||||
* @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 for the provided skill to level up.
|
||||
*
|
||||
* @param index
|
||||
* the skill index.
|
||||
* @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.
|
||||
*
|
||||
* @param index
|
||||
* the skill index.
|
||||
* @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]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.rev317.min.api.methods;
|
||||
|
||||
import org.rev317.min.Loader;
|
||||
import org.rev317.min.api.wrappers.Tile;
|
||||
import org.rev317.min.api.wrappers.TilePath;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Walking {
|
||||
|
||||
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
|
||||
* @return <b>true</b> if destination reached, otherwise <b>false</b>
|
||||
*/
|
||||
public static boolean walkDown(TilePath tilePath) {
|
||||
if(tilePath.hasReached()) {
|
||||
return true;
|
||||
}
|
||||
tilePath.traverse();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user