eKKiM 4 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?
Genius 50 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.