Megagozer Posted April 7, 2015 Share Posted April 7, 2015 (edited) Hi guys, I made this little script today that collects tokens for the defenders at warrior guild by summoning an Animated Armour. Its very very basic, probably extremely poor written as I have very little experience with java but hey, it works. In the current settings it eats lobster and uses mithril armour tho by changing the ints in the code you can change it to whatever you like. It does not bank, so you'll have to get some food yourself every now and then. Don't expect any fancy, no paint, no updates, I was just too lazy to collect the tokens myself and thought it would be nice to share it with you guys:) import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.util.Random; import org.osbot.rs07.api.Skills; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.NPCS; import java.awt.*; @ScriptManifest(author = "You", info = "My first script", name = "MegaWGuild", version = 0, logo = "") public class MegaWGuild extends Script { int randomHealth = random(30, 40); public static int foodId = 379; public static int helmId = 1159; public static int bodyId = 1121; public static int legsId = 1071; public static int tokenId = 8851; public static String goatName = "Animated Mithril Armour"; @Override public void onStart() { log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { if ((this.inventory.contains(new int[] { foodId })) && (!myPlayer().isMoving())) { if (!myPlayer().isMoving()) { NPC goat = (NPC)this.npcs.closest(new String[] {goatName}); GroundItem helm = (GroundItem)this.groundItems.closest(new int[] {helmId }); GroundItem body = (GroundItem)this.groundItems.closest(new int[] {bodyId }); GroundItem legs = (GroundItem)this.groundItems.closest(new int[] {legsId }); GroundItem token = (GroundItem)this.groundItems.closest(new int[] {tokenId }); if (currentHealth() < randomHealth) { eat(); sleep(random(300, 500)); } else if ((goat != null) && (!goat.isUnderAttack())) { goat.interact(new String[] { "Attack" }); sleep(random(1000, 1500)); } else if (body != null){ takeGroundItem(bodyId); } else if (helm != null){ takeGroundItem(helmId); } else if (legs != null){ takeGroundItem(legsId); } else if (token != null){ takeGroundItem(tokenId); sleep(random(100, 400)); } else if ((helm == null) && (legs == null) && (body == null) && (token == null)) { Item use = this.inventory.getItem(new int[] {bodyId }); use.interact(new String[] { "Use"}); sleep(random(100, 500)); RS2Object tile = this.objects.closest(new String[] { "Magical Animator" }); tile.interact(new String[] { "Use"}); sleep(random(2000, 3000)); } } } return random(200, 300); } private void eat() { Item food = this.inventory.getItem(new int[] {foodId }); food.interact(new String[] { "Eat" }); } int currentHealth() { int percperone = 100 / this.skills.getStatic(Skill.HITPOINTS); return percperone * this.skills.getDynamic(Skill.HITPOINTS); } private void takeGroundItem(int id) { try { GroundItem horn = (GroundItem)this.groundItems.closest(new int[] { id }); horn.interact(new String[] { "Take" }); sleep(random(1200, 1500)); } catch (Exception localException) {} } @Override public void onExit() { log("Thanks for running my Warrior Guild script!"); } @Override public void onPaint(Graphics2D g) { } } Edited April 8, 2015 by Megagozer 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted April 7, 2015 Share Posted April 7, 2015 nice contribute 1 Quote Link to comment Share on other sites More sharing options...
Twin Posted April 7, 2015 Share Posted April 7, 2015 Might wanna remove thanks for running my tea thiever (I'm totally messing with you by the way I made the same mistake before ) 1 Quote Link to comment Share on other sites More sharing options...
Reid Posted April 7, 2015 Share Posted April 7, 2015 2 Quote Link to comment Share on other sites More sharing options...
Megagozer Posted April 8, 2015 Author Share Posted April 8, 2015 Haha oops!:P Quote Link to comment Share on other sites More sharing options...
Fruity Posted April 28, 2015 Share Posted April 28, 2015 Bit random but why is the animated armour called goatName? otherwise nice :P 1 Quote Link to comment Share on other sites More sharing options...
darvinb98 Posted June 25, 2015 Share Posted June 25, 2015 nice pice Quote Link to comment Share on other sites More sharing options...
zentharia Posted July 16, 2015 Share Posted July 16, 2015 nice Quote Link to comment Share on other sites More sharing options...
teamalivebud Posted July 26, 2015 Share Posted July 26, 2015 time to get my dragon defender Quote Link to comment Share on other sites More sharing options...
Gold Winer Posted July 27, 2015 Share Posted July 27, 2015 Time to get some defenders! Quote Link to comment Share on other sites More sharing options...
Prolax Posted September 28, 2015 Share Posted September 28, 2015 Looks ok, I'll test it. Quote Link to comment Share on other sites More sharing options...
GetBackToOSRS Posted December 27, 2015 Share Posted December 27, 2015 I can't get this to compile properly? Saved into scripts, as a .jar, can't find it on scripts list after refreshing? Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 19, 2017 Share Posted December 19, 2017 if anyone was interested, I have fixed this script so that it works now: below is proggy and code: 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.*; import java.util.concurrent.TimeUnit; @ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "") public class Warriorguild extends Script { String[] foodName = {"Monkfish"}; NPC anim; GroundItem lootables; private String armorType = "Mithril"; String [] lootNames = {armorType + " platebody", "Warrior guild token", armorType + " platelegs", armorType + " full helm"}; @Override public void onStart() { startTime = System.currentTimeMillis(); if(hasArmour()!=true){ log("false"); } } @Override public void onExit() { log("Script has exited successfully"); } private long startTime; /* public boolean hasArmour(){ if(getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm")){ log("hasarmour is true"); return true; } return false; } */ public boolean hasArmour(){ return getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm"); } @Override public int onLoop() throws InterruptedException{ // anim = getNpcs().closest(2454); anim = getNpcs().closest("Animated " + armorType + " armour"); 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")) { 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); } } 1 Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 20, 2017 Share Posted December 20, 2017 Hi again, would someone be able to explain GUI to me. All the GUI needs to be is very simple: Take in armour type, food type and token value. Then pass this into the original java file above. I however, have no idea what i'm doing. Below is my attempt, i'd be really grateful if someone would be able to have a look and fix it or atleast point me in the right direction. import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JTextField; public class GuiSetup { private final JFrame jFrame; /* private JLabel armourType; private JLabel foodLabel; private JLabel tokenAmount; private JTextField foodName; private JTextField tokenName; private JTextField TokenAmount; */ public GuiSetup() { jFrame = new JFrame("WarriorGuild Tokens"); JPanel mainPanel = new JPanel(); JLabel armourType; JLabel foodLabel; JLabel tokenAmounta; JTextField food; JTextField armourName; JTextField tokenAmount; } /* public static String getFoodName() { return foodName; } public static String getArmourName() { return armourName; } public static String getTokenAmount() { return tokenAmount; } */ } Quote Link to comment Share on other sites More sharing options...
CasDeBlanco Posted December 20, 2017 Share Posted December 20, 2017 12 minutes ago, scriptersteve said: Hi again, would someone be able to explain GUI to me. All the GUI needs to be is very simple: Take in armour type, food type and token value. Then pass this into the original java file above. I however, have no idea what i'm doing. Below is my attempt, i'd be really grateful if someone would be able to have a look and fix it or atleast point me in the right direction. import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JTextField; public class GuiSetup { private final JFrame jFrame; /* private JLabel armourType; private JLabel foodLabel; private JLabel tokenAmount; private JTextField foodName; private JTextField tokenName; private JTextField TokenAmount; */ public GuiSetup() { jFrame = new JFrame("WarriorGuild Tokens"); JPanel mainPanel = new JPanel(); JLabel armourType; JLabel foodLabel; JLabel tokenAmounta; JTextField food; JTextField armourName; JTextField tokenAmount; } /* public static String getFoodName() { return foodName; } public static String getArmourName() { return armourName; } public static String getTokenAmount() { return tokenAmount; } */ } Create a thread in this section https://osbot.org/forum/forum/249-scripting-help/ Quote Link to comment Share on other sites More sharing options...