Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • canReach for Projectiles (Mage spells, arrows, ...)


    eKKiM

    Recommended Posts

    Posted

    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?

     

     

    • 2 months later...
    Posted

    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.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.