Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Tips on large script architecture


    boblemao1
     Share

    Recommended Posts

    Hi, I'm currently working on a large script that is supposed to handle different skilling methods as well as quests, but I'm having some trouble solidifying how I'm going to organize things moving forward. My goal with this script is to have an all in one script that takes a fresh account, finishes tutorial island, does some quests, and hops between various skilling methods until it gets past f2p trade restrictions. Perhaps I could use this to setup my own gold farm, but atm its more of a passion project with a definite goal; to consistently develop an account to 100 total level, 20 hours played, and 10 qp without getting banned.

     

    Some background on my progress so far:

    Im quite new to the scripting scene, but I've made a good dent in my goal so far. I currently have some classes called "Tasks" which implement the onLoop, onStart, onEnd methods and have a reference to the main abstract script. These are meant to be basically miniscripts that I can call within this main script. The main script calls their respective "on" methods accoridngly if theyre currently running.   I have some Tasks coded up already for some quests to get to 10qp, tutorial island, and a simple miner, but I want to make far more skilling Tasks.

    Im not currently using a node framework, and instead have Tasks doing everything atm which I think is messy. I have a stack of Tasks, of which only the top runs, and if I have a really common action such as running to the closest bank, I have a ClosestBankTask that can be switched to in which case the current task is halted, the bank task runs, brings the player to the bank, stops, then control is returned to the original task. 

     

    Problem 1:

    I'm aware of the Node and Tree frameworks, but I have some issues understanding how these normally work with scripts that require some state and relatively sequential steps. An example is that of a quest, in which theres distinct steps to take. My impression is that nodes are always considered to be run by being in the node list, and when their validate returns true, they execute. For something like quest this seems unwieldy since there can be something like 20 distinct steps to the quest, and although I can use playersettings and things like inventory state for knowing which one is active MOST of the time, I think sometimes theres multiple actions that should be done for one step but have identical game state. An example I could think of is if I need to get some items from the bank during one playersetting quest step, and the item isnt there.  In such a case, the game state before and after going to the bank is the exact same (no new item in the inventory or new playersetting) but I need to now know to go get the item. My solution would be to have some global state shared amoungst them but that seems messy and I feel there must be a better way. 

    I guess my question is, how small do you generally make a nodes responsibilities, and should there be ANY communication between nodes? What would be your guys' solution to the above scenario where it doesnt seem I can rely solely on game state. Should state even be kept seperate at all, or should it SOLELY rely on what the game can offer (whats in the inventory, playersettings, etc) for a robust script.

     

    Problem 2:

    Frameworks such as the node frameworks I see proposed sound great for smaller scripts that handle an individual skill/quest, but I dont understand how to have them work for large scripts that may do many.  My idea would be that I retain my "Task" system and each task has its own node manager that contains the specific nodes and figures out which to run, but wondering if theres a better way.

    Additionally, some nodes may need to be run anytime regardless of the task being done, such as one that should return you to where you died if you randomly died while doing another task (as a low level, random giant rats, or muggers, etc can kill you while doing seemingly safe things like mining to cutting trees). I'm trying to make my script as robust as possible so I feel I should have some general tasks that always run to catch cases such as these.

     

    Conclusion:

    I understand that I'm all over the place here, but that's exactly my problem with regards to designing larger scripts. I'd love to hear some higher level overviews of how you guys lay out large scripts. I have a thousand other small questions but the above are what I felt are the big ones, dont feel required to answer those, any general discussion on large script architectures would be helpful!

    Edited by boblemao1
    Link to comment
    Share on other sites

    Have a look at the following patterns: strategy pattern, decorator pattern, factory pattern and state pattern. They are patterns used to develop software which can help you make cleaner and more elegant code.

    Try your first step by using TaskScript as pointed above. Pm me on discord if u need more advice or want to learn together: Mhbawsddhbi#1847

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.