Jump to content

How to increase/decrease attack radius?


Recommended Posts

Posted
8 hours ago, sinclair666 said:

Thanks, I'll try to figure that out

Code snippet to help ya out:

//Some variables to be used in calculating the npc.
Area areaAroundPlayer = myPlayer().getArea(10);
String npcName = "NPCName";

//Creating a filter for the npc.
Filter<NPC> npcFilter = new Filter<NPC>() {
    @Override
    public boolean match(NPC npc) {
        return areaAroundPlayer.contains(npc) && npc.getName().equals(npcName) && npc.isAttackable() && getMap().canReach(npc);
    }
};

//You can also use lambda expressions to create the filter which would look like this
Filter<NPC> npcFilter = npc -> areaAroundPlayer.contains(npc) && npc.getName().equals(npcName) && npc.isAttackable() && getMap().canReach(npc);

//Using the filter to obtain an npc.
NPC npc = getNpcs().closest(npcFilter);

 

Posted
2 hours ago, BravoTaco said:

Code snippet to help ya out:


//Some variables to be used in calculating the npc.
Area areaAroundPlayer = myPlayer().getArea(10);
String npcName = "NPCName";

//Creating a filter for the npc.
Filter<NPC> npcFilter = new Filter<NPC>() {
    @Override
    public boolean match(NPC npc) {
        return areaAroundPlayer.contains(npc) && npc.getName().equals(npcName) && npc.isAttackable() && getMap().canReach(npc);
    }
};

//You can also use lambda expressions to create the filter which would look like this
Filter<NPC> npcFilter = npc -> areaAroundPlayer.contains(npc) && npc.getName().equals(npcName) && npc.isAttackable() && getMap().canReach(npc);

//Using the filter to obtain an npc.
NPC npc = getNpcs().closest(npcFilter);

 

Thanks!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...