RealEngine 24 Share Posted October 24, 2015 We all use combat methods that get the player in combat and player interacting !=null The problem with these is that they are awful. When in combat they will frequently return false because of the few tick delay between attacking and getting attacked and then run off trying to attack something else. I don't know how you get around this over at dreambot, but here is how I did it. (basically adds a delay after after not in combat to avoid the bot returning false for incombat method, thus not running around clicking shit) make a bool for incombat and isrunning public boolean isruning; public boolean inCombatBool = false; next in your onstart method, make a new thread that does the following isruning = true; Thread t = new Thread(() -> { int x = 0; while (isruning) { if ((getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() != null) || getLocalPlayer().getAnimation() != -1) { inCombatBool = true; x=0; } else if (x > 8) { inCombatBool = false; x = 0; } x++; log(String.valueOf(inCombatBool)); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } }); t.start(); now in your loop if (!inCombatBool) { attack(); sleep(Calculations.random(3000, 4000)); } and the method being called public void attack() { NPC slayerTask = getNpcs().closest(npc -> npc != null && npc.getName() != null && !npc.isInCombat()); if (slayerTask != null) { if (slayerTask.interact("Attack")) { changeStatus("Attacking"); sleepUntil(() -> getLocalPlayer().isInCombat() || getLocalPlayer().getInteractingCharacter() != null, Calculations.random(5000, 7000)); } } } lastly on your onExit @Override public void onExit() { super.onExit(); isruning = false; } Link to comment Share on other sites More sharing options...
JoeVasquez927 0 Share Posted February 28, 2016 Hey! I'm totally interested in learning about more code. Could you throw in some comments describing each of the steps for us noobs? Best, Joe. Link to comment Share on other sites More sharing options...
PancakePunche 0 Share Posted September 17, 2016 Hey, I just finished trying this out and it's unfortunately not waiting long enough before attacking the next NPC. I have tried increasing the delay but it doesn't seem to be working. Also, the part of the code changeStatus("Attacking"): Had to make a private void changeStatus(String attacking) { } to function properly. I am pretty sure nothing is incorrect from yours. I did not copy and paste it so I could get a better understanding of it and for the most part I get it. I little bit of help on the matter would be awesome? Edit: I fixed it! :] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.