Jump to content

Hovering entity's option


Recommended Posts

Posted
                if(myPlayer().getInteracting() != null) {
                NPC npc = npcs.closest(npc_name);
                if (npc != null && npc.isVisible()) {
                    if (hoverEntityOption(npc, "Attack")) {
                        if (myPlayer().getInteracting() != npc) {
                            if (npc.isVisible()) {
                                npc.interact("Attack");
                                log("Attacking " + npc_name);
                                sleep(random(400, 800));
                            } else {
                                camera.toEntity(npc);
                            }
                        }
                    }
                }
            }else {
                if(menu.isOpen()) {
                    if(mouse.click(false)) {
                        for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
                            sleep(random(20,40));
                        }
                    }
                } else {
                    if(npc != null && npc.isVisible()) {
                        if(npc.interact("Attack")) {
                            for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
                                sleep(random(20,40));
                            }
                        }
                    } else if(npc != null && !npc.isVisible()) {
                        camera.toEntity(npc);
                    } else {
                        log(npc_name + " gone?");
                    }
                }
            }

I'm having trouble implementing your method.

 

What am I doing wrong? The script keeps logging "npc_name gone?"

 

Don't use the method of how to attack a goblin, that was just an example. There are plenty of other tutorials which can help you more. This snippet is meant for those who knows java.

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...