supadupap00p 0 Posted May 13, 2021 Hey guys, This references my previous post, I'm generally okay with dealing with other players using the following line: NPC cow = NPCs.closest(c -> c != null && c.getName().contains(target) && !c.isHealthBarVisible() && !c.isInCombat() && c.getInteractingCharacter() == null && !c.isInteractedWith()); I know its overkill now but I kept having this issue where my player would attack a cow that was in combat with someone else. On closer inspection however this seemed to only be happening with players who were using ranged/magic and seemed to only happen when the bot and the other player clicked the cow at roughly the same time. When this happens the bot will just stop doing anything until the cow that the other player is attacking is dead, then it will resume normal behaviour. I was wondering is there a way to detect say after the bot has clicked and the message shows up that "Someone else is fighting that." that the bot should immediately look for another target? Again any pointers would be much appreciated.
NovaGTX 106 Posted May 13, 2021 Implement ChatListener and utilize the onGameMessage function. Edit: Do not perform the action within that thread though. You should only interact through your onLoop
una_maquina 35 Posted May 15, 2021 You can do an animation check, if(Client.getLocalPlayer().isAnimating()){} after it attacks the cow> then sleepUntil the cow is dead; otherwise just try to find another target using your filter, if that makes sense. I would go about doing this like this: NPC cow = NPCs.closest(c -> c != null && c.getName().contains(target) && !c.isHealthBarVisible() && !c.isInCombat() && c.getInteractingCharacter() == null && !c.isInteractedWith()); if(cow != null){ if(cow.interact()){ methodProvider.sleepUntil(()-> Client.getLocalPlayer().isAnimating(),Calculations.random(5000,7000)); if(Client.getLocalPlayer().isAnimating()){ // logic goes here; if the player isn't animating, it'll find another suitable target basically } } } MethodProvider.sleep(Calculations.random(200,400)); And you can take it step further by sleeping until the player stops moving, and then see if they're animating or not
Recommended Posts
Archived
This topic is now archived and is closed to further replies.