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
  • Extending the NPC model


    xpDad

    Recommended Posts

    Hey was wondering if anyone came up with a solution for this. So what I want to do is to extend the NPC model to have my specific methods for it as

    public class ExtNpc extends NPC {
    
    	public ExtNpc(final NPC reference) {
    		super(reference);
    	}
    
    	public void attack() {
    		interact("Attack");
    	}
    
    	public boolean isDead() {
    		return getHealthPercent() == 0;
    	}
    
    	public boolean isUnderAttack(final Character character) {
    		return !character.isInteracting(this);
    	}
    
    }

    but the problem is that it doesn't work as supposed and throws null pointers at times or has bad reference. Any ideas on this?

    Link to comment
    Share on other sites

    Well I believe that doing so will help save some time in the future and have a single point of access to do specific action which would help me to refactor or introduce new logic if needed.

    Link to comment
    Share on other sites

    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.