Cory Posted June 26, 2013 Share Posted June 26, 2013 (edited) public static RS2Object closestObjectWithAction(Script script, String action) { List<RS2Object> allObjects = script.client.getCurrentRegion().getObjects(); List<RS2Object> objects = new ArrayList<RS2Object>(); if(allObjects != null && allObjects.size() > 0) { for(RS2Object object : allObjects) { if(object != null && hasAction(object, action)) objects.add(object); } } return (RS2Object) closest(script, objects); } public static NPC closestNPCWithAction(Script script, String action) { List<NPC> allNPCs = script.client.getLocalNPCs(); List<NPC> NPCs = new ArrayList<NPC>(); if(allNPCs != null && allNPCs.size() > 0) { for(NPC npc : allNPCs) { if(npc != null && hasAction(npc, action)) NPCs.add(npc); } } return (NPC) closest(script, NPCs); } public static Entity closest(Script script, List<? extends Entity> entities) { Entity closest = null; for (Entity entity : entities) { if(closest == null) closest = entity; if(script.distance(entity) < script.distance(closest)) closest = entity; } return closest; } public static boolean hasAction(NPC npc, String action) { NPCDefinition i = npc.getDefinition(); return hasAction(i.getActions(), action); } public static boolean hasAction(RS2Object object, String action) { ObjectDefinition i = object.getDefinition(); return hasAction(i.getActions(), action); } public static boolean hasAction(String[] actions, String action) { for(String a : actions) { if(action.equals(a)) return true; } return false; } Edited June 26, 2013 by Cory Link to comment Share on other sites More sharing options...
H0ppy Posted June 26, 2013 Share Posted June 26, 2013 Thank you for sharing this with us H0ppy Link to comment Share on other sites More sharing options...
Joseph Posted June 26, 2013 Share Posted June 26, 2013 i dont get it? Link to comment Share on other sites More sharing options...
Link Posted June 26, 2013 Share Posted June 26, 2013 He's just sharing some methods he used in his rare finder. Link to comment Share on other sites More sharing options...
H0ppy Posted June 26, 2013 Share Posted June 26, 2013 Ya so we can use them ^^ Link to comment Share on other sites More sharing options...