RickyD Posted August 30, 2017 Share Posted August 30, 2017 (edited) Hello Made a little script for farming the tokens at the warriors guild for getting my dragon defender. It's currently hardcoded to lobster and mithril armour but you can edit source...:) Setup: Have lobster in inventory Have mithril platelegs, body and full helm in inventory Jar file here import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import javax.swing.*; import java.awt.*; @ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "") public class Animated extends Script { String[] foodName = {"Lobster"}; NPC anim; GroundItem lootables; String [] lootNames = {"Mithril platebody", "Warrior guild token", "Mithril full helm", "Mithril platelegs"}; @Override public void onStart() {} @Override public void onExit() {} public boolean hasArmour(){ if(getInventory().contains("Mithril platebody")){ if(getInventory().contains("Mithril platelegs")){ if(getInventory().contains("Mithril full helm")){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } @Override public int onLoop() throws InterruptedException{ anim = getNpcs().closest(2454); lootables = getGroundItems().closest(lootNames); if(getInventory().contains(foodName) && getInventory().getAmount("Warrior guild token") < 1000){ if(anim != null && anim.isInteracting(myPlayer())){ if(myPlayer().getHealthPercent() < 50){ getInventory().interact("Eat", foodName); //DTiming.waitCondition(() -> myPlayer().getAnimation() == 829, 2000); new ConditionalSleep(2000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); }else{ if(myPlayer().getInteracting() == null){ anim.interact("Attack"); } } }else{ if(lootables != null){ lootables.interact("Take"); }else{ if(hasArmour()){ getObjects().closest("Magical Animator").interact("Animate armour"); } } } }else{ JOptionPane.showMessageDialog(null, "NO FOOD or 1k Tokens", "Alert", JOptionPane.WARNING_MESSAGE); stop(false); } return 100; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) {} } Edited August 30, 2017 by RickyD 1 Quote Link to comment Share on other sites More sharing options...
Super Posted August 30, 2017 Share Posted August 30, 2017 good stuff. just in case you didn't know, you don't need so many if statements public boolean hasArmour(){ if(getInventory().contains("Mithril platebody")){ if(getInventory().contains("Mithril platelegs")){ if(getInventory().contains("Mithril full helm")){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } public boolean hasArmour(){ if(getInventory().contains("Mithril platebody") && getInventory().contains("Mithril platelegs") && getInventory().contains("Mithril full helm")) return true; } the client sees these as the same Quote Link to comment Share on other sites More sharing options...
RickyD Posted August 30, 2017 Author Share Posted August 30, 2017 11 minutes ago, superuser said: good stuff. just in case you didn't know, you don't need so many if statements the client sees these as the same For sure, I agree Quote Link to comment Share on other sites More sharing options...
Pseudo Posted September 12, 2017 Share Posted September 12, 2017 (edited) On 8/30/2017 at 11:59 PM, superuser said: good stuff. just in case you didn't know, you don't need so many if statements public boolean hasArmour(){ if(getInventory().contains("Mithril platebody")){ if(getInventory().contains("Mithril platelegs")){ if(getInventory().contains("Mithril full helm")){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } public boolean hasArmour(){ if(getInventory().contains("Mithril platebody") && getInventory().contains("Mithril platelegs") && getInventory().contains("Mithril full helm")) return true; } the client sees these as the same Also redundant code, though. It comes down to preference really. Thanks for contribution, OP. public boolean hasArmour() { return getInventory().contains("x"); } Edited September 12, 2017 by Pseudo Quote Link to comment Share on other sites More sharing options...
Super Posted September 12, 2017 Share Posted September 12, 2017 46 minutes ago, Pseudo said: Also redundant code, though. It comes down to preference really. Thanks for contribution, OP. public boolean hasArmour() { return getInventory().contains("x"); } Quote Link to comment Share on other sites More sharing options...
TTScripts Posted October 1, 2017 Share Posted October 1, 2017 (edited) You shouldn't have return 100; at the end. That's a really low return time (1/10th of a second) that speed will get you banned quickly. You should do return random(400, 700); Or something similar, but those return times have always worked for me. It's good to see you're learning though. Good luck Edited October 1, 2017 by TTScripts Quote Link to comment Share on other sites More sharing options...
iroll Posted October 2, 2017 Share Posted October 2, 2017 how do I get this onto my sdn? I've been waiting for something like this Can't open the Jar file says premium users only would deffff like to try and test / use this script Quote Link to comment Share on other sites More sharing options...
iroll Posted October 2, 2017 Share Posted October 2, 2017 The free hosting period for this file has now expired, only premium users can download it. Quote Link to comment Share on other sites More sharing options...
iroll Posted October 2, 2017 Share Posted October 2, 2017 8 hours ago, TTScripts said: You shouldn't have return 100; at the end. That's a really low return time (1/10th of a second) that speed will get you banned quickly. You should do return random(400, 700); Or something similar, but those return times have always worked for me. It's good to see you're learning though. Good luck so what part would you change? or do Quote Link to comment Share on other sites More sharing options...
TTScripts Posted October 7, 2017 Share Posted October 7, 2017 On 10/1/2017 at 9:29 PM, iroll said: so what part would you change? or do import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import javax.swing.*; import java.awt.*; @ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "") public class Animated extends Script { String[] foodName = {"Lobster"}; NPC anim; GroundItem lootables; private String armorType = "Mithril" String[] lootNames; @Override public void onStart() { startTime = System.currentTimeMillis(); lootNames = {armortType & "platebody", "Warrior guild token", armorType & " full helm", armorType & " platelegs"}; } @Override public void onExit() { log("Script has exited successfully"); } private long startTime; public boolean hasArmour(){ if(getInventory().contains(armorType & " platebody") && getInventory().contains(armortType & " platelegs") && getInventory().contains(armorType & " full helm")){ return true; } return false; } @Override public int onLoop() throws InterruptedException{ anim = getNpcs().closest(2454);//you should change this to a static method that gets the animated armor npc id //maybe anim = getNpcs().closest("Animated " & armorType & " armour"); //or something like that lootables = getGroundItems().closest(lootNames); if(getInventory().contains(foodName) && getInventory().getAmount("Warrior guild token") < 1000){ if(anim != null && anim.isInteracting(myPlayer())){ if(myPlayer().getHealthPercent() < 50){ getInventory().interact("Eat", foodName); //DTiming.waitCondition(() -> myPlayer().getAnimation() == 829, 2000); new ConditionalSleep(2000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650); }else{ if(myPlayer().getInteracting() == null){ anim.interact("Attack"); sleep(random(800, 1100); } } }else{ if(lootables != null){ if (lootables.interact("Take")) { sleep(random(1200, 1500); } }else{ if(hasArmour()){ if (getObjects().closest("Magical Animator").interact("Animate armour")) { sleep(random(1200, 2000); } } } } }else{ stop(false); JOptionPane.showMessageDialog(null, "NO FOOD or 1k Tokens", "Alert", JOptionPane.WARNING_MESSAGE); } return random(400, 700); //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { long millis = System.currentTimeMillis() - startTime; String timeStr = String.format("%02d min, %02d sec", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) ); g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14); g.setColor(Color.WHITE); g.drawString("Time running: " + timeStr, 10, 250); } } Quote Link to comment Share on other sites More sharing options...
iroll Posted October 7, 2017 Share Posted October 7, 2017 okay, I'll try Quote Link to comment Share on other sites More sharing options...
ThatGamerBlue Posted October 7, 2017 Share Posted October 7, 2017 why not public boolean hasArmour(){ return getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm"); } @TTScripts Quote Link to comment Share on other sites More sharing options...
TTScripts Posted October 7, 2017 Share Posted October 7, 2017 55 minutes ago, 3qTQlBnsOsyfetvA said: why not public boolean hasArmour(){ return getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm"); } @TTScripts you caught me. lol Quote Link to comment Share on other sites More sharing options...