Compare commits

..

3 Commits

Author SHA1 Message Date
dtookey
8414358708 doc tweaks. i think i'm done 2023-08-06 22:16:35 -04:00
dtookey
2d1f372d94 Routines has usage examples 2023-08-06 22:09:45 -04:00
dtookey
05cc6a4107 Routines has usage examples 2023-08-06 22:08:23 -04:00
2 changed files with 116 additions and 28 deletions

View File

@ -14,7 +14,7 @@ import java.awt.event.KeyEvent
* ```
* val orch = RSOrchestrator.getInstance()
* val params = StandingTaskParams(...)
* orch.doStandingTask(orch, params)
* RSOrchestrator.doStandingTask(orch, params)
* ```
*/
interface RSOrchestrator : Orchestrator {
@ -32,7 +32,7 @@ interface RSOrchestrator : Orchestrator {
* ```
* val orch = RSOrchestrator.getInstance()
* val params = StandingTaskParams(...)
* orch.doStandingTask(orch, params)
* RSOrchestrator.doStandingTask(orch, params)
* ```
*
* @param orchestrator The [RSOrchestrator] that will execute the actions.
@ -61,7 +61,7 @@ interface RSOrchestrator : Orchestrator {
* ```
* val orch = RSOrchestrator.getInstance()
* val params = TravelTaskParams(...)
* orch.doTravelTask(orch, params)
* RSOrchestrator.doTravelTask(orch, params)
* ```
*
* @param orchestrator The [RSOrchestrator] instance that will execute the actual actions.
@ -107,9 +107,7 @@ interface RSOrchestrator : Orchestrator {
*
* @param taskParams The StandingTaskParams configuring the task details like bank location, hotkeys, durations etc.
*/
fun processAtBank(
taskParams: StandingTaskParams
)
fun processAtBank(taskParams: StandingTaskParams)
/**
* Handles the crafting workflow when at a station near the bank.
@ -131,21 +129,13 @@ interface RSOrchestrator : Orchestrator {
*
* Usage example:
* ```
* val params = TravelTaskParams(
* bankLocation = Point(100, 200),
* stationLocation = Point(300, 400),
* withdrawHotkey = KeyEvent.VK_F1,
* craftHotkey = KeyEvent.VK_2,
* // ...other params
* )
* val params = TravelTaskParams(...)
* orchestrator.processAtStationNearBank(params)
* ```
*
* @param taskParams The TravelTaskParams configuring the task details like locations, durations, hotkeys etc.
*/
fun processAtStationNearBank(
taskParams: TravelTaskParams
)
fun processAtStationNearBank(taskParams: TravelTaskParams)
/**
* Gets the screen point location of the bank.
@ -161,7 +151,7 @@ interface RSOrchestrator : Orchestrator {
* orchestrator.moveMouseLeftClickAndSleep(bankPoint, 100)
*
* // Withdraw preset inventory at bank
* orchestrator.keyPress(KeyEvent.VK_F1)
* orchestrator.automaton.keyPress(KeyEvent.VK_F1)
* ```
*
* @return The Point representing the x,y screen coordinates of the bank location.
@ -185,7 +175,7 @@ interface RSOrchestrator : Orchestrator {
* Craft while standing at bank:
* ```
* val standingParams = StandingTaskParams(...)
* agent.doStandingTask(agent, standingParams)
* orchestrator.doStandingTask(agent, standingParams)
* ```
*
*

View File

@ -2,17 +2,29 @@ import java.awt.Point
import java.awt.event.KeyEvent
/**
* Routines contains utility functions to perform common bot tasks and workflows.
* Routines object containing reusable workflows for common scripts.
*
* This includes functions like:
* - fullRunIncense: Handles the full incense stick crafting workflow.
* - processInventoryAtFurnace: Processes a total volume of inventory at a furnace near the bank.
* - processRefinedPlanksIntoFrames:Processes refined planks into frames at a sawmill near the bank.
* This object encapsulates reusable routines for common botting workflows.
* It provides an easy way to invoke these flows without having to reimplement
* the lower-level actions each time.
*
* The routines use an Agent instance to perform actions like banking,
* depositing items, withdrawing presets, etc.
* The routines are structured as standalone methods that accept the necessary
* parameters. This allows them to be called independently and composed in
* different combinations.
*
* The routines are encapsulated for pure convenience
* For example, the fullRunIncense routine orchestrates the entire incense
* stick crafting workflow by invoking the individual steps:
*
* - cleanHerbs
* - cutIncenseSticks
* - coatIncenseSticks
* - infuseIncenseSticks
*
* The individual steps can also be called independently as needed.
*
* This structure makes the routines reusable, customizable, and composable.
* Scripts can invoke the routines directly rather than reimplementing the
* underlying actions. Parameters allow customizing volumes, locations etc.
*/
object Routines {
/**
@ -40,7 +52,18 @@ object Routines {
* - Infusing clean herbs into sticks
*
* It loops through each step based on the provided volumes, performing the
* actions at the bank. The bank location is prompted from the user.
* actions at the bank.
*
* Usage example:
*
* ```
* val herbs = 1000
* val logs = 2000
* val ashes = 1500
* val cleanHerbs = herbs + 150
*
* Routines.fullRunIncense(herbs, logs, ashes, cleanHerbs)
* ```
*
* Progress is printed after each step. Total elapsed time is printed at the end.
*/
@ -97,6 +120,18 @@ object Routines {
* - Depositing clean herbs
*
* It performs the actions at the bank location using the provided agent.
*
* Usage examples:
* ```
* val volume = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
* Routines.cleanHerbs(volume, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.cleanHerbs(1000)
* ```
*/
fun cleanHerbs(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams(
@ -123,6 +158,19 @@ object Routines {
* - Withdrawing magic log preset
* - Cutting magic logs into incense sticks without dialog
* - Depositing incense sticks
*
* Usage examples:
* ```
* val logs = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.cutIncenseSticks(logs, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.cutIncenseSticks(1000)
* ```
*/
fun cutIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams(
@ -149,6 +197,20 @@ object Routines {
* - Withdrawing incense stick preset
* - Coating incense sticks with ashes using hotkey
* - Depositing coated sticks
*
* Usage examples:
* ```
* val sticks = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.coatIncenseSticks(sticks, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
*
* ```
* Routines.coatIncenseSticks(1000)
* ```
*/
fun coatIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams(
@ -174,6 +236,19 @@ object Routines {
* - Withdrawing incense stick preset
* - Infusing incense sticks with herbs using hotkey
* - Depositing infused incense sticks
*
* Usage examples:
* ```
* val sticks = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.infuseIncenseSticks(sticks, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.infuseIncenseSticks(1000)
* ```
*/
fun infuseIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams(
@ -198,9 +273,17 @@ object Routines {
* This method handles the workflow of crafting potions using hotkeys while standing at a bank:
*
* - It constructs a StandingTaskParams instance defining:
* - The volume, volume per trip, bank point, crafting hotkey, and other details
* - The volume, volume per trip, bank point, crafting hotkey, and other details
* - It calls the orchestrator's doStandingTask() method to execute the task.
*
* Usage example:
* ```
* val volume = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
* Routines.craftPotionsAtBank(volume, agent, bankPoint)
* ```
*
* Progress is automatically printed during execution.
*
* @deprecated This method needs validation before use in production.
@ -236,6 +319,15 @@ object Routines {
*
* It calls the orchestrator's doTravelTask() method to execute the grinding task.
*
* Usage example:
* ```
* val volume = 1000
* val travelDuration = 5000 // 5 seconds
* val bankPoint = Point(100, 200)
* val wellPoint = Point(300, 400) // Prompted from user
* Routines.potionGrindWithWell(volume, travelDuration, bankPoint, wellPoint)
* ```
*
* Progress is automatically printed during execution.
*
* @deprecated This method needs validation before use in production.
@ -282,6 +374,12 @@ object Routines {
* The furnace and bank locations are passed in as specific Point locations.
* The agent handles the navigation and banking actions.
*
* Usage example:
*
* ```
* Routines.processAtFurnaceNearBank(1500)
* ```
*
* Before processing, the camera is reset to align points.
*/
fun processInventoryAtFurnace(volume: Int) {