Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Abstract Style State script with Object Oriented Programming - corrected I belive


    Recommended Posts

    Posted (edited)
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.container.impl.bank.Bank;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.item.GroundItems;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Logger;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.items.GroundItem;
    
    @ScriptManifest(author = "C0d33rr0r", category = Category.WOODCUTTING, name = "Draynor : Chop n Deposit - Logs WILLOW", version = 0)
    public class TestEnumstyle extends AbstractScript {
        
    	public boolean onMessage(String string) {	   
    	    return true;
    	}
        @Override
        public int onLoop() {
    	switch (BOT.TASK) {
    	case 0:
    	    Logger.log("PATH");
    	    BOT.PATH = BOT.TREEPATH;
    	    BOT.PATHA = BOT.TREEPATHA;
    	    PATH();
    	    break;
    	case 1:
    	    Logger.log("BANK");
    	    BANK();
    	    break;
    	case 2:
    	    Logger.log("CHOP");
    	    CHOP_TREE();
    	    break;
    	default:
    	    break;
    	}
    	return Calculations.random(BOT.MIN,BOT.MAX);
        }
        private boolean PATH() {
    	do {
        	    if (!Walking.isRunEnabled()) {
                    Walking.walk(BOT.PATH.getRandomTile());
                    BOT.R = 0;
                    BOT.R = Calculations.random(0, 2);
                    switch (BOT.R) {
                        case 0:
                            sleep(1999, 5555);
                            break;
                        case 1:
                            sleep(2999, 5555);
                            break;
                        case 2:
                            sleep(3999, 5555);
                            break;
                        default:
                            break;
                    }
                } else {
                    Walking.walk(BOT.PATH.getRandomTile());
                    BOT.R = 0;
                    BOT.R = Calculations.random(0, 2);
                    switch (BOT.R) {
                        case 0:
                            sleep(1999, 5555);
                            break;
                        case 1:
                            sleep(2999, 5555);
                            break;
                        case 2:
                            sleep(3999, 5555);
                            break;
                        default:
                            break;
                    }
                }
    	}while(!BOT.PATHA.contains(Players.getLocal().getTile()));
    	BOT.TASK = 2;
    	Logger.log( "TASK CHOP");
    	sleep(BOT.MIN,BOT.MAX);
    	return true;
        }
        private boolean CHOP_TREE() {
    	do {
    	    BOT.GAMEOBJECT = GameObjects.closest("Willow tree");
    	    sleep(BOT.MIN,BOT.MAX);
    	    BOT.GAMEOBJECT.interact();
    	    do {
    		if(Inventory.isFull()) {
    		    BOT.GROUNDITEM = GroundItems.closest("Clue nest (beginner)","Clue nest (easy)","Clue nest (medium)","Clue nest (hard)","Clue nest (elite)");
    		    if(BOT.GROUNDITEM != null) {
    			sleep(BOT.MIN,BOT.MAX);
    			BOT.GROUNDITEM.interact();
    			do {
    			    sleep(1);
    			}while(!Inventory.contains("Clue nest (beginner)","Clue nest (easy)","Clue nest (medium)","Clue nest (hard)","Clue nest (elite)"));
    			break;
    		    } else {
    			break;
    		    }
    		} else {
    		    BOT.GROUNDITEM = GroundItems.closest("Clue nest (beginner)","Clue nest (easy)","Clue nest (medium)","Clue nest (hard)","Clue nest (elite)");
    		    if(BOT.GROUNDITEM != null) {
    			sleep(BOT.MIN,BOT.MAX);
    			BOT.GROUNDITEM.interact();
    			do {
    			    sleep(1);
    			}while(!Inventory.contains("Clue nest (beginner)","Clue nest (easy)","Clue nest (medium)","Clue nest (hard)","Clue nest (elite)"));
    		    } else {
    			sleep(1);
    		    }
    		}
    	    }while(BOT.GAMEOBJECT.exists());
    	}while(!Inventory.isFull());
    	BOT.TASK = 1;
    	Logger.log( "TASK BANK");
    	sleep(BOT.MIN,BOT.MAX);
    	return true;
        }
        private boolean BANK() {
    	do {
            	if(!Bank.isOpen()) {
            	    BOT.R = Calculations.random(0,2);
            	    switch (BOT.R) {
            	    case 0:
            		    BOT.GAMEOBJECT = GameObjects.getTopObjectOnTile(BOT.BOOTH0);
            		    BOT.GAMEOBJECT.interact();
            		    do {
            			sleep(1);
            		    }while(!Bank.isOpen());
            		break;
            	    case 1:
            		    BOT.GAMEOBJECT = GameObjects.getTopObjectOnTile(BOT.BOOTH1);
            		    BOT.GAMEOBJECT.interact();
            		    do {
            			sleep(1);
            		    }while(!Bank.isOpen());
            		break;
            	    case 2:
            		    BOT.GAMEOBJECT = GameObjects.getTopObjectOnTile(BOT.BOOTH2);
            		    BOT.GAMEOBJECT.interact();
            		    do {
            			sleep(1);
            		    }while(!Bank.isOpen());
            		break;
            		default:
            		    break;
            	    }
            	} else {
            	    sleep(BOT.MIN,BOT.MAX);
            	    if(Inventory.contains("Clue nest (elite)")) {
            		Inventory.interact("Clue nest (elite)","Deposit-All");
            	    } else {
            		if(Inventory.contains("Clue nest (hard)")) {
            			Inventory.interact("Clue nest (hard)","Deposit-All");
            		} else {
            		    if(Inventory.contains("Clue nest (medium)")) {
            			Inventory.interact("Clue nest (medium)","Deposit-All");
            		    } else {
            			if(Inventory.contains("Clue nest (easy)")) {
            				Inventory.interact("Clue nest (easy)","Deposit-All");
            			} else {
            			    if(Inventory.contains("Clue nest (beginner)")) {
            				Inventory.interact("Clue nest (beginner)","Deposit-All");
            			    } else {
            				Inventory.interact("Willow logs","Deposit-All");
            			    }
            			}
            		    }
            		}
            	    }
            	}
    	}while(Inventory.contains("Willow logs","Clue nest (beginner)","Clue nest (easy)","Clue nest (medium)","Clue nest (hard)","Clue nest (elite)"));
    	BOT.TASK = 0;
    	Logger.log( "TASK PATH");
    	sleep(BOT.MIN,BOT.MAX);
    	return true;
        }
        private static class BOT {
    	private static GameObject GAMEOBJECT;
    	private static GroundItem GROUNDITEM;
    	private static int TASK = 0;
    	private static int R;
    	private static int MIN = 1333;
    	private static int MAX = 3333;
    	private static Tile BOOTH0 = new Tile(3091,3242,0);
    	private static Tile BOOTH1 = new Tile(3091,3243,0);
    	private static Tile BOOTH2 = new Tile(3091,3245,0);
    	private static Area PATH;
    	private static Area PATHA;
    	private final static int TPx0 = Calculations.random(3086,3090);
    	private final static int TPy0 = Calculations.random(3231,3237);
    	private final static int TPx1 = Calculations.random(3086,3090);
    	private final static int TPy1 = Calculations.random(3231,3237);
    	private final static Area TREEPATH = new Area(new Tile(TPx0,TPy0,0),new Tile(TPx1,TPy1,0));
    	private final static Area TREEPATHA = new Area(3092, 3225, 3079, 3239, 0);
        }
    
    }

    Fast short sweet and simple, I combined the styles together and came up with this.

     

    It use's the AbstractScript for looping, State style switching for tasking, OOP for information.

    Edited by c0d33rr0r
    • c0d33rr0r changed the title to Abstract Style State script with Object Oriented Programming - corrected I belive

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.