Advertisement
iant06

Untitled

Sep 17th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. package scripts.moneymaking.iplankfarmer.equipment;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api2007.Banking;
  6. import org.tribot.api2007.Equipment;
  7. import org.tribot.api2007.GameTab;
  8. import org.tribot.api2007.Interfaces;
  9. import org.tribot.api2007.Inventory;
  10. import org.tribot.api2007.WebWalking;
  11. import org.tribot.api2007.Equipment.SLOTS;
  12. import org.tribot.api2007.GameTab.TABS;
  13. import org.tribot.api2007.types.RSInterfaceChild;
  14. import org.tribot.api2007.types.RSItem;
  15.  
  16. import scripts.moneymaking.iplankfarmer.Script;
  17. import scripts.moneymaking.iplankfarmer.types.State;
  18. import scripts.moneymaking.iplankfarmer.utils.Constants;
  19. import scripts.moneymaking.iplankfarmer.utils.Locations;
  20.  
  21. public class DuelRing {
  22.  
  23. private Script script;
  24.  
  25. public DuelRing(Script script) {
  26. setScript(script);
  27. }
  28.  
  29. public boolean isWearing() {
  30. RSItem[] ring = Equipment.find(SLOTS.RING);
  31. return ring != null && ring.length > 0;
  32. }
  33.  
  34. public void rub() {
  35. RSItem[] ring = Equipment.find(Constants.DUEL_RING);
  36. if(ring != null && ring.length >= 0) {
  37. GameTab.open(TABS.EQUIPMENT);
  38. RSInterfaceChild duelInterface = Interfaces.get(Constants.DUEL_TELEPORT_INTERFACE, Constants.CASTLE_WARS_CHILD_ID);
  39. while(duelInterface == null && !Locations.isInsideCastleWars()) {
  40. ring[0].click("Operate");
  41. duelInterface = Interfaces.get(Constants.DUEL_TELEPORT_INTERFACE, Constants.CASTLE_WARS_CHILD_ID);
  42. }
  43. while(duelInterface != null && !Locations.isInsideCastleWars()) {
  44. duelInterface.click("Continue");
  45. }
  46. if(Locations.isInsideCastleWars()) {
  47. double duelRingPrice = getScript().getDuelRingPrice();
  48. double telePrice = duelRingPrice / 8;
  49. double moneySpent = getScript().getData().getMoneySpent();
  50. getScript().getData().setMoneySpent(moneySpent + telePrice);
  51. WebWalking.walkTo(Locations.CASTLE_WARS_TILE);
  52. getScript().setState(State.BANKING);
  53. }
  54. }
  55. }
  56.  
  57. public void equip() {
  58. RSItem[] ring = Inventory.find(Constants.DUEL_RING);
  59. if(ring != null && ring.length > 0) {
  60. while(!isWieldingRing(1000)) {
  61. ring[0].click("Wear");
  62. }
  63. }
  64. }
  65.  
  66. public boolean withdraw() {
  67. if(getScript().getBanking().openBankScreen()) {
  68. RSItem[] ring = Banking.find(Constants.DUEL_RING);
  69. if(ring != null && ring.length > 0) {
  70. ring[0].click("Withdraw-1");
  71. if(getScript().getBanking().isItemWithdrawn(ring[0].getID(), 1000)) {
  72. Banking.close();
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79.  
  80. private boolean isWieldingRing(int i) {
  81. long t = System.currentTimeMillis();
  82. while (Timing.timeFromMark(t) < i + General.random(100, 200)) {
  83. RSItem[] item = Equipment.find(SLOTS.RING);
  84. if (item != null && item.length > 0) {
  85. return true;
  86. }
  87. getScript().sleep(50, 150);
  88. }
  89. return false;
  90. }
  91.  
  92. public void setScript(Script script) {
  93. this.script = script;
  94. }
  95.  
  96. public Script getScript() {
  97. return script;
  98. }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement