Jump to content

If Player is in Combat, Wait


Recommended Posts

Posted

I know what I'm doing wrong but I don't know the solution. player.isInCombat doesn't work.
 
Could I do: 

else(player.isInCombat()) {
Wait until player is out of combat
}

I'm not familiar with the API and I'm not really sure how I go about finding the bits and pieces I need for my script. The API website page is really confusing and hard to find exactly what I "think" I'm looking for.

    @Override
    public int onLoop() {


     NPC manWoman = npcs.closest("Man", "Woman");
     
     if(manWoman != null){
     manWoman.interact("Attack");
     }
     


        return 100;
    }
Posted

 

I will try that...This is what I came up with:

 

     if(players.getCombat() != null)
     Thread.sleep(1500, 2000);
        return 100;

 

I would just use !myPlayer().isUnderAttack, because that will kind of sleep it from interacting with men until its out of combat.

Posted (edited)

Thank you, it works, I'm going to change Return to 1500msec because it's spam clicking them. Also, they're inside a building, sometimes outside, I need something like:

 

If(manWoman.isUnreachable && doorObject.isClosed)

open door;

 

If you know any good tutorials for complete beginners, I will definitely read them. I feel bad for basically asking you to make this script for me.

Edited by jeremy4444
Posted (edited)

Thank you, it works, I'm going to change Return to 1500msec because it's spam clicking them. Also, they're inside a building, sometimes outside, I need something like:

If(manWoman.isUnreachable && doorObject.isClosed)

open door;

If you know any good tutorials for complete beginners, I will definitely read them. I feel bad for basically asking you to make this script for me.

Did you use the ! In front of myPlayer? ! Means not or the opposite of what you're saying. If(!inventory.isFull()) means if inventory is not full.

And you can just have the bot open the door every time it's closed to make things easier.

If(door.contains("Open")

door.interact("Open");

If you want to get more advanced you can override messageListener, and say whenever "I can't reach this" shows up in chat, open the door. Then you can also do a minimap check

Which I'm not to sure how to do, because I've never used it. Or you can just set an area that doesn't contain what's outside of the door and say like

If(!MANWOMANAREA.contains(manWoman))

manWoman.interact("Attack");

Edited by twin 763
Posted
if (map.canReach(manWoman)) {
Will test if you can reach the man, finding the door in the way is a bit harder. You can use a method similar to what Twin suggested for a simple fix, but it could pick the wrong door potentially.
This was the minimap way I was talking about. Couldnt remember it off the top of my head.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...