Jump to content

Welcome to DreamBot

VIP Enhancement

Want to upgrade your DreamBot experience? Consider signing up for VIP!
VIP allows you to run as many accounts as you want, view the forums ad-free, receive 10% off all script purchases, and so much more!
Visit the store to learn about all of these great features!

Upgrade to VIP Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox

DreamBot is the only Deadman Mode supported bot on the market!

Download the DreamBot client today!





Sign in to follow this  
bueno

CowFighter Script(First script)

Recommended Posts

Here is a quick Cow Fighter Script, It's my first script. All it does is fight cows for now, will edit and learn how to add other options later.

 

 

 

import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.Category;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.interactive.NPC;

@ScriptManifest(category = Category.COMBAT, name = "CowFighter", author = "BUENO", version = 1.0, description = "CowFighter")
public class CowFighter extends AbstractScript {
    @Override
    public void onStart() {
        log("CowFighter by BUENO Activated");
        log("Enjoy!");
    }
    @Override
    public void onExit()  {
        log("Thanks for using my CowFighter script!");
    }
    public static final String COW = "Cow";
    public static final Filter<NPC> COW_FILTER = new Filter<NPC>() {
        @Override 
        public boolean match(NPC npc) {
            if (npc == null){
                 return false;
            }
            
            return npc.getName().equals(COW) && !npc.isHealthBarVisible(); 
        }
    };
    
    Area killArea = new Area(3256, 3267, 3259, 3284);
    
    @Override
    public int onLoop(){
        if(getLocalPlayer().isInCombat()){
            //do nothing
        }else if(killArea.contains(getLocalPlayer())){
            NPC cow = getNpcs().closest(COW_FILTER);
            if(cow != null){
                cow.interact("Attack");
            }
        }else {
            getWalking().walk(killArea.getRandomTile()); 
        }
        return 1000;
    }
}

Share this post


Link to post
Share on other sites

Thank you for your comments and advice, I've been using it on and off because I'm not trying to get banned. Please let me know if you find any issues!

I forgot to mention that this script is meant for the cows in Lumbridge next to goblins.

Share this post


Link to post
Share on other sites

Hi, how are you?

your filter using lambda looks like this

 

public static final Filter<NPC> COW_FILTER = npc -> npc != null && npc.getName().equals(COW) && !npc.isHealthBarVisible();
public static final Filter<NPC> COW_FILTER = npc -> npc != null && npc.getName().equals(COW) && !npc.isHealthBarVisible();

 

Share this post


Link to post
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.

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.

Sign in to follow this  

×
×
  • Create New...