Merge branch 'sfatigue' into 'master'

Fatigue training legacy compatibility

See merge request open-runescape-classic/APOS!101
This commit is contained in:
Stormy committed 2024-03-29 16:14:46 +00:00
commit d2f77deb89
5 files changed
+27 -7

No files matched your search

BIN
View File
Binary file not shown.
+1 -1
View File
@@ -707,7 +707,7 @@ public class Extension extends client implements IClient {
@Override
public boolean isFatigueTraining() {
return fatigueTraining && vg == MAX_FATIGUE;
return fatigueTraining;
}
@Override
+13
View File
@@ -596,6 +596,19 @@ public abstract class Script implements IScript {
return client.isMobWalking(client.getPlayer());
}
/**
* @deprecated For old scripts. Legacy.
* @return not what you think it returns!
*/
@Deprecated
public boolean isTricking() {
if (client.isFatigueTraining() && client.getSleepFatigue() < 708) {
useSleepingBag();
return false;
}
return client.isFatigueTraining() && client.getSleepFatigue() < 750;
}
/**
* Enables or disables fatigue tricking, which is disabled by default. If
* the player kills certain NPCs with 99% fatigue in melee combat, they can
+13 -3
View File
@@ -59,6 +59,7 @@ final class SleepListener implements ISleepListener {
private void onSleepStart() {
}
/**
* Hook to call an instance of the onSleepWord(data) method
*
@@ -67,13 +68,16 @@ final class SleepListener implements ISleepListener {
static void sleepWordHook(final byte[] data) {
instance.onSleepWord(data);
}
/**
* Processes the given byte array data to handle sleep words.
*
* @param data the byte array data to process
*/
private void onSleepWord(final byte[] data) {
if (client.isFatigueTraining() && client.getSleepFatigue() == 0) {
if (client.isFatigueTraining() &&
client.getFatigue() == 750 &&
client.getSleepFatigue() == 0) {
client.setSleeping(false);
return;
}
@@ -291,7 +295,7 @@ final class SleepListener implements ISleepListener {
return;
}
if (client.isFatigueTraining()) {
if (client.isFatigueTraining() && client.getFatigue() == 750) {
if (fatigue == 750) return;
if (fatigue == 708) {
@@ -306,6 +310,7 @@ final class SleepListener implements ISleepListener {
if (fatigue == 0) sendSleepWord();
}
/**
* Sends the sleep word using the client's CAPTCHA service.
*/
@@ -317,17 +322,22 @@ final class SleepListener implements ISleepListener {
sleepWord = null;
}
/**
* Hook that is called when sleep word is entered incorrectly
*/
static void sleepWordIncorrectHook() {
instance.onSleepWordIncorrect();
}
/**
* Called when sleep word is entered incorrectly, if greater than maximum tries, it will log out.
*/
private void onSleepWordIncorrect() {
if (client.isFatigueTraining() && ++incorrectSleepTries > MAXIMUM_INCORRECT_SLEEP_TRIES) {
if (!client.isFatigueTraining() || client.getFatigue() < 750) {
return;
}
if (++incorrectSleepTries > MAXIMUM_INCORRECT_SLEEP_TRIES) {
onSleepStop();
client.logout();
}
-3
View File
@@ -105,7 +105,6 @@ public final class S_Fatigue extends Script
@Override
public int main() {
if (start_time == -1L) {
System.out.println("line 101");
ingame_init();
init = true;
}
@@ -655,7 +654,6 @@ public final class S_Fatigue extends Script
}
private void ingame_init() {
System.out.println("ingame_init");
start_time = System.currentTimeMillis();
Arrays.fill(has_banked, false);
start_x = getX();
@@ -677,7 +675,6 @@ public final class S_Fatigue extends Script
if (cb_bank.getState()) {
pw.init(null);
pw_init = true;
System.out.println("cb_bank");
nearest_bank = pw.getNearestBank(getX(), getY());
System.out.println("Nearest bank: " +
nearest_bank.name);