Gearfighter Posted July 28, 2016 Posted July 28, 2016 Hi Everyone, My name is Gearfighter, I am interested in making a script (to start off a Flesh Crawler script) I have an understanding of some of the basics and i have looked at every tutorial i can find on this site, and any other site i could find. I was just wondering if anyone wanted to help teach me how to make a basic script. Currently these are the problems i am running into. Bot clicks regulary on NPC it is attacking (when i think that it should only be once) If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack. I think currently these are my first 2 issues that i am currently having. i will implement banking and walking at some stage, but i want to get the basic function of what the script is right first, and nice and clean as well. If you can reply here, PM me or leave me a skype username so that i can get some help, that would be greatly appreieted. If you need any more information, dont hesitate to ask and i will try my best. Cheers, Gearfighter
Juggles Posted July 28, 2016 Posted July 28, 2016 (edited) Bot clicks regulary on NPC it is attacking (when i think that it should only be once) If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack. If (myPlayer.isUnderAttack) { //doNothing } else { //Attack NPC } This will fix both your problems because it won't attack in combat. This is very basic, but should work for now. Of course you can add other things. As Acerd said, It would be helpful if you post your PasteBin. Edited July 28, 2016 by lg_juggles
Saiyan Posted July 28, 2016 Posted July 28, 2016 Hi Everyone, My name is Gearfighter, I am interested in making a script (to start off a Flesh Crawler script) I have an understanding of some of the basics and i have looked at every tutorial i can find on this site, and any other site i could find. I was just wondering if anyone wanted to help teach me how to make a basic script. Currently these are the problems i am running into. Bot clicks regulary on NPC it is attacking (when i think that it should only be once) If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack. I think currently these are my first 2 issues that i am currently having. i will implement banking and walking at some stage, but i want to get the basic function of what the script is right first, and nice and clean as well. If you can reply here, PM me or leave me a skype username so that i can get some help, that would be greatly appreieted. If you need any more information, dont hesitate to ask and i will try my best. Cheers, Gearfighter The first one is (after your interaction? if so you need to sleep or conditonal sleep under the conditions that getCombat().isFighting() && myPlayer().isUnderAttack() 2) you should always when finding a new npc and attacking check if !myPlayer().isUnderAttack() which simply means if our player isnt underattack (! means not in simple terms) (hopefully you get the gist and this works for you i hope) also post the a small section of your npc finding and interaction code :P
Gearfighter Posted July 29, 2016 Author Posted July 29, 2016 Here is my code (sorry i dont know how to pastebin right lol). Like i said this is very basic and i just want it to attack properly first before i throw anything else into the mix import java.awt.Graphics2D; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "Gearz Flesh Crawler Killer", author = "Alek", version = 1.0, info = "", logo = "") public class GearzFleshCrawlerKiller extends Script { @Override public void onStart() { log("Time to kill some Flesh Crawlers"); } @Override public void onExit() { } @Override public int onLoop() throws InterruptedException { NPC FleshCrawler = npcs.closest("Flesh Crawler"); myPlayer().getCombatTime(); myPlayer().isMoving(); { if (FleshCrawler != null) { if (FleshCrawler.isVisible()) { FleshCrawler.interact("Attack"); sleep(random(600, 900)); } else { camera.toEntity(FleshCrawler); } } sleep(random(300, 600)); } return (random(600, 900)); // The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { // This is where you will put your code for paint(s) } } Also another thing i just thought of is how do i make it so it doesnt attack mobs that are already under attack from someone else?
Gearfighter Posted July 29, 2016 Author Posted July 29, 2016 (edited) ***UPDATE**** http://pastebin.com/8XLQ1iFj This is the new updated one i just worked out today. Currently Fixes the multiple clicking on the npc while in combat problem. Now just need to work on the attacking npcs currently under attack. If you could just have a look at my coding and let me know if its ok or if it is able to be trimmed down/cleaned up that would be awesome. Thankyou all for your help so much, looking to be a contributor here. Cheers, Gearfighter Edited July 29, 2016 by Gearfighter
Chris Posted July 29, 2016 Posted July 29, 2016 (edited) ***UPDATE**** http://pastebin.com/8XLQ1iFj This is the new updated one i just worked out today. Currently Fixes the multiple clicking on the npc while in combat problem. Now just need to work on the attacking npcs currently under attack. If you could just have a look at my coding and let me know if its ok or if it is able to be trimmed down/cleaned up that would be awesome. Thankyou all for your help so much, looking to be a contributor here. Cheers, Gearfighter import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "Gearz Flesh Crawler Killer", author = "Gearfighter", version = 1.0, info = "", logo = "") public class GearzFleshCrawlerKiller extends Script { @Override public void onStart() { log("Time to kill some Flesh Crawlers"); } @Override public void onExit() { } @Override public int onLoop() throws InterruptedException { //NPC fleshCrawler = npcs.closest("Flesh Crawler"); //try building a filter NPC fleshCrawler = npcs.closest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc.exists() && npc.getName().equals("Flesh Crawler") && npc.isAttackable() && npc.getHealthPercent() > 0; } }); if (!getCombat().isFighting() || myPlayer().getInteracting() == null){ if (fleshCrawler != null) { if (fleshCrawler.isVisible()) { fleshCrawler.interact("Attack"); } } } return random(600, 900); } // The amount of time in milliseconds before the loop starts over @Override public void onPaint(Graphics2D g) { // This is where you will put your code for paint(s) } } Edited July 29, 2016 by Christopher
Gearfighter Posted July 29, 2016 Author Posted July 29, 2016 If i am only attacking one thing is it worth making a filter for it? is it personal preference? or does it just make the code that little bit neater?
Prolax Posted July 29, 2016 Posted July 29, 2016 Add the following: if npc is not visible -> turn camera to npc if current npc health < rand(30,50%) -> hover over next npc
Gearfighter Posted July 29, 2016 Author Posted July 29, 2016 Prolax that was done in the else statement. And how would I go about a hover function? And would it change targets if the target it was hovered over started getting attacked?