Jump to content

Walking issue :(


FearMe

Recommended Posts

It's starting to really annoy me, I have to walk through an area where there's aggressive monsters and the walker sometimes just stands still, meaning I get to half health...

I don't see where the problem is, sometimes it works perfectly fine but sometimes it stands still for no reason.

 

public void walkPath(Position[] path, int startIndex, boolean reverse)
throws InterruptedException {
if (script.myPlayer().getPosition()
.distance(path[reverse ? 0 : path.length - 1]) <= 3
|| script.myPlayer().getPosition().distance(path[startIndex]) > 100)
return;
if (!reverse) {
for (int i = startIndex; i < path.length; i++) {
if (!walkTile(path[i], 3))
i--;
}
} else {
for (int i = startIndex; i >= 0; i--) {
if (!walkTile(path[i], 3))
i++;
}
}
}
 
public int getPathStartIndex(Position[] path, boolean reverse) {
int closestIndex;
int closest;
if (!reverse) {
closest = script.myPlayer().getPosition().distance(path[0]);
closestIndex = 0;
for (int i = 1; i < path.length; i++) {
if (script.myPlayer().getPosition().distance(path[i]) <= closest) {
closest = script.myPlayer().getPosition().distance(path[i]);
closestIndex = i;
}
}
} else {
closest = script.myPlayer().getPosition()
.distance(path[path.length - 1]);
closestIndex = path.length - 1;
for (int i = path.length - 1; i >= 0; i--) {
if (script.myPlayer().getPosition().distance(path[i]) <= closest) {
closest = script.myPlayer().getPosition().distance(path[i]);
closestIndex = i;
}
}
}
return closestIndex;
}
 
public boolean walkTile(Position p, int margin) throws InterruptedException {
if (script.myPlayer().getPosition().distance(p) <= margin)
return true;
else if (script.myPlayer().getPosition().distance(p) > margin)
script.client.moveMouseTo(
new MinimapTileDestination(script.bot, p), false, true,
false);
 
int failsafe = 0;
while (failsafe < 10
&& script.myPlayer().getPosition().distance(p) > margin) {
if ((script.client.getRunEnergy() > MethodProvider.random(25, 40) || script.myPlayer().isUnderAttack())
&& !script.isRunning()) {
script.client.getInterface(548).getChild(93).interact();
script.sleep(MethodProvider.random(500, 700));
}
script.sleep(100);
failsafe++;
if (script.myPlayer().isMoving())
failsafe = 0;
}
 
return script.myPlayer().getPosition().distance(p) <= margin;
}
Link to comment
Share on other sites

Only suggestion is here : 7BeiI.png

 

add:

!script.client.getRunEnergy() > MethodProvider.random(25,40) && !script.isRunning() || 

That's probably the only thing i can see wrong, cos if its under attack and above the run energy it will just keep clicking run on/off

Edited by Divinity
Link to comment
Share on other sites

Only suggestion is here : 7BeiI.png

 

add:

!script.client.getRunEnergy() > MethodProvider.random(25,40) && !script.isRunning() || 

That's probably the only thing i can see wrong, cos if its under attack and above the run energy it will just keep clicking run on/off

I did that because I want the character to run when it's being attacked so the monster can't keep up. It's not in the code I'm running right now and it's still doing the standing still..

Link to comment
Share on other sites

It's there...

GWcUdg1.png

 

No dude i mean like this: 

if ((script.client.getRunEnergy() > MethodProvider.random(25, 40) && !script.isRunning() || script.myPlayer().isUnderAttack())
&& !script.isRunning()) {

For every || you have you have to declare any existing logic, it doesn't carry over by itself

Link to comment
Share on other sites

No dude i mean like this: 

if ((script.client.getRunEnergy() > MethodProvider.random(25, 40) && !script.isRunning() || script.myPlayer().isUnderAttack())
&& !script.isRunning()) {

For every || you have you have to declare any existing logic, it doesn't carry over by itself

That's checking it twice..  It works fine like this, there's nothing wrong with that lol.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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