This is what I've come up with on my own for run energy draining... it probably sucks but I've just started delving into these things.
Code:
if(runToggled || runQueue) {
if(player.getRunEnergy() < 0.01) {
walkPoint = getNextPoint();
} else if(player.getRunEnergy() > 0.01) {
runPoint = getNextPoint();
player.setRunEnergy((int) -0.88);
}
}
I haven't tested it either, will do that now.
Oh, and just above that I have:
Code:
if(player.getRunEnergy() < 100) {
player.setRunEnergy((int) +0.25);
}
Update: Yeah, that didn't work at all, client closed the connection when I logged in.
Removed the check for less than 100 energy before the check of RunQueue or RunToggled.
New code:
Code:
if(runToggled || runQueue) {
if(player.getRunEnergy() < 0.01) {
walkPoint = getNextPoint();
player.setRunEnergy((int) +0.25);
} else if(player.getRunEnergy() > 0.01) {
runPoint = getNextPoint();
player.setRunEnergy((int) -0.88);
}
}
Crashed when I clicked on the "Run" button.
New code:
Code:
if(runToggled || runQueue && player.getRunEnergy() > 0) {
runPoint = getNextPoint();
Removed --> player.setRunEnergy((int) -0.88);
}
Still crashes the client and I think it has something to do with player.setRunEnergy((int0 -0.88); but I'm not sure...
Update: Okay I removed the drain but now I need a way to drain energy if the player is running... without crashing the game.