Jump to content

Gold Ring Crafter - AlKharid


Ricky Dactyl

Recommended Posts

This script was made with the intent for the crafting of Gold Rings in AlKharid.
I made this for my own personal use, if you're going to use it then I recommend the following to ensure it works as intended.

  • Start the script in AlKharid
  • Ensure gold bars are visible in the bank
  • Ensure mould is visible in the bank

Download Jar Crafter.jar

For anyone interested the code is below :D
 

package com.shrykur.craft;

import java.util.ArrayList;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.input.mouse.RectangleDestination;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Shrykur", info = "Crafting", logo = "", name = "Crafting", version = 0)
public class Node extends Script {

	private Area bankArea;
	private Area furnaceArea;
	private Position position;
	private Boolean isSmelting;
	private Integer level;
	public ArrayList<Integer> items;

	private enum State {
		IN_BANK, BANKING, WALKING, IN_FURNACE, SMELTING;
	}

	@Override
	public void onStart() {
		this.setIsSmelting(false);
		this.setLevel(this.getSkills().getStatic(Skill.CRAFTING));
		items = new ArrayList<>();
		items.add(1592);
		items.add(2357);
		items.add(1635);

		// Setting AlKharid Areas
		this.position = this.myPosition();
		this.setBankArea(new Area(3271, 3162, 3269, 3170));
		this.setFurnaceArea(new Area(3279, 3184, 3274, 3186));
	}

	@Override
	public int onLoop() throws InterruptedException {
		this.position = this.myPosition();
		int chance = random(0, 2500);
		if (this.getLevel() != this.skills.getStatic(Skill.CRAFTING)) {
			this.setLevel(this.getSkills().getStatic(Skill.CRAFTING));
			this.setIsSmelting(false);
			chance = 0;
		}
		if (chance == 0) {
			this.getTabs().open(Tab.SKILLS);
			if (this.widgets.isVisible(320, 13)) {
				RectangleDestination craftingTab = new RectangleDestination(bot, this.widgets.get(320, 13).getBounds());
				this.mouse.move(craftingTab);
				sleep(random(1000, 5000));
				this.getTabs().open(Tab.INVENTORY);
			}
		}
		switch (getState()) {
		case IN_BANK: {
			if (!this.inventory.contains(items.get(0)) || !this.getInventory().contains(items.get(1))) {
				this.getBank().closest().interact("Bank");
			}
			break;
		}
		case BANKING: {
			if (!this.getInventory().contains(items.get(0))) {
				if (this.getBank().contains(items.get(0))) {
					this.getBank().withdraw(items.get(0), 1);
				}
			}
			if (!this.getBank().contains(items.get(1))) {
				stop();
			}
			if (this.getInventory().contains(items.get(2))) {
				this.getInventory().getItem(items.get(2)).interact("Deposit-All");
			}
			if (!this.getInventory().contains(items.get(1))) {
				this.getBank().withdrawAll(items.get(1));
			}
			this.getWalking().webWalk(this.getFurnaceArea());
			break;
		}
		case WALKING: {
			if (!this.myPlayer().isMoving()) {
				if (this.getBankArea().contains(this.closestPositionToPlayer())) {
					this.getWalking().webWalk(this.getBankArea());
				} else {
					if (this.getObjects().closest(1535) != null) {
						RS2Object door = this.getObjects().closest(1535);
						if (door.getPosition().equals(new Position(3279, 3185, 0))) {
							door.interact("Open");
						}
					}
					this.getWalking().webWalk(this.getFurnaceArea());
				}
			}

			break;
		}
		case IN_FURNACE: {
			if (!this.inventory.contains(items.get(1))) {
				this.getWalking().webWalk(this.bankArea);
			}
			if (!this.myPlayer().isAnimating()) {
				Entity furnace = this.getObjects().closest("Furnace");
				while (!furnace.isVisible()) {
					this.getCamera().toEntity(furnace);
				}
				if (furnace.isVisible() && this.getMap().canReach(furnace)) {
					furnace.interact("Smelt");
					sleep(2000);
					RS2Widget bronzeWidget = getWidgets().get(446, 7);
					if (bronzeWidget != null) {
						bronzeWidget.interact("Make-All");
						this.setIsSmelting(true);
					}
				}
			}
			break;
		}
		case SMELTING: {
			if (!this.getInventory().contains(this.items.get(1))) {
				this.setIsSmelting(false);
			}
			break;
		}
		default:

			break;
		}
		return 500;

	}

	private Position closestPositionToPlayer() {
		Position closest_destination = null;
		for (Position p : this.getFurnaceArea().getPositions()) {
			if (closest_destination != null) {
				if (p.distance(this.position) < closest_destination.distance(this.position)) {
					closest_destination = p;
				}
			} else {
				closest_destination = p;
			}
		}
		for (Position p : this.getBankArea().getPositions()) {
			if (closest_destination != null) {
				if (p.distance(this.position) < closest_destination.distance(this.position)) {
					closest_destination = p;
				}
			} else {
				closest_destination = p;
			}
		}
		return closest_destination;

	}

	public State getState() {
		if (this.getBank().isOpen()) {
			return State.BANKING;
		} else if (this.bankArea.contains(position)) {
			return State.IN_BANK;
		} else if (getIsSmelting().equals(true)) {
			return State.SMELTING;
		} else if (this.furnaceArea.contains(position)) {
			return State.IN_FURNACE;
		}
		return State.WALKING;
	}

	public Area getBankArea() {
		return bankArea;
	}

	public void setBankArea(Area bankArea) {
		this.bankArea = bankArea;
	}

	public Area getFurnaceArea() {
		return furnaceArea;
	}

	public void setFurnaceArea(Area furnaceArea) {
		this.furnaceArea = furnaceArea;
	}

	public Boolean getIsSmelting() {
		return isSmelting;
	}

	public void setIsSmelting(Boolean isSmelting) {
		this.isSmelting = isSmelting;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
}

 

Edited by Ricky Dactyl
Link to comment
Share on other sites

32 minutes ago, Samuxd said:

how much this is making p/h brou?

I actually didn't test how much per hour I was getting, I only made this script with the intent of getting from 5-20 crafting so I could bot sapphire rings, sorry my dude, if I get time tomorrow I'll add an overlay for it to display rings/hour :)

  • Like 1
Link to comment
Share on other sites

12 minutes ago, Hope said:

Congrats on the release @Shrykur! I'm looking at this code and I'm like nope... Cba to learn that insane stuff lol

The usage of states is actually something that I've never worked with before, I thought I'd give it a shot and it turned out to work out allot better than I had hoped, however I'm next looking into Task based scripts, so I'll be delving into that tomorrow ^_^

Edited by Ricky Dactyl
Link to comment
Share on other sites

29 minutes ago, Shrykur said:

The usage of states is actually something that I've never worked with before, I thought I'd give it a shot and it turned out to work out allot better than I had hoped, however I'm next looking into Task based scripts, so I'll be delving into that tomorrow ^_^

Best of luck with that ? Better see you with your own script shop one day lol

  • Heart 1
Link to comment
Share on other sites

  • 1 year later...

Nice code! I tried adapting it for gold amulets (u) and for Edgeville but for some reason when I change the banking areas and furnace area I break the code. At first it started continuously running back and forth and then I got it to bank but after withdrawing the bars it didn't go to the furnace. Any tips on how it can be adapted?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...