Deep Slayer 63 Posted February 28, 2021 Here's a simple chicken killer script I made to share. I know there are a tonne of these but I wanted to see if I could make a script without using any loops therefore only relying on the main onLoop method. Any and all feedback welcome, Thanks! Note: it's a range only script, you just need to equip a bow and iron arrows (specifically iron arrows). file download is: https://github.com/deepslayer/Dreambot/blob/main/SimpleRangeChickenKiller.jar Source code below: package Fighter; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.item.GroundItems; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.items.GroundItem; @ScriptManifest(name = "Chicken Ranger", description = "Equip a bow and Iron arrows", author = "DeepSlayer", version = 1.0, category = Category.COMBAT, image = "") public class SimpleChickenRanger extends AbstractScript { //Areas Area chickenArea = new Area(3172, 3300, 3183, 3290, 0); @Override public int onLoop() { attackPickUpLoot(); walkToBank(); walkToChickenArea(); equipIronArrows(); return Calculations.random(400,750); } //methods here private void attackPickUpLoot(){ //if im not in combat, Inventory isn't full and player is at the chicken area.. then we kill and loot if(!getLocalPlayer().isInCombat() && !Inventory.isFull() && chickenArea.contains(getLocalPlayer()) ) { NPC Chicken = NPCs.closest("Chicken"); //define closest chicken GroundItem ironArrow = GroundItems.closest("Iron arrow");//define the iron arrows //if chicken Not null, chicken can be attacked, chickens not in combat, and there are no iron arrows on the floor near us, then we can kill if (Chicken != null && Chicken.hasAction("Attack") && !Chicken.isInCombat() && (ironArrow == null || ironArrow.distance() >= 5 ) ) { Chicken.interact("Attack"); sleep(1500,2000); sleepUntil(()->!getLocalPlayer().isInteractedWith(),10000); //if nothings interacting with me, inventory is not full, and im in the chicken area, then we can loot bones. if (!getLocalPlayer().isInteractedWith() && !Inventory.isFull() && chickenArea.contains(getLocalPlayer())) { GroundItem Bones = GroundItems.closest("Bones"); int currentBoneCount = Inventory.count("Bones"); //gets current bone count before we pick new bones up if (Bones != null && Bones.hasAction("Take")) { Bones.interact("Take"); sleep(750, 1200); sleepUntil(() -> Inventory.count("Bones") > currentBoneCount, 5000); } } } if(!getLocalPlayer().isInteractedWith() && !Inventory.isFull() && chickenArea.contains(getLocalPlayer())) { if (ironArrow != null && ironArrow.hasAction("Take") && ironArrow.distance() <= 5 ) { ironArrow.interact("Take"); sleep(1000, 1500); } } } } private void walkToBank(){ //if the inventory is full, then we walk to the closest bank and open it if(Inventory.isFull()){ if(!Bank.isOpen()){ Bank.openClosest(); sleep(1000,1500); sleepUntil(()-> Walking.getDestinationDistance() > 5 ,5000); } //if the bank is open we deposit all items and close bank if(Bank.isOpen()){ Bank.depositAllItems(); sleep(1000,1500); Bank.close(); sleep(1000,1500); } } } private void walkToChickenArea(){ //if we arent at the chicken area and our Inventory is NOT full, then we walk to chicken area if(!chickenArea.contains(getLocalPlayer()) && !Inventory.isFull()){ Walking.walk(chickenArea.getRandomTile()); sleep(1000,1500); sleepUntil(()-> Walking.getDestinationDistance() > 5 ,5000); } } private void equipIronArrows(){ int rand = Calculations.random(10,20); //if our inventory has more than 10 arrows and rand lands on 15, then we can weild our arrows if((Inventory.count("Iron arrow") > 10 && rand == 15) || Inventory.isFull() ){ Inventory.interact("Iron arrow", "Wield"); sleep(1000,1500); } } }
yeeter 539 Posted February 28, 2021 Nice! While this does work you should look into the DreamBot TaskNode structure or making your own node system. It will help a ton as you progress and create larger and more complicated scripts! I haven't looked at this template for awhile so not even sure if it is up to date right now but this should point you in the right direction! https://github.com/yeetware/Dreambot-3-Node-Template If you need any help understanding / implementing something like this feel free to hit me up!
Deep Slayer 63 Author Posted March 1, 2021 Hey yeeter, Thanks for the recommendation I actually do want to get into working with the taskscript system as the scripts that I write formyself are quite long. I don't quite understand it yet but I will have a look at your link when I get more time again. Thanks!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.