Jump to content

First sand crab script help


iTalalz

Recommended Posts

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();
}
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

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