Rubick 30 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?
Pyth 128 Posted August 1, 2017 You should be able to do this for now. if (!chicken.isInCombat() && !chicken.isInteractedWith()) {
Genius 50 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");
Rubick 30 Author 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.
Genius 50 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; }
Rubick 30 Author 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.
Pandemic 2853 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
Manly 879 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.
Pandemic 2853 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).
Manly 879 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.