Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hover Function

Featured Replies

Hi everyone,

 

I am currently nearly finished with the combat portion of my script, as it is attacking only one thing at a time, and waiting till it dies to attack another NPC, and also not attacking other NPC's already in combat.

 

Something i thought that would be really good to polish of the script off would be to add in a hover option so that as soon as the npc the bot is killing dies, it clicks on the next available, not in combat npc.

 

Just something that would be good as it would make the bot get potentionally more exp/hour.

 

http://pastebin.com/7XCBwFYi

 

That is my pastebin of the script i have currently.

 

What would i need to add and explain why so i can learn. And is there anything i need to change in my script to make the script run smoother or be more functional?

 

I have been researching as well so its not like im asking for an easy cop out. i have been trying to learn java for a couple days and looking at all different open source scripts to learn more and more.

 

Cheers in advance,

 

Gearfighter

Hi everyone,

 

I am currently nearly finished with the combat portion of my script, as it is attacking only one thing at a time, and waiting till it dies to attack another NPC, and also not attacking other NPC's already in combat.

 

Something i thought that would be really good to polish of the script off would be to add in a hover option so that as soon as the npc the bot is killing dies, it clicks on the next available, not in combat npc.

 

Just something that would be good as it would make the bot get potentionally more exp/hour.

 

http://pastebin.com/7XCBwFYi

 

That is my pastebin of the script i have currently.

 

What would i need to add and explain why so i can learn. And is there anything i need to change in my script to make the script run smoother or be more functional?

 

I have been researching as well so its not like im asking for an easy cop out. i have been trying to learn java for a couple days and looking at all different open source scripts to learn more and more.

 

Cheers in advance,

 

Gearfighter

 

When you are under attack, find the next NPC which is not equal to the NPC you are attacking, that has health > 0 and is not under attack from another player, and then use hover() to hover over it.

  • Author

there's a #hover() method

How would i go about putting that into my script.

 

sorry for being nooby but ive been looking all over the place trying to do it

How would i go about putting that into my script.

 

sorry for being nooby but ive been looking all over the place trying to do it

 

Perhaps something like this (Sorry can't be bothered to test it):

import org.osbot.rs07.api.filter.NameFilter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Cow Killer", info = "Kills Cows...", author = "Explv", version = 0.1, logo = "")
public final class CowKiller extends Script {

    private NPC currentCow, nextCow;

    @Override
    public final int onLoop() throws InterruptedException {

        if(isAttackingCow()) {
            hoverNextNPC();
        } else {
            currentCow = null;
            attackNPC();
        }
        return random(150, 200);
    }

    private boolean isAttackingCow() {
        return currentCow != null &&
               currentCow.exists() &&
               currentCow.getHealthPercent() > 0 &&
               myPlayer().isInteracting(currentCow);
    }

    private void hoverNextNPC() {
        nextCow = getClosestCow();
        if(nextCow != null && !getMouse().isOnCursor(nextCow)) {
            nextCow.hover();
        }
    }

    private void attackNPC() {

        currentCow = isAttackableTarget(nextCow) ? nextCow : getClosestCow();

        if(currentCow != null && currentCow.interact("Attack")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return myPlayer().isInteracting(currentCow) ||
                           !isAttackableTarget(currentCow);
                }
            }.sleep();
        }
    }

    private NPC getClosestCow() {
        return getNpcs().closest(
                new NameFilter<>("Cow", "Cow calf"),
                npc -> npc != currentCow &&
                       isAttackableTarget(npc)
        );
    }

    private boolean isAttackableTarget(final NPC target) {
        return target != null &&
               target.exists() &&
               target.getHealthPercent() > 0 &&
               !target.isUnderAttack();
    }
}

Explanation:

- If the we are under attack:
  - If we are hovering over another cow (nextCow variable) and that cow is attackable:
    - Set that cow as the cow to attack
  - Else find the closest attackable cow
  - Store the cow that we found in the global variable currentCow, to be used when hovering
  - If we have an attackable cow (!= null):
    - Use the interaction "Attack" on the cow
    - If the interaction was successful:
      - Sleep for 5 seconds, or until we are attacking the cow,
        or until the cow is no longer attackable.

- If the player is not under attack:
  - Find the closest cow that is not the cow we are attacking (currentCow), and that is attackable
  - If a cow is found (!= null):
    - Store the cow in the global variable nextCow, to be used when attacking
    - If we are not already hovering over that cow:
      - Hover over the cow

Edited by Explv

 

