Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

If player is animating, move mouse outside screeen?

Featured Replies

Hi guys,

sorry if this is a stupid question with a simple explanation im very new to teaching myself java and scripting!

 

im having a bit of trouble with this and i couldnt find anything on the forums about it. Basically i'm making a script, and when im in combat i want the mouse to move outside of the screen, but i cant figure out exactly how to code it in. I have it written where the code should be going in!

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.Mouse;


@ScriptManifest(author = "08egans", info = "Kills ", logo = "", name = "Demon Slayer", version = 0)


public class main extends Script {
	
	public void onStart(){
		
		log("Welcome to my script!");
		
	}
	
	public void onExit(){
		
		log("Thank you for using my script, goodbye!");
		
	}
	
	public int onLoop() throws InterruptedException{
		
		NPC lesserdemon = getNpcs().closest("Lesser demon");
		if(lesserdemon !=null && !myPlayer().isAnimating()){
			lesserdemon.interact("Attack");
		}
		
		if(myPlayer().isAnimating()){
			// here is where i need help
		}
		
		return random(750,300);
	}

}

Thanks for your help guys! :)

Edited by 08egans

@08egans

Don't use isAnimating() use underAttack()

if (myPlayer().isUnderAttack()) {
  getMouse.moveOutsideScreen();
}

 

  • Author

@Viston well the problem is that im not actually getting hit, its the wizards tower lesser demon on f2p. I've gotten this issue sorted but i can't get it to stop attacking, its on a constant loop of attacking, then moving mouse outside the screen, then coming back in and attacking again. any ideas? :)

 

code 

 

is there something i could do with the return, like somehow make it return if my player has stopped animating?

or could it be on the if part, if i could make it say if lesserdemon is not under attack then to interact and attack? im just not exactly sure how to code this part in.

 


		import org.osbot.rs07.script.Script;
		import org.osbot.rs07.script.ScriptManifest;
		import org.osbot.rs07.api.model.NPC;
		import org.osbot.rs07.utility.ConditionalSleep;



		@ScriptManifest(author = "08egans", info = "Kills ", logo = "", name = "", version = 0)


		public class main extends Script {
			
			public void onStart(){
				
				log("Welcome to my script!");
				
			}
			
			public void onExit(){
				
				log("Thank you for using my script, goodbye!");
				
			}
			
			public int onLoop() throws InterruptedException{
				
				NPC lesserdemon = getNpcs().closest("Lesser demon");
				if(lesserdemon !=null && !myPlayer().isAnimating()){
					lesserdemon.interact("Attack");
				
					
				}
				
				if(myPlayer().isAnimating()){
					mouse.moveOutsideScreen();
					

				
			}
				
			return 500;
		}
		}

thank you :)

Edited by 08egans
added in code and info

change myPlayer().isAnimating() to myPlayer().isInteracting() maybe?
You could also try changing it to lesserdemon.isUnderAttack(), but you will need to filter out all of the demons you dont want to attack.
In the code you have now you are not checking if someone else is fighing the demon etc...

18 minutes ago, 08egans said:

@Viston well the problem is that im not actually getting hit, its the wizards tower lesser demon on f2p. I've gotten this issue sorted but i can't get it to stop attacking, its on a constant loop of attacking, then moving mouse outside the screen, then coming back in and attacking again. any ideas? :)

 

code 

 

is there something i could do with the return, like somehow make it return if my player has stopped animating?

or could it be on the if part, if i could make it say if lesserdemon is not under attack then to interact and attack? im just not exactly sure how to code this part in.

 



		import org.osbot.rs07.script.Script;
		import org.osbot.rs07.script.ScriptManifest;
		import org.osbot.rs07.api.model.NPC;
		import org.osbot.rs07.utility.ConditionalSleep;



		@ScriptManifest(author = "08egans", info = "Kills ", logo = "", name = "", version = 0)


		public class main extends Script {
			
			public void onStart(){
				
				log("Welcome to my script!");
				
			}
			
			public void onExit(){
				
				log("Thank you for using my script, goodbye!");
				
			}
			
			public int onLoop() throws InterruptedException{
				
				NPC lesserdemon = getNpcs().closest("Lesser demon");
				if(lesserdemon !=null && !myPlayer().isAnimating()){
					lesserdemon.interact("Attack");
				
					
				}
				
				if(myPlayer().isAnimating()){
					mouse.moveOutsideScreen();
					

				
			}
				
			return 500;
		}
		}

thank you :)

 

On ‎10‎/‎10‎/‎2017 at 1:24 AM, 08egans said:

@Viston well the problem is that im not actually getting hit, its the wizards tower lesser demon on f2p. I've gotten this issue sorted but i can't get it to stop attacking, its on a constant loop of attacking, then moving mouse outside the screen, then coming back in and attacking again. any ideas? :)

 

code 

 

is there something i could do with the return, like somehow make it return if my player has stopped animating?

or could it be on the if part, if i could make it say if lesserdemon is not under attack then to interact and attack? im just not exactly sure how to code this part in.

 



		import org.osbot.rs07.script.Script;
		import org.osbot.rs07.script.ScriptManifest;
		import org.osbot.rs07.api.model.NPC;
		import org.osbot.rs07.utility.ConditionalSleep;



		@ScriptManifest(author = "08egans", info = "Kills ", logo = "", name = "", version = 0)


		public class main extends Script {
			
			public void onStart(){
				
				log("Welcome to my script!");
				
			}
			
			public void onExit(){
				
				log("Thank you for using my script, goodbye!");
				
			}
			
			public int onLoop() throws InterruptedException{
				
				NPC lesserdemon = getNpcs().closest("Lesser demon");
				if(lesserdemon !=null && !myPlayer().isAnimating()){
					lesserdemon.interact("Attack");
				
					
				}
				
				if(myPlayer().isAnimating()){
					mouse.moveOutsideScreen();
					

				
			}
				
			return 500;
		}
		}

thank you :)

Sorry if its been answered for you; However you can do what you were asking.

Code could be wrong, as I am at work with no IDE but it should be something along the lines of,

lessordemon.isUnderAttack() || lessordemon.isInteracting(myPlayer()) <-- not sure if that's correct but along those lines

 

  • Author

Thanks guys yeah i was able to get it sorted @whipz using that exact thing, mixing some trial and error and the info from you guys :) thanks

3 minutes ago, 08egans said:

Thanks guys yeah i was able to get it sorted @whipz using that exact thing, mixing some trial and error and the info from you guys :) thanks

Awesome gl on your script

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.