08egans Posted October 7, 2017 Share Posted October 7, 2017 (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 October 7, 2017 by 08egans Quote Link to comment Share on other sites More sharing options...
Juggles Posted October 7, 2017 Share Posted October 7, 2017 mouse.moveOutSideScree(); 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted October 8, 2017 Share Posted October 8, 2017 @08egans Don't use isAnimating() use underAttack() if (myPlayer().isUnderAttack()) { getMouse.moveOutsideScreen(); } Quote Link to comment Share on other sites More sharing options...
08egans Posted October 9, 2017 Author Share Posted October 9, 2017 (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 October 9, 2017 by 08egans added in code and info Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 9, 2017 Share Posted October 9, 2017 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 Quote Link to comment Share on other sites More sharing options...
whipz Posted October 10, 2017 Share Posted October 10, 2017 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 Quote Link to comment Share on other sites More sharing options...
08egans Posted October 12, 2017 Author Share Posted October 12, 2017 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 Quote Link to comment Share on other sites More sharing options...
whipz Posted October 12, 2017 Share Posted October 12, 2017 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 Quote Link to comment Share on other sites More sharing options...