Perhaps something like this (Sorry can't be bothered to test it):

import org.osbot.rs07.api.filter.NameFilter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Cow Killer", info = "Kills Cows...", author = "Explv", version = 0.1, logo = "")
public final class CowKiller extends Script {
    
    private NPC currentCow;
    
    @Override
    public final int onLoop() throws InterruptedException {
        
        if(isAttackingCow()) {
            hoverNextNPC();    
        } else {
            currentCow = null;
            attackNPC();
        }
        return random(150, 200);
    }
    
    private boolean isAttackingCow() {
        return currentCow != null && 
               currentCow.exists() && 
               currentCow.getHealthPercent() > 0 &&
               myPlayer().isInteracting(currentCow);
    }
    
    private void hoverNextNPC() {
        NPC hoverCow = getClosestCow();
        if(hoverCow != null && !getMouse().isOnCursor(hoverCow)) {
            hoverCow.hover();
        }
    }
    
    private void attackNPC() {
        
        currentCow = getClosestCow();
        
        if(currentCow != null && currentCow.interact("Attack")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !currentCow.exists() ||
                            currentCow.getHealthPercent() == 0 || 
                            myPlayer().isUnderAttack() || 
                            myPlayer().isInteracting(currentCow);
                }
            }.sleep();
        }
    }
    
    private NPC getClosestCow() {
        return getNpcs().closest(
                new NameFilter<>("Cow", "Cow calf"),
                npc -> npc != currentCow &&
                       !npc.isUnderAttack() &&
                       npc.getHealthPercent() > 0
        );
    }
}

Explanation:

 

  • If the player is not under attack, you find the closest Cow that isn't under attack from another player, and has health > 0 (not doing it's dying animation). If a cow is successfully found (!= null), perform the interaction "Attack", and then sleep until the player is attacking that cow, or until the cow no longer exists, or for 5 seconds.
  • If the player is under attack, find the next closest Cow, that isn't equal to the Cow the player is attacking, is not under attack from another player, has health > 0. If a Cow is found, and we are not already hovering over it, then hover over it. 

 

 

This is great.

  • Author

 

Perhaps something like this (Sorry can't be bothered to test it):

import org.osbot.rs07.api.filter.NameFilter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Cow Killer", info = "Kills Cows...", author = "Explv", version = 0.1, logo = "")
public final class CowKiller extends Script {

    private NPC currentCow, nextCow;

    @Override
    public final int onLoop() throws InterruptedException {

        if(isAttackingCow()) {
            hoverNextNPC();
        } else {
            currentCow = null;
            attackNPC();
        }
        return random(150, 200);
    }

    private boolean isAttackingCow() {
        return currentCow != null &&
               currentCow.exists() &&
               currentCow.getHealthPercent() > 0 &&
               myPlayer().isInteracting(currentCow);
    }

    private void hoverNextNPC() {
        nextCow = getClosestCow();
        if(nextCow != null && !getMouse().isOnCursor(nextCow)) {
            nextCow.hover();
        }
    }

    private void attackNPC() {

        currentCow = isAttackableTarget(nextCow) ? nextCow : getClosestCow();

        if(currentCow != null && currentCow.interact("Attack")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return myPlayer().isInteracting(currentCow) ||
                           !isAttackableTarget(currentCow);
                }
            }.sleep();
        }
    }

    private NPC getClosestCow() {
        return getNpcs().closest(
                new NameFilter<>("Cow", "Cow calf"),
                npc -> npc != currentCow &&
                       isAttackableTarget(npc)
        );
    }

    private boolean isAttackableTarget(final NPC target) {
        return target != null &&
               target.exists() &&
               target.getHealthPercent() > 0 &&
               !target.isUnderAttack();
    }
}

Explanation:

- If the we are under attack:
  - If we are hovering over another cow (nextCow variable) and that cow is attackable:
    - Set that cow as the cow to attack
  - Else find the closest attackable cow
  - Store the cow that we found in the global variable currentCow, to be used when hovering
  - If we have an attackable cow (!= null):
    - Use the interaction "Attack" on the cow
    - If the interaction was successful:
      - Sleep for 5 seconds, or until we are attacking the cow,
        or until the cow is no longer attackable.

- If the player is not under attack:
  - Find the closest cow that is not the cow we are attacking (currentCow), and that is attackable
  - If a cow is found (!= null):
    - Store the cow in the global variable nextCow, to be used when attacking
    - If we are not already hovering over that cow:
      - Hover over the cow

 

Hey Explv, thankyou for this, i will give it a shot. its very helpful and informative!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.