Guest User

Untitled

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. import org.powerbot.concurrent.Task;
  2. import org.powerbot.concurrent.action.Action;
  3. import org.powerbot.game.api.ActiveScript;
  4. import org.powerbot.game.api.Manifest;
  5. import org.powerbot.game.api.methods.interactive.Npcs;
  6. import org.powerbot.game.api.methods.interactive.Players;
  7. import org.powerbot.game.api.methods.tab.Inventory;
  8. import org.powerbot.game.api.util.Filter;
  9. import org.powerbot.game.api.util.Random;
  10. import org.powerbot.game.api.util.Time;
  11. import org.powerbot.game.api.util.Timer;
  12. import org.powerbot.game.api.wrappers.interactive.Npc;
  13. import org.powerbot.game.api.wrappers.interactive.Player;
  14. import org.powerbot.game.api.wrappers.node.Item;
  15. import org.powerbot.lang.Activatable;
  16.  
  17. @Manifest(authors = { "Nighson" }, name = "Stealer", description = "Your best stealer :)", version = 1.0)
  18. public class Theaver extends ActiveScript {
  19. final int FARMER_ID = 7;
  20. final int FISH_ID = 361;
  21.  
  22.  
  23. /**
  24. *
  25. * @author Nighson
  26. *
  27. */
  28. private class Steal implements Task, Activatable {
  29. final Player player = Players.getLocal();
  30. public boolean applicable() {
  31. return player.getHpPercent() > 30;
  32. }
  33.  
  34.  
  35. public void run() {
  36. if (player.getInteracting() != null) {
  37. Time.sleep(Random.nextInt(100, 500));
  38. return;
  39. }
  40.  
  41. if(player.getHpPercent() < 60){
  42. for (Item i : Inventory.getItems()) { //get all items in inventory, using for each loop to process
  43. if (i.getId() == FISH_ID){
  44. i.getWidgetChild().interact("Eat"); //best way?
  45. break;
  46. }
  47. }
  48. }
  49.  
  50.  
  51. //A filter to return the correct object
  52. final Npc farmer = Npcs.getNearest(new Filter<Npc>() {
  53. public boolean accept(final Npc npc) {
  54. final int npcId = npc.getId();
  55. if (FARMER_ID == npcId) {
  56. return true;
  57. }
  58.  
  59. return false;
  60. }
  61. });
  62.  
  63. if (farmer != null) {
  64. farmer.interact("Pickpocket");
  65. final Timer timer = new Timer(Random.nextInt(2000, 2800));
  66.  
  67. while (timer.isRunning()) {
  68. if (farmer.getAnimation() == 422){
  69. log.info("Fail!");
  70. log.info("" + Players.getLocal().getHpPercent());
  71. Time.sleep(Random.nextInt(5000, 5500));
  72. }
  73. if (player.getSpeed() > 0) {
  74. timer.reset();
  75. }
  76. }
  77.  
  78. }
  79. }
  80. }
  81.  
  82.  
  83.  
  84. @Override
  85. protected void setup() {
  86. //make instances
  87. final Steal steal = new Steal();
  88. final Action Steal = new Action(steal, steal);
  89. //provide them for processing
  90. provide(Steal);
  91. }
  92.  
  93.  
  94. }
Add Comment
Please, Sign In to add comment