Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Script not able to move mouse?


    crazykid080

    Recommended Posts

    So a problem I've been having with the script I'm building is that it doesn't seem to want to move the mouse at all.
    I've verified that the code flow is correct and does try to interact with the NPC, but the mouse does not move at all, I do have the easeMouse class in my project but I've tried it with and without it implemented. Not sure what other issue may be causing this

    Link to comment
    Share on other sites

    There seems to be no code related to mouse movement except 

    Client.getInstance().setMouseMovementAlgorithm(new EaseMouse());

    After that the flow of code I have goes through steps that haven't caused issues in the past, but I've tried it commented and uncommented. One thing to mention though is that my main class also implements MouseListener for other purposes as well as extending TaskScript, but that didn't seem to cause any issues on my previous script. The last part of the code flow is 

    NPC target = NPCs.closest(npc -> npc != null && !npc.isInCombat() && npc.getLevel() < getLocalPlayer().getLevel() && npc.hasAction("Attack"));
    if (target == null) {
    	utils.debugString("Target not found.");
    	sleepUntil(() -> Walking.walk(currArea.getRandomTile()), 15000);
    	return utils.getSleepTime();
    }
    utils.debugString("Has action \"attack\": " + target.hasAction("Attack"));
    utils.debugString("Trying to attack");
    sleepUntil(() -> target.interact("Attack"), 5000);

    I have made sure to check that target is not null as well so that is not causing an issue

    Link to comment
    Share on other sites

    On 12/19/2020 at 11:30 PM, crazykid080 said:

    There seems to be no code related to mouse movement except 

    
    Client.getInstance().setMouseMovementAlgorithm(new EaseMouse());

    After that the flow of code I have goes through steps that haven't caused issues in the past, but I've tried it commented and uncommented. One thing to mention though is that my main class also implements MouseListener for other purposes as well as extending TaskScript, but that didn't seem to cause any issues on my previous script. The last part of the code flow is 

    
    NPC target = NPCs.closest(npc -> npc != null && !npc.isInCombat() && npc.getLevel() < getLocalPlayer().getLevel() && npc.hasAction("Attack"));
    if (target == null) {
    	utils.debugString("Target not found.");
    	sleepUntil(() -> Walking.walk(currArea.getRandomTile()), 15000);
    	return utils.getSleepTime();
    }
    utils.debugString("Has action \"attack\": " + target.hasAction("Attack"));
    utils.debugString("Trying to attack");
    sleepUntil(() -> target.interact("Attack"), 5000);

    I have made sure to check that target is not null as well so that is not causing an issue

    I wouldn't use sleepUntil's that way if I was you. Use an if on the interact and then use the sleepUntil until you are interacting with the npc
    Other than that, I would check if the npc exists before using the interact (target.exists())
    If you already tried removing the mouse algorithm to the default then I suggest you clear the game cache (sometimes it can do weird stuff to the game). Should try to also debug using an IDE if everything else fails after that

    Link to comment
    Share on other sites

    Yeah seemed to be a cache problem, it was fixed when I decided to test it again today it worked. Trying to work on the logic to fix other issues I'm having, I'll keep your suggestions in mind

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.