diff --git a/src/main/kotlin/Doer.kt b/src/main/kotlin/Doer.kt index 36aa46f..66c5cb5 100644 --- a/src/main/kotlin/Doer.kt +++ b/src/main/kotlin/Doer.kt @@ -33,7 +33,7 @@ import kotlin.random.Random * @constructor Creates a Doer instance with a Robot. */ open class Doer(private val robot: Robot = Robot()) { - companion object{ + companion object { /** * The duration in milliseconds of one "tick". The duration of 600ms matches the tick duration of game servers. * @@ -48,7 +48,6 @@ open class Doer(private val robot: Robot = Robot()) { } - /** * Extra padding in milliseconds added before actions to account for latency. 500ms is entirely arbitrary. It is * simply a value that works well during high-load periods. Better to be conservative than lossy. @@ -283,8 +282,11 @@ open class Doer(private val robot: Robot = Robot()) { * @param variance The amount of random variance to add in milliseconds. */ fun sleep(dur: Long, variance: Long) { + if (dur < 0 || variance <= 1) { + return + } val dSize = (variance) / 2 - val r1 = Random.nextLong(dSize) + val r1 = Random.nextLong(dSize) val r2 = Random.nextLong(dSize) sleep(dur + r1 + r2) } diff --git a/src/main/kotlin/Entry.kt b/src/main/kotlin/Entry.kt index 5e8b742..c6bcf42 100644 --- a/src/main/kotlin/Entry.kt +++ b/src/main/kotlin/Entry.kt @@ -1,7 +1,7 @@ import java.awt.Point fun main() { -// Routines.fullRunIncense(0, 8916, 9462, 4808) - Routines.processInventoryAtFurnace(100) + Routines.fullRunIncense(29, 29, 29, 29) +// Routines.processInventoryAtFurnace(100) } diff --git a/src/main/kotlin/Routines.kt b/src/main/kotlin/Routines.kt index 5798201..a9f37fb 100644 --- a/src/main/kotlin/Routines.kt +++ b/src/main/kotlin/Routines.kt @@ -1,5 +1,4 @@ import java.awt.Point -import java.awt.event.InputEvent import java.awt.event.KeyEvent /** @@ -35,40 +34,39 @@ object Routines { * actions at the bank. The bank location is prompted from the user. * * Progress is printed after each step. Total elapsed time is printed at the end. - * @deprecated Needs validation before using for real, as sawmill points are hardcoded */ fun fullRunIncense(volHerbs: Int, volLogs: Int, volAshes: Int, volCleanHerbs: Int) { val start = System.currentTimeMillis() //initialize the shared agent and chest point val agent = Agent() - val chest = agent.getBankPoint() + val bankPoint = agent.getBankPoint() // Loop to clean grimy herbs: // Withdraw herb preset, clean without dialog at bank if (volHerbs > 0) { - cleanHerbs(volHerbs) + cleanHerbs(volHerbs, agent, bankPoint) } println("\rHerbs cleaned") // Loop to cut magic logs into sticks: // Withdraw log preset, cut logs using hotkey at bank if (volLogs > 0) { - cutIncenseSticks(volLogs) + cutIncenseSticks(volLogs, agent, bankPoint) } println("\rLogs cut into sticks") // Loop to coat sticks in ashes: // Withdraw ash preset, coat sticks using hotkey at bank if (volAshes > 0) { - coatIncenseSticks(volAshes) + coatIncenseSticks(volAshes, agent, bankPoint) } println("\rSticks coated in ashes") // Loop to infuse clean herbs into sticks: // Withdraw herb preset, infuse sticks using hotkey at bank if (volCleanHerbs > 0) { - infuseIncenseSticks(volCleanHerbs) + infuseIncenseSticks(volCleanHerbs, agent, bankPoint) } println("\rClean herbs infused") @@ -77,11 +75,11 @@ object Routines { println("Entire chain finished in ${agent.prettyTimeString(finish - start)}") } - @Deprecated("Needs validation before you use it for realsies") + fun cleanHerbs(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { val params = StandingTaskParams( volume, - 28, + CommonVolumesPerStep.FullInventory, agent, bankPoint, KeyEvent.VK_F1, @@ -96,7 +94,7 @@ object Routines { fun cutIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { val params = StandingTaskParams( volume, - 28, + CommonVolumesPerStep.FullInventory, agent, bankPoint, KeyEvent.VK_F2, @@ -112,7 +110,7 @@ object Routines { fun coatIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { val params = StandingTaskParams( volume, - 28, + CommonVolumesPerStep.CoatingIncenseWithAsh, agent, bankPoint, KeyEvent.VK_F3, @@ -127,7 +125,7 @@ object Routines { fun infuseIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { val params = StandingTaskParams( volume, - 28, + CommonVolumesPerStep.InfusingIncenseWithHerb, agent, bankPoint, KeyEvent.VK_F4, @@ -142,7 +140,7 @@ object Routines { fun craftPotionAtBank(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { val params = StandingTaskParams( volume, - 28, + CommonVolumesPerStep.FullInventory, agent, bankPoint, KeyEvent.VK_F6, @@ -163,7 +161,7 @@ object Routines { val well = agent.promptUserForPoint("Put your mouse over the well...") val params = TravelTaskParams( volume, - 28, + CommonVolumesPerStep.FullInventory, agent, bankPoint, well,