Random Loop 0 Share Posted February 1, 2018 I'm just beggining to make some basic scripts for runescape and having tons of fun with it ! Recently, I made a script that'd simply kill chickens. I have ran into 2 problems ; Splasher. I don't know how to avoid them, my filters are that the npcs is not null, is a chicken and that he's not in combat, but I don't see how I could differentiate the ones that are being splashed vs the ones that aren't. Are there any ways? Secondly, I'd like my bot to collect feathers after killing the chickens. My solution to that would simply that after killing a chicken, the bot would wait 1.5 seconds (return 1500;) and then getGroundItem.getClosest("Feather); but I can't get the "getClosest" to actually work. Here's my code : import org.dreambot.api.methods.filter.Filter;import org.dreambot.api.methods.map.Area;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(version = 1.4, name = "Chicken Killer & Looter", category = Category.COMBAT, author = "Random Looper")public class Main extends AbstractScript {public static final String CHICKEN = "Chicken";public static final Filter<NPC> CHICKEN_FILTER = new Filter<NPC>() {@Overridepublic boolean match(NPC npc) {if (npc == null || npc.isInCombat()){return false;}return npc.getName().equals(CHICKEN);}};Area killArea = new Area(3225, 3300, 3233, 3294); // Upper left and bottom right corner of where the chickens are@Overridepublic int onLoop() {if(getLocalPlayer().isInCombat()){}else if (killArea.contains(getLocalPlayer())){NPC chicken = getNpcs().closest(CHICKEN); //Attacks the closest chicken if you're in the "kill area"if(chicken != null){chicken.interact("Attack");}}else {getWalking().walk(killArea.getCenter());}return 1000;}} Thanks for the help! Link to comment Share on other sites More sharing options...
Tweeboy 17 Share Posted February 1, 2018 Try checking for npc.getInteractingCharacter = null and see if that works? getGroundItem should work, what does your looting snippet look like atm? Link to comment Share on other sites More sharing options...
Random Loop 0 Author Share Posted February 1, 2018 Try checking for npc.getInteractingCharacter = null and see if that works? getGroundItem should work, what does your looting snippet look like atm? By snippet you mean recommendation? It "recommends" getGroundItem.getGroundItem or getGroundItem.Getclass and I've noticed that my bots sometimes clicks chickens that are in combat, is that because or the "lag" or because I did my filter wrong? Not 100% sure how the filter works yet, I'd have put all that in the loop but I guess it's too ressource intensive? Link to comment Share on other sites More sharing options...
Tweeboy 17 Share Posted February 1, 2018 By snippet you mean recommendation? It "recommends" getGroundItem.getGroundItem or getGroundItem.Getclass and I've noticed that my bots sometimes clicks chickens that are in combat, is that because or the "lag" or because I did my filter wrong? Not 100% sure how the filter works yet, I'd have put all that in the loop but I guess it's too ressource intensive? Can I see how you're trying to call detecting + picking up the Feathers? May just be a mistake there. And if someone is splashing I think isInCombat will return false Link to comment Share on other sites More sharing options...
Random Loop 0 Author Share Posted February 1, 2018 Can I see how you're trying to call detecting + picking up the Feathers? May just be a mistake there. And if someone is splashing I think isInCombat will return false GroundItem feather = getGroundItems().getClosest("Feather"); so then in my loop, I'd have chicken.interact("Attack"); return 1500; GroundItem feather = getGroundItems().getClosest("Feather"); (I'm not sure if I repeat that one or where to put it exactly, but I know it's supposed to go somewhere). getClosest gets underlined and when I hover over it it tells me that it "cannot resolve method" inCombat didn't seem to work, but I've lost my splasher now so I can't really test Thanks a lot for the help by the way! Link to comment Share on other sites More sharing options...
Tweeboy 17 Share Posted February 1, 2018 GroundItem feather = getGroundItems().getClosest("Feather"); so then in my loop, I'd have chicken.interact("Attack"); return 1500; GroundItem feather = getGroundItems().getClosest("Feather"); (I'm not sure if I repeat that one or where to put it exactly, but I know it's supposed to go somewhere). getClosest gets underlined and when I hover over it it tells me that it "cannot resolve method" inCombat didn't seem to work, but I've lost my splasher now so I can't really test Thanks a lot for the help by the way! getGroundItems().getClosest("Feather"); is just declaring GroundItem feather. You need to call feather.interact to actually pick it up Link to comment Share on other sites More sharing options...
Random Loop 0 Author Share Posted February 1, 2018 getGroundItems().getClosest("Feather"); is just declaring GroundItem feather. You need to call feather.interact to actually pick it up If I put this code : import org.dreambot.api.methods.filter.Filter; import org.dreambot.api.methods.map.Area; 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(version = 1.5, name = "Chicken Killer & Looter", category = Category.COMBAT, author = "Random Looper") public class Main extends AbstractScript { public static final String CHICKEN = "Chicken"; public static final Filter<NPC> CHICKEN_FILTER = new Filter<NPC>() { @Override public boolean match(NPC npc) { if (npc == null || npc.isInCombat() || npc.isHealthBarVisible()){ return false; } return npc.getName().equals(CHICKEN); } }; Area killArea = new Area(3225, 3300, 3233, 3294); // Upper left and bottom right corner of where the chickens are GroundItem feather = getGroundItems().getClosest("Feather"); @Override public int onLoop() { if(getLocalPlayer().isInCombat()){ }else if (killArea.contains(getLocalPlayer())){ NPC chicken = getNpcs().closest(CHICKEN); //Attacks the closest chicken if you're in the "kill area" if(chicken != null){ chicken.interact("Attack"); return 1500; feather.interact("Take"); } }else { getWalking().walk(killArea.getCenter()); } return 1000; } } and try to build, it gives me this error : Error:(23, 46) java: cannot find symbol symbol: method getClosest(java.lang.String) location: class org.dreambot.api.methods.item.GroundItems Also any reason I shouldn't add filters inside of my loop itself or is it like I said because of ressources purpose? Link to comment Share on other sites More sharing options...
Peso 61 Share Posted February 1, 2018 GroundItem feather = getGroundItems().getClosest("Feather"); not sure if this will fix it, but put that in your onLoop. also, you aren't always going to kill the chicken after 1.5 seconds so that is a poor way of deciding when to loot them. edit: just realized you are never going to reach the looting part because you have a return directly before it. use sleep(x); instead Link to comment Share on other sites More sharing options...
Random Loop 0 Author Share Posted February 1, 2018 GroundItem feather = getGroundItems().getClosest("Feather"); not sure if this will fix it, but put that in your onLoop. also, you aren't always going to kill the chicken after 1.5 seconds so that is a poor way of deciding when to loot them. edit: just realized you are never going to reach the looting part because you have a return directly before it. use sleep(x); instead Holy, in my mind my shit made sense because the return 1500; was after the chicken died but you're absolutely right, the chicken might not die. Is there any way to check when you exit combat? or should i put inside that if another if statement checking if chicken hp is 0 wait x amount of second then loot (this one makes sense no?) And nope, still the red text and doesn't let me build, should I take a screenshot? edit : Any reason that after I quote something and reply it shows as nothing on the board and I have to re-do my whole comment everytime? Link to comment Share on other sites More sharing options...
Tweeboy 17 Share Posted February 1, 2018 If I put this code : import org.dreambot.api.methods.filter.Filter; import org.dreambot.api.methods.map.Area; 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(version = 1.5, name = "Chicken Killer & Looter", category = Category.COMBAT, author = "Random Looper") public class Main extends AbstractScript { public static final String CHICKEN = "Chicken"; public static final Filter<NPC> CHICKEN_FILTER = new Filter<NPC>() { @Override public boolean match(NPC npc) { if (npc == null || npc.isInCombat() || npc.isHealthBarVisible()){ return false; } return npc.getName().equals(CHICKEN); } }; Area killArea = new Area(3225, 3300, 3233, 3294); // Upper left and bottom right corner of where the chickens are GroundItem feather = getGroundItems().getClosest("Feather"); @Override public int onLoop() { if(getLocalPlayer().isInCombat()){ }else if (killArea.contains(getLocalPlayer())){ NPC chicken = getNpcs().closest(CHICKEN); //Attacks the closest chicken if you're in the "kill area" if(chicken != null){ chicken.interact("Attack"); return 1500; feather.interact("Take"); } }else { getWalking().walk(killArea.getCenter()); } return 1000; } } and try to build, it gives me this error : Error:(23, 46) java: cannot find symbol symbol: method getClosest(java.lang.String) location: class org.dreambot.api.methods.item.GroundItems Also any reason I shouldn't add filters inside of my loop itself or is it like I said because of ressources purpose? GroundItem feather = getGroundItems().getClosest("Feather"); should be GroundItem feather = getGroundItems().closest("Feather"); also if (chicken != null) { chicken.interact("Attack"); return 1500; feather.interact("Take"); } the feather.interact("Take"); will never be reached, put it before the return if (chicken != null) { chicken.interact("Attack"); feather.interact("Take"); return 1500; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.