GetBackToOSRS Posted December 27, 2015 Share Posted December 27, 2015 Someone had posted a warrior tokens script in Local, but I can't get it to compile. Code as follows: 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 = 385; 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) { } } Quote Link to comment Share on other sites More sharing options...
Muffins Posted December 27, 2015 Share Posted December 27, 2015 probably because it's outdated as hell Quote Link to comment Share on other sites More sharing options...
steve498 Posted December 27, 2015 Share Posted December 27, 2015 (edited) Hopefully this works but completely untested. 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 main extends Script { int randomHealth = random(30, 40); public static int foodId = 385; 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) { } } Download: http://uppit.com/jrz67pk733ba/OSBOT_Script.jar I've compiled it for you. It looks kinda outdated through so I'd recommend you re-write it or something. Edited December 27, 2015 by steve498 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted December 28, 2015 Share Posted December 28, 2015 Looks decompiled.. Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted December 28, 2015 Share Posted December 28, 2015 Looks decompiled.. Impossible. Decompilers output more consistent code with better formatting. This code has been decompiled, forced through a cats anus, spat on, told to kill itself, and, to top it all off, compiled and decompiled again. 1 Quote Link to comment Share on other sites More sharing options...