Advertisement
Guest User

Untitled

a guest
Aug 11th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. import org.osbot.script.MethodProvider;
  2. import org.osbot.script.Script;
  3. import org.osbot.script.rs2.map.Position;
  4. import org.osbot.script.rs2.model.Entity;
  5. import org.osbot.script.rs2.model.Player;
  6. import org.osbot.script.rs2.model.RS2Object;
  7. import org.osbot.script.rs2.utility.Area;
  8.  
  9. public class FroobsCowKiller extends Script{
  10.  
  11. private final Area BANK_AREA = (new Area(3099, 3500, 3090, 3487));
  12. private final Area Cow_Area = (new Area(3253 , 3255 ,3264 , 3297) );
  13. final String BANKBOOTH = "Bankbooth";
  14.  
  15. private int[][] path1 = new int[][] { {3245 , 3273 },{3240 , 3288},{3239 , 3304},{3247 , 3315},{3258 , 3325},{3270 , 3332},{3279 , 3323},{3277 , 3308},{3274 , 3290},{3274 , 3273},{3276 , 3257},{3278 , 3241},{3278 , 3225},{3278 , 3207},{3280 , 3192},{3277 , 3174},{3269 , 3168}};
  16. private int[][] path2 = new int[][] { { 3091, 3491 }, { 3088, 3484 },
  17. { 3093, 3475 }, { 3096, 3468 } };
  18.  
  19. public void onstart(){
  20.  
  21. }
  22.  
  23. public void onexit(){
  24.  
  25. }
  26.  
  27.  
  28. public int onloop() throws InterruptedException{
  29.  
  30. Entity cow = closestAttackableNPCForName("Cow");
  31. Player player = client.getMyPlayer();
  32. Entity cowhide = closestGroundItem(1739);
  33.  
  34.  
  35. if (client.getInventory().isFull()) {
  36. walkToBank();
  37. } else {
  38. walkToCows();
  39. }
  40.  
  41. if(player.isInArea(Cow_Area)){
  42. cow.interact("Attack");
  43. }
  44.  
  45. if (player.isInArea(BANK_AREA) && client.getInventory().isFull()) {
  46. bankDeposit();
  47. }
  48.  
  49. if(closestGroundItem(1739) != null){
  50. cowhide.interact("Take");
  51. }
  52.  
  53.  
  54. return 50;
  55. }
  56.  
  57.  
  58.  
  59. public void onpaint(){
  60.  
  61. }
  62.  
  63. public void walkToBank() {
  64. WalkAlongPath(path1, true);
  65. }
  66. public void walkToCows() {
  67. WalkAlongPath(path2, true);
  68. }
  69.  
  70. public boolean WalkAlongPath(int[][] path, boolean AscendThroughPath,
  71. int distanceFromEnd) {
  72. if (distanceToPoint(AscendThroughPath ? path[path.length - 1][0]
  73. : path[0][0], AscendThroughPath ? path[path.length - 1][1]
  74. : path[0][1]) <= distanceFromEnd)
  75. return true;
  76. else {
  77. WalkAlongPath(path, AscendThroughPath);
  78. return false;
  79. }
  80. }
  81.  
  82. public void WalkAlongPath(int[][] path, boolean AscendThroughPath) {
  83. int destination = 0;
  84. for (int i = 0; i < path.length; i++)
  85. if (distanceToPoint(path[i][0], path[i][1]) < distanceToPoint(
  86. path[destination][0], path[destination][1]))
  87. destination = i;
  88. if (client.getMyPlayer().isMoving()
  89. && distanceToPoint(path[destination][0], path[destination][1]) > (isRunning() ? 3
  90. : 2))
  91. return;
  92. if (AscendThroughPath && destination != path.length - 1
  93. || !AscendThroughPath && destination != 0)
  94. destination += (AscendThroughPath ? 1 : -1);
  95. try {
  96. walk(new Position(path[destination][0], path[destination][1], 0));
  97. Thread.sleep(700 + MethodProvider.random(600));
  98. } catch (InterruptedException e) {
  99. e.printStackTrace();
  100. }
  101. }
  102.  
  103. private int distanceToPoint(int pointX, int pointY) {
  104. return (int) Math.sqrt(Math
  105. .pow(client.getMyPlayer().getX() - pointX, 2)
  106. + Math.pow(client.getMyPlayer().getY() - pointY, 2));
  107. }
  108.  
  109. public void bankDeposit() throws InterruptedException {
  110. RS2Object booth = closestObjectForName(new String[] { "Bank booth" });
  111. if ((booth != null) && (booth.interact("Bank"))) {
  112. booth.interact("Bank");
  113. sleep(2500);
  114. }
  115. while (this.client.getMyPlayer().isMoving()) {
  116. sleep(1500);
  117. }
  118. if (this.client.getBank().isOpen()) {
  119. this.client.getBank().depositAll();
  120. sleep(1000);
  121. }
  122. if (this.client.getInventory().isEmpty()) {
  123. this.client.getBank().close();
  124. }
  125. }
  126.  
  127.  
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement