BugFix
This commit is contained in:
@ -8,18 +8,23 @@ global targetWindow := "DirtyLeague"
|
||||
global isRunning := false
|
||||
global actionQueue := []
|
||||
global timerStates := Map()
|
||||
global timerFunctions := []
|
||||
global timerFunctions := [] ; PROPERLY INITIALIZED ARRAY
|
||||
global startupDelay := 5000 ; 5-second global delay (ms)
|
||||
|
||||
; Timer configurations
|
||||
timers := [
|
||||
[25, "Common", [1850, 1150]],
|
||||
[50, "Rare", [1300, 450]],
|
||||
[90, "Epic", [2520, 450]]
|
||||
[25, "Common", [1850, 1150]],
|
||||
[50, "Rare", [1300, 450]],
|
||||
[90, "Epic", [2520, 450]]
|
||||
]
|
||||
|
||||
; Common click sequence
|
||||
CommonSequence := [{ action: "Start Battle", pos: [1945, 1780], delay: 30000 }, { action: "Close Results", pos: [980,
|
||||
1630], delay: 4000 }, { action: "Close Shop", pos: [3700, 120], delay: 4000 }
|
||||
]
|
||||
|
||||
; === INITIALIZATION ===
|
||||
Sleep startupDelay ; GLOBAL STARTUP DELAY HERE
|
||||
Sleep startupDelay ; GLOBAL STARTUP DELAY
|
||||
SetupTimers()
|
||||
SetTimer ProcessQueue, 1000
|
||||
SetTimer UpdateStatusTooltip, 1000
|
||||
@ -40,33 +45,32 @@ SetTimer UpdateStatusTooltip, 1000
|
||||
; === TIMER SETUP ===
|
||||
SetupTimers() {
|
||||
global timers, timerStates, timerFunctions, startupDelay
|
||||
|
||||
For i, timer in timers {
|
||||
|
||||
for i, timer in timers {
|
||||
timerName := "Timer" i
|
||||
ms := timer[1] * 60000
|
||||
|
||||
|
||||
timerStates[timerName] := {
|
||||
interval: ms,
|
||||
nextRun: A_TickCount + startupDelay + (1000 * i), ; Includes global delay
|
||||
nextRun: A_TickCount + startupDelay + (1000 * i),
|
||||
opponent: timer[2],
|
||||
position: timer[3]
|
||||
}
|
||||
|
||||
|
||||
fn := ObjBindMethod(MyTimer, "Trigger", timerName)
|
||||
timerFunctions.Push(fn)
|
||||
SetTimer fn, ms
|
||||
SetTimer fn, -(startupDelay + (1000 * i)) ; Respects global delay
|
||||
SetTimer fn, -(startupDelay + (1000 * i))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyTimer {
|
||||
static Trigger(name) {
|
||||
global actionQueue, timerStates
|
||||
|
||||
; Update next run time for this timer
|
||||
|
||||
; Update next run time
|
||||
timerStates[name].nextRun := A_TickCount + timerStates[name].interval
|
||||
|
||||
|
||||
; Add to queue
|
||||
actionQueue.Push({
|
||||
name: name,
|
||||
@ -78,24 +82,24 @@ class MyTimer {
|
||||
}
|
||||
|
||||
ProcessQueue() {
|
||||
global isRunning, actionQueue, CommonSequence
|
||||
|
||||
global isRunning, actionQueue, CommonSequence, targetWindow
|
||||
|
||||
if (!isRunning && actionQueue.Length > 0) {
|
||||
isRunning := true
|
||||
current := actionQueue.RemoveAt(1)
|
||||
|
||||
|
||||
if WinExist(targetWindow) {
|
||||
WinActivate
|
||||
WinWaitActive
|
||||
|
||||
|
||||
; Opponent-specific step
|
||||
ToolTip "Attacking: " current.opponent, 10, 10
|
||||
MouseMove current.opponentPos[1], current.opponentPos[2]
|
||||
Click
|
||||
Sleep 4000
|
||||
|
||||
|
||||
; Common sequence
|
||||
For step in CommonSequence {
|
||||
for step in CommonSequence {
|
||||
ToolTip step.action "...", 10, 10
|
||||
MouseMove step.pos[1], step.pos[2]
|
||||
Click
|
||||
@ -105,24 +109,22 @@ ProcessQueue() {
|
||||
ToolTip "ERROR: Window not found", 10, 10
|
||||
Sleep 2000
|
||||
}
|
||||
|
||||
ToolTip ; Clear action tooltip
|
||||
|
||||
ToolTip
|
||||
isRunning := false
|
||||
}
|
||||
}
|
||||
|
||||
UpdateStatusTooltip() {
|
||||
global isRunning, timerStates
|
||||
|
||||
global isRunning, timerStates, actionQueue
|
||||
|
||||
if (isRunning) {
|
||||
; Don't update status during battles
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
statusText := "Next Battles:`n`n"
|
||||
totalWidth := 300 ; Tooltip width in pixels
|
||||
|
||||
; Calculate time until next run for each timer
|
||||
totalWidth := 300
|
||||
|
||||
for name, timer in timerStates {
|
||||
remaining := timer.nextRun - A_TickCount
|
||||
if (remaining < 0) {
|
||||
@ -131,24 +133,22 @@ UpdateStatusTooltip() {
|
||||
mins := Floor(remaining / 60000)
|
||||
secs := Mod(Floor(remaining / 1000), 60)
|
||||
progress := 100 - (remaining * 100 / timer.interval)
|
||||
progress := Min(Max(progress, 0), 100) ; Clamp 0-100
|
||||
|
||||
; Create progress bar
|
||||
barWidth := Floor(totalWidth * (progress/100))
|
||||
progressBar := "[" . Format("{:-" barWidth "}", "")
|
||||
. Format("{:" (totalWidth-barWidth) "}", "") . "]"
|
||||
|
||||
statusText .= name ": " Format("{1:02}:{2:02}", mins, secs)
|
||||
. " (" progress "%)`n" progressBar "`n"
|
||||
progress := Min(Max(progress, 0), 100)
|
||||
|
||||
barWidth := Floor(totalWidth * (progress / 100))
|
||||
progressBar := "[" . Format("{:-" barWidth "}", "")
|
||||
. Format("{:" (totalWidth - barWidth) "}", "") . "]"
|
||||
|
||||
statusText .= name ": " Format("{1:02}:{2:02}", mins, secs)
|
||||
. " (" progress "%)`n" progressBar "`n"
|
||||
}
|
||||
}
|
||||
|
||||
; Add queue status if any
|
||||
|
||||
if (actionQueue.Length > 0) {
|
||||
statusText .= "`nQueued: " actionQueue.Length " battles"
|
||||
}
|
||||
|
||||
ToolTip statusText, 10, 10, 1 ; Tooltip with ID 1
|
||||
|
||||
ToolTip statusText, 10, 10, 1
|
||||
}
|
||||
|
||||
; Clear tooltips when script exits
|
||||
|
||||
Reference in New Issue
Block a user