Jump to content

Method to hover over next npc


Recommended Posts

Posted (edited)
20 minutes ago, Prolax said:

Does anyone have a method to hover over next npc for a combat script?

Or some advice on how to write my own method for this?

Thanks!

U can filter closest NPC:
Example(Not sure as I typed it her not in IDE so check it out):

NPC npc = getNpcs().closest(f-> !f.isUnderAttack && f.gethitpoints > 0 && !f.isHitbarvisibile)

EDIT: check fruity's post

Edited by progamerz
Posted (edited)
Character<?> character = script.myPlayer().getInteracting();
if (character != null && character.getHealthPercentCache() < 30) {
    NPC next = script.getNpcs().closest(n -> n.getName().equals("NAME") && !n.isUnderAttack() && n != character && n.getHealthPercentCache() > 0);
    next.hover();
}

Make sure to add n.getName().equals("NAME")

Not tested but im sure it will be something similar

Edited by Fruity
  • Like 4
Posted
11 minutes ago, Fruity said:

Character<?> character = script.myPlayer().getInteracting();
if (character != null && character.getHealthPercentCache() < 30) {
    NPC next = script.getNpcs().closest(n -> n.getName().equals("NAME") && !n.isUnderAttack() && n != character && n.getHealthPercentCache() > 0);
    next.hover();
}

Make sure to add n.getName().equals("NAME")

Not tested but im sure it will be something similar

Thanks, it works!

  • Like 1
Posted
2 hours ago, Trees said:

Make sure to add a delay between hovering and either choose to hover over the same NPC or it might just hover over what's closest (depending how you have it coded), which could change frequently.

Indeed, I noticed the same. Just a random delay or conditional sleep?

Posted
18 hours ago, Prolax said:

Indeed, I noticed the same. Just a random delay or conditional sleep?

Use a delay, in case you need to eat, tele, etc.

Also make sure when you calculate the random delay, you set it to a variable. Otherwise every loop it will recalculate and be more likely to be a shorter delay.

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...