-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleCoinFarming Code
More file actions
360 lines (324 loc) · 10.4 KB
/
SimpleCoinFarming Code
File metadata and controls
360 lines (324 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#NoEnv
#SingleInstance, Force
SendMode, Input
SetWorkingDir, %A_ScriptDir%
CoordMode, Mouse, Screen
SetDefaultMouseSpeed, 2
; ===== SETTINGS =====
Global TargetWindowTitle := "ahk_class"
Global WindowWidth := 800
Global WindowHeight := 599
Global ClickDelay := 1000
Global FastClickDelay := 100
; ===== VARIABLES =====
Global ScriptActive := false
Global WindowX := 0, WindowY := 0, WindowFound := false, WindowHWND := 0
Global Stage2Active := false
Global Stage2Index := 1
Global DebugMode := true
; ===== GUI SETTINGS =====
Global AutoOpen := false
Global EnableMods := false
Global EnableSpeedup := false
Global ModsSelected := []
; ===== COORDINATES =====
Block1 := [ [560,228], [961,712], [957,534], [889,551], [859,499] ]
Block2 := [ [958,725], [1000,362], [994,318], [886,728] ]
ModOpen := [621,765]
ModVote := [1036,710]
ModClose := [1074,398]
ScrollStartX := 846
ScrollStartY := 471
ModGroups := [ { scrollY: 471, coords: [[891,474],[958,474],[1024,474],[891,544],[958,544],[1024,544]] }
, { scrollY: 516, coords: [[891,526],[958,526],[1024,526]] }
, { scrollY: 557, coords: [[891,474],[958,474],[1024,474],[891,544]] } ]
SpeedupButton := [743,794]
SpeedupConfirm := [957,624]
; ===== FUNCTIONS =====
LoadSettings() {
Global AutoOpen, EnableMods, EnableSpeedup, ModsSelected
IniRead, AutoOpen, settings.ini, General, AutoOpen, 0
IniRead, EnableMods, settings.ini, General, EnableMods, 0
IniRead, EnableSpeedup, settings.ini, General, EnableSpeedup, 0
Loop, 13 {
IniRead, val, settings.ini, Mods, mod_%A_Index%, 0
ModsSelected[A_Index] := (val = 1)
}
}
SaveSettings() {
Global AutoOpen, EnableMods, EnableSpeedup, ModsSelected
IniWrite, %AutoOpen%, settings.ini, General, AutoOpen
IniWrite, %EnableMods%, settings.ini, General, EnableMods
IniWrite, %EnableSpeedup%, settings.ini, General, EnableSpeedup
Loop, 13 {
IniWrite, % (ModsSelected[A_Index] ? 1 : 0), settings.ini, Mods, mod_%A_Index%
}
}
FindTargetWindow() {
Global WindowFound, WindowX, WindowY, WindowHWND, WindowWidth, WindowHeight, TargetWindowTitle
WindowFound := false
WinGet, windowsList, List, %TargetWindowTitle%
Loop, %windowsList% {
thisID := windowsList%A_Index%
WinGetPos, wx, wy, ww, wh, ahk_id %thisID%
if (Abs(ww - WindowWidth) < 3 && Abs(wh - WindowHeight) < 3) {
WindowX := wx
WindowY := wy
WindowHWND := thisID
WindowFound := true
break
}
}
if (!WindowFound) {
ToolTip, Window 800x599 not found! Clicking absolute coordinates., 0, 0
SetTimer, RemoveToolTip, -3000
WindowX := 0
WindowY := 0
WindowHWND := 0
}
}
ClickAt(relX, relY, delayAfter := 200, forceClick := false) {
Global WindowFound, WindowX, WindowY, WindowHWND, DebugMode
if (WindowFound && WindowHWND) {
WinActivate, ahk_id %WindowHWND%
WinWaitActive, ahk_id %WindowHWND%, , 2
Sleep, 200
x := WindowX + relX
y := WindowY + relY
if (DebugMode) {
ToolTip, % "Click: X=" x " Y=" y " (rel: " relX "," relY ")`nWindow: " WindowX "," WindowY, 0, 0
SetTimer, RemoveToolTip, -1500
}
} else {
x := relX
y := relY
if (DebugMode) {
ToolTip, % "Click (abs): X=" x " Y=" y, 0, 0
SetTimer, RemoveToolTip, -1500
}
}
MouseMove, x, y, 5
Sleep, 50
Click, left, 1
Sleep, delayAfter
}
ScrollTo(targetY) {
Global ScrollStartX, ScrollStartY, WindowFound, WindowX, WindowY, DebugMode
if (WindowFound) {
startX := WindowX + ScrollStartX
startY := WindowY + ScrollStartY
targetY_abs := WindowY + targetY
if (DebugMode) {
ToolTip, % "Scroll: from " startX "," startY " to " startX "," targetY_abs, 0, 0
SetTimer, RemoveToolTip, -1500
}
} else {
startX := ScrollStartX
startY := ScrollStartY
targetY_abs := targetY
if (DebugMode) {
ToolTip, % "Scroll (abs): from " startX "," startY " to " startX "," targetY_abs, 0, 0
SetTimer, RemoveToolTip, -1500
}
}
MouseMove, startX, startY, 5
Sleep, 100
MouseClickDrag, Left, startX, startY, startX, targetY_abs, 10
Sleep, 500
}
ApplyModifiers() {
Global ModsSelected, ModGroups, ModOpen, ModVote, ModClose, DebugMode
ToolTip, % "1. Opening modifiers window (" ModOpen[1] "," ModOpen[2] ")", 0, 0
ClickAt(ModOpen[1], ModOpen[2], 1500)
Sleep, 1000
ToolTip, Re-click to be sure..., 0, 0
ClickAt(ModOpen[1], ModOpen[2], 500)
Sleep, 1500
ToolTip, Window opened waiting 2 sec..., 0, 0
Sleep, 2000
groupIndex := 0
For idxGroup, group in ModGroups {
groupIndex++
ToolTip, % "Group " groupIndex " (scroll " group.scrollY ")", 0, 0
if (group.scrollY != 471) {
ScrollTo(group.scrollY)
Sleep, 1000
}
startIdx := 0
if (groupIndex = 1)
startIdx := 1, endIdx := 6
else if (groupIndex = 2)
startIdx := 7, endIdx := 9
else if (groupIndex = 3)
startIdx := 10, endIdx := 13
modIdxInGroup := 0
For i, coord in group.coords {
modIdxInGroup++
globalModIdx := startIdx + modIdxInGroup - 1
if (ModsSelected[globalModIdx]) {
ToolTip, % "Clicking mod #" globalModIdx " (" coord[1] "," coord[2] ")", 0, 0
ClickAt(coord[1], coord[2], 600)
}
}
}
ToolTip, % "Voting... (" ModVote[1] "," ModVote[2] ")", 0, 0
ClickAt(ModVote[1], ModVote[2], 1000)
ToolTip, % "Closing... (" ModClose[1] "," ModClose[2] ")", 0, 0
ClickAt(ModClose[1], ModClose[2], 800)
ToolTip, Modifiers applied, 0, 0
SetTimer, RemoveToolTip, -2000
}
DoSpeedup() {
Global SpeedupButton, SpeedupConfirm
ClickAt(SpeedupButton[1], SpeedupButton[2], 500)
ClickAt(SpeedupConfirm[1], SpeedupConfirm[2], 500)
ClickAt(SpeedupButton[1], SpeedupButton[2], 500)
}
Stage2Timer:
if (!Stage2Active || !ScriptActive) {
SetTimer, Stage2Timer, Off
return
}
coord := Block2[Stage2Index]
ClickAt(coord[1], coord[2], 0)
Stage2Index := (Stage2Index >= Block2.Length()) ? 1 : Stage2Index + 1
return
; ===== GUI (без функции, но с toggle) =====
ShowGUI:
if WinExist("TDS Farm Settings") {
Gui, Destroy
return
}
Gui, New, , TDS Farm Settings
Gui, Color, 2E2E2E, 2E2E2E
Gui, Font, s10 cWhite, Segoe UI
Gui, Add, GroupBox, x10 y10 w330 h80, Main Settings
Gui, Add, CheckBox, x20 y30 vAutoOpen, Automatically open game on start (wait 3 min)
Gui, Add, CheckBox, x20 y55 vEnableMods, Enable Modifiers block
Gui, Add, CheckBox, x20 y80 vEnableSpeedup, Enable Speedup (Fast Forward)
Gui, Add, GroupBox, x10 y100 w330 h300, Modifiers (check to select)
ModNames := ["Hidden Enemies", "Glass", "Exploding Enemies", "Limitation Makes Creativity", "Committed", "Healthy Enemies", "Speedy Enemies", "Quarantine", "Fog", "Flying Enemies", "Broke", "Jailed Towers", "Inflation"]
Loop, 13 {
yPos := 120 + (A_Index-1)*22
Gui, Add, CheckBox, x20 y%yPos% vMod_%A_Index%, % ModNames[A_Index]
}
Gui, Font, s12 cWhite
Gui, Add, Button, x10 y420 w40 h30 gShowInfo, ⌂
Gui, Font, s10
Gui, Add, Button, x60 y420 w100 h30 gSaveAndClose, Save & Close
Gui, Add, Button, x170 y420 w100 h30 gCancel, Cancel
Gui, Font, s8 cGray
Gui, Add, Text, x10 y460 w330 Center, Hotkeys: F1 - Show menu | Home - Start/Stop | End - Exit | F2 - Mouse coords
LoadSettings()
GuiControl, , AutoOpen, %AutoOpen%
GuiControl, , EnableMods, %EnableMods%
GuiControl, , EnableSpeedup, %EnableSpeedup%
Loop, 13 {
GuiControl, , Mod_%A_Index%, % ModsSelected[A_Index]
}
Gui, Show, w350 h500
return
ShowInfo:
MsgBox, 64, About, This script automatically simulates clicks to help earn coins in the game Tower Defense Simulator.`n`nAuthor: Oysolute`nCreated with the assistance of AI.
return
SaveAndClose:
Gui, Submit, NoHide
AutoOpen := AutoOpen
EnableMods := EnableMods
EnableSpeedup := EnableSpeedup
ModsSelected := []
Loop, 13 {
ModsSelected[A_Index] := Mod_%A_Index%
}
SaveSettings()
Gui, Destroy
return
Cancel:
Gui, Destroy
return
; ===== MAIN LOOP =====
MainLoop:
if (!ScriptActive)
return
For index, coord in Block1 {
if (!ScriptActive)
return
ClickAt(coord[1], coord[2], ClickDelay)
}
if (!ScriptActive)
return
if (EnableMods) {
ToolTip, Waiting 2 minutes before modifiers..., 0, 0
Loop, 120 {
Sleep, 1000
if (!ScriptActive) {
ToolTip
return
}
}
ToolTip
ApplyModifiers()
} else {
ToolTip, Waiting 20 seconds..., 0, 0
Loop, 20 {
Sleep, 1000
if (!ScriptActive) {
ToolTip
return
}
}
ToolTip
}
if (EnableSpeedup) {
DoSpeedup()
}
Stage2Active := true
Stage2Index := 1
SetTimer, Stage2Timer, %FastClickDelay%
return
; ===== HOTKEYS =====
F1::
Gosub, ShowGUI
return
F2::
MouseGetPos, mouseX, mouseY
if (WindowFound && WindowHWND) {
WinGetPos, winX, winY, , , ahk_id %WindowHWND%
relX := mouseX - winX
relY := mouseY - winY
ToolTip, % "Abs: " mouseX "," mouseY "`nRel: " relX "," relY "`nWindow: " winX "," winY, 0, 0
SetTimer, RemoveToolTip, -3000
} else {
ToolTip, % "Abs: " mouseX "," mouseY "`nWindow not found", 0, 0
SetTimer, RemoveToolTip, -3000
}
return
Home::
if (!ScriptActive) {
LoadSettings()
ScriptActive := true
if (AutoOpen) {
Run, https://play-tds.paradoxum.gg/
ToolTip, Browser opened. Waiting 3 minutes...
SetTimer, RemoveToolTip, -2000
Sleep, 180000
}
FindTargetWindow()
ToolTip, Script started, 0, 0
SetTimer, RemoveToolTip, -2000
SetTimer, MainLoop, -10
} else {
ScriptActive := false
Stage2Active := false
SetTimer, Stage2Timer, Off
ToolTip, Script stopped, 0, 0
SetTimer, RemoveToolTip, -2000
}
return
End::ExitApp
RemoveToolTip:
ToolTip
return
; ===== AUTO-OPEN GUI ON START =====
Gosub, ShowGUI
return