Jump to content

Randomized target selection


Recommended Posts

Posted (edited)

Here's a Java 8 way to do it:

Predicate<NPC> predicate = o -> (o != null && o.exists() && o.getName().equals("Rat") && getMap().canReach(o));
List<NPC> potential = getNpcs().getAll().stream().filter(predicate).collect(Collectors.toList());
NPC target = potential.size() > 0 ? potential.get(random.nextInt(potential.size())) : null;
Edited by Botre
  • Like 2
Posted

 

Here's a Java 8 way to do it:

Predicate<NPC> predicate = o -> (o != null && o.exists() && o.getName().equals("Rat") && getMap().canReach(o));
List<NPC> potential = getNpcs().getAll().stream().filter(predicate).collect(Collectors.toList());
NPC target = potential.size() > 0 ? potential.get(random.nextInt(potential.size())) : null;

 

my scripting knowledge is not enough to understand how that works lol.

 

im really just familiar with the simple commands like npc.closest and like npc.interact

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