Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package wall_safer;
- import java.util.ArrayList;
- import java.util.List;
- import org.osbot.pl;
- import org.osbot.script.Script;
- import org.osbot.script.rs2.map.Position;
- import org.osbot.script.rs2.model.Item;
- import org.osbot.script.rs2.model.Player;
- import org.osbot.script.rs2.model.RS2Object;
- public class Methods {
- static Script script = Context.script;
- /*
- * @Param Locations An Array of positions
- *
- * @Param Object the name of the RS2Object
- *
- * This method will return the object if all the players in the region are
- * not on the locations
- */
- public static ArrayList<Position> getPlayerPositions() {
- List<Player> players = Context.script.client.getLocalPlayers();
- ArrayList<Position> pos = new ArrayList<Position>();
- for (int i = 0; i < players.size(); i++) {
- if (players.get(i).exists()) {
- pos.add(players.get(i).getPosition());
- }
- }
- if (pos.contains(Context.script.client.getMyPlayer().getPosition())) {
- pos.remove(Context.script.client.getMyPlayer().getPosition());
- }
- return pos;
- }
- public static Position getBestSafePosition(Position[] locations,
- ArrayList<Position> players) {
- for (int i = 0; i < locations.length; i++) {
- boolean locationFree = true;
- for (int p = 0; p < players.size(); p++) {
- if (locations[i].equals(players.get(p))) {
- locationFree = false;
- break;
- }
- }
- if (locationFree) {
- return locations[i];
- }
- }
- return null;
- }
- /*
- * @Param food the string of the food name and also will just check if
- * inventory contains food and it will eat food
- */
- public static RS2Object getObjectAt(Position p, int id) {
- List<RS2Object> o = Context.script.client.getCurrentRegion()
- .getObjects();
- RS2Object correct = null;
- for (int i = 0; i < o.size(); i++) {
- if (o.get(i) != null) {
- if (o.get(i).getPosition().getX() == p.getX()
- && o.get(i).getPosition().getY() == p.getY()
- && o.get(i).getPosition().getZ() == p.getZ())
- if (o.get(i).getDefinition().getRealId() == id) {
- correct = o.get(i);
- return correct;
- }
- }
- }
- return null;
- }
- public static void eatFood(String food) throws InterruptedException {
- long foodamount = script.client.getInventory().getAmount(food);
- if (foodamount > 0) {
- Context.script.client.getInventory().interactWithName(food, "Eat");
- Context.script.sleep(600 + script.gRandom(100, 200));
- }
- }
- public static int bankItemIdByName(String Item_Name) {
- Item items[] = Context.script.client.getBank().getItems();
- int item_id = 0;
- for (Item single_item : items) {
- if (single_item.getName().equals(Item_Name)) {
- item_id = single_item.getId();
- return item_id;
- }
- }
- return item_id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment