Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. package com.matslo.bots.skilling;
  2.  
  3. import com.matslo.bots.api.Local;
  4. import com.runemate.game.api.hybrid.entities.GameObject;
  5. import com.runemate.game.api.hybrid.entities.PredefinedEntity;
  6. import com.runemate.game.api.hybrid.input.Keyboard;
  7. import com.runemate.game.api.hybrid.input.Mouse;
  8. import com.runemate.game.api.hybrid.local.Skill;
  9. import com.runemate.game.api.hybrid.local.hud.InteractableRectangle;
  10. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
  11. import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
  12. import com.runemate.game.api.hybrid.location.Coordinate;
  13. import com.runemate.game.api.script.Execution;
  14. import com.runemate.game.api.script.framework.LoopingBot;
  15. import com.runemate.game.api.script.framework.listeners.SkillListener;
  16. import com.runemate.game.api.script.framework.listeners.events.SkillEvent;
  17.  
  18. import java.awt.event.KeyEvent;
  19.  
  20. public class AlKharid extends LoopingBot implements SkillListener {
  21.  
  22. //private final static Coordinate[] guildCoords = {new Coordinate(3028, 9720, 0), new Coordinate(3029, 9721, 0), new Coordinate(3030, 9720, 0)};
  23. //private final static Coordinate[] ardyCoords = {new Coordinate( 2691, 3329, 0 ), new Coordinate( 2692, 3328, 0 ), new Coordinate( 2693, 3329, 0 )};
  24. private final static Coordinate[] varrockIronCoords = new Coordinate[]{new Coordinate(3285, 3369, 0), new Coordinate(3285, 3368, 0), new Coordinate(3286, 3369, 0), new Coordinate(3288, 3370, 0)};
  25. private final static Coordinate[] varrockCopperCoords = new Coordinate[]{new Coordinate(3289, 3363, 0), new Coordinate(3290, 3362, 0)};
  26. private final static Coordinate[] alKharid = {new Coordinate(3295, 3311, 0), new Coordinate(3294, 3310, 0), new Coordinate(3295, 3309, 0)};
  27. private final static Coordinate rockcoord1 = new Coordinate(3295, 3311, 0);
  28. private final static Coordinate rockcoord2 = new Coordinate(3294, 3310, 0);
  29. private final static Coordinate rockcoord3 = new Coordinate(3295, 3309, 0);
  30. private final static PredefinedEntity rock1 = PredefinedEntity.gameobject(rockcoord1, "Rocks");
  31. private final static PredefinedEntity rock2 = PredefinedEntity.gameobject(rockcoord2, "Rocks");
  32. private final static PredefinedEntity rock3 = PredefinedEntity.gameobject(rockcoord3, "Rocks");
  33. private int i = 0;
  34. private SpriteItem first, second;
  35. private boolean flag = true;
  36. private Local local = new Local();
  37. private int xp = 0;
  38. private final static InteractableRectangle slot0 = Inventory.getBoundsOf(0);
  39. private final static InteractableRectangle slot1 = Inventory.getBoundsOf(1);
  40. private boolean isOreInSlot0 = true;
  41. private boolean isOreInSlot1 = true;
  42. private final static int oreXP = 35;
  43.  
  44. // private int[] copperRockID = new int[]{11161};
  45. // private int[] ironRockID = new int[]{11364, 11365, 11391};
  46.  
  47. @Override
  48. public void onStart(String... arguments) {
  49. setLoopDelay(200, 400);
  50. Mouse.setPathGenerator(Mouse.MLP_PATH_GENERATOR);
  51. getEventDispatcher().addListener(this);
  52.  
  53. }
  54.  
  55.  
  56. @Override
  57. public void onExperienceGained(SkillEvent event) {
  58. if (event.getSkill() == Skill.MINING) {
  59. xp += event.getChange();
  60. getLogger().info(xp);
  61. isOreInSlot0 = event.getChange()>=oreXP;
  62. isOreInSlot1 = event.getChange()>=2*oreXP;
  63. }
  64. }
  65.  
  66. @Override
  67. public void onLoop() {
  68. Keyboard.pressKey(KeyEvent.VK_SHIFT);
  69. switch (i) {
  70. case (0): {
  71. //GameObject rock1 = GameObjects.newQuery().names("Rocks").on(rockcoord1).ids(ironRockID).results().first();
  72. if (rock1.isValid())
  73. dropAndMine(rock1, Skill.MINING.getExperience());
  74.  
  75. else
  76. System.out.println("Rock1 is null");
  77. break;
  78. }
  79. case 1: {
  80. //GameObject rock2 = GameObjects.newQuery().names("Rocks").on(rockcoord2).ids(ironRockID).results().first();
  81. if (rock2.isValid())
  82. dropAndMine(rock2, Skill.MINING.getExperience());
  83.  
  84. else
  85. System.out.println("Rock2 is null");
  86. break;
  87. }
  88. case 2: {
  89. //GameObject rock3 = GameObjects.newQuery().names("Rocks").on(rockcoord3).ids(ironRockID).results().first();
  90. if (rock3.isValid())
  91. dropAndMine(rock3, Skill.MINING.getExperience());
  92.  
  93. else
  94. System.out.println("Rock3 is null");
  95. break;
  96. }
  97. }
  98. i++;
  99. i %= 3;
  100. }
  101.  
  102. private void dropAndMine(PredefinedEntity rock, int miningExp){
  103. if (isOreInSlot0 && slot0.hover() && slot0.click())isOreInSlot0 = false;
  104. if (isOreInSlot1 && slot1.hover() && slot1.click())isOreInSlot1 = false;
  105. if(rock.interact("Mine"))
  106. {
  107. slot0.hover();
  108. Execution.delayUntil(() -> miningExp != Skill.MINING.getExperience() || !rock.isValid(),
  109. () -> local.getAnimationId() != -1, 1200, 1800);
  110. }
  111. }
  112.  
  113. private void dropAndMine2(PredefinedEntity rock, int miningExp) {
  114. first = Inventory.getItemIn(0);
  115.  
  116. if (first != null && first.hover()) first.click();
  117. if (!flag && second != null && second.hover() && second.click()) flag = true;
  118.  
  119. if (rock.interact("Mine")) {
  120. if (first != null) first.hover();
  121.  
  122. Execution.delayUntil(() -> {
  123.  
  124. if (flag) {
  125. second = Inventory.getItemIn(1);
  126. if (second != null) flag = false;
  127. }
  128.  
  129. return miningExp != Skill.MINING.getExperience() || !rock.isValid();
  130.  
  131. }, () -> local.getAnimationId() != -1, 1200, 1800);
  132. }
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement