1. Formula (Add this in PlayerAssistant)
Code:
public double getAgilityRunRestore() {
return 2260 - (c.playerLevel[16] * 10);
}
2. In Client class under "process() {" (If you use eventmanager for this, set the timer on a tick (600ms))
Code:
if (runEnergy < 100) {
if (System.currentTimeMillis() > getPA().getAgilityRunRestore(this) + lastRunRecovery) {
runEnergy++;
lastRunRecovery = System.currentTimeMillis();
getPA().sendFrame126(runEnergy+"%", 149);
}
}
3. In Player class under "absY += Misc.directionDeltaY[dir];"
Code:
if (isRunning()) {
Client c = (Client) this;
if (runEnergy > 0) {
runEnergy--;
c.getPA().sendFrame126(runEnergy+"%", 149);
} else {
isRunning2 = false;
c.getPA().setConfig(173, 0);
}
}
4. Add these anywhere in Player class
Code:
public int runEnergy = 100;
public long lastRunRecovery;
public boolean isRunning() {
return isNewWalkCmdIsRunning() || (isRunning2 && isMoving);
}
5. To save the energy when a player logs, place these in PlayerSave class
Code:
characterfile.write("run-energy = ", 0, 13);
characterfile.write(Integer.toString(p.runEnergy), 0, Integer.toString(p.runEnergy).length());
characterfile.newLine();
Code:
else if (token.equals("run-energy")) {
p.runEnergy = Integer.parseInt(token2);
}
and in client class, somewhere in the "initialize" method add:
Code:
c.getPA().sendFrame126(runEnergy+"%", 149);
6. To make the run button work, go to ClickingButtons packet and add:
Code:
case 152 :
if (c.runEnergy < 1) {
c.isRunning = false;
c.getPA().setConfig(173, 0);
return;
}
c.isRunning = !c.isRunning;
c.getPA().setConfig(173, c.isRunning ? 0 : 1);
break;
And that's it
Credits to Russian.