forked from Bredomant/SC2-MacroTrainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Macro Trainer V2.979.ahk
11291 lines (9830 loc) · 473 KB
/
Macro Trainer V2.979.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
;-----------------------
; For updates:
; Change version number in exe and config file
; Upload the changelog, file version and new exe files to the ftp server
; check dont have debugging hotkeys and clipboards at end of script
; check dont have the 'or debug' uncommented
;-----------------------
; git add -A
; git commit -m "Msg"
; git push
;-----------------------
; if script re-copied from github should save it using UTF-8 with BOM (otherwise some of the ascii symbols like • wont be displayed correctly)
/* Things to do
g_ControlShiftTimer make off routine
Update unit panel structure so can add build progress and hallucination properties
Check if chrono structures are powered - It seems to be a behaviour ' Power User (Queue) '
Team send warn message after clicking building..maybe
*/
/*
Known Problems:
Pressing Esc to cancel chat while having one base selected will cancel auto production for 4.5 seconds
SC2 will not respond to a 'tab'-next subgroup command if the chat is open even when its not in focus
the Shift+Tab (previous subgroup) does however work
*/
/*
For Updates:
Disable Auto-Inject
Disable Auto Grouping
Disable Hostile colour assist
Change ToggleWorkerState to #F2
Disable Spread and RemoveUnit
*/
/*
MEMORY BENCHMARKS - NUMGET VS NORMAL METHOD
Numget is ~20x faster when iterating the unit structure and gleaming same amount of information.
(this is achieved by dumping the entire unit structure, then using numget to retrieve the info for the units)
It is ~10x faster when iterating same unit structure but getting 2x the information
To just dump the raw unit structure for 993 units takes 0.050565 ms
(this is done via ReadMemoryDump(B_uStructure, GameIdentifier, MVALUE, 0x1C0 * getHighestUnitIndex()))
Numget is still faster even for a single memory read!
for example, it takes 0.007222 ms for a single normal memory read e.g. unit x position
numget (when dumping the entire unit i.e 0x1c0 bytes) takes 0.004794 ms
numget (when dumping just the int/ x position - 4 bytes) takes 0.004575 ms
These numbers were averaged over 10,000 reads.
*/
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#MaxHotkeysPerInterval 999999 ; a user requested feature (they probably have their own macro script)
#InstallMouseHook
#InstallKeybdHook
#UseHook
#Persistent
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#MaxThreads 20 ; don't know if this will affect anything
SetStoreCapslockMode, off ; needed in case a user bind something to the capslock key in sc2 - other AHK always sends capslock to adjust for case.
OnExit, ShutdownProcedure
ListLines(False)
Menu, Tray, Icon
if !A_IsAdmin
{
if (A_OSVersion = "WIN_XP") ; apparently the below command wont work on XP
RunAsAdmin()
else try Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
; Process, Priority, , H
Process, Priority, , A
Menu Tray, Add, &Settings && Options, options_menu
Menu Tray, Add, &Check For Updates, TrayUpdate
Menu Tray, Add, &Homepage, Homepage
Menu Tray, Add, &Reload, g_reload
Menu Tray, Add, Exit, ExitApp ;this is actually a label not the command!
Menu Tray, Default, &Settings && Options
If A_IsCompiled
Menu Tray, NoStandard
Else
{
Menu Tray, Icon, Included Files\Used_Icons\Starcraft-2.ico
debug := 1
debug_name := "Kalamity"
hotkey, ^+!F12, g_GiveLocalPalyerResources
}
start:
config_file := "MT_Config.ini"
old_backup_DIR := "Old Macro Trainers"
url := []
url.vr := "http://www.users.on.net/~jb10/macro_trainer_version.txt"
url.changelog := "http://www.users.on.net/~jb10/MT_ChangeLog.html"
url.HelpFile := "http://www.users.on.net/~jb10/MTSite/helpfulAdvice.html"
url.ChronoRules := "http://www.users.on.net/~jb10/MTSite/chronoBoost.html"
url.Homepage := "http://www.users.on.net/~jb10/MTSite/overview.html"
url.buyBeer := "http://www.users.on.net/~jb10/MTSite/buyBeer.html"
url.PixelColour := url.homepage "Macro Trainer/PIXEL COLOUR.htm"
program := []
program.info := {"IsUpdating": 0} ; program.Info.IsUpdating := 0 ;has to stay here as first instance of creating infor object
ProgramVersion := 2.979
l_GameType := "1v1,2v2,3v3,4v4,FFA"
l_Races := "Terran,Protoss,Zerg"
GameWindowTitle := "StarCraft II"
GameIdentifier := "ahk_exe SC2.exe"
GameExe := "SC2.exe"
SAPI := ComObjCreate("SAPI.SpVoice") ; ComObjCreate("SAPI.SpVoice").Speak("Please read this file")
pToken := Gdip_Startup()
SetupUnitIDArray(A_unitID, A_UnitName)
setupTargetFilters(a_UnitTargetFilter)
SetupColourArrays(HexColour, MatrixColour)
Menu, Tray, Tip, MT_V%ProgramVersion% Coded By Kalamity
If InStr(A_ScriptDir, old_backup_DIR)
{
Msgbox, 4372, Launch Directoy?, This program has been launched from the "%old_backup_DIR%" directory.`nThis could be caused by running the program via a shortcut/link after the program has updated.`nThis is due to the fact that the windows shortcut is updated to the old versions 'new/backup' location.`nIn future, please don't run this program using shortcuts.`n`nI recommend pressing NO to EXIT.`n`n %A_Tab% Continue?
IfMsgBox No
ExitApp
}
Gosub, pre_startup ; go read the ini file
if MTCustomIcon
Menu, Tray, Tip, %A_Space% ;clear the tool tip on mouse over
SetProgramWaveVolume(programVolume)
SAPI.volume := speech_volume
; this is required to enable drag and drop on vista and above systems while running with admin privileges
; this has a 'process wide' scope (tested it, and it seems to mean what it says i.e.
; only for this process and so reverts on closing)
if A_OSVersion in WIN_8,WIN_7,WIN_VISTA
{
DllCall("ChangeWindowMessageFilter", uint, 0x49, uint, 1) ; 1 allows message to be received
DllCall("ChangeWindowMessageFilter", uint, 0x233, uint, 1)
}
;-----------------------
; Startup
;-----------------------
InstallSC2Files()
#include %A_ScriptDir%\Included Files\Gdip.ahk
#include %A_ScriptDir%\Included Files\Colour Selector.ahk
#include %A_ScriptDir%\Included Files\Class_BufferInputFast.AHk
#include %A_ScriptDir%\Included Files\Class_ChangeButtonNames.AHk
CreatepBitmaps(a_pBitmap, a_unitID)
aUnitInfo := []
a_pBrush := []
If (auto_update AND A_IsCompiled AND CheckForUpdates(ProgramVersion, url.vr ))
{
; changelog_text := Url2Var(url.changelog)
Gui, New
Gui +Toolwindow +LabelAUpdate_On
Gui, Add, Picture, x12 y10 w90 h90 , %A_Temp%\Starcraft-2.ico
Gui, Font, S10 CDefault Bold, Verdana
Gui, Add, Text, x112 y10 w220, An update is available.
Gui, Font, Norm
Gui, Add, Text, x112 y35 w560, Click UPDATE to download the latest version.
Gui, Add, Text, x112 y+10 w560, Click CANCEL to continue running this version.
Gui, Add, Text, x112 y+10 w560, Click DISABLE to stop the program automatically checking for updates.
Gui, Font, S8 CDefault, Verdana
Gui, Add, Text, x112 y+5 w560, %A_Tab% (You can still update via right clicking the tray icon.)
Gui, Font, S10
Gui, Add, Text, x112 y+10, You're currently running version %ProgramVersion%
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x10 y+5 w80, Changelog:
Gui, Font, Norm
; Gui, Add, Edit, x12 y+10 w560 h220 readonly -E0x200, % LTrim(changelog_text)
Gui Add, ActiveX, x12 w560 h220 vWB, Shell.Explorer
WB.Navigate(url.changelog)
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Button, Default x50 y+20 w100 h30 gUpdate, &Update
Gui, Font, Norm
Gui, Add, Button, x+100 yp w100 h30 gLaunch vDisable_Auto_Update, &Disable
Gui, Add, Button, x+100 yp w100 h30 gLaunch vCancel_Auto_Update, &Cancel
Gui, Show, w600, Macro Trainer Update
Return
}
Launch:
If (A_GuiControl = "Disable_Auto_Update")
Iniwrite, % auto_update := 0, %config_file%, Misc Settings, auto_check_updates
If (A_GuiControl = "Disable_Auto_Update" OR A_GuiControl = "Cancel_Auto_Update")
Gui Destroy
If launch_settings
gosub options_menu
if (MTCustomProgramName && A_ScriptName != MTCustomProgramName && A_IsCompiled)
{
FileCopy, %A_ScriptName%, %MTCustomProgramName%, 1
FullPath := A_ScriptDir "\" MTCustomProgramName
if (A_OSVersion = "WIN_XP") ; apparently the below command wont work on XP
try RunAsAdmin(FullPath, A_ScriptDir)
else try Run *RunAs "%FullPath%"
ExitApp
}
Try hotkey, q, g_DoNothing ; hotkeys that contain q give 'q' is not a valid hotkey on russian language settings
Catch, Error ;error is an object
{
clipboard := "Error: " error.message "`nLine: " error.line "`nExtra: "error.Extra
msgbox % "There was an error while creating a hotkey.`n`nIf you are using a non-English language/character-set, I recommend you try changing your keyboard layout/language to English."
. "`n`nThis error has been copied to your clipboard if you wish to report it.`n`nError: " error.message "`nLine: " error.line "`nSpecifically: " error.Extra
}
; it seems that some russian language keyboard layouts cause a prblem with <#q hotkey
Try hotkey, q, off ;disable the ruski guard test hotkey
; Note: Emergency Restart Hotkey - Something to keep in mind if actually using the Real BlockInput Command
; Certain types of hook hotkeys can still be triggered when BlockInput is on.
; Examples include MButton (mouse hook) and LWin & Space
; ***(KEYBOARD HOOK WITH EXPLICIT PREFIX RATHER THAN MODIFIERS "$#")***.
; hence <#Space wont work
CreateHotkeys() ;create them before launching the game in case users want to edit them
process, exist, %GameExe%
If !errorlevel
{
MT_StarCraftOpenOnLanuch := 0
try run % StarcraftExePath()
}
else MT_StarCraftOpenOnLanuch := 1
Process, wait, %GameExe% ; waits for starcraft to exist
while (!(B_SC2Process := getProcessBaseAddress(GameIdentifier)) || B_SC2Process < 0) ;using just the window title could cause problems if a folder had the same name e.g. sc2 folder
sleep 400 ; required to prevent memory read error - Handle closed: error
LoadMemoryAddresses(B_SC2Process)
settimer, clock, 250
settimer, timer_exit, 5000, -100
SetTimer, OverlayKeepOnTop, 1000, -20 ;better here, as since WOL 2.0.4 having it in the "clock" section isn't reliable
l_Changeling := A_unitID["ChangelingZealot"] "," A_unitID["ChangelingMarineShield"] "," A_unitID["ChangelingMarine"]
. "," A_unitID["ChangelingZerglingWings"] "," A_unitID["ChangelingZergling"]
if A_OSVersion in WIN_7,WIN_VISTA
{
if !DwmIsCompositionEnabled() && !MT_DWMwarned && !MT_Restart && A_IsCompiled ; so not restarted via hotkey or icon
{
ChangeButtonNames.set("DWM is Disabled?", "Help", "Ignore")
; msgbox with exclamation and Ok, Cancel Buttons
MsgBox, 49, DWM is Disabled?
, % "Desktop Widows Management (DWM) is disabled!`n`n"
. "This will cause significant performance issues while using this program.`n"
. "Your FPS can be expected to decrease by 70%`n`n"
. "Click 'Help' to launch some URLs explaining how to do enable DWM.`n`n"
. "You will not see this warning again!"
IniWrite, % MT_DWMwarned := True, %config_file%, Misc Info, MT_DWMwarned
ifMsgbox Ok ; 'Help'
gosub, g_HTTPEnableDWM
}
}
; SC2 Window Modes EXStyle
; Windowed FullScreen := 0x00040000
; FullScreen := 0x00040008
; Windowed := 0x00040100
; Breakdown
; WS_THICKFRAME = 0x00040000 ; WindowedFullScreen
; WS_EX_TOPMOST = 0x00000008
; WS_EX_WINDOWEDGE = 0x00000100
; winset fails when attempting to modify these values
; Style or ExStyle: Retrieves an 8-digit hexadecimal number representing style
; or extended style (respectively) of a window.
; If there are no matching windows, OutputVar is made blank.
SC2WindowEXStyles := []
SC2WindowEXStyles.WindowedFullScreen := 0x00040000
SC2WindowEXStyles.FullScreen := 0x00040008
SC2WindowEXStyles.Windowed := 0x00040100
if !MT_StarCraftOpenOnLanuch
sleep 2000 ; give time for SC2 to fully launch. This may be required on slower or stressed computers
; to give time for the window to fully launch and activate to allow the below check
; to work properly
If WinGet("EXStyle", GameIdentifier) = SC2WindowEXStyles.FullScreen
&& (DrawMiniMap || DrawAlerts || DrawSpawningRaces
|| DrawIncomeOverlay || DrawResourcesOverlay || DrawArmySizeOverlay
|| DrawWorkerOverlay || DrawIdleWorkersOverlay || DrawLocalPlayerColourOverlay
|| DrawUnitOverlay)
&& !MT_Restart && A_IsCompiled ; so not restarted via hotkey or icon
{
ChangeButtonNames.set("SC2 Is NOT in 'windowed Fullscreen' mode!", "Disable", "Continue")
; OK/Cancel messagebox
MsgBox, 49, SC2 Is NOT in 'windowed Fullscreen' mode!
, % "Starcraft seems to be in 'fullscreen' mode and you have overlays enabled within"
. " the Macro Trainer.`n`n"
. "The Minimap hack and overlays will only be visible while in 'windowed Fullscreen' mode.`n`n"
. "This setting can be changed within the SC2 options menu.`n`n"
. "Click 'Disable' to turn off all the overlays in Macro Trainer.`n"
. "Click 'Continue' if you intend on changing the SC2 Window Mode."
ifMsgbox Ok ; 'Disable'
{
DrawMiniMap := DrawAlerts := DrawSpawningRaces := DrawIncomeOverlay := DrawResourcesOverlay
:= DrawArmySizeOverlay := DrawWorkerOverlay := DrawIdleWorkersOverlay
:= DrawLocalPlayerColourOverlay := DrawUnitOverlay := 0
gosub, ini_settings_write
}
}
settimer, g_CheckForScriptToGetGameInfo, -3600000 ; 1hour
return
;-----------------------
; End of execution
;-----------------------
;2147483647 - highest priority so if i ever give something else a high priority, this key combo will still interupt (if thread isnt critical)
;#MaxThreadsBuffer on
;<#Space::
g_EmergencyRestart:
;Thread, Priority, 2147483647 ; doubt this does anything. But due to problem with using the hotkeycommand try it
SetMouseDelay, 10 ; to ensure release modifiers works
SetKeyDelay, 10
releaseAllModifiers() ;This will be active irrespective of the window
RestoreModifierPhysicalState() ;input on ; this doesnt really do anything now - not needed
settimer, EmergencyInputCountReset, 5000, -100
EmergencyInputCount ++
If (EmergencyInputCount = 1)
{
BufferInputFast.disableHotkeys()
BufferInputFast.createHotkeys(aButtons.List)
CreateHotkeys()
}
else If (EmergencyInputCount >= 3)
{
IniWrite, Hotkey, %config_file%, Misc Info, RestartMethod ; could have achieved this using running the new program with a parameter then checking %1%
g_reload:
if (A_ThisLabel = "g_reload")
IniWrite, Icon, %config_file%, Misc Info, RestartMethod
SoundPlay, %A_Temp%\Windows Ding.wav
if time && alert_array[GameType, "Enabled"]
doUnitDetection(unit, type, owner, "Save") ;these first 3 vars are nothing - they wont get Read
; try Run "%A_ScriptFullPath%"
if (A_OSVersion = "WIN_XP") ; apparently the below command wont work on XP
try RunAsAdmin()
else try Run *RunAs "%A_ScriptFullPath%"
ExitApp ;does the shutdown procedure.
}
SoundPlay, %A_Temp%\Windows Ding2.wav
return
;#MaxThreadsBuffer Off
EmergencyInputCountReset:
settimer, EmergencyInputCountReset, off
EmergencyInputCount := 0
Return
; this is required as the 'exit' on the tray icon can only launch labels
; and if it actually goes to " ShutdownProcedure: " the shudown procedure will actually get run twice! (not a big deal....)
; Once from the label, and a second time due to the first use of ExitApp command
ExitApp:
ExitApp ; invokes the shutdown procedure
return
g_ListVars:
ListVars
return
g_GetDebugData:
clipboard := debugData := DebugData()
IfWinExist, DebugData Vr: %ProgramVersion%
WinClose
Gui, New
Gui, Add, Edit, x12 y+10 w980 h640 readonly -E0x200, % LTrim(debugData)
Gui, Show,, DebugData Vr: %ProgramVersion%
return
Stealth_Exit:
ExitApp
return
g_PlayModifierWarningSound:
SoundPlay, %A_Temp%\ModifierDown.wav
return
ping:
send, !g
sleep 10
Click
Return
g_DoNothing:
Return
g_LbuttonDown: ;Get the location of a dragbox
MouseGetPos, MLDownX, MLDownY
Return
g_GiveLocalPalyerResources:
SetPlayerMinerals()
SetPlayerGas()
return
g_GLHF:
ReleaseModifiers(0)
SetStoreCapslockMode, On ;as I turned it off in the auto Exec section
if !isChatOpen()
send, +{Enter}
send, GL{ASC 3}HF{!}
SetStoreCapslockMode, Off ; this isn't really needed as it is no off by default for new threads
return
g_DeselectUnit:
if (getSelectionCount() > 1)
{
mousegetpos, Xmouse, Ymouse
ClickUnitPortrait(0, X, Y, Xpage, Ypage) ; -1 as selection index begins at 0 i.e 1st unit at pos 0 top left
send +{click Left %X%, %Y%}
send {click %Xmouse%, %Ymouse%, 0}
}
return
; This ReleaseModifiers function needs to wait an additional amount of time, as SC2 can be slow to
; update its keystate and/or it buffers input/keys for a while. Perhaps checking logical keystate would be better
; but this isnt solid as the game state is still slower to change than this.
; I have added the AdditionalKeys which is mainly used for zerg burrow
; and i have provided an additional 15 ms sleep time if burrow is being held down
; can't use critical inside function, as that will delay all timers too much
/*
ReleaseModifiersOld(Beep = 1, CheckIfUserPerformingAction = 0, AdditionalKeys = "", timeout := "") ;timout in ms
{
GLOBAL HotkeysZergBurrow
PreviousBatchLines := A_BatchLines
SetBatchLines, -1
startTime := A_Tickcount
startReleaseModifiers:
while getkeystate("Ctrl", "P") || getkeystate("Alt", "P")
|| getkeystate("Shift", "P") || getkeystate("LWin", "P") || getkeystate("RWin", "P")
|| AdditionalKeys && (ExtraKeysDown := isaKeyPhysicallyOrLogicallyDown(AdditionalKeys)) ; ExtraKeysDown should actually return the actual key
|| (isPerformingAction := CheckIfUserPerformingAction && isUserPerformingAction()) ; have this function last as it can take the longest if lots of units selected
{
loopCount++
ModifierDown := 1
if (timeout && A_Tickcount - startTime >= timeout)
return 1 ; was taking too long
if (loopCount = 1 && Beep && !isPerformingAction && !ExtraKeysDown) ;wont beep if casting or burrow AKA 'extra key' is down
SoundPlay, %A_Temp%\ModifierDown.wav
if ExtraKeysDown
LastExtraKeyHeldDown := ExtraKeysDown ; as ExtraKeysDown will get blanked in the loop preventing detection in the below if
else LastExtraKeyHeldDown := ""
sleep, 5
}
if ModifierDown
{
ModifierDown := 0
if (LastExtraKeyHeldDown = HotkeysZergBurrow)
sleep 50 ;as burrow can 'buffer' within sc2
else sleep, 35 ;give time for sc2 to update keystate - it can be a slower than AHK (or it buffers)!
Goto, startReleaseModifiers
}
SetBatchLines, %PreviousBatchLines%
return
}
*/
ReleaseModifiers(Beep = 1, CheckIfUserPerformingAction = 0, AdditionalKeys = "", timeout := "") ;timout in ms
{
PreviousBatchLines := A_BatchLines
SetBatchLines, -1
startTime := A_Tickcount
While getkeystate("Shift", "P") || getkeystate("Control", "P") || getkeystate("Alt", "P")
|| getkeystate("LWin", "P") || getkeystate("RWin", "P")
|| getkeystate("Shift", "L") || getkeystate("Control", "L") || getkeystate("Alt", "L")
|| getkeystate("LWin", "L") || getkeystate("RWin", "L")
|| getkeystate("LButton", "P") || getkeystate("LButton", "L")
|| getkeystate("RButton", "P") || getkeystate("RButton", "L")
|| readModifierState()
|| (AdditionalKeys && isaKeyPhysicallyOrLogicallyDown(AdditionalKeys)) ; ExtraKeysDown should actually return the actual key
|| (isPerformingAction := CheckIfUserPerformingAction && isUserPerformingAction()) ; have this function last as it can take the longest if lots of units selected
{
if (timeout && A_Tickcount - startTime >= timeout)
return 1 ; was taking too long
if (A_Index = 1 && Beep && !isPerformingAction) ;wont beep if casting or burrow AKA 'extra key' is down
SoundPlay, %A_Temp%\ModifierDown.wav
sleep(5)
}
SetBatchLines, %PreviousBatchLines%
return
}
isaKeyPhysicallyOrLogicallyDown(Keys)
{
if isobject(Keys)
{
for Index, Key in Keys
if getkeystate(Key, "P") || getkeystate(Key, "L")
return key
}
else if getkeystate(Keys, "P") || getkeystate(Keys, "L")
return Keys ;keys!
return 0
}
g_SendBaseCam:
send, {Backspace}
return
g_CreateBaseCam1:
send, +{F2}
Return
g_CreateBaseCam2:
send, +{F3}
Return
g_CreateBaseCam3:
send, +{F4}
Return
g_BaseCam1:
send, {F2}
Return
g_BaseCam2:
send, {F3}
Return
g_BaseCam3:
send, {F4}
Return
g_FineMouseMove:
FineMouseMove(A_ThisHotkey)
Return
FineMouseMove(Hotkey)
{
MouseGetPos, MX, MY
if (Hotkey = "Left")
mousemove, (MX-1), MY
else if (Hotkey = "Right")
mousemove, (MX+1), MY
else if (Hotkey = "Up")
mousemove, MX, MY-1
else if (Hotkey = "Down")
mousemove, MX, MY+1
}
g_FindTestPixelColourMsgbox:
IfWinExist, Pixel Colour Finder
{
WinActivate
Return
}
Gui, New
Gui +Toolwindow +AlwaysOnTop
Gui, Font, S10 CDefault Bold, Verdana
Gui, Add, Text, x+40 y+10 w220, Colour Finder:
Gui, Font,
Gui, Add, Text, x20 y+10, Click " Help " to learn how to set the pixel colour.
Gui, Add, Text, x20 Y+10, Click " Start " to begin.
Gui, Add, Text, x20 y+10, Click " Cancel " to leave.
Gui, Add, Button, Default x30 y+30 w100 h30 default gg_PixelColourFinderHelpFile, &Help
Gui, Add, Button, Default x+30 w100 h30 gg_FindTestPixelColour, Start
Gui, Add, Button, Default x+30 w100 h30 gGuiReturn, Cancel
Gui, Font, Norm
gui, show,, Pixel Colour Finder
return
g_PixelColourFinderHelpFile:
IfWinExist, Pixel Finder - How To:
{ WinActivate
Return
}
Gui, New
Gui Add, ActiveX, xm w980 h640 vWB, Shell.Explorer
WB.Navigate(url.PixelColour)
Gui, Show,, Pixel Finder - How To:
Return
g_FindTestPixelColour:
Gui, Destroy
g_FindTestPixelColour()
Return
g_FindTestPixelColour()
{ global AM_MiniMap_PixelColourAlpha, AM_MiniMap_PixelColourRed, AM_MiniMap_PixelColourGreen, AM_MinsiMap_PixelColourBlue
SoundPlay, %A_Temp%\Windows Ding.wav
l_DirectionalKeys := "Left,Right,Up,Down"
loop, parse, l_DirectionalKeys, `,
hotkey, %A_loopfield%, g_FineMouseMove, on
loop
{
pBitMap := GDIP_BitmapFromScreen()
MouseGetPos, MX, MY
FoundColour := GDIP_GetPixel(pbitmap, MX, MY) ;ARGB format
GDIP_DisposeImage(pBitMap)
tooltip, % "Found Colour: " A_Tab FoundColour "`n`nUse the Left/Right/Up/Down Arrows to move the mouse accurately`n`n" A_Tab "Press Enter To Save`n`n" A_Tab "Press Backspace To Cancel", MX+50, MY-70
if getkeystate("Enter", "P")
{
SoundPlay, %A_Temp%\Windows Ding.wav
Gdip_FromARGB(FoundColour, A, R, G, B)
guicontrol, Options:, AM_MiniMap_PixelColourAlpha, %A%
guicontrol, Options:, AM_MiniMap_PixelColourRed, %R%
guicontrol, Options:, AM_MiniMap_PixelColourGreen, %G%
guicontrol, Options:, AM_MinsiMap_PixelColourBlue, %B%
break
}
else if getkeystate("Backspace", "P")
break
}
tooltip
loop, parse, l_DirectionalKeys, `,
hotkey, %A_loopfield%, g_FineMouseMove, off
return
}
g_PrevWarning:
If PrevWarning
{
DSpeak(PrevWarning.speech)
MiniMapWarning.insert({"Unit": PrevWarning.unitIndex, "Time": Time})
}
Else DSpeak("There have been no alerts")
Return
Adjust_overlay:
Dragoverlay := 1
{
SetBatchLines, -1
gosub overlay_timer
if DrawUnitOverlay
gosub g_unitPanelOverlay_timer
SetTimer, OverlayKeepOnTop,off
SetTimer, overlay_timer, 50, 0 ; make normal priority so it can interupt this thread to move
SetTimer, g_unitPanelOverlay_timer, 50, 0
SoundPlay, %A_Temp%\On.wav
}
sleep 500
KeyWait, %AdjustOverlayKey%, T40
Dragoverlay := 0
{
SetBatchLines, %SetBatchLines%
SetTimer, OverlayKeepOnTop, 1000, -20
SetTimer, overlay_timer, %OverlayRefresh%, -8
SetTimer, g_unitPanelOverlay_timer, %UnitOverlayRefresh%, -9
SoundPlay, %A_Temp%\Off.wav
WinActivate, %GameIdentifier%
}
Return
Toggle_Identifier:
If OverlayIdent = 3
OverlayIdent := 0
Else OverlayIdent ++
Iniwrite, %OverlayIdent%, %config_file%, Overlays, OverlayIdent
gosub, overlay_timer
gosub, g_unitPanelOverlay_timer
Return
Overlay_Toggle:
if (A_ThisHotkey = CycleOverlayKey)
{
If ((ActiveOverlays := DrawIncomeOverlay + DrawResourcesOverlay + DrawArmySizeOverlay + DrawUnitOverlay) > 1)
{
DrawResourcesOverlay := DrawArmySizeOverlay := DrawIncomeOverlay := DrawUnitOverlay := 0
DrawResourcesOverlay(-1), DrawArmySizeOverlay(-1), DrawIncomeOverlay(-1), DrawUnitOverlay(-1)
}
Else If (ActiveOverlays = 0)
DrawIncomeOverlay := 1
Else
{
If DrawIncomeOverlay
DrawResourcesOverlay := !DrawIncomeOverlay := DrawUnitOverlay := 0, DrawIncomeOverlay(-1)
Else If DrawResourcesOverlay
DrawArmySizeOverlay := !DrawResourcesOverlay := DrawUnitOverlay := 0, DrawResourcesOverlay(-1)
Else If DrawArmySizeOverlay
DrawUnitOverlay := !DrawResourcesOverlay := DrawArmySizeOverlay := 0, DrawArmySizeOverlay(-1)
Else If DrawUnitOverlay ; turn them all on
DrawResourcesOverlay := DrawArmySizeOverlay := DrawIncomeOverlay := 1
}
gosub, overlay_timer
gosub, g_unitPanelOverlay_timer
}
Else If (A_ThisHotkey = ToggleIncomeOverlayKey)
{
If (!DrawIncomeOverlay := !DrawIncomeOverlay)
DrawIncomeOverlay(-1)
}
Else If (A_ThisHotkey = ToggleResourcesOverlayKey)
{
If (!DrawResourcesOverlay := !DrawResourcesOverlay)
DrawResourcesOverlay(-1)
}
Else If (A_ThisHotkey = ToggleArmySizeOverlayKey)
{
If (!DrawArmySizeOverlay := !DrawArmySizeOverlay)
DrawArmySizeOverlay(-1)
}
Else If (A_ThisHotkey = ToggleWorkerOverlayKey)
{
If (!DrawWorkerOverlay := !DrawWorkerOverlay)
DrawWorkerOverlay(-1)
}
Else If (A_ThisHotkey = ToggleIdleWorkersOverlayKey)
{
If (!DrawIdleWorkersOverlay := !DrawIdleWorkersOverlay)
DrawIdleWorkersOverlay(-1)
}
Else If (A_ThisHotkey = ToggleUnitOverlayKey)
{
If (!DrawUnitOverlay := !DrawUnitOverlay)
DrawUnitOverlay(-1)
}
If (A_ThisHotkey = ToggleUnitOverlayKey)
gosub, g_unitPanelOverlay_timer
else gosub, overlay_timer ;this makes the change take effect immediately.
Return
mt_pause_resume:
if (mt_on := !mt_on) ; 1st run mt_on blank so considered false and does else
{
game_status := "lobby" ; with this clock = 0 when not in game
timeroff("clock", "money", "gas", "scvidle", "supply", "worker", "inject", "unit_bank_read", "Auto_mine", "Auto_Group", "AutoGroupIdle", "MiniMap_Timer", "overlay_timer", "g_unitPanelOverlay_timer", "g_autoWorkerProductionCheck", "g_ForceInjectSuccessCheck")
inject_timer := 0 ;ie so know inject timer is off
DSpeak("Macro Trainer Paused")
}
Else
{
settimer, clock, 250
DSpeak("Macro Trainer Resumed")
}
return
;------------
; clock
;------------
clock:
time := GetTime()
if (!time AND game_status = "game") OR (UpdateTimers) ; time=0 outside game
{
game_status := "lobby" ; with this clock = 0 when not in game (while in game at 0s clock = 44)
timeroff("money", "gas", "scvidle", "supply", "worker", "inject", "unit_bank_read", "Auto_mine", "Auto_Group", "AutoGroupIdle", "MiniMap_Timer", "overlay_timer", "g_unitPanelOverlay_timer", "g_autoWorkerProductionCheck", "g_ForceInjectSuccessCheck")
inject_timer := TimeReadRacesSet := UpdateTimers := Overlay_RunCount := PrevWarning := WinNotActiveAtStart := ResumeWarnings := 0 ;ie so know inject timer is off
Try DestroyOverlays()
}
Else if (time AND game_status <> "game" AND getLocalPlayerNumber() <> 16) OR (debug AND time AND game_status <> "game") ; Local slot = 16 while in lobby - this will stop replay announcements
{
game_status := "game", warpgate_status := "not researched", gateway_count := warpgate_warning_set := 0
AW_MaxWorkersReached := TmpDisableAutoWorker := 0
MiniMapWarning := [], a_BaseList := [], aUnitModel := [], aGatewayWarnings := []
aResourceLocations := []
BufferInputFast.disableHotkeys() ; disable any previously created buffered hotkeys in case user has changed the key blocking list
BufferInputFast.createHotkeys(aButtons.List) ; re-create the hotkeys
if WinActive(GameIdentifier)
ReDraw := ReDrawIncome := ReDrawResources := ReDrawArmySize := ReDrawWorker := RedrawUnit := ReDrawIdleWorkers := ReDrawLocalPlayerColour := 1
if idle_enable ;this is the idle AFK
settimer, user_idle, 1000, -5
if (MaxWindowOnStart && time < 5 && !WinActive(GameIdentifier))
{
WinActivate, %GameIdentifier%
MouseMove A_ScreenWidth/2, A_ScreenHeight/2
WinNotActiveAtStart := 1
}
Gosub, player_team_sorter
if (ResumeWarnings || UserSavedAppliedSettings && alert_array[GameType, "Enabled"])
doUnitDetection(unit, type, owner, "Resume") ;these first 3 vars are nothing - they wont get Read
Else
doUnitDetection(unit, type, owner, "Reset") ; clear the variables within the function
If (F_Inject_Enable && a_LocalPlayer["Race"] = "Zerg")
{
zergGetHatcheriesToInject(oHatcheries)
settimer, g_ForceInjectSuccessCheck, %FInjectHatchFrequency%
}
aResourceLocations := getMapInforMineralsAndGeysers()
if mineralon
settimer, money, 500, -5
if gas_on
settimer, gas, 1000, -5
if idleon ;this is the idle worker
settimer, scvidle, 500, -5 ; the idle scv pointer changes every game
if supplyon
settimer, supply, 200, -5
if workeron
settimer, worker, 1000, -5
LocalPlayerRace := a_LocalPlayer["Race"] ; another messy lazy variable
if (EnableAutoWorker%LocalPlayerRace%Start && (a_LocalPlayer["Race"] = "Terran" || a_LocalPlayer["Race"] = "Protoss") )
{
SetTimer, g_autoWorkerProductionCheck, 200
EnableAutoWorker%LocalPlayerRace% := 1
}
if ( Auto_Read_Races AND race_reading ) && !((ResumeWarnings || UserSavedAppliedSettings) && time > 12)
SetTimer, find_races_timer, 1000, -20
If (a_LocalPlayer["Race"] = "Terran")
SupplyType := A_unitID["SupplyDepot"]
Else If (a_LocalPlayer["Race"] = "Protoss")
SupplyType := A_unitID["Pylon"]
if (alert_array[GameType, "Enabled"] || warpgate_warn_on || supplyon)
settimer, unit_bank_read, %UnitDetectionTimer_ms%, -5
SetMiniMap(minimap)
setupMiniMapUnitLists()
l_ActiveDeselectArmy := setupSelectArmyUnits(l_DeselectArmy, A_unitID)
ShortRace := substr(LongRace := a_LocalPlayer["Race"], 1, 4) ;because i changed the local race var from prot to protoss i.e. short to long - MIGHT NO be needed now
setupAutoGroup(a_LocalPlayer["Race"], A_AutoGroup, A_unitID, A_UnitGroupSettings)
If A_UnitGroupSettings["AutoGroup", a_LocalPlayer["Race"], "Enabled"]
{
settimer, Auto_Group, %AutoGroupTimer% ; set to 30 ms via config ini default
; WITH Normal 1 priority so it should run once every 30 ms
settimer, AutoGroupIdle, %AutoGroupTimerIdle%, -9999 ; default ini value 5 ms - Lowest priority so will only run when script is idle! And wont interrupt any other timer
; and so wont prevent the minimap or overlay being drawn
; note may delay some timers from launching for a fraction of a ms while its in thread, no timers interupt mode (but it takes less than 1 ms to run anyway)
} ; Hence with these two timers running autogroup will occur at least once every 30 ms, but generally much more frequently
CreateHotkeys()
if (a_LocalPlayer["Name"] == "Kalamity" || a_LocalPlayer["Name"] == "CumBackKid" )
{
Hotkey, If, WinActive(GameIdentifier) && time && !BufferInputFast.isInputBlockedOrBuffered()
hotkey, >!g, g_GLHF
Hotkey, If
}
If (DrawMiniMap OR DrawAlerts OR DrawSpawningRaces)
SetTimer, MiniMap_Timer, %MiniMapRefresh%, -7
SetTimer, overlay_timer, %OverlayRefresh%, -8
SetTimer, g_unitPanelOverlay_timer, %UnitOverlayRefresh%, -9
; SetTimer, g_ControlShiftTimer, 40
EnemyBaseList := GetEBases()
UserSavedAppliedSettings := 0
}
return
setupMiniMapUnitLists()
{ local list, unitlist, ListType
list := "UnitHighlightList1,UnitHighlightList2,UnitHighlightList3,UnitHighlightList4,UnitHighlightList5,UnitHighlightList6,UnitHighlightList7,UnitHighlightExcludeList"
Loop, Parse, list, `,
{
ListType := A_LoopField
Active%ListType% := "" ;clear incase changed via options between games
StringReplace, unitlist, %A_LoopField%, %A_Space%, , All ; Remove Spaces also creates var unitlist
unitlist := Trim(unitlist, " `t , |") ; , or `, both work - remove spaces, tabs and commas
loop, parse, unitlist, `,
Active%ListType% .= A_unitID[A_LoopField] ","
Active%ListType% := RTrim(Active%ListType%, ",")
}
Return
}
setupSelectArmyUnits(l_input, A_unitID)
{
a_Units := []
StringReplace, l_input, l_input, %A_Space%, , All ; Remove Spaces
l_input := Trim(l_input, " `t , |")
loop, parse, l_input, `,
l_army .= A_unitID[A_LoopField] ","
return l_army := Trim(l_army, " `t , |")
}
;----------------------
; player_team_sorter
;-----------------------
player_team_sorter:
a_player := [], a_LocalPlayer := []
;LocalPlayerNumber := ReadMemory_Str(local_ID_off, , , , "#")
Loop, 16 ;doing it this way allows for custom games with blank slots ;can get weird things if 16 (but filtering them for nonplayers)
{
if !getPlayerName(A_Index) ;empty slot custom games?
|| IsInList(getPlayerType(A_Index), "None", "Neutral", "Hostile", "Referee", "Spectator")
Continue
a_player.insert( new c_Player(A_Index) )
If (A_Index = getLocalPlayerNumber()) OR (debug AND getPlayerName(A_Index) == debug_name)
a_LocalPlayer := new c_Player(A_Index)
}
IF (IsInList(a_LocalPlayer.Type, "Referee", "Spectator") OR (A_IsCompiled AND getLocalPlayerNumber() = 16 )) ; dont really need this 16 check, as timer wont activate as clock label checks if local player != 16 (so this will cause issues if it really is a 16 player game as local payer number is 16, but this prevents announcements during replays)
timeroff("money", "gas", "scvidle", "supply", "worker", "inject", "unit_bank_read", "Auto_mine", "Auto_Group", "AutoGroupIdle", "MiniMap_Timer", "overlay_timer", "g_unitPanelOverlay_timer", "g_autoWorkerProductionCheck", "g_ForceInjectSuccessCheck") ;Pause all warnings. Clock still going so will resume next game
GameType := GetGameType(a_Player)
return
;-------------------------
; End of Game 'Setup'
;-------------------------
Cast_ChronoStructure:
UserPressedHotkey := A_ThisHotkey ; as this variable can get changed very quickly
ReleaseModifiers()
Critical ;just blocking here so can use critical, otherwise would need nothread timers if wanted to track input then re-send
SetKeyDelay, %EventKeyDelay% ;this only affects send events - so can just have it, dont have to set delay to original as its only changed for current thread
SetMouseDelay, %EventKeyDelay% ;again, this wont affect send click (when input/play is in use) - I think some other commands may be affected?
BufferInputFast.BlockInput()
if (UserPressedHotkey = Cast_ChronoStargate_Key)
Cast_ChronoStructure(A_unitID.Stargate)
Else if (UserPressedHotkey = Cast_ChronoForge_Key)
Cast_ChronoStructure(A_unitID.Forge)
Else if (UserPressedHotkey = Cast_ChronoNexus_Key)
Cast_ChronoStructure(A_unitID.Nexus)
Else If (UserPressedHotkey = Cast_ChronoGate_Key)
Cast_ChronoStructure(A_unitID.WarpGate) ; this will also do gateways
Else If (UserPressedHotkey = Cast_ChronoRoboticsFacility_Key)
Cast_ChronoStructure(A_unitID.RoboticsFacility) ; this will also do gateways
BufferInputFast.disableBufferingAndBlocking()
Critical Off
return
Cast_ChronoStructure(StructureToChrono)
{ GLOBAL A_unitID, CG_control_group, chrono_key, CG_nexus_Ctrlgroup_key, CG_chrono_remainder, ChronoBoostSleep
, HumanMouse, HumanMouseTimeLo, HumanMouseTimeHi, NextSubgroupKey
oStructureToChrono := [], a_gateways := [], a_gatewaysConvertingToWarpGates := [], a_WarpgatesOnCoolDown := []
MouseGetPos, start_x, start_y
HighlightedGroup := getSelectionHighlightedGroup()
send % "^" CG_control_group
send % CG_nexus_Ctrlgroup_key
sleep(5) ;needs a few ms to update the selection buffer
numGetUnitSelectionObject(oSelection)
for index, object in oSelection.units
{
if (object.type = A_unitID.Nexus && !isUnderConstruction(unit))
nexus_chrono_count += Floor(getUnitEnergy(object.UnitIndex)/25)
if !isUnitAStructure(object.unitIndex) ; as units will have higher priority and appear in group 0/top left control card - and this isnt compatible with this macro
{
dspeak("Error in Base Control Group.")
return
}
}
IF nexus_chrono_count
{
Unitcount := DumpUnitMemory(MemDump)
if (StructureToChrono = A_UnitID.WarpGate)
{
while (A_Index <= Unitcount)
{
unit := A_Index - 1
if isTargetDead(TargetFilter := numgetUnitTargetFilter(MemDump, unit)) || !isOwnerLocal(numgetUnitOwner(MemDump, Unit))
|| isTargetUnderConstruction(TargetFilter)
Continue
Type := numgetUnitModelType(numgetUnitModelPointer(MemDump, Unit))
IF ( type = A_unitID["WarpGate"] && !isUnitChronoed(unit)) && (cooldown := getWarpGateCooldown(unit))
a_WarpgatesOnCoolDown.insert({"Unit": unit, "Cooldown": cooldown})
Else IF (type = A_unitID["Gateway"] && !isUnitChronoed(unit))
{
if isGatewayConvertingToWarpGate(unit)
a_gatewaysConvertingToWarpGates.insert(unit)
else
{
progress := getBuildStats(unit, QueueSize) ; need && QueueSize as if progress reports 0 when idle it will be added to the list
if ( (progress < .95 && QueueSize) || QueueSize > 1) ; as queue size of 1 means theres only 1 item being produced
a_gateways.insert({Unit: unit, QueueSize: QueueSize, progress: progress})
}
}
}
if a_WarpgatesOnCoolDown.MaxIndex()
Sort2DArray(a_WarpgatesOnCoolDown, "Cooldown", 0) ;so warpgates with longest cooldown get chronoed first
if a_gatewaysConvertingToWarpGates.MaxIndex()
RandomiseSimpleArray(a_gatewaysConvertingToWarpGates)
if a_gateways.MaxIndex()
{
Sort2DArray(a_gateways, "progress", 1) ; so the strucutes with least progress gets chronoed (providing have same queue size)
Sort2DArray(a_gateways, "QueueSize", 0) ; so One with the longest queue gets chronoed first
}
for index, Warpgate in a_WarpgatesOnCoolDown ; so Warpgates will get chronoed 1st
oStructureToChrono.insert({Unit: Warpgate.Unit}) ; among warpgates longest cooldown gets done first
for index, gateway in a_gatewaysConvertingToWarpGates ; gateways converting to warpgates get chronoed next
oStructureToChrono.insert({Unit:gateway}) ; among these gateways, order is random
for index, object in a_gateways ; gateways producing a unit come last
oStructureToChrono.insert({Unit: object.Unit}) ; among these it goes first by queue size, then progress
}
else
{
while (A_Index <= Unitcount)
{
unit := A_Index - 1
if isTargetDead(TargetFilter := numgetUnitTargetFilter(MemDump, unit)) || !isOwnerLocal(numgetUnitOwner(MemDump, Unit))
|| isTargetUnderConstruction(TargetFilter)
Continue
Type := numgetUnitModelType(numgetUnitModelPointer(MemDump, Unit))
IF ( type = StructureToChrono && !isUnitChronoed(unit) )
{
progress := getBuildStats(unit, QueueSize) ; need && QueueSize as if progress reports 0 when idle it will be added to the list
if ( (progress < .95 && QueueSize) || QueueSize > 1) ; as queue size of 1 means theres only 1 item being produced