-
Notifications
You must be signed in to change notification settings - Fork 0
/
RankQuests.ahk
3753 lines (3350 loc) · 200 KB
/
RankQuests.ahk
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Requires AutoHotkey v2.0 ; Ensures the script runs only on AutoHotkey version 2.0, which supports the syntax and functions used in this script.
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; RANK QUEST - AutoHotKey 2.0 Macro for Pet Simulator 99
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; DIRECTIVES & CONFIGURATIONS
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
#SingleInstance Force ; Forces the script to run only in a single instance. If this script is executed again, the new instance will replace the old one.
CoordMode "Mouse", "Client" ; Sets the coordinate mode for mouse functions (like Click, MouseMove) to be relative to the active window's client area, ensuring consistent mouse positioning across different window states.
CoordMode "Pixel", "Client" ; Sets the coordinate mode for pixel functions (like PixelSearch, PixelGetColor) to be relative to the active window's client area, improving accuracy in color detection and manipulation.
SetMouseDelay 10 ; Sets the delay between mouse events to 10 milliseconds, balancing speed and reliability of automated mouse actions.
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; GLOBAL VARIABLES
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; Titles and versioning for GUI elements.
MACRO_TITLE := "Rank Quests" ; The title displayed in main GUI elements.
MACRO_VERSION := "1.0.0 (Test Build 2)" ; Script version, helpful for user support and debugging.
LOG_FOLDER := A_ScriptDir "\Logs\" ; Path to the README file, provides additional information to users.
DATE_TODAY := FormatTime(A_Now, "yyyyMMdd")
; Mathematics and constants.
RADIUS := 100 ; Standard radius used for calculations in positioning or graphics.
PI := 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 ; Mathematical constant Pi, crucial for circular calculations.
ONE_SECOND := 1000 ; Number of milliseconds in one second, used for timing operations.
; Zone settings defining game areas.
BEST_ZONE := 219 ; Identifier for the best zone, typically where optimal actions occur.
SECOND_BEST_ZONE := 218 ; Identifier for the second-best ZONE
RARE_EGG_ZONE := 209
USE_FLAG_ZONES := [200, 201, 202, 203, 204] ; Define the zones where flags will be used.
; Font settings for GUI and other text displays.
TIMES_NEW_ROMAN := A_ScriptDir "\Assets\TimesNewRoman.ttf" ; Path to Times New Roman font.
TIMES_NEW_ROMAN_INVERTED := A_ScriptDir "\Assets\TimesNewRoman-Inverted.ttf" ; Path to Times New Roman font (inverted).
FREDOKA_ONE_REGULAR := A_ScriptDir "\Assets\FredokaOne-Regular.ttf" ; Path to Fredoka One Regular font.
SOURCE_SANS_PRO_BOLD := A_ScriptDir "\Assets\SourceSansPro-Bold.ttf" ; Path to Source Sans Pro Bold font.
; User settings loaded from an INI file.
SETTINGS_INI := A_ScriptDir "\Settings.ini" ; Path to settings INI file.
DARK_MODE := getSetting("DarkMode") ; User preference for dark mode, loaded from settings.
SHOW_OCR_OUTLINE := getSetting("ShowOcrOutline") ; User preference for displaying OCR outlines.
; Pixel colours for the Supercomputer menus.
UPGRADE_POTIONS_BUTTON := ["0x281759", "0x0CC60F"]
UPGRADE_ENCHANTS_BUTTON := ["0xFADB35", "0x810606"]
GOLD_PETS_BUTTON := ["0xFFFFC8", "0xC98151"]
RAINBOW_PETS_BUTTON := ["0xF4D200", "0x1EFB01"]
; Pixel colours for the close icon for each of the user interface windows.
ERROR_WINDOW_X := Map("Start", [603, 109], "End", [603, 109], "Colour", "0xFF155F", "Tolerance", 2)
INVENTORY_MENU_X := Map("Start", [730, 109], "End", [730, 109], "Colour", "0xFF155F", "Tolerance", 2)
REWARDS_MENU_X := Map("Start", [730, 109], "End", [730, 109], "Colour", "0xFF155F", "Tolerance", 2)
FREE_GIFTS_MENU_X := Map("Start", [608, 109], "End", [608, 109], "Colour", "0xFF155F", "Tolerance", 2)
TELEPORT_MENU_X := Map("Start", [725, 109], "End", [725, 109], "Colour", "0xFF155F", "Tolerance", 2)
HATCHING_MENU_X := Map("Start", [614, 109], "End", [614, 109], "Colour", "0xFF155F", "Tolerance", 2)
AUTOHATCH_MENU_X := Map("Start", [605, 109], "End", [605, 109], "Colour", "0xFF155F", "Tolerance", 2)
SUPERCOMPUTER_MENU_X := Map("Start", [730, 109], "End", [730, 109], "Colour", "0xFF155F", "Tolerance", 2)
; Pixel colours for other checks.
CHAT_ICON_WHITE := Map("Start", [81, 24], "End", [81, 24], "Colour", "0xFFFFFF", "Tolerance", 2)
LEADERBOARD_RANK_STAR := Map("Start", [652, 43], "End", [678, 59], "Colour", "0xB98335", "Tolerance", 50)
OOPS_ERROR_QUESTION_MARK := Map("Start", [434, 287], "End", [438, 291], "Colour", "0xFFB436", "Tolerance", 5)
ITEM_MISSING := Map("Start", [293, 425], "End", [293, 425], "Colour", "0xA51116", "Tolerance", 5)
CLAIM_BUTTON_SHADOW := Map("Start", [294, 113], "End", [747, 469], "Colour", "0x6E864D", "Tolerance", 2)
INVENTORY_BUTTON := Map("Start", [384, 505], "End", [384, 505], "Colour", "0x15DECF", "Tolerance", 2)
ZONE_SEARCH := Map("Start", [437, 243], "End", [437, 243], "Colour", "0x5BDBFF", "Tolerance", 2)
HATCHING_MENU_BUY := Map("Start", [191, 451], "End", [191, 451], "Colour", "0x6BF206", "Tolerance", 2)
FREE_GIFTS_READY := Map("Start", [67, 172], "End", [67, 172], "Colour", "0xFF0948", "Tolerance", 2)
AUTO_HATCH_MENU := Map("Start", [439, 155], "End", [604, 438], "Colour", "0x6FF308", "Tolerance", 2)
SKILL_MASTERY := Map("Start", [88, 309], "End", [88, 309], "Colour", "0xFFFFFF", "Tolerance", 2)
; Pixel colours for droppable boosts.
LUCKY_BLOCK_PINK := Map("Start", [140, 0], "End", [660, 400], "Colour", "0xEFB4FB", "Tolerance", 2)
LUCKY_BLOCK_BLUE := Map("Start", [140, 280], "End", [660, 400], "Colour", "0x00ACFF", "Tolerance", 2)
LUCKY_BLOCK_YELLOW := Map("Start", [140, 280], "End", [660, 400], "Colour", "0xFFA300", "Tolerance", 2)
COMET_COLOUR := Map("Start", [140, 280], "End", [660, 400], "Colour", "0x00A6FB", "Tolerance", 2)
PINATA_COLOUR := Map("Start", [140, 200], "End", [660, 400], "Colour", "0xFF00FF", "Tolerance", 2)
; OCR Text Render display.
OCR_RESULTS_RENDER := TextRender()
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; LIBRARIES
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; Third-party Libraries:
#Include <OCR> ; Includes an Optical Character Recognition library for extracting text from images.
#Include <Pin> ; Includes a library for creating pinned overlays or highlights on the screen, enhancing visual interfaces.
#Include <JXON> ; Includes a library for handling JSON data, useful for configuration and data management tasks.
#Include <DarkMode> ; Includes a library to support dark mode functionality, improving UI aesthetics and reducing eye strain.
#Include <TextRender> ; Includes a library to render text to the screen.
; Macro Related Libraries:
#Include "%A_ScriptDir%\Modules" ; Includes all scripts located in the 'Modules' directory relative to the script's directory.
#Include "Coords.ahk" ; Includes a script defining coordinates for GUI elements, useful for automation tasks.
#Include "Delays.ahk" ; Includes a script that defines various delay times for operations, ensuring timing accuracy.
#Include "Movement.ahk" ; Includes a script managing movement or navigation automation within the application.
#Include "Quests.ahk" ; Includes a script that handles quest-related data and operations.
#Include "Zones.ahk" ; Includes a script that defines different game zones or areas, used in navigation and contextual actions.
#Include "Ranks.ahk" ; Includes a script that defines different game ranks.
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; MACRO
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
runMacro()
; ----------------------------------------------------------------------------------------
; runMacro Function
; Description: Executes the main macro loop, performing initial setup tasks, running tests, and continuously checking for key game conditions and quest priorities.
; Operation:
; - Performs initial setup tasks and environment preparation.
; - Writes a start log entry.
; - Displays a GUI for quest management.
; - Activates the Roblox window for reliable input.
; - Runs preliminary tests.
; - Continuously checks for disconnection to ensure ongoing functionality.
; - Closes unnecessary windows.
; - Checks if the player has reached the maximum rank.
; - Prioritizes and completes quests based on current priorities.
; Dependencies:
; - completeInitialisationTasks: Prepares the macro environment by setting variables and performing initial tasks.
; - writeToLogFile: Logs macro start information.
; - displayQuestsGui: Displays a GUI for managing quests.
; - activateRoblox: Ensures the Roblox window is active.
; - runTests: Executes preliminary tests.
; - checkForDisconnection: Monitors the connection status.
; - closeAllWindows: Closes all unnecessary windows.
; - checkForMaxRank: Verifies if the player has reached the maximum rank.
; - priortiseAndCompleteQuests: Manages and executes quests based on priority.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
runMacro() {
completeInitialisationTasks() ; Perform all initial tasks necessary for the macro's setup, such as setting variables or preparing the environment.
writeToLogFile("*** MACRO START ***")
displayQuestsGui() ; Creates and displays a graphical user interface that lists quests and other activities, enhancing user interaction and control.
activateRoblox() ; Ensures that the Roblox window is active and ready for input, critical for reliably sending commands to the game.
runTests() ; Executes preliminary tests to ensure the macro's functionality.
checkForDisconnection() ; Continuously monitors the connection status to handle any disconnections promptly, maintaining the macro's functionality.
closeAllWindows() ; Closes any unnecessary windows that may interfere with the macro's operations.
checkForMaxRank() ; Verifies if the player has reached the maximum rank available, which might change the behavior of the macro or disable certain functions.
priortiseAndCompleteQuests() ; Analyzes available quests to determine priorities and executes them accordingly, managing the macro's main objectives effectively.
}
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; GUI INITIALISATION
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; ----------------------------------------------------------------------------------------
; displayQuestsGui Function
; Description: Sets up and displays a GUI for quest management and macro control.
; Operation:
; - Creates a GUI with always-on-top property for constant visibility.
; - Configures the GUI with title, font, and interactive elements such as list views and buttons.
; - Positions the GUI and assigns functions to buttons for operational control.
; Dependencies:
; - Gui, guiMain.Show, guiMain.GetPos, guiMain.Move: Functions for GUI creation and manipulation.
; Parameters:
; - None
; Return: None; creates a GUI for interacting with the macro.
; ----------------------------------------------------------------------------------------
displayQuestsGui() {
; Initialize the main GUI with "AlwaysOnTop" property.
global guiMain := Gui("+AlwaysOnTop")
guiMain.Title := MACRO_TITLE " v" MACRO_VERSION ; Set the title incorporating global variables for title and version.
guiMain.SetFont("s8", "Segoe UI") ; Use "Segoe UI" font for a modern look.
; Create a list view for quests with various columns.
global lvQuests := guiMain.AddListView("r4 w650 NoSortHdr", ["★", "Type", "Quest", "Amount", "Priority", "Status", "Zone", "OCR"])
lvQuests.ModifyCol(1, 25) ; Modify column widths for better data presentation.
lvQuests.ModifyCol(2, 0)
lvQuests.ModifyCol(3, 200)
lvQuests.ModifyCol(4, 55)
lvQuests.ModifyCol(5, 50)
lvQuests.ModifyCol(6, 60)
lvQuests.ModifyCol(7, 40)
lvQuests.ModifyCol(8, 200) ; Set the last column width to 0 as it may contain OCR data not needed for display.
; Create another list view for displaying current activities.
global lvCurrent := guiMain.AddListView("xs r1 w650 NoSortHdr", ["Loop", "Zone", "Area", "Quest", "Action", "Time"])
lvCurrent.Add(, "-", "-", "-", "-", "-") ; Initialize with a default row.
lvCurrent.ModifyCol(1, 50)
lvCurrent.ModifyCol(2, 40)
lvCurrent.ModifyCol(3, 100)
lvCurrent.ModifyCol(4, 200)
lvCurrent.ModifyCol(5, 200)
lvCurrent.ModifyCol(6, 40)
; Add control buttons to the GUI for various functions.
btnPause := guiMain.AddButton("xs", "⏸ &Pause (" getSetting("pauseMacroKey") ")")
btnWiki := guiMain.AddButton("yp", "🌐 &Wiki")
btnRefresh := guiMain.AddButton("yp", "🔄 &Refresh")
btnReconnect := guiMain.AddButton("yp", "🔁 &Reconnect")
btnFont := guiMain.AddButton("yp", "𝔄 &Default Font")
; Display the GUI window.
guiMain.Show()
; Retrieve and adjust the GUI window position to the top right of the screen.
guiMain.GetPos(,, &Width,)
guiMain.Move(A_ScreenWidth - Width + 8, 0)
; Assign events to buttons for respective functionalities.
btnPause.OnEvent("Click", pauseMacro)
btnWiki.OnEvent("Click", openWiki)
btnRefresh.OnEvent("Click", refreshQuests)
btnReconnect.OnEvent("Click", reconnectClient)
btnFont.OnEvent("Click", changeToDefaultFont)
; Apply a dark mode theme if enabled.
if (DARK_MODE == "true") {
SetWindowAttribute(guiMain)
SetWindowTheme(guiMain)
}
}
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; GUI FUNCTIONS
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; ----------------------------------------------------------------------------------------
; openWiki Function
; Description: Opens a help text file in Notepad for user assistance.
; Operation:
; - Executes Notepad with a specified file path to display help documentation.
; Dependencies:
; - Run: Function to execute external applications.
; Parameters:
; - None; uses a global variable for the file path.
; Return: None; opens a text file for user reference.
; ----------------------------------------------------------------------------------------
openWiki(*) {
Run "https://github.com/waktool/RankQuests/wiki"
}
; ----------------------------------------------------------------------------------------
; pauseMacro Function
; Description: Toggles the pause state of the macro.
; Operation:
; - Sends a keystroke to simulate a pause/unpause command.
; - Toggles the pause state of the script.
; Dependencies:
; - Send: Function to simulate keystrokes.
; Parameters:
; - None
; Return: None; toggles the paused state of the macro.
; ----------------------------------------------------------------------------------------
pauseMacro(*) {
writeToLogFile("*** PAUSED ***")
Pause -1 ; Toggle the pause status of the macro.
}
; ----------------------------------------------------------------------------------------
; exitMacro Function
; Description: Exits the macro application completely.
; Operation:
; - Terminates the application.
; Dependencies:
; - ExitApp: Command to exit the application.
; Parameters:
; - None
; Return: None; closes the application.
; ----------------------------------------------------------------------------------------
exitMacro(*) {
ExitApp ; Exit the macro application.
}
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; QUEST PRIORITISATION & COMPLETION
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; ----------------------------------------------------------------------------------------
; priortiseAndCompleteQuests Function
; Description: Coordinates multiple tasks in a macro for Pet Simluator 99, managing looped actions based on game settings and quest priorities.
; Operation:
; - Adjusts the camera view and applies game-specific settings.
; - Loops through a set number of iterations, performing tasks such as checking for rewards, refreshing quests, and executing the highest priority quest.
; - Manages disconnections and utilizes special abilities based on game conditions.
; - Continuously updates loop count and handles quest failure conditions.
; Dependencies:
; - Various game-specific functions like changeCameraView, applyAutoHatchSettings, checkForClaimRewards, refreshQuests, setCurrentLoop, doQuest, useUltimate, checkForDisconnection, claimFreeGifts.
; Parameters:
; - None; utilizes game settings and state to determine actions.
; Return: None; loops indefinitely, managing game actions continuously.
; ----------------------------------------------------------------------------------------
priortiseAndCompleteQuests(*) {
applyAutoHatchSettings() ; Applies settings relevant to auto-hatching features.
; Main loop to handle all macro actions repeatedly.
Loop {
DATE_TODAY := FormatTime(A_Now, "yyyyMMdd")
loopTimes := getSetting("NumberOfLoops") ; Retrieve the number of times the loop should run.
; Perform defined tasks for each iteration of the loop.
Loop loopTimes {
checkForClaimRewards() ; Check and claim any available game rewards.
refreshQuests() ; Update the list of quests from the game interface.
currentLoop := A_Index "/" loopTimes ; Update the current loop count.
setCurrentLoop(currentLoop) ; Display the current loop count in the UI.
; Find the quest with the highest priority to execute.
highestPriority := 0
priorityIndex := 0
failedQuests := 0
Loop lvQuests.GetCount() { ; Iterate through all listed quests.
currentPriority := lvQuests.GetText(A_Index, 5)
currentPriority := (currentPriority == "") ? 0 : Integer(currentPriority)
if (currentPriority > 0 && currentPriority >= highestPriority) { ; Identify the highest priority quest.
priorityIndex := A_Index
highestPriority := currentPriority
}
if (lvQuests.GetText(A_Index, 3) == "?") {
failedQuests++ ; Count quests that failed to read correctly.
}
}
; Execute the quest with the highest priority or default to a waiting quest.
if (priorityIndex > 0) {
currentType := lvQuests.GetText(priorityIndex, 2)
currentQuest := lvQuests.GetText(priorityIndex, 3)
currentAmount := lvQuests.GetText(priorityIndex, 4)
doQuest(currentType, currentQuest, currentAmount)
} else if (failedQuests != lvQuests.GetCount()) {
doQuest(100, "Waiting For A Quest") ; Perform a default action if no specific quests are available.
}
if (getCurrentZone() == BEST_ZONE) {
useUltimate() ; Use the ultimate ability if in the best ZONE
}
checkForDisconnection() ; Monitor and handle any disconnections.
}
eatFruit() ; Consume fruit as part of the game actions.
claimFreeGifts() ; Claim any free gifts available in the game.
if (getSetting("ReconnectAfterLoopsCompleted") == "true") {
reconnectClient()
}
Reload ; Reload the script to refresh all settings and start fresh.
}
}
; ----------------------------------------------------------------------------------------
; refreshQuests Function
; Description: Processes the quests in the game by performing OCR, combining text lines, and updating the quest list view.
; Operation:
; - Activates the game window and prepares the environment for quest processing.
; - Clears existing quest data and performs OCR to read new quest information.
; - Combines OCR text lines based on proximity and formatting rules.
; - Updates the quest list view with new quest data, including quest ID, name, status, priority, zone, and amount.
; - Logs the OCR results and quest details.
; - Updates the GUI with rank and reward progress.
; Dependencies:
; - activateRoblox: Ensures the game window is focused.
; - lvQuests.Delete: Clears the quest list view.
; - closeAllWindows: Closes any open windows.
; - clickRewardsButton: Clicks the rewards button to open the rewards menu.
; - writeToLogFile: Logs the current action or message.
; - getOcrResult: Performs OCR on the specified screen area and returns the results.
; - getSetting: Retrieves the specified setting.
; - getquestId: Determines the quest ID from the OCR text.
; - fixAmount: Corrects the OCR-extracted amount if necessary.
; - waitTime: Pauses for a specified duration.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
refreshQuests(*) {
setCurrentAction("Reading Quests") ; Signal the beginning of quest processing.
activateRoblox() ; Focus the game window for interaction.
lvQuests.Delete() ; Clear existing quest data from the list view.
closeAllWindows() ; Close all open windows.
clickRewardsButton() ; Click the rewards button to open the rewards menu.
writeToLogFile("*** REFRESH QUESTS ***") ; Log the refresh quest action.
ocrQuests := getOcrResult([130, 280], [135, 135], 30, false) ; Perform OCR to read quest information.
; Combine lines from the OCR result based on a number of factors.
combinedLines := []
for line in ocrQuests.Lines { ; Loop all quest lines.
; Combine with previous line if the first character is lowercase.
if (combinedLines.Length > 0 && RegExMatch(line.Text, "^[a-z]")) {
combinedLines[combinedLines.Length] .= " " line.Text
; Combine with previous line if the distance between the lines is less than or equal to 15 pixels.
} else if (combinedLines.Length > 0 && (line.Words[1].y - previousLineY <= 15)) {
combinedLines[combinedLines.Length] .= " " line.Text
} else {
combinedLines.Push(line.Text)
}
previousLineY := line.Words[1].y
}
; Process each combined quest line.
for quest in combinedLines {
if (getSetting("Do" A_Index "StarQuests") == "true") { ; Check settings if the quest level should be processed.
ocrTextResult := quest
questId := getquestId(ocrTextResult) ; Identify the quest type from OCR results.
questName := QUEST_DATA[questId]["Name"] ; Retrieve the name of the quest from a map based on questId.
questStatus := QUEST_DATA[questId]["Status"] ; Get the status of the quest.
questPriority := QUEST_PRIORITY[questId] ; Determine the priority of the quest.
questZone := QUEST_DATA[questId]["Zone"] ; Get the associated quest zone.
questAmount := fixAmount(ocrTextResult, questId) ; Correct the OCR-extracted amount if necessary.
starsMultiplier := (getSetting("HasGamepassDoubleStars") == "true") ? 2 : 1 ; Determine star multiplier based on gamepass.
questStars := starsMultiplier * A_Index ; Calculate the total stars earned for this quest.
lvQuests.Add(, questStars, questId, questName, questAmount, questPriority, questStatus, questZone, ocrTextResult) ; Add quest data to the list view.
writeToLogFile(" OCR Result: " ocrTextResult " Id: " questId " Quest: " questName " Amount: " Round(questAmount, 0) " Priority: " questPriority)
waitTime("QuestAfterOcrCompleted") ; Pause until OCR processing is confirmed complete.
}
}
activateRoblox() ; Re-focus the game window if it lost focus.
ocrTextResult := getOcrResult(COORDS["OCR"]["RankProgressStart"], COORDS["OCR"]["RankProgressSize"], 20) ; Read the rank progress using OCR.
rankArray := StrSplit(ocrTextResult, " ")
rankDetails := getRankDetails(rankArray[2])
writeToLogFile(" Rank Details: " ocrTextResult) ; Log the rank details.
; Update the main GUI title with the rank, reward progress, and current time.
guiMain.Title := MACRO_TITLE " v" MACRO_VERSION " (Rank: " rankDetails.rankNumber ", " rankDetails.rankName ", " rankArray[1] ") (" FormatTime(A_Now, "h:mm tt") ")"
closeAllWindows() ; Close all open windows.
setCurrentAction("-") ; Reset the current action status.
}
; ----------------------------------------------------------------------------------------
; getquestId Function
; Description: Determines the quest ID based on OCR text by matching it against known regex patterns.
; Operation:
; - Iterates through each quest entry in a global quest map.
; - Uses regex matching to identify if the OCR text corresponds to a specific quest pattern.
; - Returns the quest key if a match is found or a default value if no match is found.
; Dependencies:
; - Quest: A globally defined map containing quest details such as regex patterns.
; - regexMatch: Function used to match strings against regular expression patterns.
; Parameters:
; - OcrText: The text obtained from OCR that needs to be checked against quest patterns.
; Return:
; - String: Returns the quest key if a match is found; otherwise returns a default "-" indicating no match.
; ----------------------------------------------------------------------------------------
getquestId(ocrTextResult) {
; Iterate through each quest in the globally defined Quest.
for questKey, questItem in QUEST_DATA {
; Check if the OCR text matches the regex pattern defined for the current quest.
if (regexMatch(ocrTextResult, questItem["Regex"])) {
return questKey ; If a match is found, return the key associated with this quest.
}
}
return "-" ; If no matches are found after checking all quests, return a default value.
}
; ----------------------------------------------------------------------------------------
; doQuest Function
; Description: Handles different quests based on the provided questId and Name. Adjusts game state accordingly.
; Operation:
; - Activates the Roblox window to ensure it's the active application.
; - Checks if the current quest has changed and stops certain actions if necessary.
; - Updates the current quest for tracking.
; - Executes different quest actions based on the questId.
; Dependencies:
; - activateRoblox, getCurrentQuest, stopHatching, setCurrentQuest, and various quest-related functions.
; Parameters:
; - questId: Identifier for the quest.
; - Name: Name of the quest.
; - Amount: Optional parameter for the amount needed in certain quests (default is 1).
; Return: None; modifies game actions based on the quest requirements.
; ----------------------------------------------------------------------------------------
doQuest(questId, questName, questAmount := 1) {
activateRoblox() ; Focus on the Roblox window to ensure actions are sent to the right place.
writeToLogFile("*** ACTIVE QUEST*** Id: " questId " Quest: " questName " Amount: " Round(questAmount, 0) " Loop: " getCurrentLoop())
; Check if the current quest is still active, and stop hatching if in an egg area.
if (questName != getCurrentQuest()) {
if getCurrentArea() == "Best Egg"
stopHatching() ; Stop hatching actions if the area is for hatching eggs.
else if getCurrentArea() == "Rare Egg" {
stopHatching()
applyAutoHatchSettings()
}
}
setCurrentQuest(questName) ; Update the system with the new or current quest.
; Perform actions based on the quest ID provided.
Switch questId {
Case "7": ; Quest for earning diamonds.
earnDiamonds()
Case "9": ; Quest for breaking diamond breakables.
breakDiamondBreakables()
Case "14": ; Quest for collecting potions.
upgradePotions(questId, questAmount)
Case "15": ; Quest for collecting enchants.
upgradeEnchants(questId, questAmount)
Case "20": ; Quest for hatching the best egg.
hatchBestEgg(questAmount)
Case "21": ; Quest for breaking breakables in the best area.
breakBreakables()
Case "33": ; Quest for using flags.
useFlags(questAmount)
Case "34-1", "34-2", "34-3": ; Quest for using specific tier potions.
usePotions(questId, questAmount)
Case "35": ; Quest for eating fruitArray.
useFruit(questAmount)
Case "37": ; Quest for breaking coin jars.
breakBasicCoinJars(questId, questAmount)
Case "38": ; Quest for breaking comets.
breakComets(questId, questAmount)
Case "39": ; Quest for breaking mini-chests.
breakMiniChests()
Case "40": ; Quest for making golden pets from the best egg.
makeGoldenPets(questId, questAmount)
Case "41": ; Quest for making rainbow pets from the best egg.
makeRainbowPets(questId, questAmount)
Case "42": ; Quest for hatching rare pets.
hatchRarePetEgg()
Case "43": ; Quest for breaking pinatas.
breakPinatas(questId, questAmount)
Case "44": ; Quest for breaking lucky blocks.
breakLuckyBlocks(questId, questAmount)
Case "66": ; "Break Superior Mini-Chests in Best Area"
breakSuperiorMiniChests()
Case "100": ; Default action when there are no specific quests.
waitForQuest()
Default:
; No action for undefined questId.
}
}
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; QUEST FUNCTIONS
; ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
; ----------------------------------------------------------------------------------------
; breakComets Function
; Description: Executes the task of breaking comets in the game by navigating to the best zone and performing a series of actions based on quest requirements.
; Operation:
; - Navigates to the optimal zone for breaking comets.
; - Iterates through the number of comets specified by the quest.
; - Uses a boost keybind for each comet and breaks the loop if the item is not used.
; - Performs a pixel search within specified coordinates to locate comets by color.
; - Clicks on the comet's location if found within the time limit.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves settings such as the time to break a comet and the keybind for comets.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - useBoostKeybind: Uses the specified keybind for the comet quest.
; - PixelSearch: Searches for a pixel within specified coordinates.
; - leftClickMouse: Simulates a left mouse click at the specified coordinates.
; Parameters:
; - questId: The ID of the quest that specifies which comets to break.
; - questAmount: The number of comets to be broken as part of the quest.
; Return: None
; ----------------------------------------------------------------------------------------
breakComets(questId, questAmount) {
farmBestZone() ; Navigate to the optimal zone for breaking comets.
keybind := getSetting("CometKeybind")
timeToBreakComet := getSetting("TimeToBreakComet")
Loop questAmount {
currentAction := "Breaking Comets (" A_Index "/" questAmount ")"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
itemUsed := useBoostKeybind(keybind, questId)
if !itemUsed
break ; Exit the loop if the item is not used successfully.
newTime := DateAdd(A_Now, timeToBreakComet, "Seconds")
Loop {
if PixelSearch(&foundX, &foundY, ; Perform pixel search within specified coordinates and color.
COMET_COLOUR["Start"][1], COMET_COLOUR["Start"][2],
COMET_COLOUR["End"][1], COMET_COLOUR["End"][2],
COMET_COLOUR["Colour"], COMET_COLOUR["Tolerance"])
{
leftClickMouse([foundX, foundY]) ; Click on the comet's location if found.
}
if A_Now > newTime {
break ; Exit the inner loop if the time limit is reached.
}
}
}
}
; ----------------------------------------------------------------------------------------
; breakPinatas Function
; Description: Executes the task of breaking piñatas in the game by navigating to the best zone and performing a series of actions based on quest requirements.
; Operation:
; - Navigates to the optimal zone for breaking piñatas.
; - Determines the appropriate keybind and time setting for breaking piñatas.
; - Iterates through the number of piñatas specified by the quest.
; - Uses a boost keybind for each piñata and breaks the loop if the item is not used.
; - Performs a pixel search within specified coordinates to locate piñatas by color.
; - Clicks on the piñata's location if found within the time limit.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves settings such as the time to break a piñata and the keybind for piñatas.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - useBoostKeybind: Uses the specified keybind for the piñata quest.
; - PixelSearch: Searches for a pixel within specified coordinates.
; - leftClickMouse: Simulates a left mouse click at the specified coordinates.
; Parameters:
; - questId: The ID of the quest that specifies which piñatas to break.
; - questAmount: The number of piñatas to be broken as part of the quest.
; Return: None
; ----------------------------------------------------------------------------------------
breakPinatas(questId, questAmount) {
farmBestZone() ; Navigate to the optimal zone for breaking piñatas.
keybind := getSetting("PinataKeybind")
timeToBreakPinata := getSetting("TimeToBreakPinata")
; Loop through the number of piñatas to break.
Loop questAmount {
currentAction := "Breaking Pinatas (" A_Index "/" questAmount ")"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
itemUsed := useBoostKeybind(keybind, questId)
if !itemUsed
break ; Exit the loop if the item is not used successfully.
newTime := DateAdd(A_Now, timeToBreakPinata, "Seconds")
Loop {
; Perform pixel search within specified coordinates and color.
if PixelSearch(&foundX, &foundY,
PINATA_COLOUR["Start"][1], PINATA_COLOUR["Start"][2],
PINATA_COLOUR["End"][1], PINATA_COLOUR["End"][2],
PINATA_COLOUR["Colour"], PINATA_COLOUR["Tolerance"])
{
leftClickMouse([foundX, foundY]) ; Click on the piñata's location if found.
}
if A_Now > newTime {
break ; Exit the inner loop if the time limit is reached.
}
}
}
}
; ----------------------------------------------------------------------------------------
; breakLuckyBlocks Function
; Description: Executes the task of breaking Lucky Blocks in the game by navigating to the best zone and performing a series of actions based on quest requirements.
; Operation:
; - Navigates to the optimal zone for breaking Lucky Blocks.
; - Retrieves the keybind and time setting for breaking Lucky Blocks.
; - Iterates through the number of Lucky Blocks specified by the quest.
; - Uses a boost keybind for each Lucky Block and breaks the loop if the item is not used.
; - Performs a pixel search within specified coordinates to locate Lucky Blocks by color.
; - Clicks on the Lucky Block's location if found within the time limit.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves settings such as the time to break a Lucky Block and the keybind for Lucky Blocks.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - useBoostKeybind: Uses the specified keybind for the Lucky Block quest.
; - PixelSearch: Searches for a pixel within specified coordinates.
; - leftClickMouse: Simulates a left mouse click at the specified coordinates.
; Parameters:
; - questId: The ID of the quest that specifies which Lucky Blocks to break.
; - questAmount: The number of Lucky Blocks to be broken as part of the quest.
; Return: None
; ----------------------------------------------------------------------------------------
breakLuckyBlocks(questId, questAmount) {
farmBestZone() ; Navigate to the optimal zone for breaking Lucky Blocks.
keybind := getSetting("LuckyBlockKeybind")
timeToBreakLuckyBlock := getSetting("TimeToBreakLuckyBlock") ; Get the set time to break a Lucky Block.
; Loop through the number of Lucky Blocks to break.
Loop questAmount {
currentAction := "Breaking Lucky Blocks (" A_Index "/" questAmount ")"
setCurrentAction(currentAction) ; Display the current action in the UI.
writeToLogFile(currentAction) ; Log the current action status.
itemUsed := useBoostKeybind(keybind, questId)
if !itemUsed
break ; Exit the loop if the item is not used successfully.
newTime := DateAdd(A_Now, timeToBreakLuckyBlock, "Seconds")
Loop {
; Perform pixel search for pink Lucky Blocks within specified coordinates and color.
if PixelSearch(&foundX, &foundY,
LUCKY_BLOCK_PINK["Start"][1], LUCKY_BLOCK_PINK["Start"][2],
LUCKY_BLOCK_PINK["End"][1], LUCKY_BLOCK_PINK["End"][2],
LUCKY_BLOCK_PINK["Colour"], LUCKY_BLOCK_PINK["Tolerance"])
{
leftClickMouse([foundX, foundY]) ; Click on the Lucky Block's location if found.
}
; Perform pixel search for blue Lucky Blocks within specified coordinates and color.
if PixelSearch(&foundX, &foundY,
LUCKY_BLOCK_BLUE["Start"][1], LUCKY_BLOCK_BLUE["Start"][2],
LUCKY_BLOCK_BLUE["End"][1], LUCKY_BLOCK_BLUE["End"][2],
LUCKY_BLOCK_BLUE["Colour"], LUCKY_BLOCK_BLUE["Tolerance"])
{
leftClickMouse([foundX, foundY]) ; Click on the Lucky Block's location if found.
}
; Perform pixel search for yellow Lucky Blocks within specified coordinates and color.
if PixelSearch(&foundX, &foundY,
LUCKY_BLOCK_YELLOW["Start"][1], LUCKY_BLOCK_YELLOW["Start"][2],
LUCKY_BLOCK_YELLOW["End"][1], LUCKY_BLOCK_YELLOW["End"][2],
LUCKY_BLOCK_YELLOW["Colour"], LUCKY_BLOCK_YELLOW["Tolerance"])
{
leftClickMouse([foundX, foundY]) ; Click on the Lucky Block's location if found.
}
if A_Now > newTime {
break ; Exit the inner loop if the time limit is reached.
}
}
}
}
; ----------------------------------------------------------------------------------------
; breakBasicCoinJars Function
; Description: Executes the task of breaking basic coin jars in the game by navigating to the best zone and performing a series of actions based on quest requirements.
; Operation:
; - Navigates to the optimal zone for breaking coin jars.
; - Iterates through the number of coin jars specified by the quest.
; - Uses a boost keybind for each coin jar and breaks the loop if the item is not used.
; - Waits for the specified amount of time to break each coin jar.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves settings such as the time to break a coin jar and the keybind for coin jars.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - useBoostKeybind: Uses the specified keybind for the coin jar quest.
; - loopAmountOfSeconds: Waits for a specified amount of time.
; Parameters:
; - questId: The ID of the quest that specifies which coin jars to break.
; - questAmount: The number of coin jars to be broken as part of the quest.
; Return: None
; ----------------------------------------------------------------------------------------
breakBasicCoinJars(questId, questAmount) {
farmBestZone() ; Navigate to the optimal zone for breaking coin jars.
; Loop through the number of coin jars to break.
Loop questAmount {
currentAction := "Breaking Coin Jars (" A_Index "/" questAmount ")"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
keybind := getSetting("BasicCoinJarKeybind")
itemUsed := useBoostKeybind(keybind, questId)
if !itemUsed
break ; Exit the loop if the item is not used successfully.
loopAmountOfSeconds(getSetting("TimeToBreakBasicCoinJar")) ; Wait for the specified amount of time to break the coin jar.
}
}
; ----------------------------------------------------------------------------------------
; breakMiniChests Function
; Description: Executes the task of breaking mini-chests in the game by navigating to the best zone and performing actions based on settings.
; Operation:
; - Navigates to the optimal zone for breaking mini-chests.
; - Sets and displays the current action status.
; - Logs the current action.
; - Waits for the specified amount of time to break mini-chests.
; - Resets the action status after completion.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves the setting for the time to break mini-chests.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - loopAmountOfSeconds: Waits for a specified amount of time.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
breakMiniChests() {
farmBestZone() ; Navigate to the optimal zone for breaking mini-chests.
currentAction := "Breaking Mini-Chests"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
loopAmountOfSeconds(getSetting("TimeToBreakMiniChests")) ; Wait for the specified amount of time to break the mini-chests.
}
; ----------------------------------------------------------------------------------------
; breakSuperiorMiniChests Function
; Description: Executes the task of breaking superior mini-chests in the game by navigating to the best zone and performing actions based on settings.
; Operation:
; - Navigates to the optimal zone for breaking superior mini-chests.
; - Sets and displays the current action status.
; - Logs the current action.
; - Waits for the specified amount of time to break superior mini-chests.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves the setting for the time to break superior mini-chests.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - loopAmountOfSeconds: Waits for a specified amount of time.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
breakSuperiorMiniChests() {
farmBestZone() ; Navigate to the optimal zone for breaking superior mini-chests.
currentAction := "Breaking Superior Mini-Chests"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
loopAmountOfSeconds(getSetting("TimeToBreakSuperiorMiniChests")) ; Wait for the specified amount of time to break the superior mini-chests.
}
; ----------------------------------------------------------------------------------------
; useFruit Function
; Description: Distributes a specified total amount of actions equally across different fruit types.
; Operation:
; - Calculates the amount of each fruit type to be used based on the total amount divided by the number of fruit types.
; - Iterates over a list of fruit types and applies the same amount of action to each fruit.
; Dependencies:
; - useItem: Function to consume items in the game.
; Parameters:
; - Amount: Total amount of actions to be distributed among the fruitArray.
; Return: None; modifies game state by consuming fruitArray.
; ----------------------------------------------------------------------------------------
useFruit(amountToUse) {
amountPerFruit := Ceil(amountToUse / 6) ; Calculate how many times each fruit type should be used by dividing the total amount by 6.
fruitArray := ["Apple", "Banana", "Orange", "Pineapple", "Rainbow Fruit", "Watermelon"] ; List of fruitArray to be used.
; Loop through each fruit in the list and apply the action.
for fruit in fruitArray {
useItem(fruit, 2, amountPerFruit) ; Use the calculated amount of each fruit.
}
}
; ----------------------------------------------------------------------------------------
; useFlags Function
; Description: Uses a specified number of flags in different zones by teleporting to each zone, moving to the center, and executing the flag action.
; Operation:
; - Initializes necessary variables.
; - Iterates through predefined zones to use flags.
; - Teleports to each zone and moves to its center.
; - Uses flags and handles any errors that occur.
; - Repeats until the specified number of flags is used or the quest is completed.
; Dependencies:
; - getSetting: Retrieves settings such as the keybind for using flags.
; - teleportToZone: Teleports to the specified zone.
; - moveToZoneCentre: Moves to the center of the specified zone.
; - shootDownBalloons: Executes the action to shoot down balloons in the zone.
; - setCurrentAction: Updates the current action status display.
; - isOopsWindowOpen: Checks if the 'Oops' window is open, indicating an error.
; - closeAllWindows: Closes all open windows.
; - moveMouseToCentreOfScreen: Re-centers the mouse on the screen.
; Parameters:
; - amountToUse: The number of flags to use.
; Return: None
; ----------------------------------------------------------------------------------------
useFlags(amountToUse) {
flagsUsed := 0
keybind := getSetting("QuestFlagKeybind")
questCompleted := false
for zoneItem in USE_FLAG_ZONES { ; Iterate through each zone
teleportToZone(zoneItem) ; Teleport to the current zone
moveToZoneCentre(zoneItem) ; Move to the center of the zone
shootDownBalloons() ; Shoot down balloons in the zone
Loop {
flagsUsed += 1
setCurrentAction("Using Flags (" flagsUsed "/" amountToUse ")") ; Update and display the current action status
SendEvent keybind ; Send the keybind event to use the flag
Sleep 250 ; Wait for 250 milliseconds
if isOopsWindowOpen() {
flagsUsed -= 1 ; Decrement the flag count if 'Oops' window is open
break ; Exit the loop
}
questCompleted := (flagsUsed == amountToUse)
if questCompleted
break ; Exit the loop if the quest is completed
}
closeAllWindows() ; Close all open windows
moveMouseToCentreOfScreen() ; Re-center the mouse on the screen
if questCompleted
return ; Exit the function if the quest is completed
}
}
; ----------------------------------------------------------------------------------------
; usePotions Function
; Description: Uses a specified number of potions based on the quest ID by sending the appropriate keybind.
; Operation:
; - Determines the potion type keybind based on the quest ID.
; - Iterates through the specified number of potions to use.
; - Sets and displays the current action status.
; - Sends the keybind for using the potion and waits for a short duration between uses.
; Dependencies:
; - getSetting: Retrieves the setting for the potion keybind based on the quest ID.
; - setCurrentAction: Updates the current action status display.
; Parameters:
; - questId: The ID of the quest that specifies which type of potion to use.
; - amountToUse: The number of potions to be used.
; Return: None
; ----------------------------------------------------------------------------------------
usePotions(questId, amountToUse) {
Switch questId { ; Determine the potion type based on the quest ID.
Case "34-1":
keybind := getSetting("PotionTier3Keybind")
Case "34-2":
keybind := getSetting("PotionTier4Keybind")
Case "34-3":
keybind := getSetting("PotionTier5Keybind")
Default:
keybind := "" ; No action for undefined questId.
}
if keybind != "" {
Loop amountToUse {
currentAction := "Using potions (" A_Index "/" amountToUse ")"
setCurrentAction(currentAction) ; Update and display the current action status.
SendEvent keybind ; Send the keybind for using the potion.
Sleep 500 ; Wait for 0.5 seconds between each use.
}
}
}
; ----------------------------------------------------------------------------------------
; breakBreakables Function
; Description: Executes the task of breaking breakable objects in the game by navigating to the best zone and performing actions based on settings.
; Operation:
; - Navigates to the optimal zone for breaking breakables.
; - Sets and displays the current action status.
; - Logs the current action.
; - Waits for the specified amount of time to break breakables.
; Dependencies:
; - farmBestZone: Navigates to the optimal zone for the task.
; - getSetting: Retrieves the setting for the time to break breakables.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - loopAmountOfSeconds: Waits for a specified amount of time.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
breakBreakables() {
farmBestZone() ; Navigate to the optimal zone for breaking breakables.
currentAction := "Breaking Breakables"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
loopAmountOfSeconds(getSetting("TimeToBreakBreakables")) ; Wait for the specified amount of time to break the breakables.
}
; ----------------------------------------------------------------------------------------
; breakDiamondBreakables Function
; Description: Executes the task of breaking diamond breakables in the game by navigating to the VIP area if available or the best zone otherwise, and performing actions based on settings.
; Operation:
; - Checks if the player has a VIP gamepass.
; - Navigates to the VIP area if the gamepass is available, otherwise navigates to the best zone.
; - Sets and displays the current action status.
; - Logs the current action.
; - Waits for the specified amount of time to break diamond breakables.
; Dependencies:
; - getSetting: Retrieves the setting for VIP gamepass availability and the time to break diamond breakables.
; - goToVipArea: Navigates to the VIP area for exclusive activities.
; - farmBestZone: Navigates to the best zone for general activities.
; - setCurrentAction: Updates the current action status display.
; - writeToLogFile: Logs the current action.
; - loopAmountOfSeconds: Waits for a specified amount of time.
; Parameters: None
; Return: None
; ----------------------------------------------------------------------------------------
breakDiamondBreakables() {
if (getSetting("HasGamepassVip") == "true") { ; Check for VIP gamepass availability.
goToVipArea() ; Navigate to VIP area for exclusive activities.
} else {
farmBestZone() ; Navigate to the best zone for general activities.
}
currentAction := "Breaking Diamond Breakables"
setCurrentAction(currentAction) ; Update and display the current action status.
writeToLogFile(currentAction) ; Log the current action status.
loopAmountOfSeconds(getSetting("TimeToBreakDiamondBreakables")) ; Wait for the specified amount of time to break the diamond breakables.
}