Jump to content

If player is animating, move mouse outside screeen?


Recommended Posts

Posted (edited)

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
Posted (edited)

@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
Posted

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

 

Posted
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

 

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