Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1.  
  2. public void attackMan() {
  3. RSNPC man = getNearestMan(menarea, "Man");
  4. if(man != null){
  5. atNPC(man, "Attack");
  6. wait(random(1500, 2000));
  7. moveMouse(random(50, 300), random(50, 300));
  8. if (getMyPlayer().getInteracting() != null
  9. && getMyPlayer().getInteracting() instanceof RSNPC) {
  10. while (getMyPlayer().getInteracting() != null) {
  11. wait(random(50, 200));
  12. if (skills.getCurrentSkillLevel(STAT_HITPOINTS) < 6) {
  13. eatFood();
  14. }
  15. }
  16.  
  17. }
  18. kills++;
  19. wait(random(2700, 3000));
  20.  
  21.  
  22. } else {
  23. wait(random(1000,2000));
  24. }
  25. }
  26.  
  27. public RSNPC getNearestMan(final RSArea toSearch, final String name) {//RSHELPER!
  28. int Dist = 20;
  29. RSNPC closest = null;
  30. final int[] validNPCs = Bot.getClient().getRSNPCIndexArray();
  31. final org.rsbot.accessors.RSNPC[] npcs = Bot.getClient()
  32. .getRSNPCArray();
  33.  
  34. for (final int element : validNPCs) {
  35. if (npcs[element] == null)
  36. continue;
  37. final RSNPC Monster = new RSNPC(npcs[element]);
  38. try {
  39. if (name == null || !name.equalsIgnoreCase(Monster.getName())
  40. || Monster.getHPPercent() == 0 || !toSearch.contains(Monster.getLocation()))
  41. continue;
  42. final int distance = distanceTo(Monster);
  43. if (distance < Dist) {
  44. Dist = distance;
  45. closest = Monster;
  46. }
  47. } catch (final Exception e) {
  48. e.printStackTrace();
  49. }
  50. }
  51. return closest;
  52. }
Add Comment
Please, Sign In to add comment