Jump to content

How to constantly check if under attacked?


The Legman

Recommended Posts

On 24-11-2017 at 12:14 PM, The Legman said:

onLoop.PNG.2e966a32ebee923378562df4e2e9c591.PNG This currently how I build my scripts. The issue is when it runs through a task, such as normalRocks ( a completely different script btw), it will never interrupt that task while it's mid way done - which is what I want it to do. Thus I will end up trying to put that code in the onLoop. Thanks!

Stopscript == true?

 

Link to comment
Share on other sites

If you're using conditional sleeps, your bot will be unresponsive to attacking players. Add a condition in your conditional sleep to check if you're under attack to break out of the sleep, and have your "under attack" case be first in your code so it takes priority.

new ConditionalSleep(45000){
	public boolean condition() throws InterruptedException {
		return myPlayer().isUnderAttack() || (other conditions);
	}
}.sleep();

 

Link to comment
Share on other sites

Just to expand on what HeyImJamie said. Only teleporting after you're under attack might be too late and hopping afterwards is impossible. You can iterate through the players that are loaded and check if their combat level can attack you(Example: Your combat level is 30, they're 45 and you're in 10 wilderness it won't hop or teleport. If they're 37, you would hop.). If you don't want to do that, an easier way to do it would be to check the size of local players and if it's greater than 2 it will hop(It counts your player). This will hop no matter what though, whether they can attack you or not. Then check for active tasks. 

 

P.S I would also recommend checking for teleblock with onMessage so that you don't have the bot spamming the teleport. And isUnderAttack so it's not trying to hop worlds.

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