March 12, 201510 yr What would the code be for randomizing attack targets? To even create two attack targets would I first have to make a variable as the closest npc, and then make another with the condition variableone !=null? Edited March 12, 201510 yr by eleax
March 12, 201510 yr 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 March 12, 201510 yr by Botre
March 12, 201510 yr Author 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