March 8, 201510 yr Hello! This script is killing goblins near Lumbridge using training sword and training shield. This is my first script for OSBot so i'm looking for feedback (whats wrong, what to improve). Git repository: https://bitbucket.org/grzekru/osbot-grzekru/src/ Thanks Edited March 8, 201510 yr by grzekru
March 8, 201510 yr Just skimmed over the code, here are a few suggestions - Use filters for NPCs (both goblins and randoms), yes what you have is fine, but the goblin npc getter could be slightly optimized public Filter<NPC> goblin = new Filter<NPC>() { @Override public boolean match(NPC n) { if (!n.getName().equalsIgnoreCase("Goblin")) { return false; } if (n.getHealth() == 0) { return false; } if (!getMap().canReach(n)) { return false; } return true; } }; In this case, it will only attack goblins with health above 0 (alive) that it can currently reach. - Use getNpcs().closest(goblin) or ("Goblin", "Chicken", "Lesser demon") to get the nearest npc, instead of sorting them by distance manually- You can use npc.interact("Attack"), or simply hover and mouse click, however make sure you are not redundantly hovering over the npc, so if (hover) { ////blahblah} else {mouse.hover(..);} - Avoid sleep(Long.MAX_VALUE), instead, (assuming you want to stop the script) just call stop(); and it will logout automatically and terminate the script Overall, your code displays background knowledge with java however, a lack of understanding of the OSBot API, you can find it here So, take some time to familiarize yourself with the OSBot API and you should be just fine Edited March 9, 201510 yr by Czar
March 23, 201510 yr Hi, i want to ask what is this u.* in your code? examples from your code: if (u.ins == null){ u.initUtils(this); //or if (selectedGoblin == null || selectedGoblin.getHealth() == 0 || u.isAttackedByOtherPlayer(selectedGoblin) || !selectedGoblin.exists()) //or u.antiBan(); Its just im learning stuff from open sources and i got confused what is this u.* used everywhere.