Guest User

Methods

a guest
Oct 2nd, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. package wall_safer;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.osbot.pl;
  7. import org.osbot.script.Script;
  8. import org.osbot.script.rs2.map.Position;
  9. import org.osbot.script.rs2.model.Item;
  10. import org.osbot.script.rs2.model.Player;
  11. import org.osbot.script.rs2.model.RS2Object;
  12.  
  13. public class Methods {
  14. static Script script = Context.script;
  15.  
  16. /*
  17. * @Param Locations An Array of positions
  18. *
  19. * @Param Object the name of the RS2Object
  20. *
  21. * This method will return the object if all the players in the region are
  22. * not on the locations
  23. */
  24. public static ArrayList<Position> getPlayerPositions() {
  25. List<Player> players = Context.script.client.getLocalPlayers();
  26. ArrayList<Position> pos = new ArrayList<Position>();
  27. for (int i = 0; i < players.size(); i++) {
  28. if (players.get(i).exists()) {
  29. pos.add(players.get(i).getPosition());
  30. }
  31. }
  32. if (pos.contains(Context.script.client.getMyPlayer().getPosition())) {
  33. pos.remove(Context.script.client.getMyPlayer().getPosition());
  34. }
  35. return pos;
  36. }
  37.  
  38. public static Position getBestSafePosition(Position[] locations,
  39. ArrayList<Position> players) {
  40. for (int i = 0; i < locations.length; i++) {
  41. boolean locationFree = true;
  42. for (int p = 0; p < players.size(); p++) {
  43. if (locations[i].equals(players.get(p))) {
  44. locationFree = false;
  45. break;
  46. }
  47. }
  48. if (locationFree) {
  49. return locations[i];
  50. }
  51. }
  52. return null;
  53. }
  54.  
  55. /*
  56. * @Param food the string of the food name and also will just check if
  57. * inventory contains food and it will eat food
  58. */
  59.  
  60. public static RS2Object getObjectAt(Position p, int id) {
  61. List<RS2Object> o = Context.script.client.getCurrentRegion()
  62. .getObjects();
  63. RS2Object correct = null;
  64. for (int i = 0; i < o.size(); i++) {
  65. if (o.get(i) != null) {
  66. if (o.get(i).getPosition().getX() == p.getX()
  67. && o.get(i).getPosition().getY() == p.getY()
  68. && o.get(i).getPosition().getZ() == p.getZ())
  69. if (o.get(i).getDefinition().getRealId() == id) {
  70. correct = o.get(i);
  71. return correct;
  72. }
  73. }
  74. }
  75. return null;
  76. }
  77.  
  78. public static void eatFood(String food) throws InterruptedException {
  79. long foodamount = script.client.getInventory().getAmount(food);
  80. if (foodamount > 0) {
  81. Context.script.client.getInventory().interactWithName(food, "Eat");
  82. Context.script.sleep(600 + script.gRandom(100, 200));
  83. }
  84. }
  85.  
  86. public static int bankItemIdByName(String Item_Name) {
  87. Item items[] = Context.script.client.getBank().getItems();
  88. int item_id = 0;
  89. for (Item single_item : items) {
  90. if (single_item.getName().equals(Item_Name)) {
  91. item_id = single_item.getId();
  92. return item_id;
  93. }
  94. }
  95. return item_id;
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment