Guest User

Untitled

a guest
Oct 23rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. import java.awt.Graphics;
  2.  
  3. import org.rsbuddy.tabs.Attack;
  4. import org.rsbuddy.tabs.Equipment;
  5. import org.rsbuddy.tabs.Prayer;
  6.  
  7. import com.rsbuddy.event.listeners.PaintListener;
  8. import com.rsbuddy.script.ActiveScript;
  9. import com.rsbuddy.script.Manifest;
  10. import com.rsbuddy.script.methods.Game;
  11. import com.rsbuddy.script.methods.Inventory;
  12. import com.rsbuddy.script.methods.Skills;
  13. import com.rsbuddy.script.wrappers.Item;
  14.  
  15. @Manifest(authors = { "Red_Clown" }, name = "Red's Switcher", keywords = { "" }, version = 0.5, description = "")
  16. public class ItemSwitcher extends ActiveScript implements PaintListener {
  17. private int[] prayerPotID = { 2434, 139, 141, 143 };
  18. private int[] strengthPotID = { 2440, 157, 159, 161 };
  19. private int[] attackPotID = { 2436, 145, 147, 149 };
  20. private int[] DDSID = { 1215, 5698, 5680, 1231 };
  21. private int fullPrayerPotRestore = 0;
  22. private int prayerPotRestore = 0;
  23. private int prayerlol = 0;
  24. private int fullStrengthPotRestore = 0;
  25. private int strengthPotRestore = 0;
  26. private int strength = 0;
  27. private int fullAttackPotRestore = 0;
  28. private int attackPotRestore = 0;
  29. private int attacklol = 0;
  30.  
  31. private int strengthLvl = 0;
  32. private int attackLvl = 0;
  33. private int prayerLvl = 0;
  34.  
  35. private int maxHit = 0;
  36.  
  37. private int strengthBonus = 0;
  38. private int baseDamage = 0;
  39. private int effectiveStrength = 0;
  40.  
  41. @Override
  42. public boolean onStart() {
  43. if (Game.isLoggedIn()) {
  44. attackLvl = Skills.getMaxLevel(Skills.ATTACK);
  45. strengthLvl = Skills.getMaxLevel(Skills.STRENGTH);
  46. prayerLvl = Skills.getMaxLevel(Skills.PRAYER);
  47. return true;
  48. }
  49. log("Log-in before using");
  50. return false;
  51. }
  52.  
  53. @Override
  54. public void onFinish() {
  55. }
  56.  
  57. @Override
  58. public int loop() {
  59. if (/* his hp */1 < maxHit) { // need to figure out, perhaps connect to the hi-scores somehow
  60. CheckStrength();
  61. CheckAttack();
  62. if (needToPrayer()) {
  63. executePrayer();
  64. }
  65. SetPrayer();
  66. DDsSpec();
  67. }
  68. return 100;
  69. }
  70.  
  71. private void SetPrayer() {
  72. if (!Prayer.isQuickPrayersActive()) {
  73. Prayer.toggleQuickPrayers(true);
  74. }
  75. }
  76.  
  77. private void CheckStrength() {
  78. if (Inventory.containsOneOf(strengthPotID)) {
  79. if (Skills.getCurrentLevel(Skills.STRENGTH) <= strengthPotRestore
  80. + strengthLvl) {
  81. Item Pot = Inventory.getItem(strengthPotID);
  82. if (Pot.interact("Drink")) {
  83. for (int i = 0; i < 20
  84. && Skills.getCurrentLevel(Skills.STRENGTH) <= strengthPotRestore
  85. + strengthLvl; i++) {
  86. sleep(100, 120);
  87. }
  88. }
  89. }
  90. }
  91. }
  92.  
  93. private void CheckAttack() {
  94. if (Inventory.containsOneOf(attackPotID)) {
  95. if (Skills.getCurrentLevel(Skills.ATTACK) <= attackPotRestore
  96. + attackLvl) {
  97. Item Pot = Inventory.getItem(attackPotID);
  98. if (Pot.interact("Drink")) {
  99. for (int i = 0; i < 20
  100. && Skills.getCurrentLevel(Skills.ATTACK) <= attackPotRestore
  101. + attackLvl; i++) {
  102. sleep(100, 120);
  103. }
  104. }
  105. }
  106. }
  107. }
  108.  
  109. private void executePrayer() {
  110. if (Inventory.containsOneOf(prayerPotID)) {
  111. if (Skills.getCurrentLevel(Skills.PRAYER) <= prayerPotRestore
  112. + prayerLvl) {
  113. Item Pot = Inventory.getItem(prayerPotID);
  114. if (Pot.interact("Drink")) {
  115. for (int i = 0; i < 20
  116. && Skills.getCurrentLevel(Skills.ATTACK) <= prayerPotRestore
  117. + prayerLvl; i++) {
  118. sleep(100, 120);
  119. }
  120. }
  121. }
  122. }
  123. }
  124.  
  125. private boolean needToPrayer() {
  126. return Skills.getCurrentLevel(Skills.PRAYER) <= prayerPotRestore
  127. + prayerLvl
  128. && Inventory.containsOneOf(prayerPotID);
  129. }
  130.  
  131. private void DDsSpec() {
  132. if (Inventory.containsOneOf(DDSID)) {
  133. Item DDS = Inventory.getItem(DDSID);
  134. DDS.interact("Wield");
  135. for (int i = 0; i < 20 && Inventory.containsOneOf(DDSID); i++) {
  136. sleep(100, 120);
  137.  
  138. }
  139. if (Attack.getSpecialEnergy() >= 25
  140. && !Inventory.containsOneOf(DDSID)) {
  141. Attack.setSpecial(true);
  142. }
  143. }
  144. }
  145.  
  146. @Override
  147. public void onRepaint(Graphics g1) {
  148.  
  149. effectiveStrength = (int) (8 + ((strengthLvl + fullStrengthPotRestore) * 1.15) + 3);
  150. baseDamage = 5 + effectiveStrength * (1 + strengthBonus / 64);
  151. maxHit = (int) (baseDamage * 1.15);
  152.  
  153. if (Inventory.containsOneOf(prayerPotID)) {
  154. prayerlol = Skills.getMaxLevel(Skills.PRAYER);
  155. fullPrayerPotRestore = 7 + (prayerlol / 4);
  156. prayerPotRestore = fullPrayerPotRestore / 2;
  157. }
  158. if (Inventory.containsOneOf(attackPotID)) {
  159. attacklol = Skills.getMaxLevel(Skills.ATTACK);
  160. fullAttackPotRestore = 5 + ((attacklol / 100) * 15);
  161. attackPotRestore = fullAttackPotRestore / 2;
  162. }
  163. if (Inventory.containsOneOf(strengthPotID)) {
  164. strength = Skills.getMaxLevel(Skills.STRENGTH);
  165. fullStrengthPotRestore = 5 + ((strength / 100) * 15);
  166. strengthPotRestore = fullStrengthPotRestore / 2;
  167. }
  168. }
  169.  
  170. }
Add Comment
Please, Sign In to add comment