crezzy Posted April 9, 2018 Share Posted April 9, 2018 (edited) Well I got lazy training at Ankous so I wrote a script to do it for me lol Feedback on the code would be nice Anything I'm doing wrong or can be improved please let me know. Thanks in-advanced. Seems to be working flawlessly Features: Kills Ankous (Guess it would most likely be fine to kill them anywhere but I was using in the stronghold of security) Loots: "Death rune", "Blood rune", "Law rune", "Mithril ore", "Pure essence", "Adamant arrow", "Ranarr seed", "Torstol seed", "Snapdragon seed", "Bones" Uses bones to peaches tablets on bones for food Eats peaches obtained from b2p Uses dragon dagger(p++) special attack once 100% special energy Jar file: AnkouKiller.jar Source code: Spoiler Main.java import java.awt.Graphics2D; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Crezzy", name = "Anokou Killer", info = "Kills Ankous", logo = "", version = 1) public class Main extends Script { private final List<Node> nodes = new ArrayList<>(); private final List<Node> cache = new ArrayList<>(); private int startExp; private long startTime; private long timeRunning; @Override public void onStart() { startTime = System.currentTimeMillis(); startExp = getSkills().getTotalExperience(); cache.add(new BonesToPeaches(this)); cache.add(new Attack(this)); cache.add(new Loot(this)); cache.add(new Eat(this)); cache.add(new SpecialAttack(this)); getCombat().toggleAutoRetaliate(true); } @Override public int onLoop() { int delay = 333; timeRunning = System.currentTimeMillis() - startTime; if (!cache.isEmpty()) { nodes.clear(); nodes.addAll(cache.stream().filter(Node::validate).collect(Collectors.toList())); if (!nodes.isEmpty()) delay = getSuitabletasksNode().execute(); } return delay; } public Node getSuitabletasksNode() { Node node = null; if (!nodes.isEmpty()) { node = nodes.get(0); if (nodes.size() > 1) { for (Node possible : nodes) { if (node.priority() < possible.priority()) node = possible; } } } return node; } @Override public void onPaint(Graphics2D g) { int runtimeExp = getSkills().getTotalExperience() - startExp; int expPerHour = (int) ((runtimeExp * 3600000.0D) / timeRunning); Graphics2D paint = (Graphics2D) g.create(); paint.drawString("Time running: " + formatTime(timeRunning), 10, 300); paint.drawString("Experience gained: " + runtimeExp, 10, 315); paint.drawString("Experience an hour: " + expPerHour, 10, 330); } private String formatTime(final long ms) { long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } } Node.java import org.osbot.rs07.script.Script; public abstract class Node { protected Script c; public Node(Script c) { this.c = c; } public abstract int priority(); public abstract boolean validate(); public abstract int execute(); } Loot.java import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; public class Loot extends Node { GroundItem item; String[] itemsToLoot = { "Death rune", "Blood rune", "Law rune", "Mithril ore", "Pure essence", "Adamant arrow", "Ranarr seed", "Torstol seed", "Snapdragon seed", "Bones" }; public Loot(Script c) { super(c); } @Override public boolean validate() { for (String i : itemsToLoot) { item = c.groundItems.closest(i); if (item != null) { if (item.getId() != 526 && c.getInventory().isFull()) return true; if (!c.getInventory().isFull()) return true; } } return false; } @Override public int execute() { c.log("Picking uo item: " + item.getName()); item.interact("Take"); return 1000; } @Override public int priority() { return 4; } } SpecialAttack.java import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.ui.EquipmentSlot; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; public class SpecialAttack extends Node { public SpecialAttack(Script c) { super(c); } @Override public int priority() { return 3; } @Override public boolean validate() { return c.getCombat().getSpecialPercentage() == 100 && c.getInventory().contains("Dragon dagger(p++)") && c.getCombat().isFighting(); } @Override public int execute() { Item originalWeapon = c.getEquipment().getItemInSlot(EquipmentSlot.WEAPON.slot); while (c.getCombat().getSpecialPercentage() > 0) { if(!c.getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Dragon dagger(p++)")) { c.getInventory().getItem("Dragon dagger(p++)").interact("Wield"); c.log("Equiping dragon dagger"); } if(!c.getCombat().isFighting()) { c.log("Ankou died exit special attack loop."); break; } c.log("Actiating special attack"); c.getCombat().toggleSpecialAttack(true); try { MethodProvider.sleep(1200); } catch (InterruptedException e) { e.printStackTrace(); } } c.log("Special energy depleated - requiping original weapon."); c.getInventory().getItem(originalWeapon.getName()).interact("Wield"); return 1200; } } Attack.java import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; public class Attack extends Node { public Attack(Script c) { super(c); } @Override public boolean validate() { return !c.getCombat().isFighting() && !c.myPlayer().isUnderAttack() && c.myPlayer().isAttackable(); } @Override public int execute() { c.log("Attacking ankou"); NPC ankou = c.getNpcs().closest("Ankou"); if(ankou != null && ankou.isAttackable() && ankou.isVisible()) ankou.interact("Attack"); return 2000; } @Override public int priority() { return 4; } } BonesToPeaches.java import org.osbot.rs07.script.Script; public class BonesToPeaches extends Node { public BonesToPeaches(Script c) { super(c); } @Override public int priority() { return 1; } @Override public boolean validate() { if (c.getInventory().contains("Bones to peaches")) { if (c.getInventory().getAmount("Bones") >= 15) return true; if (c.getInventory().contains("Bones") && !c.getInventory().contains(6883)) return true; } return false; } @Override public int execute() { c.getInventory().getItem("Bones to peaches").interact("Break"); return 1000; } } Eat.java import org.osbot.rs07.script.Script; public class Eat extends Node { public Eat(Script c) { super(c); } @Override public int priority() { return 5; } @Override public boolean validate() { return (c.skills.myPlayer().getHealthPercent() <= 50 && c.getInventory().contains(6883)); } @Override public int execute() { c.getInventory().getItem(6883).interact("Eat"); return 100; } } Edited April 10, 2018 by crezzy 5 Quote Link to comment Share on other sites More sharing options...
Guy Fieri Posted April 9, 2018 Share Posted April 9, 2018 Clean and organized code, keep it up!! Quote Link to comment Share on other sites More sharing options...
Suorin Posted April 9, 2018 Share Posted April 9, 2018 Awesome! Good work man, keep it up. Quote Link to comment Share on other sites More sharing options...
Butters Posted April 9, 2018 Share Posted April 9, 2018 Sweet, nicely done. Just why do you reinitialize the loot array each time you run the validate method? String[] itemsToLoot = { "Death rune", "Blood rune", "Law rune", "Mithril ore", "Pure essence", "Adamant arrow", "Ranarr seed", "Torstol seed", "Snapdragon seed", "Bones" }; Just make it a class variable 1 Quote Link to comment Share on other sites More sharing options...
crezzy Posted April 9, 2018 Author Share Posted April 9, 2018 (edited) 11 minutes ago, Butters said: Sweet, nicely done. Just why do you reinitialize the loot array each time you run the validate method? String[] itemsToLoot = { "Death rune", "Blood rune", "Law rune", "Mithril ore", "Pure essence", "Adamant arrow", "Ranarr seed", "Torstol seed", "Snapdragon seed", "Bones" }; Just make it a class variable Good point. Shall make it a global variable instead. Thanks Edited April 9, 2018 by crezzy Quote Link to comment Share on other sites More sharing options...
Choke On Air Posted April 9, 2018 Share Posted April 9, 2018 Thank you, I love this Ankou killer Quote Link to comment Share on other sites More sharing options...
Chikan Posted April 9, 2018 Share Posted April 9, 2018 You might want to hide your username a bit better in the first screenshot. 1 Quote Link to comment Share on other sites More sharing options...
crezzy Posted April 10, 2018 Author Share Posted April 10, 2018 (edited) 14 hours ago, Chikan said: You might want to hide your username a bit better in the first screenshot. Haha didn't even notice. Thanks for letting me know Updated; added dragon dagger(p++) special attack. Can add more or even a text box or something for the user to input their special weapon if requested(it will automatically know your primary weapon and switch back to it). Edited April 10, 2018 by crezzy Quote Link to comment Share on other sites More sharing options...
vutspez Posted April 17, 2018 Share Posted April 17, 2018 just noticed it tried to spam pick up law rune drop but my invent was full. maybe something you can fix? Quote Link to comment Share on other sites More sharing options...
ScummyBotter Posted April 17, 2018 Share Posted April 17, 2018 Here's a 5 and a half hour proggy, still going strong! One thing I've noticed at further out zooms is that is can frequently misclick on the doors and lock you out as a result, haven't experienced it since I zoomed in though! 1 Quote Link to comment Share on other sites More sharing options...
erik1919 Posted May 14, 2018 Share Posted May 14, 2018 looks good i'll give it a try Quote Link to comment Share on other sites More sharing options...
er389 Posted May 20, 2018 Share Posted May 20, 2018 been running for a while, came into a few problems 1) if inventory is full but not all drops collected yet will spam the floor 2) the door thing from above 3) something else because i cant run it for more than like 4 hours without it shutting down , not exactly sure what happens for it to turn off Quote Link to comment Share on other sites More sharing options...
cokecan Posted June 12, 2018 Share Posted June 12, 2018 Great script only 2 complaints 1) the DDS spec is programmed to fast causing the script to get confused. 2) the script attempts to pick up items whilst inventory is full and doesn't make room (god knows how many seeds i missed without knowing this!) best to start app with 1 of each item that gets looted! Quote Link to comment Share on other sites More sharing options...