June 25, 20178 yr So I'm trying to make the bot not attack the NPC that is under attack. I tried using !closestMonster.isInteracting() but no luck. NPC closestMonster = s.getNpcs().closest(Vars.radius, Vars.combatMonster); if (closestMonster != null && !closestMonster.isAttackable() && s.getInventory().contains(Vars.combatFood)) { s.getWalking().walk(closestMonster); } else if (closestMonster != null && !s.myPlayer().isUnderAttack() && s.getInventory().contains(Vars.combatFood)) { if (s.myPlayer().isAnimating()) { Vars.lastAnimation = System.currentTimeMillis(); } else if (closestMonster.interact("Attack") && System.currentTimeMillis() > (Vars.lastAnimation + 1000)) { Paint.status = "Attacking..."; Sleep.sleepUntil(() -> s.myPlayer().isUnderAttack(), 5000); } } Edited June 25, 20178 yr by Visty
June 25, 20178 yr I imagine you don't want to attack an NPC which is under attack, but you want to attack one which is not. Here's how to find that monster: NPC notUnderAttack = getNpcs().closest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return !npc.isUnderAttack() && !npc.isAnimating(); } }); Edited June 25, 20178 yr by Adept
June 25, 20178 yr Author 7 minutes ago, Adept said: I imagine you don't want to attack an NPC which is under attack, but you want to attack one which is not. Here's how to find that monster: NPC notUnderAttack = getNpcs().closest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc.isAttackable() && !npc.isHitBarVisible() && !npc.isAnimating(); } }); But will that fix the issue with people splashing on NPCs? Because, isUnderAttack() seems to fix the issue with people normally attacking the NPC. But when people splash on NPCs, you can't see their HitBar, so it doesn't work Edited June 25, 20178 yr by Visty
June 25, 20178 yr Don't quote me on this but I believe NPCs "animate" when under attack (and are being splashed on) so !npc.isAnimating() should take care of that. Also, I just checked the API and the "!npc.isUnderAttack()" check in the filter I provided earlier is redundant since it's already checked for with "npc.isAttackable()". However since you explicitly stated to check for an NPC which is not under attack and not one which is attackable it makes more sense to keep the former. Edited my reply to reflect that. Edited June 25, 20178 yr by Adept
June 25, 20178 yr I think this will work for you. NPC npc = getNpcs().closest(npc -> npc.getName().equals(npcName) && npc.getInteracting() == null && !npc.isUnderAttack()); If an NPC is being splashed on #getInteracting will not return null (iirc). Edited June 25, 20178 yr by Eliot
June 26, 20178 yr Author 3 hours ago, Eliot said: I think this will work for you. NPC npc = getNpcs().closest(npc -> npc.getName().equals(npcName) && npc.getInteracting() == null && !npc.isUnderAttack()); If an NPC is being splashed on #getInteracting will not return null (iirc). I appreciate your responds. Your piece of code works Also, just noticed that my code above checks useless stuff in the If statements lel Edited June 26, 20178 yr by Visty
June 26, 20178 yr Author 3 hours ago, Alek said: Try checking out my Macro Killer source code, I made it public. Thank you, will do
June 26, 20178 yr 51 minutes ago, Visty said: I appreciate your responds. Your piece of code works Also, just noticed that my code above checks useless stuff in the If statements lel Awesome! I'm glad I could help.
June 26, 20178 yr 7 hours ago, Alek said: Try checking out my Macro Killer source code, I made it public. Link?
Create an account or sign in to comment