Alek Posted February 17, 2017 Share Posted February 17, 2017 Someone asked me for the source, here you go: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.ui.EquipmentSlot; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; import java.util.Arrays; import java.util.Comparator; import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; /** * Created by Alek on 6/26/2016. */ @ScriptManifest(name = "Macro Killer", author = "Alek", version = 1.4, info = "Macro Killer", logo = "") public class MacroKiller extends Script { private boolean isUsingRanged = false; private Area combatArea; private String state = "State: Idle"; private Font titleFont = new Font("Sans-Serif", Font.BOLD, 10); private String ammoType; private int ammoRemaining = 0; private boolean isAvasEquipped = false; private int collectAmmo = 0; private Predicate<NPC> suitableNPC = n -> getMap().canReach(n) && n.getHealthPercent() > 0 && n.hasAction("Attack") && combatArea.contains(n) && !n.isUnderAttack() && getMap().realDistance(n) < 7; private Predicate<GroundItem> suitableArrowStack = g -> g.getName().contains(ammoType) && getMap().realDistance(g) < 4; @Override public void onPaint(Graphics2D g) { g.setFont(titleFont); g.setColor(Color.WHITE); g.drawRect(mouse.getPosition().x - 3, mouse.getPosition().y - 3, 6, 6); g.drawString("Macro Killer v1.5 - Written by Alek", 10, 250); g.drawString(state, 10, 265); if (isUsingRanged) g.drawString("Remaining " + ammoType + "s: " + ammoRemaining, 10, 280); } @Override public void onStart() { if (getEquipment().getItemInSlot(EquipmentSlot.WEAPON.slot).getName().contains("bow")) { Item ammo = getEquipment().getItemInSlot(EquipmentSlot.ARROWS.slot); if (ammo != null && ammo.getAmount() > 1) { ammoType = ammo.getName().toLowerCase().split(" ")[1]; isUsingRanged = true; } if (isUsingRanged) { Item item = getEquipment().getItemInSlot(EquipmentSlot.CAPE.slot); isAvasEquipped = item != null && (item.getName().contains("Ava's")); } } combatArea = myPlayer().getArea(6); } @Override public int onLoop() { if (getSkills().getDynamic(Skill.HITPOINTS) < (getSkills().getStatic(Skill.HITPOINTS) / 2)) { state = "State: Looking for food to eat"; Optional<Item> foodItem = Arrays.stream(getInventory().getItems()).filter(i -> i != null && (i.hasAction("Eat") || i.hasAction("Drink"))).findFirst(); if (foodItem.isPresent()) { state = "State: Eating food " + foodItem.get().getName(); foodItem.get().interact("Eat", "Drink"); } else { state = "State: No food remaining, logging out"; stop(true); } } else if (!getCombat().isFighting() || myPlayer().getInteracting() == null) { if (isUsingRanged) { state = "State: Checking equipment for " + ammoType + "s"; Item arrows = getEquipment().getItemInSlot(EquipmentSlot.ARROWS.slot); if (arrows == null || arrows.getAmount() < 10) { state = "State: Not enough arrows, logging out"; stop(true); return 0; } ammoRemaining = arrows.getAmount(); state = "State: Scanning ground for " + ammoType + "s"; java.util.List<GroundItem> arrowItems = groundItems.getAll().stream().filter(suitableArrowStack).collect(Collectors.toList()); arrowItems.sort(Comparator.comparingInt(GroundItem::getAmount).thenComparingInt(GroundItem::getAmount).reversed()); if (!isAvasEquipped && !arrowItems.isEmpty()) { if (arrowItems.get(0).getAmount() > 1 || ((collectAmmo = ~collectAmmo & 1) == 1)) { state = "State: Looting " + arrowItems.get(0).getName() + "(s) with a stack size of " + arrowItems.get(0).getAmount(); if (arrowItems.get(0).interact("Take")) { ConditionalSleep pickup = new ConditionalSleep(4000, 500) { @Override public boolean condition() throws InterruptedException { return !arrowItems.get(0).exists(); } }; if (pickup.sleep()) { if (arrowItems.get(0).getName().equals(getEquipment().getItemInSlot(EquipmentSlot.ARROWS.slot).getName())) getInventory().interact("Wield", arrowItems.get(0).getId()); } } } } } state = "State: Searching for monsters to kill"; java.util.List<NPC> npcs = getNpcs().getAll().stream().filter(suitableNPC).collect(Collectors.toList()); if (!npcs.isEmpty()) { npcs.sort(Comparator.<NPC>comparingInt(a -> getMap().realDistance(a)).thenComparingInt(b -> getMap().realDistance(b))); if (npcs.get(0).interact("Attack")) { state = "State: Attacking " + npcs.get(0).getName(); new ConditionalSleep(3000, 500) { @Override public boolean condition() throws InterruptedException { return !npcs.get(0).exists() || npcs.get(0).isUnderAttack(); } }.sleep(); } } } return 500; } } 12 1 Quote Link to comment Share on other sites More sharing options...
Bamboozled Posted February 17, 2017 Share Posted February 17, 2017 Thanks king @Alek Quote Link to comment Share on other sites More sharing options...
Saiyan Posted February 17, 2017 Share Posted February 17, 2017 dank i will use this for my gwd 3 Quote Link to comment Share on other sites More sharing options...
k9thebeast Posted February 17, 2017 Share Posted February 17, 2017 (edited) @Alek Is this considered SIII material? Or is this just the standard we hold @Extreme Scripts to Edited February 17, 2017 by k9thebeast Quote Link to comment Share on other sites More sharing options...
Shudsy Posted February 17, 2017 Share Posted February 17, 2017 (edited) If i want to train ranged using a Seercull, won't the isUsingrRanged return false Edited February 17, 2017 by Shudsy Quote Link to comment Share on other sites More sharing options...
Alek Posted February 17, 2017 Author Share Posted February 17, 2017 1 minute ago, Shudsy said: If i want to train ranged using a Seercull, won't the isUsingrRanged return false It's a simple free script, don't expect the world. 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted February 17, 2017 Share Posted February 17, 2017 Great stuff. Will definitely help people to learn. Quote Link to comment Share on other sites More sharing options...
Satire Posted February 18, 2017 Share Posted February 18, 2017 Nice! Alek, the king of abusing lambda hehe Quote Link to comment Share on other sites More sharing options...
bournez Posted February 18, 2017 Share Posted February 18, 2017 god insta ban right`? Quote Link to comment Share on other sites More sharing options...
Eliot Posted June 24, 2017 Share Posted June 24, 2017 Thanks, helped me discover Optionals! 2 Quote Link to comment Share on other sites More sharing options...
sourcecos Posted June 27, 2017 Share Posted June 27, 2017 Did you not make a GUI? Quote Link to comment Share on other sites More sharing options...
Funfight Posted June 28, 2017 Share Posted June 28, 2017 On 6/27/2017 at 7:23 AM, sourcecos said: Did you not make a GUI? nope Quote Link to comment Share on other sites More sharing options...
TheRealAssume Posted July 28, 2017 Share Posted July 28, 2017 if (ammo != null && ammo.getAmount() > 1) { ammoType = ammo.getName().toLowerCase().split(" ")[1]; isUsingRanged = true; } if (isUsingRanged) { Item item = getEquipment().getItemInSlot(EquipmentSlot.CAPE.slot); isAvasEquipped = item != null && (item.getName().contains("Ava's")); } What's the point of this code? There's no reason to have a check for isUsingRanged right after setting the value of isUsingRanged. Just put that code in the previous if statement. Quote Link to comment Share on other sites More sharing options...
Kira1 Posted July 30, 2017 Share Posted July 30, 2017 what's the code behind this? does npc have to have hitsplats on them or wat cuz for splashing it attacks npcs under atk already Quote !n.isUnderAttack() Quote Link to comment Share on other sites More sharing options...
Chris Posted July 30, 2017 Share Posted July 30, 2017 27 minutes ago, Kira1 said: what's the code behind this? does npc have to have hitsplats on them or wat cuz for splashing it attacks npcs under atk already try npc.getInteracting() == null 1 Quote Link to comment Share on other sites More sharing options...