jelknab Posted July 11, 2013 Share Posted July 11, 2013 (edited) Hai, I made this little crafting interface manager to make your life more easy. I also included an example for usage. SmithItem enum SmithItem.java import java.awt.*; public enum SmithItem { // Row 1 DAGGER( new Rectangle(20, 49, 30, 30), new int[] {121, 153} ), SWORD( new Rectangle(20, 103, 30, 30), new int[] {112, 152} ), SCIMITAR( new Rectangle(20, 157, 30, 30), new int[] {114, 143} ), LONG_SWORD( new Rectangle(20, 211, 30, 30), new int[] {113, 116} ), TWO_HAND_SWORD( new Rectangle(20, 265, 20, 30), new int[] {115, 117} ), // Row 2 AXE( new Rectangle(95, 49, 30, 30), new int[] {118, 154} ), MACE( new Rectangle(95, 103, 30, 30), new int[] {120, 157} ), WARHAMMER( new Rectangle(95, 157, 30, 30), new int[] {111, 145} ), BATTLE_AXE( new Rectangle(95, 211, 30, 30), new int[] {119, 122} ), // Row 3 CHAIN_BODY( new Rectangle(168, 49, 30, 30), new int[] {125, 136} ), PLATE_LEGS( new Rectangle(168, 103, 30, 30), new int[] {126, 137} ), PLATE_SKIRT( new Rectangle(168, 157, 30, 30), new int[] {128, 138} ), PLATE_BODY( new Rectangle(168, 211, 30, 30), new int[] {127, 139} ), OIL_LANTERN_FRAME( new Rectangle(168, 265, 30, 30), new int[] {171, 169} ), // Row 4 MEDIUM_HELM( new Rectangle(270, 49, 30, 30), new int[] {129, 155} ), FULL_HELM( new Rectangle(270, 103, 30, 30), new int[] {130, 140} ), SQUARE_SHIELD( new Rectangle(270, 157, 30, 30), new int[] {131, 141} ), KITE_SHIELD( new Rectangle(270, 211, 30, 30), new int[] {132, 142} ), NAILS( new Rectangle(270, 265, 30, 30), new int[] {173, 172} ), // Row 5 DART_TIPS( new Rectangle(350, 49, 30, 30), new int[] {134, 156} ), ARROWTIPS( new Rectangle(350, 103, 30, 30), new int[] {135, 158} ), THOWING_KNIVES( new Rectangle(350, 157, 30, 30), new int[] {133, 159} ), IRON_SPIT( new Rectangle(350, 211, 30, 30), new int[] {123, 160} ), // Row 6 BOLTS( new Rectangle(439, 49, 30, 30), new int[] {178, 176} ), LIMBS( new Rectangle(439, 103, 30, 30), new int[] {175, 177} ); SmithItem(Rectangle rectangle, int[] childIds) { this.getRectangle = rectangle; this.getChildIds = childIds; } public final Rectangle getRectangle; public final int[] getChildIds; } Interactions and such SmithingInterface.java package Superheater; import org.osbot.script.MethodProvider; import org.osbot.script.Script; import org.osbot.script.mouse.RectangleDestination; import org.osbot.script.rs2.model.Item; public class SmithingInterface { Script script; public SmithingInterface(Script script) { this.script = script; } public boolean close() throws InterruptedException { while (isOpen() && script.client.getInterface(312).isVisible()) { script.client.getInterface(312).getChild(184).interact(); script.sleep(MethodProvider.random(750, 1250)); } return isOpen(); } public boolean makeAmount(SmithItem smithItem, int amount, String bar) throws InterruptedException { if (isOpen()) { if (amount >= 10 && getBarsNeeded(smithItem) * 10 <= getBarAmount(bar)) { return make10(smithItem, bar); } if (amount >= 5 && getBarsNeeded(smithItem) * 5 <= getBarAmount(bar)) { return make5(smithItem, bar); } if (amount >= 1 && getBarsNeeded(smithItem) <= getBarAmount(bar)) { return make1(smithItem, bar); } script.log("It appears you cannot make " + amount +" " + script.client.getInterface(312).getChild(smithItem.getChildIds[0]).getMessage() + "'s."); close(); } return false; } public boolean make10(SmithItem smithItem, String bar) throws InterruptedException { if (isOpen()) { if (getBarsNeeded(smithItem) * 10 <= getBarAmount(bar)) { if (!smithItem.equals(SmithItem.DART_TIPS) && !smithItem.equals(SmithItem.ARROWTIPS) && !smithItem.equals(SmithItem.THOWING_KNIVES) && !smithItem.equals(SmithItem.IRON_SPIT)) { return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make 10"); } return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make 10 sets"); } else { script.log("You cannot make that many."); close(); } } return false; } public boolean make5(SmithItem smithItem, String bar) throws InterruptedException { if (isOpen()) { if (getBarsNeeded(smithItem) * 5 <= getBarAmount(bar)) { if (!smithItem.equals(SmithItem.DART_TIPS) && !smithItem.equals(SmithItem.ARROWTIPS) && !smithItem.equals(SmithItem.THOWING_KNIVES) && !smithItem.equals(SmithItem.IRON_SPIT)) { return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make 5"); } return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make 5 sets"); } else { script.log("You cannot make that many."); close(); } } return false; } public boolean make1(SmithItem smithItem, String bar) throws InterruptedException { if (isOpen()) { if (getBarsNeeded(smithItem) <= getBarAmount(bar)) { if (!smithItem.equals(SmithItem.DART_TIPS) && !smithItem.equals(SmithItem.ARROWTIPS) && !smithItem.equals(SmithItem.THOWING_KNIVES) && !smithItem.equals(SmithItem.IRON_SPIT)) { return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make"); } return script.selectOption(null, new RectangleDestination(smithItem.getRectangle), "Make set"); } else { script.log("You cannot make that many."); close(); } } return false; } public int getBarsNeeded(SmithItem smithItem) { if (isOpen()) { return Integer.parseInt(script.client.getInterface(312).getChild(smithItem.getChildIds[1]).getMessage().split("")[1]); } return -1; } public String getActualName(SmithItem smithItem) { return script.client.getInterface(312).getChild(smithItem.getChildIds[0]).getMessage(); } public int getBarAmount(String name) { int bars = 0; for (Item item : script.client.getInventory().getItems()) { if (item != null && item.getName().toLowerCase().contains((name.toLowerCase() + " bar"))) { bars++; } } return bars; } public boolean isOpen() { return script.client.getInterface(312).isValid() && script.client.getInterface(312).isVisible(); } } example Tester.java package smithingMenu; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "smith interface tester", info = "", version = 0.1D, author = "Jelknab") public class Tester extends Script { SmithingInterface smithingInterface = new SmithingInterface(this); SmithItem smithItem = SmithItem.PLATE_BODY; @Override public int onLoop() throws InterruptedException { smithingInterface.makeAmount(smithItem, 15, "iron"); return 5000; } @Override public void onPaint(Graphics g) { if (smithingInterface.isOpen()) { Rectangle r = smithItem.getRectangle; g.drawRect(r.x, r.y, r.width, r.height); } } } And a picture because fuck you. Giving me credits would be nice, but i won't force you to. Have fun. And burn in hell. Edited July 13, 2013 by jelknab Link to comment Share on other sites More sharing options...
TheAnswer Posted July 13, 2013 Share Posted July 13, 2013 wow nice man Link to comment Share on other sites More sharing options...
Illumi Posted July 13, 2013 Share Posted July 13, 2013 Nice, thanks for this. Link to comment Share on other sites More sharing options...
H0ppy Posted July 13, 2013 Share Posted July 13, 2013 Haha dat topic title x3 Thx for burning in hell? ^^ Good job man! grtz H0ppy Link to comment Share on other sites More sharing options...