public void doNPC(int type, String Action) throws InterruptedException { int loops = 0; while (loops < 5) { NPC target = getNPC(type, SC.ON_SCREEN); if (target == null) { target = getNPC(type, SC.ON_MINI_MAP); if (target == null) { target = getNPC(type, SC.NONE); if (target == null) { return; } else { Tile destination = getTile(target); int loops2 = 0; while (distanceTo(destination) > 3 && loops2 < 100) { walk(findTileOnWayToTile(destination)); loops2++; } } } else { walk(findTileOnWayToTile(getTile(target))); while (isMoving()) { sleep(100); } } } else { XY screen = getScreenXY(target); if (screen != null) { mouseClickRight(screen); Menu menu = getMenu(Areas.GAME, 2000); if (menu != null) { menu.selectContains(Action); return; } } } loops++; } }