eKKiM 1 Share Posted September 26, 2022 I am looking for an equivalent for canReach but for projectiles (arrows, mage spells, ...) I am unable to find something like this in the docs... Any ideas how i can implement this myself? Link to comment Share on other sites More sharing options...
Genius 49 Share Posted December 7, 2022 Don't mean to revive this thread if you've figured it out, but since you didn't get any responses.. I'm assuming you're referring to whether an NPC is reachable with arrows/mage spells. This is probably just a simple distance check you could add in your filter for NPC declaration. private boolean canRangeAttack() { NPC target = NPCs.closest(t -> t != null && t.getName().equals("WhatYouAreAttacking") && t.getDistance() < 7); return (target != null); } The number 7 is just a guess, but you can play with that distance constraint until it works as you expect. You could also pass in NPC as a parameter. private boolean canRangeAttack(NPC target) { return (target != null && target.getDistance() < 7); } An easy way to get a good idea of this distance would be to log your distance to the target NPC when your animation == shooting an arrow or casting a spell. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now