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.

First sand crab script help

Featured Replies

heyy, i was wondering if someone could help me with this
not sure how exactly to check when sand crabs have lost agro. when they are in the state where we can not attack them
this is the code i am currently using and it does not work
 
if (sandCrab != null && sandCrab.exists() && !sandCrab.hasAction("Attack")) {
 log("agro reset");
 resetAgro();
}

Just check for how long your player hasn't been in combat for, if it's greater than like 20 seconds reset agro.

if (myPlayer().isUnderAttack()) {
            lastAttack = System.currentTimeMillis();
            //KEEP AFKING
        } else if (System.currentTimeMillis() > (lastAttack + resetTime) && !myPlayer().isUnderAttack()) {
            //RESET PLAYER
        }

Reset time is the amount of time the player should not be in combat in milliseconds, which indicates whether we are still aggro or not. In your case, I suggest putting it at around 20000 milliseconds = 20 seconds.

Edited by PureKiller

iirc the sand crabs have a different name when they're not Agro'd, I believe it's sandy rock or something?

ya search combat area for sandy rocks, if they're present for longer than 5-20 secs reset. thats my approach.

something like

if(sandyRocksInArea && playerOnCombatTile && !myPlayerInCombat)

{

startCustomTimer();

}else{

         resetCustomTimer();

        }

 

if(timer>random(5000,20000))

{

reset();

}

Edited by cammofunk

  • Author

Thanks for the help guys. 

I ended up going with Slut's method. As I didn't wanna use a timer. And that was my problem basically, I was treating both, sand crabs and sandy rocks as the same.

On 6/25/2018 at 7:06 PM, Slut said:

iirc the sand crabs have a different name when they're not Agro'd, I believe it's sandy rock or something?

 

So far its working good. If anyone else wants to use it, feel free.

        if (!getCombat().isFighting() && sandyRocks != null && sandyRocks.exists() && (sandCrab == null || !sandCrab.exists()) ) {
            sleep(random(1000, 5000));    
            if (npcs.closest(myArea, "Sand Crab") == null) {
                log("reseting agro");
                resetAgro();
            }
        }

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.