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
  • AbstractScripting Inheritance


    zharovigor

    Recommended Posts

    So I stumbled upon alot of code and other projects to study the DreamBot API. As you may know I am working on a multi-functional bot script that is basically a Runescape Artificial Intelligent  program that cycles thru creature with Random Intervals of specific times accumulating player's activity, chops tree, lights fires, banks, travels, mules, banks, fight, loot, bury, cook, eat everything a usual player would do yet programmatically. The cycling of creatures and activity wont be consisted in a simple algorithmic patterns.

    This post is to verify whether inheritance of multiply subclass of organized objective code to for fill a purpose .

     Always start Script with  "@ScriptManifest" on the main  extender.

    @ScriptManifest(
    		category = Category.MISC, 
    		name = "IgorBot", author = "Igor", 
    		version = 0.1)

     

    Extend class to AbstractScript

    public class AbstractContext extends AbstractScript {
    	AbstractContext acorn = this;

    Call onStart and onLoop in main handler.

    @Override
        public void onStart() {
        	log("Index: " + getClient().getLoginIndex());
        	
        	targetChick.initStart(acorn);
        }
    	
    	@Override
    	public int onLoop() {
    		targetChick.initLoop(acorn);
    		return 0;
    	}

    Extend Main AbstractScript Handle

    public class TargetChicken extends AbstractContext {

     

    Coding the subclass that I searched for the chicken killer script and added to my project. This is an example of part of my program I am developing.

    public void initStart(AbstractScript script) {
        	for(Skill s : Skill.values()){ //Start all skill trackers.
                getSkillTracker().start(s, !getClient().getInstance().getScriptManager().isRunning());
            }
            ui = new UserInterface(this); //This gets both classes to work together.
            ui.setVisible(true); //Makes the GUI visible
        }
        
        public int initLoop(AbstractScript script) {
        	if(isStarted){
                Item food = getInventory().get(item -> item != null && item.hasAction("Eat"));
                if(getSkills().getBoostedLevels(Skill.HITPOINTS) < getSkills().getRealLevel(Skill.HITPOINTS)/2){
                    if(food != null && food.interact("Eat"))
                        sleep(400, 800);
                    else
                        stop(); //No more food left
                }
                if(ui.isBanking() && getInventory().isFull() && (!ui.getBuryBones() || !getInventory().contains("Bones"))){
                    if(bank.contains(getLocalPlayer())){
                        if(getBank().isOpen()){
                            if(getBank().depositAllExcept(item -> item != null && item.hasAction("Eat")))
                                getBank().close();
                        }else {
                            if (getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals("Bank booth") && gameObject.hasAction("Bank")).interact("Bank")) {
                                sleepUntil(() -> getBank().isOpen(), 10000);
                                return 10;
                            }
                        }
                    }else{
                        walkToArea(bank);
                    }
                }
    
                if((ui.isBanking() && !getInventory().isFull()) || !ui.isBanking())
                    if (ui.getKillChickens()) { //Killing chickens
                        if (areaContainsDestOrPlayer(chickenPen)) { //We're in our area
                            if (attack(getNpcs().closest(npc -> npc.getName().equals("Chicken") && npc.hasAction("Attack") && !npc.isInCombat() && chickenPen.contains(npc) && getMap().canReach(npc)))) {
                                loot();
                                killCount++;
                            }
                            buryBones();
                        } else {
                            walkToArea(chickenPen); //We're not in our area, time to walk to it
                        }
                    } else {
                        stop(); //Neither cows nor chickens were selected
                    }
    
            }
            return 500;
        }

    I am planning on adding logic to the program with conditional statements and boolean checks and to cycle thru  AbstractContexts with isActive(true);

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

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