Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. package scripts;
  2.  
  3. import org.powerbot.script.Condition;
  4. import org.powerbot.script.Filter;
  5. import org.powerbot.script.PollingScript;
  6. import org.powerbot.script.Script;
  7. import org.powerbot.script.rt6.*;
  8.  
  9. import javax.swing.*;
  10. import java.util.concurrent.Callable;
  11.  
  12.  
  13.  
  14.  
  15. @Script.Manifest( name="Script_1" , description="WiP" , properties="author=G; topic=999 client=6")
  16.  
  17.  
  18. public class Script_1 extends PollingScript<org.powerbot.script.rt6.ClientContext> {
  19.  
  20.  
  21.  
  22. final static int MONSTER_ID[] = { 12362, 12363, 12364, 12365, 12366 };
  23.  
  24. final static int FOOD = 2142; // cooked meat
  25.  
  26.  
  27.  
  28. @Override
  29. public void start() {
  30. System.out.println("Started");
  31. }
  32.  
  33. @Override
  34. public void stop() {
  35. System.out.println("Stopped");
  36. }
  37.  
  38. @Override
  39. public void poll() {
  40.  
  41. if(hasFood()) {
  42.  
  43. if (NeedsHealth()) {
  44. System.out.println("Eating");
  45. heal();
  46. }
  47.  
  48. else {
  49.  
  50.  
  51. if (!InCombat() && !FullLoad() && HasLog()) {
  52. System.out.println("Looking For A Fight");
  53. attack();
  54. System.out.println("Grabbing Raw Beef");
  55. pickup();
  56.  
  57. }
  58. else {
  59. if (!InCombat() && FullLoad()) {
  60. System.out.println("Burning Stuff");
  61. makefire();
  62. }
  63. else {
  64. if (!InCombat() && !HasLog() && NeedsCooked()){
  65. System.out.println("Cooking Meat");
  66. cook();
  67. }
  68. }
  69. }
  70. }
  71.  
  72.  
  73. }
  74. else {
  75. System.out.println("No Food");
  76. }
  77.  
  78. }
  79.  
  80. public boolean NeedsCooked(){
  81. return ((ctx.backpack.select().count() == 27) && (ctx.backpack.select().id(2132).count() > 0));
  82. }
  83.  
  84. public boolean FullLoad(){
  85. return ctx.backpack.select().count() == 28;
  86. }
  87.  
  88. public boolean HasLog() {return ctx.backpack.id(1511).count() > 0;}
  89.  
  90. public boolean NeedsHealth() {
  91. return ctx.combatBar.health() < ((ctx.combatBar.maximumHealth() / 100) * 50); //eat when health drops below 50%
  92. }
  93.  
  94. public boolean InCombat() {
  95.  
  96. return ctx.players.local().inCombat();
  97. }
  98.  
  99. public boolean hasFood(){
  100. return ctx.backpack.id(FOOD).count() < 1;
  101. }
  102.  
  103. public void attack() {
  104.  
  105. final Npc MonsterToKill = ctx.npcs.id(MONSTER_ID).select(new Filter<Npc>() {
  106.  
  107. @Override
  108. public boolean accept(Npc npc) {
  109. return !npc.inCombat();
  110. }
  111. }).nearest().poll();
  112.  
  113. MonsterToKill.interact("Attack");
  114.  
  115. if(MonsterToKill.inCombat()){
  116. return;
  117. }
  118.  
  119. Condition.wait(new Callable<Boolean>() {
  120. @Override
  121. public Boolean call() throws Exception {
  122. return ctx.players.local().inCombat();
  123. }
  124. }, 5000, 1); // Try 1 time every 3000ms
  125. Condition.wait(new Callable<Boolean>() {
  126.  
  127. @Override
  128. public Boolean call() throws Exception {
  129. return ctx.players.local().inCombat();
  130. }
  131. },200,1);
  132.  
  133. }
  134.  
  135. public void heal() {
  136. Item EAT = ctx.backpack.select().id(FOOD).poll();
  137.  
  138. EAT.interact("Eat" );
  139.  
  140. final int startingHealth = ctx.combatBar.health();
  141.  
  142. Condition.wait(new Callable<Boolean>() {
  143. @Override
  144. public Boolean call() throws Exception {
  145. final int currentHealth = ctx.combatBar.health();
  146. return currentHealth != startingHealth;
  147. }
  148. }, 150, 20);
  149.  
  150.  
  151. }
  152.  
  153. public void pickup() {
  154.  
  155. Condition.sleep(4200);
  156. GroundItem PICKUP = ctx.groundItems.select().id(2132).nearest().poll();
  157. PICKUP.interact("take" , "raw");
  158.  
  159. final int startingBeef = ctx.backpack.count();
  160.  
  161. Condition.wait(new Callable<Boolean>() {
  162. @Override
  163. public Boolean call() throws Exception {
  164. final int BeefAmount = ctx.backpack.select().count();
  165. return BeefAmount != startingBeef;
  166. }
  167. });
  168. }
  169.  
  170. public void makefire() {
  171.  
  172. Item LOG = ctx.backpack.select().id(1511).poll();
  173. LOG.interact("Light");
  174.  
  175. final int startingLogs = ctx.skills.experience(Constants.SKILLS_FIREMAKING);
  176.  
  177. Condition.wait(new Callable<Boolean>() {
  178. @Override
  179. public Boolean call() throws Exception {
  180. final int MadeFire = ctx.skills.experience(Constants.SKILLS_FIREMAKING);
  181. return MadeFire != startingLogs;
  182. }
  183. });
  184.  
  185. }
  186.  
  187. public void cook() {
  188. Item COOK = ctx.backpack.select().id(2132).poll();
  189. COOK.interact("use");
  190. ctx.objects.select().id(70755).nearest().poll().interact("use");
  191. System.out.println("Clicking Widget");
  192. Condition.sleep(3000);
  193. ctx.widgets.component(1370, 20).click("cook");
  194.  
  195.  
  196.  
  197. Condition.wait(new Callable<Boolean>() {
  198. @Override
  199. public Boolean call() throws Exception {
  200. System.out.println("Cooking Throw");
  201. return ctx.backpack.select().id(2132).count() == 0;
  202. }
  203. });
  204. }
  205.  
  206.  
  207.  
  208.  
  209.  
  210. }// end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement