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
  • Need help with my script


    Geek

    Recommended Posts

    @ScriptManifest(category = Category.COMBAT, name = "Raeve Cow Killer", author = "Raeve", description = "Kills cows picks up hides", version = 1.0)
    public class Main extends AbstractScript {
        public static final String COWHIDE = "Cowhide";
        public static final Filter<Item> HIDE_FILTER = new Filter<Item>() {
            @Override
            public boolean match(Item item) {
                if (item == null) {
                    return false;
                }
    
                return item.getName().equals(COWHIDE); //Checks if item equals Cowhide
            }
        };
        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(); //Checks NPC name= Cow and that healthbar is not there
            }
        };
    
        Area killArea = new Area(3264, 3256, 3254, 3297);
        //Area bankArea = new Area();//Later for banking
    
        @Override
        public int onLoop() {
            if (getLocalPlayer().isInCombat()) {
    
            } else if (killArea.contains(getLocalPlayer())) {
                NPC cow = getNpcs().closest(COW_FILTER);
                if (cow != null) {
                    cow.interact("Attack");//Checks player in killArea, Closest cows and attacks
                    }
                    if (!getLocalPlayer().isInCombat() && !getInventory().isFull())//If inv not full and not in combat.
                    {
                        getGroundItems().closest(COWHIDE).interact("Take"); //Take cowhide
                    } else {
                        return -1;
                    }
                }
    
             else {
                getWalking().walk(killArea.getCenter()); //Walks to killArea
            }
            return 2000;
        }
        }

    This is my script it works pretty good so far only problem I am facing is that it loots all cowhides that appear.

    Even when in combat :( I would like it to loot only once and that right after the NPC dies.

     

    Anyone able to help me ?

    Link to comment
    Share on other sites

    the likeliness that you are in combat as soon as the attack interaction is called is rather small. So as soon as the interact is finished it will then go to the next if and therefore loot cowhide.

    Link to comment
    Share on other sites

    1 minute ago, Eclipseop said:

    the likeliness that you are in combat as soon as the attack interaction is called is rather small. So as soon as the interact is finished it will then go to the next if and therefore loot cowhide.

    Do I just fix it with a sleep or ?

     

    Also how can I add that the script only loots cowhides with the distance of <4 tiles

    Link to comment
    Share on other sites

    sleeping after is a sloppy quick fix. There are a lot of ways to handle this differently and more efficiently. A sleep will work "Some" of the time. For example if the monster is as far away as possible and you interact with it, there is no guarantee the sleep will be enough time to run to the monster and fully interact with it. Restructuring your script so that when you want to fight make sure you start a fight. I personally am not a fan of what I can "While sleeps" for example while (inCombat){Sleep(1000)); not that there is anything inherently wrong with it, it just think it wastes too much time.

    For the second question, here is a snippet from my open source AIO fighter and looter that handles picking up arrows below a distance (Loot being a groundItem):

    if (RETRIEVE_ARROWS && loot != null && getLocalPlayer().distance(loot.getTile()) < 6
    					&& !getLocalPlayer().isInCombat() && !getLocalPlayer().isAnimating()
    					&& !getLocalPlayer().isMoving()) {
    				Looter.lootbyId(EQUIPPED_ARROW);
               }

    Feel free to check out parts of my open source fighter for help with this.

    https://bitbucket.org/zylski424/aio-fighter/src/master/src/

    Link to comment
    Share on other sites

    When you are in combat you might want to do the following things:

    • Sleep for a random amount of time (1500-3000 milliseconds)
    • Move the mouse or camera around by random chance.
    • Check the health, and if the health is lower then, say, 40%, then eat food or run to a safespot.
    • I would also attack the cow only if your inventory is not full, then after check if there is loot on the ground.
    Link to comment
    Share on other sites

    20 hours ago, ArmyofDragons said:

    When you are in combat you might want to do the following things:

    • Sleep for a random amount of time (1500-3000 milliseconds)
    • Move the mouse or camera around by random chance.
    • Check the health, and if the health is lower then, say, 40%, then eat food or run to a safespot.
    • I would also attack the cow only if your inventory is not full, then after check if there is loot on the ground.

    1. Would that even have usefull inpact?

    2. Good idea will try that.

    3. That is for later ;) First want it to work without fancy stuff xD

    4. Changed that thanks man ! :)

    Link to comment
    Share on other sites

    • 2 weeks later...

    A simple solution would be, making it pick up after filtering for

    !npc.Exists()

    This will make it collect after your cow dies.

    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.