Tezlaz

fighting

Aug 6th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. package scripts.tools;
  2.  
  3. import org.tribot.api.DynamicClicking;
  4. import org.tribot.api.General;
  5. import org.tribot.api.Timing;
  6. import org.tribot.api.input.Mouse;
  7. import org.tribot.api2007.ChooseOption;
  8. import org.tribot.api2007.Game;
  9. import org.tribot.api2007.GameTab;
  10. import org.tribot.api2007.NPCs;
  11. import org.tribot.api2007.Player;
  12. import org.tribot.api2007.Projection;
  13. import org.tribot.api2007.Skills;
  14. import org.tribot.api2007.GameTab.TABS;
  15. import org.tribot.api2007.types.RSModel;
  16. import org.tribot.api2007.types.RSNPC;
  17. import org.tribot.api2007.types.RSTile;
  18.  
  19.  
  20. public class Fighting {
  21.  
  22. @SuppressWarnings("unused")
  23. private static void SwitchStyle(int style) {
  24. GameTab.open(TABS.COMBAT);
  25.  
  26. if (style == 1) {
  27. Mouse.click(General.random(594, 615), General.random(266, 282), 1);
  28. General.sleep(300, 600);
  29. }
  30. if (style == 2) {
  31. Mouse.click(General.random(671, 701), General.random(266, 282), 1);
  32. General.sleep(300, 600);
  33. }
  34. if (style == 3) {
  35. Mouse.click(General.random(594, 615), General.random(316, 332), 1);
  36. General.sleep(300, 600);
  37. }
  38. if (style == 4) {
  39. Mouse.click(General.random(671, 701), General.random(316, 332), 1);
  40. General.sleep(300, 600);
  41. }
  42. }
  43.  
  44. // Attacks specified monster
  45. public static boolean AttackMonster(int[] chickens) {
  46. // Creates an array of all nearby monsters
  47. RSNPC[] monsters = NPCs.findNearest(chickens);
  48. // Goes for closest monster that isn't null or in combat
  49. for (RSNPC monster : monsters) {
  50. if (monster != null && monster.isValid() && !monster.isInCombat()) {
  51. // Gets the model (more accurate clicking)
  52. RSModel model = monster.getModel();
  53. // Clicks on the monster model to attack it if not null
  54. if (model != null && DynamicClicking.clickRSModel(model, "Attack")) {
  55. General.sleep(500, 1000);
  56. long t = System.currentTimeMillis();
  57. while (Timing.timeFromMark(t) < General.random(1500, 2000)) {
  58. if (Player.getRSPlayer().isInCombat()) {
  59. System.out.println("Succesfully attacked monster!");
  60. General.sleep(2000, 3000);
  61. return true;
  62. } else if (Player.isMoving()) {
  63. t = System.currentTimeMillis();
  64. }
  65. General.sleep(50, 100);
  66. }
  67. break;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73.  
  74. /** Checks if we are in combat */
  75. public static boolean IsInCombat() {
  76. int startHpXp = Skills.getXP(Skills.SKILLS.HITPOINTS);
  77. long t = System.currentTimeMillis();
  78. while (Timing.timeFromMark(t) < General.random(800, 1200)) {
  79. if (Player.getRSPlayer().isInCombat() || Skills.getXP(Skills.SKILLS.HITPOINTS) > startHpXp) {
  80. return true;
  81. }
  82. General.sleep(40, 80);
  83. }
  84. return false;
  85. }
  86.  
  87.  
  88. public static boolean ClickNPC(RSNPC npc, String option) {
  89. // Mouse.setSpeed(General.random(100,120));
  90. RSTile loc = null;
  91. if (npc != null && npc.isOnScreen()) {
  92. loc = npc.getPosition();
  93. Mouse.move(Projection.tileToScreen(loc, 10));
  94. if (Game.isUptext(option)) {
  95. Mouse.click(1);
  96. return true;
  97. } else {
  98. Mouse.click(3);
  99. if (ChooseOption.isOpen()) {
  100. ChooseOption.select(option);
  101. }
  102. }
  103. }
  104. return false;
  105. }
  106.  
  107. }
Add Comment
Please, Sign In to add comment