Jump to content

[Snippet] Hover over a game object


saturn

Recommended Posts

Use this simple snippet to hover over any game object like an NPC, SceneObject, GroundItem and Players:

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.entity.GameEntity;

public class Hover {

    public static boolean hover(APIContext ctx, GameEntity ge){
        if(!isHovering(ctx, ge)){
            return ge.hover();
        }
        return true;
    }

    private static boolean isHovering(APIContext ctx, GameEntity ge){
        return ge.contains(ctx.mouse().getLocation());
    }
}

How to use this snippet:

  1. In your project, save the above snippet in a file called Hover.java
  2. In your script, when you want to hover over something use the snippet like in the example below

Example for hovering over a Banker NPC:

APIContext ctx = getAPIContext();

Npc banker = ctx.npcs().query()
                          .named("Banker")
                          .actions("Bank")
                          .results()
                          .nearest();

if(banker != null){
	boolean hovering = Hover.hover(ctx, banker);
	//Use the hovering variable however you see fit, or ignore it if it's unnecessary
}

 

Edited by saturn
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...