Jump to content

Check if stunned while thieving


Recommended Posts

Posted (edited)

Just now figured out that using vertices count is the way to go.
The birds that appear add to your vertices count, bumping it up by 42. 
Set your starting vertices count in onStart. Then you can check if stunned by comparing it against your current vertex count. 

Something like...
 

// When player is stunned their vertices count goes up by ~42.
// Get baseline vertices when idle to determine when stunned.
MidStunUtil.approxVerticesCountStunned = myPlayer().getModel().getVerticesCount() + 42;
public static boolean isPlayerStunned() {
    return approxVerticesCountStunned - globalMethodProvider.myPlayer().getModel().getVerticesCount() <= 5;
}



I used to use player height (normal ~ 198, stunned ~ 240) but that doesn't work if player is wielding certain items like a staff that increases your height over 240. Checking animation also is a nogo, The animation id flips back to -1 before the stun ends. So you wouldn't be able to ConditionalSleep until unstunned. Player hp is also bad, what if dodgy necklace procs? 

 
Edited by yfoo
  • Like 1
Posted
2 hours ago, yfoo said:

Just now figured out that using vertices count is the way to go.
The birds that appear add to your vertices count, bumping it up by 42. 
Set your starting vertices count in onStart. Then you can check if stunned by comparing it against your current vertex count. 

Something like...
 

// When player is stunned their vertices count goes up by ~42.
// Get baseline vertices when idle to determine when stunned.
MidStunUtil.approxVerticesCountStunned = myPlayer().getModel().getVerticesCount() + 42;
public static boolean isPlayerStunned() {
    return approxVerticesCountStunned - globalMethodProvider.myPlayer().getModel().getVerticesCount() <= 5;
}



I used to use player height (normal ~ 198, stunned ~ 240) but that doesn't work if player is wielding certain items like a staff that increases your height over 240. Checking animation also is a nogo, The animation id flips back to -1 before the stun ends. So you wouldn't be able to ConditionalSleep until unstunned. Player hp is also bad, what if dodgy necklace procs? 

 

 

 

So what I do for this is I have an onMessage set a boolean

public void onMessage(Message m) throws InterruptedException {
            if(m.getMessage().contains("You fail")) {
                isStunned = true;
            }
        

    }

 

On the top of my onLoop I have this

if(isStunned) {
                log("I am stunned");
                int myVertCount = myPlayer().getModel().getVerticesCount();
                if (inventory.contains("Coin pouch")) {
                    inventory.getItem("Coin pouch").interact("Open-all");
                } else if (needsToEat()) {
                    if (hasFood()) {
                        eatFood();
                    }
                }
                new ConditionalSleep(5_000) {@Override public boolean condition() {return myPlayer().getModel().getVerticesCount() < myVertCount;}}.sleep();
                log("I am no longer stunned");
                myTarget = null;
                isStunned = false;
            }

 

It works really well regardless of what you might be wielding as far as I've been able to tell.

Posted (edited)
1 hour ago, Alakazizam said:

 

 

So what I do for this is I have an onMessage set a boolean

public void onMessage(Message m) throws InterruptedException {
            if(m.getMessage().contains("You fail")) {
                isStunned = true;
            }
        

    }

 

On the top of my onLoop I have this

if(isStunned) {
                log("I am stunned");
                int myVertCount = myPlayer().getModel().getVerticesCount();
                if (inventory.contains("Coin pouch")) {
                    inventory.getItem("Coin pouch").interact("Open-all");
                } else if (needsToEat()) {
                    if (hasFood()) {
                        eatFood();
                    }
                }
                new ConditionalSleep(5_000) {@Override public boolean condition() {return myPlayer().getModel().getVerticesCount() < myVertCount;}}.sleep();
                log("I am no longer stunned");
                myTarget = null;
                isStunned = false;
            }

 

It works really well regardless of what you might be wielding as far as I've been able to tell.

If you're are already using myVertCount to determine how long you're stunned you should go ahead and also use it to determine if you are stunned. There is no reason to use 2 since one can do both for you. 
 

Edited by yfoo
Posted
1 minute ago, yfoo said:

If you're are already using myVertCount to determine how long you're stunned you should go ahead and also use it to determine if you are stunned. There is no reason to use 2 since one can do both for you. 

I like to use the on message to start the stun because it's ignored by any sleeps that may be taking place on the onLoop. I use the vert count as the sleep condition because the amount of time that's passed before that point will change depending on if the coin pouch needs to be open or if food is being eaten. I also wasn't 100% how different any vert change differences would be between wearing different gear so I didn't want to use that to trigger the stun.

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...