Jump to content

Oak Larder [Construction Script][Open Source]


Lol_marcus

Recommended Posts

Hi all,

This is the very first version of the script. It runs flawlessly until it runs into unexpected problems. Some of them have been worked out, but further testing is being done to iron out all the problems. I'll be continuing to work on the script, making it more efficient and fail-safe with the intention of making it 100% flawless. :)

new I've released a second version. It's better than the first in many aspects. You can start anywhere inside or outside your house and it'll do the rest. I've tested it until 82 construction and it didn't fail me, the longest I ran it was for 2.5 hours. 

Future updates to come and I slowly work on making it cleaner and more efficient.

Any feedback is always more than welcome.

 

FEATURES

  • Makes oak larders
  • Exchanges oak plank notes for unnoted with Phials
  • Gets +- 80k construction xp/ph
  • new Cool little pop up message in the beginning :) 
  • new Run time, XP gained and XP/ph is shown
  • new Shows mouse trail so you know how to bot is doing everything (plus it's rainbow colored)

INVENTORY SETUP - make sure these are the ONLY items in your inventory

  • Saw
  • Hammer
  • Coins
  • Noted Oak planks (and unnoted if you'd like to start straight away)

HOW TO RUN - make sure you start ONLY once inside your house

  • Start inside your house (preferable close to portal or larder) new Start anywhere inside or outside your house
  • Have your house set to Rimmington
  • Ideally have your camera set to half way, or further out new The script will adjust the camera by itself

 

HOW TO ADD SCRIPT TO YOUR CLIENT

  • Download the ConstructionLite.jar file
  • Copy and paste it into: C:\Users\*YOURUSERNAME*\OSBot\Scripts

New Source Code - you would have to remove the custom mouse and zoom control for it to work, because it's a separate class file

package core;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
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.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import utils.MouseTrail;
import utils.ZoomControl;

import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;


@ScriptManifest(name = "Construction Lite V1.1", version = 1.1, author = "Marcus", logo = "", info = "Creates oak larders")


public class Main extends Script {
		
    private final Area portalPos = new Area(2953,3222,2954,3224);
    private final Area phialsPos = new Area(2951,3213,2952,3214);	

	private MouseTrail trail = new MouseTrail(0, 255, 255, 2000, this);
	
    private long startTime = System.currentTimeMillis();
    
    @Override
    public void onStart() throws InterruptedException {
    
        ImageIcon icon = null;
		try {
			icon = new ImageIcon(new URL("https://vignette.wikia.nocookie.net/2007scape/images/6/65/Demon_butler_chathead.png/revision/latest?cb=20151103211007"));
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        JOptionPane.showMessageDialog(null, "MAKE SURE YOU HAVE COINS, OAK PLANKS, A SAW AND A HAMMER", "Construction Lite", JOptionPane.INFORMATION_MESSAGE, icon);
    	
        getExperienceTracker().start(Skill.CONSTRUCTION);
        
    	if (!ZoomControl.isInRange(getCamera().getScaleZ(), 500)) {
    	    ZoomControl.setZoom(getBot(), 500);
    	}
    }
    
    

    @Override
    public int onLoop() throws InterruptedException {
        if(hasPlanks()){
            if(larderExists()){
                interactLarder();
            }else{
                goHome();
            }
        }else{
            if(larderExists()){
                exitHome();
        }else{
               getMaterials();
               unnote();
               getAll();      
            }
        }
        return 700;
    }
    
    private boolean larderExists(){
        return (getObjects().closest("Larder space") != null || getObjects().closest("Larder") != null);
    }

    public boolean hasPlanks() {
        return (inventory.contains(8794,2347,995,8779) &&
        	   (inventory.contains(8778) && inventory.getAmount(8778) >= 8));
    }

    public void interactLarder() throws InterruptedException {
    	
		RS2Object larder = getObjects().closestThatContains("Larder");

        if  (larder != null); {
            if (larder.hasAction("Build")){
                larder.interact("Build");
                sleep(random(900, 1200));
                buildit();
            } else if (larder.hasAction("Remove")){
                larder.interact("Remove");
           	 	sleep(random(900, 1200));
           	 	removeit();      
            }
            new ConditionalSleep(500, 20) {
                @Override
                public boolean condition() throws InterruptedException {
                    return (getInventory().isEmptyExcept(8794,2347,995,8779));
                }
            }.sleep();
        }
      }
    
	public void buildit() throws InterruptedException	{
		
        RS2Widget furni = getWidgets().get(458, 1);
		RS2Object larder = getObjects().closestThatContains("Larder");
        
			if (furni != null && furni.isVisible()) {
	           	 	keyboard.typeString("2");
				new ConditionalSleep(200, 20) {
				    @Override
				    public boolean condition() {
				        return (!larder.hasAction("Build"));
				    }
				}.sleep();
			}
		}
	
	public void removeit() throws InterruptedException	{
		
        RS2Widget furni2 = getWidgets().getWidgetContainingText(219,"Really remove it?");
		RS2Object larder = getObjects().closestThatContains("Larder");
        
			if (furni2 != null && furni2.isVisible()) {
	           	 	keyboard.typeString("1");
				new ConditionalSleep(200, 20) {
				    @Override
				    public boolean condition() {
				        return (!larder.hasAction("Remove"));
				    }
				}.sleep();
			}
		}
	
    private void exitHome() throws InterruptedException {
    	
		RS2Object portal = getObjects().closest("Portal");
		
        if (portal != null  && getMap().isInHouse()) {
            portal.interact("Enter");
            sleep(random(1000, 1500));
			new ConditionalSleep(3000, 50) {
			    @Override
			    public boolean condition() {
			        return (!getMap().isInHouse());
			    }
			}.sleep();
		    }
		}
    
    private void getMaterials() throws InterruptedException {
    	
		NPC Phials = npcs.closest("Phials");
		
		if(getInventory().isEmptyExcept(8794,2347,995,8779)) {
        	if(!Phials.isVisible()) {
        	getWalking().walk(phialsPos);
        	sleep(random(500, 1000)); {
        		}
        	}
		}
    }
        	
	public void unnote() throws InterruptedException	{
		
		NPC Phials = npcs.closest("Phials");
        RS2Widget widget = getWidgets().getWidgetContainingText(219,"Exchange All: 120 coins");

		if(getInventory().isEmptyExcept(8794,2347,995,8779)) {
			if (!getInventory().isItemSelected())	{
				getInventory().getItem("Oak plank").interact("use");
				sleep(random(250, 750));
				if (Phials != null && Phials.isVisible()){
						Phials.interact(); 
						}
						new ConditionalSleep(3000, 50) {
						    @Override
						    public boolean condition() {
						        return (widget != null && widget.isVisible());
						    }
						}.sleep();
					    }
					}
				}
	
	public void getAll() throws InterruptedException	{
		
        RS2Widget widget = getWidgets().getWidgetContainingText(219,"Exchange All: 120 coins");

		if(getInventory().isEmptyExcept(8794,2347,995,8779)) {
			if (widget != null && widget.isVisible())	{
				dialogues.selectOption("Exchange All: 120 coins");
				sleep(random(250, 750));
				new ConditionalSleep(1500, 20) {
				    @Override
				    public boolean condition() {
				        return getInventory().contains(8778);
				    }
				}.sleep();
			}else{
	            stop(false);
			}
		}
	}
    
    private void goHome() throws InterruptedException {
    	
		RS2Object portal = getObjects().closest("Portal");
		
	if(getInventory().isEmptyExcept(8794,2347,995,8778,8779)) {
        if (portal != null && !portal.isVisible()) {
        	getWalking().walk(portalPos);
        	sleep(random(500, 1000));
        	}else if (portal != null && portal.isVisible()) {
        portal.interact("Build mode");
		new ConditionalSleep(3000, 20) {
		    @Override
		    public boolean condition() {
		        return getMap().isInHouse();
		    }
		}.sleep();
        	}
        }
    }


    @Override
    public void onPaint(Graphics2D g) {
    	
        int	cXp = getExperienceTracker().getGainedXP(Skill.CONSTRUCTION);
        int cXpph = getExperienceTracker().getGainedXPPerHour(Skill.CONSTRUCTION);
        int lvl = getSkills().getDynamic(Skill.CONSTRUCTION);
        
        g.setColor(new Color(0, 0, 0, 155));
        g.fillRect(5, 238, 238, 99);
        
        g.setColor(new Color(255, 255, 255));
        g.drawRect(5, 238, 238, 99);
        
        g.setFont(g.getFont().deriveFont(14.0f));
        
    	trail.paint(g);
        Point mP = getMouse().getPosition();
        g.drawLine(mP.x, 501, mP.x, 0);
        g.drawLine(0, mP.y, 764, mP.y);
    	
        super.onPaint(g);
        g.drawString("Construction level(Current): " + lvl, 15, 295);
        g.drawString("Construction XP: " + cXp, 15, 310);
        g.drawString("Construction XP/PH: " + cXpph, 15, 325);
        g.drawString("Construction Lite", 65, 255);
        g.drawString("Run time: " +String.valueOf(formatTime(System.currentTimeMillis() - startTime)), 15, 275);
    }

    private String formatTime(final long ms){
        long s = ms / 1000, m = s / 60, h = m / 60;
        s %= 60; m %= 60; h %= 24;
        return String.format("%02d:%02d:%02d", h, m, s);
    }
    }

ConstructionLite.jar

Construct.jar

Edited by Lol_marcus
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...
  • 2 months later...
On 11/8/2020 at 5:09 AM, Lol_marcus said:

Is it crashing at a specific time, or does it just randomly crash?

almost every time i go to phias, i have a demon butler, idk if you can make it so i could use him but i go to him and it crashes and just stops and sometimes it gets stuck with the portal because of the camera.  Im still using it, its good enoug to use so jagex doesnt think im botting becasue im also playing while the script is going and im constantly restarting the script\

edit: watching the script now, he clicks on the noted planks and the script crashes.  just disappears. Im using the first link, constructionlite.

edit 2: Its the zoom feature thats the problem, if i keep it zoomed all the way out it works longer.

Edited by chronichemp
Link to comment
Share on other sites

  • 4 weeks later...

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...