Jump to content

Check if stunned while thieving


yfoo

Recommended Posts

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

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.

Link to comment
Share on other sites

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

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.

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