Jump to content

First sand crab script help


Recommended Posts

Posted
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();
}
Posted (edited)

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
  • Like 2
Posted (edited)

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
  • Like 1
Posted

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();
            }
        }

  • Heart 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...