Using this for Woody's Fighter to attack next monster faster.
/**
* @author Woody
* @param entity - The entity which has the chosen option
* @param option - The option you want to hover
* @return true if hovering over entity option
* @throws InterruptedException
*/
private boolean hoverEntityOption(Entity entity, String option) throws InterruptedException {
if(entity != null && menu.isOpen()) {
List<Option> options = menu.getMenu();
Rectangle optionRec = null;
int index = 0;
if(options != null) {
for(; index < options.size(); index++) {
if(options.get(index).action.equals(option)) {
optionRec = menu.getOptionRectangle(index);
break;
}
}
} else {
return false;
}
if(optionRec != null) {
if(!optionRec.contains(mouse.getPosition())) {
int x = menu.getX() + Script.random(10, 160);
int y = menu.getY() + 23 + index * 15;
Script.sleep(Script.random(200, 400));
return mouse.move(x, y);
}
} else {
return false;
}
} else if(entity != null && !menu.isOpen()) {
EntityDestination ed = new EntityDestination(bot, entity);
mouse.click(ed, true);
}
return false;
}
How to use:
if(myPlayer().getInteracting() != null) {
NPC goblin = npcs.closest("Goblin");
if(goblin != null && goblin.isVisible()) {
if(hoverEntityOption(goblin, "Attack")) {
//the mouse is now hovering attack option and is ready to attack next goblin, when the
//fight is over
}
}
} else {
if(menu.isOpen()) {
if(mouse.click(false)) {
for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
sleep(20, 40);
}
}
} else {
if(goblin != null && goblin.isVisible()) {
if(goblin.interact("Attack ")) {
for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
sleep(20, 40);
}
}
} else if(goblin != null && !goblin.isVisible()) {
camera.toEntity(goblin);
} else {
log("Goblin gone?!");
}
}
}
Any suggestions/ideas/complains are appreciated.