Jump to content

If player is animating, move mouse outside screeen?


08egans

Recommended Posts

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

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

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

 

Link to comment
Share on other sites

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

 

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