Jump to content

How to increase/decrease attack radius?


sinclair666

Recommended Posts

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);

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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