Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. package osbotOS;
  2.  
  3. import java.awt.Color;
  4. import java.util.ArrayList;
  5. import java.util.Collections;
  6.  
  7. import org.osbot.rs07.api.ui.EquipmentSlot;
  8. import org.osbot.rs07.api.ui.Skill;
  9. import org.osbot.rs07.script.Script;
  10.  
  11. import Data.Constants;
  12. import Methods.BankingMethods;
  13. import Methods.Core;
  14. import Methods.PositionMethods;
  15. import Methods.PouchMethods;
  16.  
  17. public class ActivityInBank extends Node {
  18.  
  19. public boolean pouchesFull = false;
  20. public boolean bankingIsDone = false;
  21. public static ArrayList<Node> subnodes = new ArrayList<>();
  22.  
  23. public int eatAt;
  24. public int foodID;
  25. public int foodHeals;
  26. public boolean usingTabs;
  27. public boolean usingGlory;
  28. public boolean usingPrayer;
  29. public boolean usingStam;
  30. public int tabAmount;
  31.  
  32. public boolean needToWithdrawFood;
  33. public boolean needToWithdrawGlory;
  34. public boolean needToWithdrawPrayer;
  35. public boolean needToWithdrawRunes;
  36. public boolean needToWithdrawTabs;
  37. public boolean needToWithdrawStam;
  38.  
  39. public boolean nearBank = this.validateNearBank();
  40.  
  41. public BankingMethods bankMethods = new BankingMethods();
  42. public PositionMethods positionMethods = new PositionMethods();
  43. public PouchMethods pouchMethods = new PouchMethods();
  44. public Core coreMethods = new Core();
  45. public Constants c = new Constants();
  46.  
  47. public ActivityInBank(Script script) {
  48. super(script);
  49.  
  50. this.needToWithdrawFood = this.validateFood();
  51. this.needToWithdrawGlory = this.validateGlory();
  52. this.needToWithdrawPrayer = this.validatePrayer();
  53. this.needToWithdrawRunes = this.validateRunes();
  54. this.needToWithdrawTabs = this.validateTabs();
  55. this.needToWithdrawStam = this.validateStam();
  56.  
  57. // TODO Auto-generated constructor stub
  58. }
  59.  
  60. @Override
  61. public void execute() {
  62. Collections.addAll(subnodes, new SubActivityInBankGetTabs(this.script),
  63. new SubActivityInBankGetRunes(this.script),
  64. new SubActivityInBankGetGlory(this.script),
  65. new SubActivityInBankGetFood(this.script),
  66. new SubActivityInBankGetPrayer(this.script),
  67. new SubActivityInBankGetStam(this.script)); //add all nodes to the ArrayList
  68. this.bankMethods.openBank(this.script, this.c.BANK_ID,
  69. this.c.BANK_OPTION);
  70. while (!this.bankingIsDone) {
  71. for (Node node : subnodes) {
  72. if (node.validate()) {
  73. node.execute();
  74. }
  75. }
  76. this.coreMethods.waitTime(50);
  77. }
  78. this.bankMethods.closeBank(this.script);
  79.  
  80. }
  81.  
  82. @Override
  83. public boolean validate() {
  84. this.bankingIsDone = !(this.needToWithdrawFood
  85. || this.needToWithdrawGlory || this.needToWithdrawPrayer
  86. || this.needToWithdrawRunes || this.needToWithdrawTabs);
  87. this.script.log("Banking is done: " + this.bankingIsDone);
  88. return this.nearBank && !this.bankingIsDone;
  89. }
  90.  
  91. public boolean validateFood() {
  92. int playerMaxHealth = this.script.getSkills()
  93. .getStatic(Skill.HITPOINTS);
  94. int playerHealth = this.script.myPlayer().getHealth();
  95. int currentHealth = playerMaxHealth * (playerHealth / 100);
  96. return (currentHealth <= this.eatAt);
  97. }
  98.  
  99. public boolean validateGlory() {
  100. EquipmentSlot glorySlot = this.script.equipment
  101. .getForNameThatContains("Amulet of glory");
  102. boolean gloryIsEmpty = !this.script.equipment
  103. .isWearingItemThatContains(glorySlot, "Amulet of glory(");
  104. boolean needAGlory = false;
  105. if (gloryIsEmpty) {
  106. needAGlory = true;
  107. }
  108. return (needAGlory && this.usingGlory);
  109. }
  110.  
  111. public boolean validatePrayer() {
  112. int[] prayerIDs = new int[] { 2434, 139, 141, 143 };
  113. boolean hasPrayerPot = this.script.inventory.contains(prayerIDs);
  114. return !hasPrayerPot && this.usingPrayer;
  115. }
  116.  
  117. public boolean validateRunes() {
  118. int[] brokenIds = { 5511, 5513, 5515 };
  119. boolean isBroken = this.script.inventory.contains(brokenIds);
  120. return isBroken;
  121. }
  122.  
  123. public boolean validateTabs() {
  124. boolean hasTabs = this.script.inventory.getAmount("Teleport to house") != 0;
  125. return !hasTabs && this.usingTabs;
  126. }
  127.  
  128. public boolean validateNearBank() {
  129. boolean inBank = this.positionMethods.isPlayerInBox(this.script, 3095,
  130. 3098, 3494, 3497);
  131. return inBank;
  132. }
  133.  
  134. public boolean validateStam() {
  135. Color stamColor = new Color(228, 115, 61); //color at 581 141
  136. boolean needAStam = !this.script.colorPicker.colorAt(581, 141).equals(
  137. stamColor);
  138. return needAStam;
  139. }
  140.  
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement