Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Graphics;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Skills;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import scripts.DeadmanBar.State;
- @ScriptManifest(authors = { "helloworldlol" }, category = "Magic", name = " Emerald bolts")
- public class Enchanting extends Script implements Painting {
- @Override
- public void onPaint(Graphics g) {
- g.setColor(Color.WHITE);
- g.drawString("State: " + SCRIPT_STATE, 10, 65);
- int xpGained = (CURRENT_XP - START_XP);
- long timeRan = System.currentTimeMillis() - START_TIME;
- double multiplier = timeRan / 3600000D;
- int xpPerHour = (int) (xpGained / multiplier);
- g.drawString("Mage XP Gained: " + (int) (xpGained) + " | " + "Per Hour: " + (int) (xpPerHour), 10, 80);
- }
- private final int START_XP = Skills.getXP(SKILLS.MAGIC);
- private final long START_TIME = System.currentTimeMillis();
- private int CURRENT_XP = START_XP;
- private boolean running = true;
- private State SCRIPT_STATE = getState();
- @Override
- public void run() {
- while (running) {
- CURRENT_XP = Skills.getXP(SKILLS.MAGIC);
- SCRIPT_STATE = getState();
- switch (SCRIPT_STATE) {
- case ENCHANT:
- enchant();
- break;
- case LOG_OUT:
- running = false;
- break;
- default:
- break;
- }
- }
- }
- private State getState() {
- State state = hasRunes() ? State.ENCHANT : State.LOG_OUT;
- return state;
- }
- private void enchant() {
- if (TABS.MAGIC.isOpen()) {
- if (isEnchantOpen()) {
- RSInterfaceChild emeralds = Interfaces.get(80, getBoltInterface());
- if (emeralds != null && !emeralds.isHidden()) {
- Mouse.clickBox(emeralds.getAbsoluteBounds(), 1);
- long t = System.currentTimeMillis();
- int r = General.random(750, 1750);
- while (Timing.timeFromMark(t) < r) {
- sleep(25, 50);
- if (!isEnchantOpen())
- break;
- }
- }
- } else {
- if (Magic.selectSpell("Enchant Crossbow Bolt")) {
- long t = System.currentTimeMillis();
- int r = General.random(400, 1850);
- while (Timing.timeFromMark(t) < r) {
- sleep(25, 50);
- if (isEnchantOpen())
- break;
- }
- }
- }
- } else
- TABS.MAGIC.open();
- }
- private int getBoltInterface() {
- int mage = Skills.SKILLS.MAGIC.getActualLevel();
- if (mage >= 4 && mage < 7) {
- return 2;
- } else if (mage >= 7 && mage < 27)
- return 3;
- else
- return 6;
- }
- private boolean isEnchantOpen() {
- RSInterface enchant = Interfaces.get(80);
- return enchant != null && !enchant.isHidden();
- }
- private boolean hasRunes() {
- RSItem[] nature = Inventory.find("Nature rune");
- RSItem[] cosmic = Inventory.find("Cosmic rune");
- RSItem[] bolts = Inventory.find("Emerald bolts");
- return nature.length > 0 && cosmic.length > 0 && bolts.length > 0;
- }
- private enum State {
- ENCHANT, LOG_OUT;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement