This commit is contained in:
{ИМЯ}
2025-07-13 22:43:34 +03:00
parent e4dc7cd52a
commit fea53fdd8f

View File

@ -8,7 +8,7 @@ global targetWindow := "DirtyLeague"
global isRunning := false global isRunning := false
global actionQueue := [] global actionQueue := []
global timerStates := Map() global timerStates := Map()
global timerFunctions := [] global timerFunctions := [] ; PROPERLY INITIALIZED ARRAY
global startupDelay := 5000 ; 5-second global delay (ms) global startupDelay := 5000 ; 5-second global delay (ms)
; Timer configurations ; Timer configurations
@ -18,8 +18,13 @@ timers := [
[90, "Epic", [2520, 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 === ; === INITIALIZATION ===
Sleep startupDelay ; GLOBAL STARTUP DELAY HERE Sleep startupDelay ; GLOBAL STARTUP DELAY
SetupTimers() SetupTimers()
SetTimer ProcessQueue, 1000 SetTimer ProcessQueue, 1000
SetTimer UpdateStatusTooltip, 1000 SetTimer UpdateStatusTooltip, 1000
@ -41,13 +46,13 @@ SetTimer UpdateStatusTooltip, 1000
SetupTimers() { SetupTimers() {
global timers, timerStates, timerFunctions, startupDelay global timers, timerStates, timerFunctions, startupDelay
For i, timer in timers { for i, timer in timers {
timerName := "Timer" i timerName := "Timer" i
ms := timer[1] * 60000 ms := timer[1] * 60000
timerStates[timerName] := { timerStates[timerName] := {
interval: ms, interval: ms,
nextRun: A_TickCount + startupDelay + (1000 * i), ; Includes global delay nextRun: A_TickCount + startupDelay + (1000 * i),
opponent: timer[2], opponent: timer[2],
position: timer[3] position: timer[3]
} }
@ -55,16 +60,15 @@ SetupTimers() {
fn := ObjBindMethod(MyTimer, "Trigger", timerName) fn := ObjBindMethod(MyTimer, "Trigger", timerName)
timerFunctions.Push(fn) timerFunctions.Push(fn)
SetTimer fn, ms SetTimer fn, ms
SetTimer fn, -(startupDelay + (1000 * i)) ; Respects global delay SetTimer fn, -(startupDelay + (1000 * i))
} }
} }
class MyTimer { class MyTimer {
static Trigger(name) { static Trigger(name) {
global actionQueue, timerStates global actionQueue, timerStates
; Update next run time for this timer ; Update next run time
timerStates[name].nextRun := A_TickCount + timerStates[name].interval timerStates[name].nextRun := A_TickCount + timerStates[name].interval
; Add to queue ; Add to queue
@ -78,7 +82,7 @@ class MyTimer {
} }
ProcessQueue() { ProcessQueue() {
global isRunning, actionQueue, CommonSequence global isRunning, actionQueue, CommonSequence, targetWindow
if (!isRunning && actionQueue.Length > 0) { if (!isRunning && actionQueue.Length > 0) {
isRunning := true isRunning := true
@ -95,7 +99,7 @@ ProcessQueue() {
Sleep 4000 Sleep 4000
; Common sequence ; Common sequence
For step in CommonSequence { for step in CommonSequence {
ToolTip step.action "...", 10, 10 ToolTip step.action "...", 10, 10
MouseMove step.pos[1], step.pos[2] MouseMove step.pos[1], step.pos[2]
Click Click
@ -106,23 +110,21 @@ ProcessQueue() {
Sleep 2000 Sleep 2000
} }
ToolTip ; Clear action tooltip ToolTip
isRunning := false isRunning := false
} }
} }
UpdateStatusTooltip() { UpdateStatusTooltip() {
global isRunning, timerStates global isRunning, timerStates, actionQueue
if (isRunning) { if (isRunning) {
; Don't update status during battles
return return
} }
statusText := "Next Battles:`n`n" statusText := "Next Battles:`n`n"
totalWidth := 300 ; Tooltip width in pixels totalWidth := 300
; Calculate time until next run for each timer
for name, timer in timerStates { for name, timer in timerStates {
remaining := timer.nextRun - A_TickCount remaining := timer.nextRun - A_TickCount
if (remaining < 0) { if (remaining < 0) {
@ -131,9 +133,8 @@ UpdateStatusTooltip() {
mins := Floor(remaining / 60000) mins := Floor(remaining / 60000)
secs := Mod(Floor(remaining / 1000), 60) secs := Mod(Floor(remaining / 1000), 60)
progress := 100 - (remaining * 100 / timer.interval) progress := 100 - (remaining * 100 / timer.interval)
progress := Min(Max(progress, 0), 100) ; Clamp 0-100 progress := Min(Max(progress, 0), 100)
; Create progress bar
barWidth := Floor(totalWidth * (progress / 100)) barWidth := Floor(totalWidth * (progress / 100))
progressBar := "[" . Format("{:-" barWidth "}", "") progressBar := "[" . Format("{:-" barWidth "}", "")
. Format("{:" (totalWidth - barWidth) "}", "") . "]" . Format("{:" (totalWidth - barWidth) "}", "") . "]"
@ -143,12 +144,11 @@ UpdateStatusTooltip() {
} }
} }
; Add queue status if any
if (actionQueue.Length > 0) { if (actionQueue.Length > 0) {
statusText .= "`nQueued: " actionQueue.Length " battles" statusText .= "`nQueued: " actionQueue.Length " battles"
} }
ToolTip statusText, 10, 10, 1 ; Tooltip with ID 1 ToolTip statusText, 10, 10, 1
} }
; Clear tooltips when script exits ; Clear tooltips when script exits