Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • isInCombat returning incorrectly?


    Rubick

    Recommended Posts

    Posted

    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?

    Posted

    You should be able to do this for now.

    if (!chicken.isInCombat() && !chicken.isInteractedWith()) {
    Posted

    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");
    
    Posted

     

    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.

    Posted

    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;
        }
    
    Posted

     

    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.

    Posted

    Checking it out


    Seems to be working for me, if you find any scenarios where it's wrong let me know :)

    Posted

    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.

    Posted

    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).

    Posted

    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.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.