things are a bit better organized. have a super function to handle full-chain incense production
This commit is contained in:
parent
99e050822d
commit
2eb471a5c4
@ -13,12 +13,19 @@ class Agent {
|
||||
const val LeftClick = InputEvent.BUTTON1_DOWN_MASK
|
||||
}
|
||||
|
||||
val doer= Doer(Robot())
|
||||
private val doer = Doer(Robot())
|
||||
|
||||
|
||||
fun doLoop(volume: Int, step: Int, task: (Agent)->Unit){
|
||||
fun doLoop(totalVolume: Int, volumePerStep: Int, task: (Agent) -> Unit) {
|
||||
require(totalVolume>0){
|
||||
"You must make at least 1 thing in total"
|
||||
}
|
||||
require(volumePerStep>0){
|
||||
"You must consume at least 1 thing per step"
|
||||
}
|
||||
fun computeTotalSteps(totalVolume: Int, volumePerStep: Int) = (ceil((totalVolume / volumePerStep).toDouble()) + 1).toInt()
|
||||
val r = Doer(Robot())
|
||||
val totalSteps =(ceil((volume/step).toDouble()) +1).toInt()
|
||||
val totalSteps =computeTotalSteps(totalVolume, volumePerStep)
|
||||
|
||||
val start = System.currentTimeMillis()
|
||||
for (i in 0 until totalSteps) {
|
||||
@ -36,19 +43,43 @@ class Agent {
|
||||
print("\rStep $step of $of (${prettyTimeString(dur)} complete\t|\t~${prettyTimeString(remaining)} remaining) ")
|
||||
}
|
||||
|
||||
private fun prettyTimeString(remaining: Long): String{
|
||||
if (remaining == 0L){
|
||||
fun prettyTimeString(durationMillis: Long): String {
|
||||
if (durationMillis == 0L) {
|
||||
return "No time data yet"
|
||||
}
|
||||
val sec = 1000L
|
||||
val min = 60L * sec
|
||||
val hour = 60L * min
|
||||
return if(remaining>hour){
|
||||
return "${remaining/hour}h${(remaining%hour)/min}m${(remaining%min)/sec}s"
|
||||
}else if (remaining > min){
|
||||
return "${(remaining%hour)/min}m${(remaining%min)/sec}s"
|
||||
val millisPerSecond = 1000L
|
||||
val millisPerMinute = 60L * millisPerSecond
|
||||
val millisPerHour = 60L * millisPerMinute
|
||||
return if (durationMillis > millisPerHour) {
|
||||
return "${durationMillis / millisPerHour}h${(durationMillis % millisPerHour) / millisPerMinute}m${(durationMillis % millisPerMinute) / millisPerSecond}s"
|
||||
} else if (durationMillis > millisPerMinute) {
|
||||
return "${(durationMillis % millisPerHour) / millisPerMinute}m${(durationMillis % millisPerMinute) / millisPerSecond}s"
|
||||
} else {
|
||||
"${(remaining%min)/sec}s"
|
||||
"${(durationMillis % millisPerMinute) / millisPerSecond}s"
|
||||
}
|
||||
}
|
||||
|
||||
fun promptUserForPoint(prompt: String): Point {
|
||||
println(prompt)
|
||||
|
||||
for (i in 5 downTo 1) {
|
||||
print("\rtaking point snapshot in $i...")
|
||||
doer.sleep(1000)
|
||||
}
|
||||
|
||||
print("\r ")
|
||||
|
||||
return doer.getPointerLocationAfter(1000)
|
||||
}
|
||||
|
||||
fun scrollOutToFixedHeight(){
|
||||
doer.sleep(1000)
|
||||
|
||||
for(i in 0 until 16){
|
||||
doer.scrollIn()
|
||||
}
|
||||
for(i in 0 until 8){
|
||||
doer.scrollOut()
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,12 +99,12 @@ class Agent {
|
||||
doer.sleep(waitDurationMillis, waitDurationVariance)
|
||||
}
|
||||
|
||||
fun bankStandWithoutDialog(chest: Point){
|
||||
fun bankStandWithoutDialog(chest: Point, invKey: Int, hotKey: Int) {
|
||||
doer.mouseMove(chest)
|
||||
doer.moveMouseLeftClickAndSleep(doer.getAlmostPoint(chest), 900, 400)
|
||||
doer.keypress(F6)
|
||||
doer.keypress(invKey)
|
||||
doer.sleepForNTicks(1)
|
||||
doer.keypress(Minus)
|
||||
doer.keypress(hotKey)
|
||||
doer.sleepForNTicks(1)
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +75,10 @@ class Doer(val r: Robot) {
|
||||
r.mouseWheel(1)
|
||||
sleep(25, 26)
|
||||
}
|
||||
fun scrollIn(){
|
||||
r.mouseWheel(-1)
|
||||
sleep(25, 26)
|
||||
}
|
||||
|
||||
fun getPointerLocationAsValDeclarationString(varName: String) {
|
||||
TimeUnit.SECONDS.sleep(5)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
fun main() {
|
||||
Routines.processInventoryAtFurnace(28)
|
||||
Routines.fullRunIncense(1, 1, 1, 1)
|
||||
}
|
||||
|
||||
|
||||
@ -1,46 +1,83 @@
|
||||
import java.awt.Point
|
||||
import java.awt.Robot
|
||||
import java.awt.event.KeyEvent
|
||||
|
||||
object Routines {
|
||||
|
||||
fun fullRunIncense(volHerbs: Int, volLogs: Int, volAshes: Int, volCleanHerbs: Int){
|
||||
val agent = Agent()
|
||||
val start = System.currentTimeMillis()
|
||||
val chest = agent.promptUserForPoint("Hold your mouse over the bank...")
|
||||
|
||||
//process any grimy herbs we might need
|
||||
if(volHerbs > 0){
|
||||
agent.doLoop(volHerbs, 28){
|
||||
agent.bankStandWithoutDialog(chest, KeyEvent.VK_F1, KeyEvent.VK_1)
|
||||
}
|
||||
}
|
||||
println("\rHerbs cleaned")
|
||||
|
||||
//cut up any magic logs we might need
|
||||
if(volLogs > 0){
|
||||
agent.doLoop(volLogs, 26){
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F2, KeyEvent.VK_2, 26000, 1200)
|
||||
}
|
||||
}
|
||||
println("\rLogs cut into sticks")
|
||||
|
||||
//coat any sticks
|
||||
if(volAshes > 0){
|
||||
agent.doLoop(volAshes, 26){
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F3, KeyEvent.VK_3, 21000, 600)
|
||||
}
|
||||
}
|
||||
println("\rSticks coated in ashes")
|
||||
|
||||
//infuse any sticks
|
||||
if(volCleanHerbs > 0){
|
||||
agent.doLoop(volCleanHerbs, 27){
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F4, KeyEvent.VK_4, 48600, 600)
|
||||
}
|
||||
}
|
||||
println("\rClean herbs infused")
|
||||
|
||||
val finish = System.currentTimeMillis()
|
||||
|
||||
println("Entire chain finished in ${agent.prettyTimeString(finish-start)}")
|
||||
}
|
||||
|
||||
fun cleanHerbs(volume: Int, step: Int = 14){
|
||||
val agent = Agent()
|
||||
|
||||
val step = 28;
|
||||
val r = Doer(Robot())
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = r.getPointerLocationAfter(3000L)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
agent.doLoop(volume, step){
|
||||
agent.bankStandWithoutDialog(chest)
|
||||
agent.bankStandWithoutDialog(chest, KeyEvent.VK_F1, KeyEvent.VK_1)
|
||||
}
|
||||
}
|
||||
fun cutIncenseSticks(volume: Int, step: Int = 26){
|
||||
fun cutIncenseSticks(volume: Int, step: Int = 28){
|
||||
val agent = Agent()
|
||||
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = agent.doer.getPointerLocationAfter(3000L)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
|
||||
agent.doLoop(volume, step){
|
||||
agent.bankStandForLoop(chest, Agent.F6, Agent.Minus, 26000, 1200)
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F2, KeyEvent.VK_2, 26000, 1200)
|
||||
}
|
||||
}
|
||||
fun coatIncenseSticks(volume: Int, step: Int = 26){
|
||||
val agent = Agent()
|
||||
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = agent.doer.getPointerLocationAfter(3000L)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
|
||||
agent.doLoop(volume, step){
|
||||
agent.bankStandForLoop(chest, Agent.F6, Agent.Minus, 21000, 600)
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F3, KeyEvent.VK_3, 21000, 600)
|
||||
|
||||
}
|
||||
}
|
||||
fun infuseIncenseSticks(volume: Int, step: Int = 27 ){
|
||||
val agent = Agent()
|
||||
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = agent.doer.getPointerLocationAfter(3000L)
|
||||
agent.doLoop(volume, step){
|
||||
|
||||
agent.bankStandForLoop(chest, Agent.F6, Agent.Minus, 48600, 600)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
agent.doLoop(volume, step){
|
||||
agent.bankStandForLoop(chest, KeyEvent.VK_F4, KeyEvent.VK_4, 48600, 600)
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +85,7 @@ object Routines {
|
||||
val agent = Agent()
|
||||
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = agent.doer.getPointerLocationAfter(3000L)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
agent.doLoop(volume, step){
|
||||
agent.bankStandForLoop(chest, Agent.F6, Agent.Minus, 19200, 600)
|
||||
}
|
||||
@ -56,10 +93,10 @@ object Routines {
|
||||
|
||||
fun potionGrindWithWell(volume: Int, step: Int = 14){
|
||||
val agent = Agent()
|
||||
println("Put your mouse over the bank...")
|
||||
val chest = agent.doer.getPointerLocationAfter(3000L)
|
||||
println("Put your mouse over the well...")
|
||||
val well = agent.doer.getPointerLocationAfter(3000L)
|
||||
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
|
||||
val well = agent.promptUserForPoint("Put your mouse over the well...")
|
||||
|
||||
agent.doLoop(volume, step){
|
||||
agent.processAtStationNearBank(chest, well, Agent.F6, 0, 0, 18600, 600)
|
||||
@ -68,13 +105,11 @@ object Routines {
|
||||
|
||||
fun supremeOverloadGrind(volume: Int, step: Int = 4){
|
||||
val agent = Agent()
|
||||
println("Place mouse over chest")
|
||||
val chestPoint = agent.doer.getPointerLocationAfter(3000L)
|
||||
println("Place mouse over well")
|
||||
val wellPoint = agent.doer.getPointerLocationAfter(3000L)
|
||||
val chest = agent.promptUserForPoint("Put your mouse over the bank...")
|
||||
val well = agent.promptUserForPoint("Put your mouse over the well...")
|
||||
|
||||
agent.doLoop(volume, step){
|
||||
agent.processAtStationNearBank(chestPoint, wellPoint, Agent.F6, 0, 0, 6500, 1000)
|
||||
agent.processAtStationNearBank(chest, well, Agent.F6, 0, 0, 6500, 1000)
|
||||
}
|
||||
|
||||
}
|
||||
@ -82,11 +117,7 @@ object Routines {
|
||||
fun processInventoryAtFurnace(volume: Int, step: Int = 28){
|
||||
val agent = Agent()
|
||||
println("Reset the camera and zoom in")
|
||||
agent.doer.sleep(1000)
|
||||
|
||||
for(i in 0 until 8){
|
||||
agent.doer.scrollOut()
|
||||
}
|
||||
agent.scrollOutToFixedHeight()
|
||||
|
||||
val furnaceFromChest = Point(776, 321)
|
||||
val chestFromFurance = Point(1713, 843)
|
||||
@ -102,10 +133,7 @@ object Routines {
|
||||
fun processRefinedPlanksIntoFrames(volume: Int, step: Int){
|
||||
println("You must zoom in all the way and have the compass pointing straight N with a completely top-down view\n you must also be standing at the touch point on the saw")
|
||||
val agent = Agent()
|
||||
agent.doer.sleep(1000)
|
||||
for(i in 0 until 8){
|
||||
agent.doer.scrollOut()
|
||||
}
|
||||
agent.scrollOutToFixedHeight()
|
||||
|
||||
val sawFromChest = Point(1079, 907)
|
||||
val chestFromSaw = Point(1226, 180)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user