-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDQMSL1.mq
479 lines (400 loc) · 10.3 KB
/
DQMSL1.mq
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
If True Then
Dim WORKING_DIR = "/storage/emulated/0/Docs/DQMSL/"
Dim IMG_TITLE = "Title"
Dim IMG_QUEST="Quests"
Dim IMG_ARENA = "Arena"
Dim IMG_MISC = "MISC"
Dim IMG_CONN = "Connecting"
Dim IMG_LOSE = "Battle_Lose"
Dim IMG_WIN = "Battle_Win"
Dim IMG_BTN_OK = "Btn_OK"
Dim IMG_BTN_SKIP = "Btn_Skip"
Dim IMG_BTN_BACK = "Btn_Back"
Dim IMG_BTN_YES="Btn_Yes"
Dim IMG_BTN_YES2="Btn_Yes2"
Dim IMG_BTN_AI="Btn_AI"
Dim IMG_BTN_EXPAND="Btn_Expand"
//Leauge Battle Images
Dim IMG_BTN_LEAGUEBATTLE="Btn_LeagueBattle"
Dim IMG_BTN_BATTLELITE="Btn_BATTLELITE"
Dim IMG_BTN_DOBATTLE="Btn_DoBattle"
Dim IMG_OPPONENT="Battle_opponent"
Dim IMG_BTN_START="Btn_StartBattle"
//Quest Images
Dim IMG_BTN_NORMAL="Btn_QuestNormal"
Dim IMG_BTN_SPECIAL="Btn_QuestSpecial"
Dim IMG_BTN_FIRSTQUEST="Btn_FirstQuest"
Dim IMG_BTN_FIRSTQUESTSUB="Btn_FirstQuestSub"
Dim IMG_BTN_QUESTSELECT="Btn_QuestSelet"
Dim IMG_BTN_QUESTSELECTSUB="Btn_QuestSeletSub"
Dim IMG_QUESTSELECT="Quest_Select"
Dim IMG_FRIEND="Friend"
Dim IMG_POINTS="Points"
Dim IMG_BTN_VENTURE="Btn_VentureForth"
Dim IMG_EXP="EXP"
Dim IMG_BTN_AI_GREY="Btn_AIGrey"
Dim IMG_BTN_AI_DARK="Btn_AIDark"
//
Dim SCR_WIDTH = GetScreenX()
Dim SCR_LENGTH = GetScreenY()
Dim MID_X = SCR_WIDTH/2
Dim MID_Y = SCR_LENGTH/2
Dim T_CONN = 60
Dim T_Launch = 40
Dim T_Battle = 120
Dim INTERVAL = 500
Dim P_STROKE = 0.05
Dim FUZZ_LOW = 0.55
Dim FUZZ_HIGH = 0.8
End If
//login
If Login() = false Then Goto EndOfMacro
//If LeagueBattle() < 0 Then Goto EndOfMacro
Test1()
Rem EndOfMacro
TracePrint "EndOfMacro"
Function Test1()
Dim u = 0, l = 1, d = 2, r = 3, f = 4, treasure = 5, leave = 6, nextLevel
Dim procedure
//procedure2_2 = Array(l,u,f,u,u,u,u,f,r,d,r,f,u,u,leave)
procedure = Array(l, u, f, u, u, u, u, f, r, d, r, f, u, u, leave)
TracePrint QuestRun(True, 2, 2, procedure)
End Function
Function Login
Login = False
Dim result = False
RunApp "com.garena.game.dqmsl"
Dim i = 0
TracePrint "Logging in"
Do
i=i+1
Delay INTERVAL
If IconLookup(IMG_TITLE) = True Then
ScreenTap
ElseIf IconLookup(IMG_ARENA) = True Then
result = True
Exit Do
Else
IconTap(IMG_BTN_SKIP)
End If
Loop While i < T_CONN
//T_CONN
If result=True Then
TracePrint "Login successful."
Login = True
Else
TracePrint "Login failed"
End If
End Function
Function LeagueBattle
Dim result = -1
Dim i = 0
Dim names
LeagueBattle = -1
TracePrint "League Battle starting..."
names = Array(IMG_ARENA,IMG_BTN_LEAGUEBATTLE,IMG_BTN_BATTLELITE,IMG_BTN_DOBATTLE,IMG_OPPONENT,IMG_BTN_START,IMG_BTN_YES,IMG_BTN_AI)
IconsWaitTap (names, False)
TracePrint "Fighting..."
//Exit Function
//IconsTapUntilFound(names, IMG_ARENA)
Do
i = i + 1
Delay INTERVAL
If IconTap(IMG_LOSE) = True Then
result = 0
ElseIf IconTap(IMG_WIN) = True Then
result = 1
ElseIf IconTap(IMG_BTN_OK) = True Then
TracePrint "OK button pressed, you received stuff"
ElseIf IconLookup(IMG_ARENA) = True Then
TracePrint "Battle ended."
Exit Do
Else
ScreenTap
End If
Loop While i<T_Battle
If result = 0 Then
TracePrint "You lost the battle."
ElseIf result = 1 Then
TracePrint "You won the battle."
Else
TracePrint "Something went wrong!"
End If
LeagueBattle = result
End Function
Function QuestRun(bNormalQuest, iLevel, iSublevel, procedure)
Dim result = -1
Dim i = 0
Dim j = 0
Dim names,exits
QuestRun = False
If iLevel<1 Then iLevel=1
If iSublevel<1 Then iLevel=1
TracePrint "Advanture starting..."
i=0
Do
i = i + 1
Delay INTERVAL
If IconTap(IMG_QUEST) = True Then
TracePrint "Entering World Map..."
ElseIf IconLookup(IMG_QUESTSELECT) = True Then
Exit Do
ElseIf IconTap(IMG_BTN_BACK) = True Then
TracePrint "Back pressed."
End If
Loop While i<T_CONN
TracePrint "Selecting quest..."
If bNormalQuest = True Then
If IconLookup(IMG_BTN_SPECIAL)=False Then
If IconTap(IMG_BTN_NORMAL)=False Then Exit Function
End If
Else
If IconLookup(IMG_BTN_NORMAL)=False Then
If IconTap(IMG_BTN_SPECIAL)=False Then Exit Function
End If
End If
//selecting level
i=0
Do
Delay 1000
i=i+1
If IconLookup(IMG_BTN_FIRSTQUEST)=False Then
ScreenSweepUp(P_STROKE)
Else
TracePrint "Found first one"
Exit Do
End If
Loop While i<T_CONN
If i=T_CONN Then Exit Function
TracePrint "Selecting quest..."
Delay 1500
For i=2 To iLevel
ScreenSweepDown(P_STROKE)
Delay 1500
Next
IconWait(IMG_BTN_QUESTSELECT)
If IconTap(IMG_BTN_QUESTSELECT)=False Then Exit Function
Do
Delay 1000
i=i+1
If IconLookup(IMG_BTN_FIRSTQUESTSUB)=False Then
ScreenSweepUp(P_STROKE)
Else
TracePrint "Found first one"
Exit Do
End If
Loop While i<T_CONN
If i=T_CONN Then Exit Function
Delay 1500
For i=2 To iSublevel
ScreenSweepDown(P_STROKE)
Delay 1500
Next
IconWait(IMG_BTN_QUESTSELECTSUB)
names = Array(IMG_BTN_QUESTSELECTSUB,IMG_FRIEND,IMG_POINTS,IMG_BTN_YES,IMG_BTN_VENTURE,IMG_BTN_YES)
exits = Array(IMG_EXP)
If IconsTapUntilFound(names, exits, T_CONN * 8, False) = "" Then Exit Function
Delay 1000
If Not actionsTake(procedure) Then Exit Function
QuestRun = True
End Function
Function actionsTake(operations)
Dim u = 0, l = 1, d = 2, r = 3, f = 4, treasure = 5, leave = 6, nextLevel
Dim SwipeUPDown = 0.3
Dim SwipeLeftRight = 0.6
Dim icons,exits
actionsTake = False
For Each item In operations
Select Case item
Case u
ScreenSweepDown(SwipeUPDown)
Case l
ScreenSweepRight(SwipeLeftRight)
Case d
ScreenSweepUp(SwipeUPDown)
Case r
ScreenSweepLeft(SwipeLeftRight)
Case f
//icons = Array(IMG_BTN_AI, IMG_BTN_AI_GREY, IMG_BTN_AI_DARK)
icons = Array(IMG_BTN_AI)
exits = Array(IMG_EXP)
Case treasure
//IconsTapAll
Case leave
icons = Array(IMG_BTN_YES, IMG_BTN_YES2, IMG_BTN_OK)
exits = Array(IMG_ARENA,IMG_BTN_EXPAND)
Case nextLevel
End Select
Select Case item
Case f, leave
If IconsTapUntilFound(icons, exits, T_Battle, True) = "" Then
Exit Function
End If
End Select
Delay 1200
Next
actionsTake = True
End Function
//---------------------------------------------------------------->
Function IconLookup(name)
IconLookup = False
Dim path = "/storage/emulated/0/Docs/DQMSL/" & name & ".png"
Dim intX, intY
Dim fuzz = FUZZ_HIGH
If Dir.Exist(path) = 0 Then Exit Function
If name = IMG_BTN_OK Or name = IMG_BTN_YES Then fuzz = FUZZ_LOW
FindPic 0, 0, 0, 0, path, 000000, 0, fuzz, intX, intY
If intX > -1 And intY > -1 Then
IconLookup = True
End If
End Function
Function UBound(arr)
Dim a, i : i = 0
For Each a In arr
i = i + 1
Next
UBound = i - 1
End Function
Function IconsTapUntilFound(iconsToTap, iconsToExit, timer, bTaping)
Dim i = 0
Dim bTapped
//Dim count = UBound(iconsToTap)
//Dim timer = T_CONN * count
IconsTapUntilFound = ""
Do
i = i + 1
bTapped = False
For Each item In iconsToTap
If IconTap(item) = True Then
TracePrint(item & " was pressed.")
bTapped = True
Exit For
End If
Next
Delay INTERVAL
For Each item In iconsToExit
If IconLookup(item) Then
TracePrint(item & " was found & pressed.")
IconsTapUntilFound = item
Exit Do
End If
Next
If bTaping And Not bTapped Then ScreenTap()
Loop While i < timer
End Function
Function IconsLookupOr(names)
IconsLookupOr = False
For Each item In Names
If IconLookup(item) Then
IconsLookupOr = True
Exit Function
End If
Next
End Function
Function IconsLookupAnd(names)
IconsLookupAnd = True
For Each item In Names
If Not IconLookup(item) Then
IconsLookupOr = False
Exit Function
End If
Next
End Function
Function IconTap(name)
IconTap = False
Dim path = WORKING_DIR & name & ".png"
Dim intX,intY
Dim fuzz = FUZZ_HIGH
If Dir.Exist(path) = 0 Then Exit Function
If name = IMG_BTN_OK Or name = IMG_BTN_YES Then fuzz = FUZZ_LOW
FindPic 0, 0, 0, 0, path, 000000, 0, fuzz, intX, intY
If intX > -1 And intY > -1 Then
IconTap = true
Tap(intX,intY)
End If
End Function
Function IconsTapOne(names)
IconsTapOne = False
For Each item In Names
If IconTap(item) Then
IconsTapOne = True
Exit Function
End If
Next
End Function
Function IconWait(name)
Dim i = 0
IconWait = False
While i < T_CONN
i = i + 1
If IconLookup(name) = True Then
IconWait = True
Exit While
End If
Delay INTERVAL
Wend
End Function
Function IconWaitFor(name, secends)
Dim i = 0
IconWait = False
secends = secends * 2
While i < secends
i = i + 1
If IconLookup(name) = True Then
IconWait = True
Exit While
End If
Delay INTERVAL
Wend
End Function
Function IconWaitTap(name)
Dim i = 0
IconWaitTap = False
While i < T_CONN
i=i+1
If IconTap(name) = True Then
IconWaitTap = True
Exit While
End If
Delay INTERVAL
Wend
End Function
Function IconsWaitTap(names, allowSkipping)
Dim tapped = False
IconsWaitTap = False
For Each item In names
tapped = False
tapped = IconWaitTap(item)
If tapped = False And allowSkipping = False Then
Exit Function
End If
Next
IconsWaitTap = True
End Function
Sub ScreenTap
Tap(MID_X, MID_Y)
End Sub
Function ScreenSweepUp(percentage)
Dim sLen = SCR_LENGTH * percentage / 2.0
Dim y1 = MID_Y + sLen
Dim y2 = MID_Y - sLen
Swipe(MID_X, y1, MID_X, y2)
End Function
Function ScreenSweepDown(percentage)
Dim sLen = SCR_LENGTH * percentage / 2.0
Dim y1 = MID_Y - sLen
Dim y2 = MID_Y + sLen
Swipe(MID_X, y1, MID_X, y2)
End Function
Function ScreenSweepLeft(percentage)
Dim sLen = SCR_WIDTH * percentage / 2.0
Dim x1 = MID_X + sLen
Dim x2 = MID_X - sLen
Swipe(x1, MID_Y, x2, MID_Y)
End Function
Function ScreenSweepRight(percentage)
Dim sLen = SCR_WIDTH * percentage / 2.0
Dim x1 = MID_X - sLen
Dim x2 = MID_X + sLen
Swipe(x1, MID_Y, x2, MID_Y)
End Function