sinclair666 Posted November 15, 2019 Posted November 15, 2019 I'm wondering how I would be able to increase the range osbot scans for NPC's to attack. I've looked through the API and couldn't find anything related to this but I've seen other combat scripts offering this so I'm wondering how they did it.
sinclair666 Posted November 15, 2019 Author Posted November 15, 2019 1 minute ago, Malcolm said: When you create your NPC to attack you can use a filter and filter it by an area Thanks, I'll try to figure that out
BravoTaco Posted November 15, 2019 Posted November 15, 2019 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);
sinclair666 Posted November 15, 2019 Author Posted November 15, 2019 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!