import org.osbot.script.MethodProvider; import org.osbot.script.Script; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.Player; import org.osbot.script.rs2.model.RS2Object; import org.osbot.script.rs2.utility.Area; public class FroobsCowKiller extends Script{ private final Area BANK_AREA = (new Area(3099, 3500, 3090, 3487)); private final Area Cow_Area = (new Area(3253 , 3255 ,3264 , 3297) ); final String BANKBOOTH = "Bankbooth"; private int[][] path1 = new int[][] { {3245 , 3273 },{3240 , 3288},{3239 , 3304},{3247 , 3315},{3258 , 3325},{3270 , 3332},{3279 , 3323},{3277 , 3308},{3274 , 3290},{3274 , 3273},{3276 , 3257},{3278 , 3241},{3278 , 3225},{3278 , 3207},{3280 , 3192},{3277 , 3174},{3269 , 3168}}; private int[][] path2 = new int[][] { { 3091, 3491 }, { 3088, 3484 }, { 3093, 3475 }, { 3096, 3468 } }; public void onstart(){ } public void onexit(){ } public int onloop() throws InterruptedException{ Entity cow = closestAttackableNPCForName("Cow"); Player player = client.getMyPlayer(); Entity cowhide = closestGroundItem(1739); if (client.getInventory().isFull()) { walkToBank(); } else { walkToCows(); } if(player.isInArea(Cow_Area)){ cow.interact("Attack"); } if (player.isInArea(BANK_AREA) && client.getInventory().isFull()) { bankDeposit(); } if(closestGroundItem(1739) != null){ cowhide.interact("Take"); } return 50; } public void onpaint(){ } public void walkToBank() { WalkAlongPath(path1, true); } public void walkToCows() { WalkAlongPath(path2, true); } public boolean WalkAlongPath(int[][] path, boolean AscendThroughPath, int distanceFromEnd) { if (distanceToPoint(AscendThroughPath ? path[path.length - 1][0] : path[0][0], AscendThroughPath ? path[path.length - 1][1] : path[0][1]) <= distanceFromEnd) return true; else { WalkAlongPath(path, AscendThroughPath); return false; } } public void WalkAlongPath(int[][] path, boolean AscendThroughPath) { int destination = 0; for (int i = 0; i < path.length; i++) if (distanceToPoint(path[i][0], path[i][1]) < distanceToPoint( path[destination][0], path[destination][1])) destination = i; if (client.getMyPlayer().isMoving() && distanceToPoint(path[destination][0], path[destination][1]) > (isRunning() ? 3 : 2)) return; if (AscendThroughPath && destination != path.length - 1 || !AscendThroughPath && destination != 0) destination += (AscendThroughPath ? 1 : -1); try { walk(new Position(path[destination][0], path[destination][1], 0)); Thread.sleep(700 + MethodProvider.random(600)); } catch (InterruptedException e) { e.printStackTrace(); } } private int distanceToPoint(int pointX, int pointY) { return (int) Math.sqrt(Math .pow(client.getMyPlayer().getX() - pointX, 2) + Math.pow(client.getMyPlayer().getY() - pointY, 2)); } public void bankDeposit() throws InterruptedException { RS2Object booth = closestObjectForName(new String[] { "Bank booth" }); if ((booth != null) && (booth.interact("Bank"))) { booth.interact("Bank"); sleep(2500); } while (this.client.getMyPlayer().isMoving()) { sleep(1500); } if (this.client.getBank().isOpen()) { this.client.getBank().depositAll(); sleep(1000); } if (this.client.getInventory().isEmpty()) { this.client.getBank().close(); } } }