Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void attackMan() {
- RSNPC man = getNearestMan(menarea, "Man");
- if(man != null){
- atNPC(man, "Attack");
- wait(random(1500, 2000));
- moveMouse(random(50, 300), random(50, 300));
- if (getMyPlayer().getInteracting() != null
- && getMyPlayer().getInteracting() instanceof RSNPC) {
- while (getMyPlayer().getInteracting() != null) {
- wait(random(50, 200));
- if (skills.getCurrentSkillLevel(STAT_HITPOINTS) < 6) {
- eatFood();
- }
- }
- }
- kills++;
- wait(random(2700, 3000));
- } else {
- wait(random(1000,2000));
- }
- }
- public RSNPC getNearestMan(final RSArea toSearch, final String name) {//RSHELPER!
- int Dist = 20;
- RSNPC closest = null;
- final int[] validNPCs = Bot.getClient().getRSNPCIndexArray();
- final org.rsbot.accessors.RSNPC[] npcs = Bot.getClient()
- .getRSNPCArray();
- for (final int element : validNPCs) {
- if (npcs[element] == null)
- continue;
- final RSNPC Monster = new RSNPC(npcs[element]);
- try {
- if (name == null || !name.equalsIgnoreCase(Monster.getName())
- || Monster.getHPPercent() == 0 || !toSearch.contains(Monster.getLocation()))
- continue;
- final int distance = distanceTo(Monster);
- if (distance < Dist) {
- Dist = distance;
- closest = Monster;
- }
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
- return closest;
- }
Add Comment
Please, Sign In to add comment