Jump to content

If Player is in Combat, Wait


jeremy4444

Recommended Posts

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;
    }
Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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