NotSinan / DreamBotQuester

DreamBotQuester is a powerful Java library that allows players of the popular online game, RuneScape, to automate their quests using the DreamBot API. With a range of tools for interacting with the API and executing tasks in the game, DreamBotQuester is an ideal choice for players looking to save time on tedious quests or optimize their progress.
MIT License
16 stars 4 forks source link

Witch's potion script doesn't end when completed. #27

Closed NotSinan closed 1 year ago

NotSinan commented 1 year ago

When quest complete, script is still running.

Dreambotter420 commented 1 year ago

This is because of the Quest branch checking if Quest is finished before executing the FinishedQuestLeaf inside the Quest branch:

return FreeQuest.WITCHS_POTION.hasRequirements() && !FreeQuest.WITCHS_POTION.isFinished();

To resolve this, we can apply a check inside the isValid method of the Quest branch, which checks for requirements and finished status, then call ScriptManager.getScriptManager().stop(); and return false if requirements are not met or quest is finished, then afterwards return true to execute Quest branch if the quest can be performed.

Dreambotter420 commented 1 year ago

For example:

@Override public boolean isValid() { if(FreeQuest.WITCHS_POTION.hasRequirements()) { Logger.log("Do not have requirements to start Witchs Potion, stopping script...!"); ScriptManager.getScriptManager().stop(); return false; }

    if(FreeQuest.WITCHS_POTION.isFinished()) {
        Logger.log("Finished Witchs Potion, stopping script...!");
        ScriptManager.getScriptManager().stop();
        return false;
    }

    return true;
}
NotSinan commented 1 year ago

For example:

@OverRide public boolean isValid() { if(FreeQuest.WITCHS_POTION.hasRequirements()) { Logger.log("Do not have requirements to start Witchs Potion, stopping script...!"); ScriptManager.getScriptManager().stop(); return false; }

    if(FreeQuest.WITCHS_POTION.isFinished()) {
        Logger.log("Finished Witchs Potion, stopping script...!");
        ScriptManager.getScriptManager().stop();
        return false;
    }

    return true;
}

I think this is perfect

Dreambotter420 commented 1 year ago

Added class CheckRequirements and method checkRequirements(Quest quest) that implements this method and revised all Quest branches to implement this in next commit.