Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.lang.reflect.Array;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Game.Tab;
- import com.rarebot.script.wrappers.RSArea;
- import com.rarebot.script.wrappers.RSItem;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSTile;
- import com.rarebot.script.wrappers.RSWeb;
- import com.rarebot.script.util.Timer;
- @ScriptManifest(
- authors = {"Mortemer2112"},
- name = "AIO Jewel Crafter",
- description = "Crafts Any Gold or Silver Item At Edgeville & AlKharid",
- keywords = "Crafting",
- version= 1.03)
- public class AIOJewelCrafter extends Script implements PaintListener{
- private static enum Location{Edgeville, Alkharid;
- public static Location getValueAtIndex(int i){
- return values()[i];
- }
- }
- private enum Job {StopScript,WalkToBank,WalkToForge,Bank,Crafting,MakeAll,OpenForge}
- private static String task;
- private static String locationName;
- private static String itemName;
- private Job job = Job.WalkToBank;
- AFGUI gui= new AFGUI();
- private RSWeb webby;
- private static boolean guiWait = true;
- private static boolean outOfItems = false;
- private static RSTile forgeTile;
- private static RSTile bankTile;
- private static RSArea bankArea;
- private static RSArea forgeArea;
- private static int mouseSpeed;
- private static int bankMode;
- private static int interfaceID;
- private static int componentID;
- private static int craftItemID;
- private static int mouldID = 0;
- private static int gemID = 0;
- private static int forgeID;
- private final Color GREEN = new Color(51, 255, 0);
- private final Color RED = new Color(255, 0, 0);
- private final Color BLACK = new Color(0, 0, 0);
- private static String skillName;
- private static long startTime;
- private static double xpOfItem;
- private static double realHours;
- private static int totalItemsCrafted;
- private static int craftsPerHour;
- private static int skillCheckXP;
- private static int xpPerHour;
- private static int gainedXP;
- private static int startXP;
- private static int skill;
- private static int mx;
- private static int my;
- private static int levelPercent;
- public boolean onStart(){
- gui.setVisible(true);
- while(guiWait){
- sleep(1000);
- }
- task = "starting up";
- job = Job.WalkToBank;
- startXP = skills.getCurrentExp(skill);
- startTime = System.currentTimeMillis();
- return true;
- }
- public void onFinish(){
- log("AIO Jewel Crafter Ran For "+Timer.format(System.currentTimeMillis() - startTime));
- log("Crafted "+totalItemsCrafted+" ("+craftsPerHour+" p/h)");
- log("Earned "+gainedXP+" "+skillName+" XP ("+xpPerHour+" p/h)");
- }
- @Override
- public int loop() {
- mouse.setSpeed(random(mouseSpeed,mouseSpeed+1));
- switch(job){
- case Crafting:
- return Crafting();
- case MakeAll:
- return MakeAll();
- case OpenForge:
- return OpenForge();
- case WalkToForge:
- return WalkToForge();
- case Bank:
- return Bank();
- case WalkToBank:
- return WalkToBank();
- case StopScript:
- log("You Have Run Out Of Crafting Ingredients");
- return -1;
- default:
- log("loop defaulted");
- }
- return -1;
- }
- private int Crafting(){
- task = "Crafting";
- if(!inventory.containsAll(craftItemID,mouldID)){
- job = Job.WalkToBank;
- return 300;
- }
- if(!isCrafting()){
- job = Job.OpenForge;
- return 300;
- }
- return Antiban();
- }
- private int Antiban(){
- int x = random(0,100);
- switch(x){
- case 0:
- task = "Antiban: Check Exp";
- game.openTab(Tab.STATS);
- sleep(400,700);
- skills.doHover(skillCheckXP);
- sleep(2000,4000);
- game.openTab(Tab.INVENTORY);
- sleep(500,1000);
- mouse.moveSlightly();
- break;
- default:
- if(x > 95){
- mouse.moveOffScreen();
- }else if(x > 90){
- mouse.moveSlightly();
- }else if(x > 85){
- mouse.moveRandomly(30);
- }else if(x > 80){
- camera.setAngle(camera.getAngle()+random(5,80));
- }else if(x > 75){
- camera.setAngle(camera.getAngle()-random(5,80));
- }
- break;
- }
- return 500;
- }
- private int MakeAll(){
- if(!interfaces.getComponent(interfaceID, componentID).isValid()){
- job = Job.OpenForge;
- return 300;
- }
- task = "Clicking - Make All";
- mouse.click(interfaces.getComponent(interfaceID, componentID).getPoint(), 5, 5, false);
- sleep(random(50,100));
- if(menu.click("Make All")){
- job = Job.Crafting;
- return 300;
- }
- return 300;
- }
- private boolean isCrafting(){
- int start= inventory.getCount(craftItemID);
- if(start == 0)return false;
- for(int i = 0; i < 10; i++){
- sleep(500);
- if(inventory.getCount(craftItemID) != start){
- return true;
- }
- }
- return false;
- }
- private int OpenForge(){
- if(!forgeArea.contains(getMyPlayer().getLocation())){
- job= Job.WalkToForge;
- return 300;
- }
- if(interfaces.getComponent(interfaceID, componentID).isValid()){
- job = Job.MakeAll;
- return 300;
- }
- if(usedOnForge()){
- while(true){
- sleep(500,1000);
- if(interfaces.getComponent(interfaceID, componentID).isValid())
- break;
- if(!getMyPlayer().isMoving())
- break;
- }
- job = Job.MakeAll;
- return 300;
- }
- return 200;
- }
- private boolean usedOnForge(){
- RSObject forge = objects.getNearest(forgeID);
- RSItem item = inventory.getItem(craftItemID);
- task = "Using "+item.getName()+" On Forge";
- if(inventory.isItemSelected() || inventory.selectItem(item)){
- if(forge.doClick(false)){
- sleep(50,100);
- if(menu.click("Use "+item.getName()+" -> Furnace")){
- return true;
- }
- }else{
- camera.turnTo(forge, 50);
- }
- }
- return false;
- }
- private int Bank(){
- if(!bankArea.contains(getMyPlayer().getLocation())){
- job= Job.WalkToBank;
- return 300;
- }
- if(bank.isOpen() || bank.open()){
- task = "Banking";
- switch(bankMode){
- case 1://one item
- if(Bank1()){
- job = Job.WalkToForge;
- return 300;
- }else if(outOfItems){
- job = Job.StopScript;
- return 300;
- }
- break;
- case 2://two items
- if(Bank2()){
- job = Job.WalkToForge;
- return 300;
- }else if(outOfItems){
- job = Job.StopScript;
- return 300;
- }
- break;
- case 3://3 items
- bank.depositAllExcept(mouldID,craftItemID,gemID);
- if(Bank3()){
- job = Job.WalkToForge;
- return 300;
- }else if(outOfItems){
- job = Job.StopScript;
- return 300;
- }
- break;
- }
- }
- return 300;
- }
- private boolean Bank1(){
- bank.depositAllExcept(craftItemID);
- if(inventory.getCount(craftItemID) != 28){
- bank.depositAllExcept(craftItemID);
- sleep(random(400,600));
- try{
- bank.withdraw(craftItemID, 0);
- } catch(Exception e) {
- log("Out of crafting materials - stopping script");
- outOfItems = true;
- }
- }
- return inventory.getCount(craftItemID) == 28;
- }
- private boolean Bank2(){
- bank.depositAllExcept(mouldID,craftItemID);
- boolean mould = false;
- boolean item = false;
- if(inventory.getCount(mouldID) == 1 || setItem(mouldID,1))
- mould = true;
- if(inventory.getCount(craftItemID) == 27 || setItem(craftItemID,27))
- item = true;
- return mould && item;
- }
- private boolean Bank3(){
- bank.depositAllExcept(mouldID,craftItemID,gemID);
- boolean mould = false;
- boolean item = false;
- boolean gem = false;
- if(inventory.getCount(mouldID) == 1 || setItem(mouldID,1))
- mould = true;
- if(inventory.getCount(craftItemID) == 13 || setItem(craftItemID,13))
- item = true;
- if(inventory.getCount(gemID) == 13 || setItem(gemID,13))
- gem = true;
- return mould && item && gem;
- }
- private boolean setItem(int id, int num){
- if(inventory.isFull()){
- bank.depositAll();
- sleep(400,600);
- }
- if(inventory.getCount(id) > num){
- bank.deposit(id, inventory.getCount(id) - num);
- sleep(400,600);
- }
- if(inventory.getCount(id) < num){
- bank.withdraw(id, num - inventory.getCount(id));
- sleep(400,600);
- }
- return inventory.getCount(id) == num;
- }
- private int WalkToForge(){
- task = "Walking To Forge";
- if(walkTo(forgeTile,forgeArea))
- job = Job.OpenForge;
- return 300;
- }
- private int WalkToBank(){
- task = "Walking To Bank";
- if(walkTo(bankTile,bankArea))
- job = Job.Bank;
- return 300;
- }
- private boolean walkTo(RSTile tile,RSArea area){
- if(!area.contains(getMyPlayer().getLocation()) &&
- (walking.getDestination() == null || !area.contains(walking.getDestination()))){
- if(webby == null || !webby.getEnd().equals(tile))
- webby = web.getWeb(getMyPlayer().getLocation(), tile);
- webby.step();
- NRG();
- }
- return area.contains(getMyPlayer().getLocation());
- }
- private void NRG(){
- if(!walking.isRunEnabled() && walking.getEnergy() >= random(9,20)){
- mouse.click(interfaces.getComponent(750, 1).getPoint(), 5, 5, true);
- sleep(500,1000);
- }
- }
- @Override
- public void onRepaint(Graphics g) {
- mx= mouse.getLocation().x;
- my= mouse.getLocation().y;
- gainedXP= skills.getCurrentExp(skill) - startXP;
- totalItemsCrafted= (int)(gainedXP / xpOfItem);
- realHours = (System.currentTimeMillis() - startTime) / 3600000.0;
- craftsPerHour = (int)((double)totalItemsCrafted / realHours);
- xpPerHour = (int)(craftsPerHour * xpOfItem);
- levelPercent = skills.getPercentToNextLevel(skill);
- g.setColor(RED);
- g.fillRoundRect(3, 320, 511, 21, 16, 16);
- g.setColor(GREEN);
- g.fillRoundRect(3, 320, (int)(levelPercent/100.0 * 511.0), 21, 16, 16);
- g.drawString("+ "+totalItemsCrafted+" Items Made ("+craftsPerHour+" P/H)", 8, 281);
- g.drawString("+ "+gainedXP+" Exp Gained ("+xpPerHour+" P/H)", 8, 299);
- g.drawString("Making "+itemName+"'s At "+locationName, 8, 317);
- g.setColor(BLACK);
- g.drawLine(5, my, 750, my);
- g.drawLine(mx, 5, mx, 500);
- g.drawString(Timer.format(System.currentTimeMillis() - startTime), 460, 335);
- g.drawString(levelPercent+"% To Level "+(skills.getRealLevel(skill)+1)+" "+skillName, 200, 335);
- g.drawString(task, 13, 335);
- }
- class AFGUI extends JFrame {
- public AFGUI() {
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setBounds(100, 100, 320, 135);
- final JPanel contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- final JComboBox LocationSelect = new JComboBox();
- LocationSelect.setModel(new DefaultComboBoxModel(
- new String[] {"Edgeville", "Alkharid"}));
- LocationSelect.setBounds(5, 5, 150, 30);
- contentPane.add(LocationSelect);
- final JComboBox mSpeed = new JComboBox();
- mSpeed.setModel(new DefaultComboBoxModel(
- new String[] {"Mouse speed 1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}));
- mSpeed.setBounds(160, 5, 150, 30);
- contentPane.add(mSpeed);
- final JComboBox ItemSelect = new JComboBox();
- ItemSelect.setModel(new DefaultComboBoxModel(
- new String[] {"Ring", "Necklace", "Amulet", "Bracelet", "Holy Symbol", "Silver Tiara", "Silver Bar", "Gold Bar"}));
- ItemSelect.setBounds(5, 40, 150, 30);
- contentPane.add(ItemSelect);
- final JComboBox gemSelect = new JComboBox();
- gemSelect.setModel(new DefaultComboBoxModel(
- new String[] {"No Gem", "Sapphire", "Emerald", "Ruby", "Diamond", "Dragonstone", "Onyx"}));
- gemSelect.setBounds(160, 40, 150, 30);
- contentPane.add(gemSelect);
- JButton btnStart = new JButton("START");
- btnStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- try {
- declareVariables(ItemSelect.getSelectedIndex(),
- gemSelect.getSelectedIndex(),
- Location.getValueAtIndex(LocationSelect.getSelectedIndex()),
- mSpeed.getSelectedIndex()+1);
- } catch (Exception e) {
- JOptionPane.showConfirmDialog(gui, "error: "+e);
- return;
- }
- guiWait = false;
- gui.dispose();
- }
- });
- btnStart.setBounds(85, 75, 150, 30);
- contentPane.add(btnStart);
- }
- }
- private void declareVariables(int craft,int gem,Location loc,int speed){
- /*Ring
- *Neck
- *Amulet
- *Bracelet
- *Holy Symbol
- *Tiara
- *Silver bar
- *Gold bar
- */
- final double[][] XP = {
- {15.0, 40.0, 55.0, 70.0, 85.0, 100.0, 115.0},
- {20.0, 55.0, 60.0, 75.0, 90.0, 105.0, 120.5},
- {30.0, 65.0, 70.0, 85.0, 100.0, 150.0, 165.0},
- {25.0, 60.0, 65.0, 80.0, 95.0, 110.0, 125.0},
- {50.0},
- {52.5},
- {13.7},
- {22.5}
- };
- final int[][] BANKMODE = {
- {2,3,3,3,3,3,3},
- {2,3,3,3,3,3,3},
- {2,3,3,3,3,3,3},
- {2,3,3,3,3,3,3},
- {2},
- {2},
- {1},
- {1}
- };
- final int[][] COMPONENTS = {
- {82,84,86,88,90,92,94},
- {68,70,72,74,76,78,80},
- {53,55,57,59,61,63,65},
- {33,35,37,39,41,43,45},
- {16},
- {44},
- {14},
- {14}
- };
- final int[] INTERFACES = {446,446,446,446,905,905,438,438};
- final int[] GEMIDS = {0,1607,1605,1603,1601,1615,6573};
- final int[] CRAFTITEM = {2357,2357,2357,2357,2355,2355,442,444};
- final int[] MOULD = {1592,1597,1595,11065,1599,5523,0,0};
- final String[] itemmys = {"Ring","Necklace","Amulet","Bracelet","Holy Symbol","Tiara","Silver Bar","Gold Bar"};
- final String[] gemmys = {"Gold ","Sapphire ","Emerald ","Ruby ","Diamond ","Dragonstone ","Onyx "};
- bankMode = BANKMODE[craft][gem];
- xpOfItem = XP[craft][gem];
- interfaceID = INTERFACES[craft];
- componentID= COMPONENTS[craft][gem];
- mouldID = MOULD[craft];
- craftItemID = CRAFTITEM[craft];
- gemID = GEMIDS[gem];
- mouseSpeed = speed;
- if(loc.equals(Location.Edgeville)){
- forgeTile= new RSTile(3108,3499);
- bankTile= new RSTile(3094,3496);
- bankArea= new RSArea(new RSTile (3091,3488),new RSTile(3098,3499));
- forgeArea= new RSArea(new RSTile(3106,3497),new RSTile(3111,3502));
- forgeID = 26814;
- }else if(loc.equals(Location.Alkharid)){
- forgeTile= new RSTile(3275,3186);
- bankTile= new RSTile(3269,3167);
- bankArea= new RSArea(new RSTile (3269,3161),new RSTile(3272,3173));
- forgeArea= new RSArea(new RSTile (3272,3188),new RSTile(3277,3184));
- forgeID = 2742;
- if(craft == 6 || craft == 7){
- skill= skills.SMITHING;
- skillCheckXP= skills.INTERFACE_SMITHING;
- skillName = "Smithing";
- }else{
- skill= skills.CRAFTING;
- skillCheckXP= skills.INTERFACE_CRAFTING;
- skillName = "Crafting";
- }
- locationName = loc.name();
- switch(craft){
- case 0:
- case 1:
- case 2:
- case 3:
- itemName = gemmys[gem]+itemmys[craft];
- break;
- default:
- itemName = itemmys[craft];
- break;
- }
- }}
- }
Add Comment
Please, Sign In to add comment