Rubick 30 Share Posted August 1, 2017 I have a checker before attacking an NPC: if (!chicken.isInCombat()) { chicken.interact("Attack")) } Why is it still attacking chickens already in combat with other players? Link to comment Share on other sites More sharing options...
Pyth 127 Share Posted August 1, 2017 You should be able to do this for now. if (!chicken.isInCombat() && !chicken.isInteractedWith()) { Link to comment Share on other sites More sharing options...
Genius 48 Share Posted August 1, 2017 I have a checker before attacking an NPC: if (!chicken.isInCombat()) { chicken.interact("Attack")) } Why is it still attacking chickens already in combat with other players? Likely because when you declared the chicken object it wasn't in combat, though it could be broken. Is your chicken being updated (looped over)? Using a filter instead might be easier. Edit: If it is broken try adding Noodle's suggestion to the filter. //I didn't type this in an IDE so you might need to fix a syntax error or two =) NPC chicken = getNpcs().closest(c -> c != null && c.getName().equals("Chicken") && !c.isInCombat); if (chicken != null && !getLocalPlayer.isInCombat()) chicken.interact("Attack"); Link to comment Share on other sites More sharing options...
Rubick 30 Author Share Posted August 1, 2017 You should be able to do this for now. if (!chicken.isInCombat() && !chicken.isInteractedWith()) { Is IsInCombat() working as intended or is that part of the API bugged? Thanks for the work around. Link to comment Share on other sites More sharing options...
Genius 48 Share Posted August 1, 2017 Is IsInCombat() working as intended or is that part of the API bugged? Thanks for the work around. Run a script with this in your onLoop to test then just fight some stuff: @Override public int onLoop() { log("In combat: " + String.valueOf(getLocalPlayer().isInCombat())); return 1000; } Link to comment Share on other sites More sharing options...
Rubick 30 Author Share Posted August 1, 2017 Run a script with this in your onLoop to test then just fight some stuff: @Override public int onLoop() { log("In combat: " + String.valueOf(getLocalPlayer().isInCombat())); return 1000; } Ah, good thinking. I'll test this out tomorrow. Got the script running with 's fix to see if that works out of curiosity first. Link to comment Share on other sites More sharing options...
Pandemic 2494 Share Posted August 1, 2017 Checking it out Seems to be working for me, if you find any scenarios where it's wrong let me know Link to comment Share on other sites More sharing options...
Manly 879 Share Posted August 1, 2017 Checking it out Seems to be working for me, if you find any scenarios where it's wrong let me know I have a filter such as this: final Player p = getPlayers().closest(player -> player != null && player.exists() && player.isInCombat() && player.getInteractingCharacter() != null && player.isInteracting(getLocalPlayer())); It returns true even though the player trades me instead of attacking in the wilderness. Link to comment Share on other sites More sharing options...
Pandemic 2494 Share Posted August 1, 2017 I have a filter such as this: final Player p = getPlayers().closest(player -> player != null && player.exists() && player.isInCombat() && player.getInteractingCharacter() != null && player.isInteracting(getLocalPlayer())); It returns true even though the player trades me instead of attacking in the wilderness. There's no way we can differentiate between attacking / trading, they both just show as interacting with (our basis for isInCombat). Link to comment Share on other sites More sharing options...
Manly 879 Share Posted August 1, 2017 There's no way we can differentiate between attacking / trading, they both just show as interacting with (our basis for isInCombat). #isInCombat checks for interaction? I guess I should add a check for health bar visibility. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.